12#include <ns3/boolean.h>
13#include <ns3/double.h>
14#include <ns3/integer.h>
15#include <ns3/internet-stack-helper.h>
16#include <ns3/ipv4-address-helper.h>
17#include <ns3/ipv4-interface-container.h>
18#include <ns3/ipv4-static-routing-helper.h>
20#include <ns3/lte-enb-net-device.h>
21#include <ns3/lte-helper.h>
22#include <ns3/lte-ue-net-device.h>
23#include <ns3/lte-ue-rrc.h>
24#include <ns3/mobility-helper.h>
25#include <ns3/net-device-container.h>
26#include <ns3/node-container.h>
27#include <ns3/point-to-point-epc-helper.h>
28#include <ns3/point-to-point-helper.h>
29#include <ns3/rng-seed-manager.h>
30#include <ns3/simulator.h>
54 std::vector<LteCellSelectionTestCase::UeSetup_t> w;
69 TestCase::Duration::QUICK);
84 TestCase::Duration::QUICK);
102 uint16_t expectedCellId1,
103 uint16_t expectedCellId2)
104 : position(Vector(relPosX, relPosY, 0.0)),
105 isCsgMember(isCsgMember),
106 checkPoint(checkPoint),
107 expectedCellId1(expectedCellId1),
108 expectedCellId2(expectedCellId2)
115 double interSiteDistance,
116 std::vector<UeSetup_t> ueSetupList)
149 lteHelper->SetAttribute(
"PathlossModel",
StringValue(
"ns3::FriisSpectrumPropagationLossModel"));
157 lteHelper->SetEpcHelper(epcHelper);
184 positionAlloc->Add(Vector(0.0, 0.0, 0.0));
188 std::vector<UeSetup_t>::const_iterator itSetup;
195 positionAlloc->Add(uePos);
199 mobility.SetMobilityModel(
"ns3::ConstantPositionMobilityModel");
200 mobility.SetPositionAllocator(positionAlloc);
201 mobility.Install(enbNodes);
202 mobility.Install(ueNodes);
210 lteHelper->SetEnbDeviceAttribute(
"CsgIndication",
BooleanValue(
false));
211 enbDevs.
Add(lteHelper->InstallEnbDevice(enbNodes.
Get(0)));
215 lteHelper->SetEnbDeviceAttribute(
"CsgIndication",
BooleanValue(
true));
216 enbDevs.
Add(lteHelper->InstallEnbDevice(enbNodes.
Get(1)));
220 lteHelper->SetEnbDeviceAttribute(
"CsgIndication",
BooleanValue(
false));
221 enbDevs.
Add(lteHelper->InstallEnbDevice(enbNodes.
Get(2)));
225 lteHelper->SetEnbDeviceAttribute(
"CsgIndication",
BooleanValue(
true));
226 enbDevs.
Add(lteHelper->InstallEnbDevice(enbNodes.
Get(3)));
236 if (itSetup->isCsgMember)
253 itSetup->expectedCellId1,
254 itSetup->expectedCellId2);
256 if (lastCheckPoint < itSetup->checkPoint)
258 lastCheckPoint = itSetup->checkPoint;
262 stream += lteHelper->AssignStreams(enbDevs, stream);
263 stream += lteHelper->AssignStreams(ueDevs, stream);
282 remoteHostContainer.
Create(1);
285 internet.Install(remoteHostContainer);
294 ipv4h.
SetBase(
"1.0.0.0",
"255.0.0.0");
301 remoteHostStaticRouting->AddNetworkRouteTo(
Ipv4Address(
"7.0.0.0"),
306 internet.Install(ueNodes);
317 ueStaticRouting->SetDefaultRoute(epcHelper->GetUeDefaultGatewayAddress(), 1);
330 "/NodeList/*/DeviceList/*/LteUeRrc/InitialCellSelectionEndOk",
333 "/NodeList/*/DeviceList/*/LteUeRrc/InitialCellSelectionEndError",
335 Config::Connect(
"/NodeList/*/DeviceList/*/LteUeRrc/ConnectionEstablished",
339 lteHelper->Attach(ueDevs);
356 uint16_t expectedCellId1,
357 uint16_t expectedCellId2)
359 uint16_t actualCellId = ueDev->GetRrc()->GetCellId();
361 if (expectedCellId2 == 0)
365 "IMSI " << ueDev->GetImsi() <<
" has attached to an unexpected cell");
369 bool pass = (actualCellId == expectedCellId1) || (actualCellId == expectedCellId2);
372 "IMSI " << ueDev->GetImsi() <<
" has attached to an unexpected cell"
373 <<
" (actual: " << actualCellId <<
","
374 <<
" expected: " << expectedCellId1 <<
" or "
375 << expectedCellId2 <<
")");
378 if (expectedCellId1 > 0)
382 "UE " << ueDev->GetImsi() <<
" is not at CONNECTED_NORMALLY state");
394 NS_LOG_FUNCTION(
this << imsi << cellId << rnti << oldState << newState);
395 m_lastState.at(
static_cast<unsigned int>(imsi - 1)) = newState;
Testing the initial cell selection procedure by UE at IDLE state in the beginning of simulation.
~LteCellSelectionTestCase() override
std::vector< UeSetup_t > m_ueSetupList
UE setup list.
void CheckPoint(Ptr< LteUeNetDevice > ueDev, uint16_t expectedCellId1, uint16_t expectedCellId2)
Verifies if the given UE is attached to either of the given two cells and in a CONNECTED_NORMALLY sta...
void InitialCellSelectionEndOkCallback(std::string context, uint64_t imsi, uint16_t cellId)
Initial cell selection end ok callback function.
std::vector< LteUeRrc::State > m_lastState
The current UE RRC state.
LteCellSelectionTestCase(std::string name, bool isEpcMode, bool isIdealRrc, double interSiteDistance, std::vector< UeSetup_t > ueSetupList)
Creates an instance of the initial cell selection test case.
void DoRun() override
Setup the simulation according to the configuration set by the class constructor, run it,...
bool m_isEpcMode
whether the LTE configuration in test is using EPC
double m_interSiteDistance
inter site distance
void ConnectionEstablishedCallback(std::string context, uint64_t imsi, uint16_t cellId, uint16_t rnti)
Connection established callback function.
void InitialCellSelectionEndErrorCallback(std::string context, uint64_t imsi, uint16_t cellId)
Initial cell selection end error callback function.
bool m_isIdealRrc
whether the LTE is configured to use ideal RRC
void StateTransitionCallback(std::string context, uint64_t imsi, uint16_t cellId, uint16_t rnti, LteUeRrc::State oldState, LteUeRrc::State newState)
State transition callback function.
Test suite for executing the cell selection test cases in without-EPC and with-EPC scenarios.
LteCellSelectionTestSuite()
Class for representing data rates.
aggregate IP/TCP/UDP functionality to existing Nodes.
A helper class to make life easier while doing simple IPv4 address assignment in scripts.
void SetBase(Ipv4Address network, Ipv4Mask mask, Ipv4Address base="0.0.0.1")
Set the base network number, network mask and base address.
Ipv4InterfaceContainer Assign(const NetDeviceContainer &c)
Assign IP addresses to the net devices specified in the container based on the current network prefix...
Ipv4 addresses are stored in host order in this class.
Access to the IPv4 forwarding table, interfaces, and configuration.
holds a vector of std::pair of Ptr<Ipv4> and interface index.
a class to represent an Ipv4 address mask
Helper class that adds ns3::Ipv4StaticRouting objects.
Ptr< Ipv4StaticRouting > GetStaticRouting(Ptr< Ipv4 > ipv4) const
Try and find the static routing protocol as either the main routing protocol or in the list of routin...
The LteUeNetDevice class implements the UE net device.
State
The states of the UE RRC entity.
Helper class used to assign positions and mobility models to nodes.
holds a vector of ns3::NetDevice pointers
uint32_t GetN() const
Get the number of Ptr<NetDevice> stored in this container.
std::vector< Ptr< NetDevice > >::const_iterator Iterator
NetDevice container iterator.
Iterator Begin() const
Get an iterator which refers to the first NetDevice in the container.
void Add(NetDeviceContainer other)
Append the contents of another NetDeviceContainer to the end of this container.
Iterator End() const
Get an iterator which indicates past-the-last NetDevice in the container.
Ptr< NetDevice > Get(uint32_t i) const
Get the Ptr<NetDevice> stored in this container at a given index.
keep track of a set of node pointers.
std::vector< Ptr< Node > >::const_iterator Iterator
Node container iterator.
Iterator End() const
Get an iterator which indicates past-the-last Node in the container.
uint32_t GetN() const
Get the number of Ptr<Node> stored in this container.
void Create(uint32_t n)
Create n nodes and append pointers to them to the end of this NodeContainer.
Iterator Begin() const
Get an iterator which refers to the first Node in the container.
Ptr< Node > Get(uint32_t i) const
Get the Ptr<Node> stored in this container at a given index.
Build a set of PointToPointNetDevice objects.
void SetDeviceAttribute(std::string name, const AttributeValue &value)
Set an attribute value to be propagated to each NetDevice created by the helper.
void SetChannelAttribute(std::string name, const AttributeValue &value)
Set an attribute value to be propagated to each Channel created by the helper.
NetDeviceContainer Install(NodeContainer c)
Smart pointer class similar to boost::intrusive_ptr.
static uint64_t GetRun()
Get the current run number.
static uint32_t GetSeed()
Get the current seed value which will be used by all subsequently instantiated RandomVariableStream o...
static EventId Schedule(const Time &delay, FUNC f, Ts &&... args)
Schedule an event to expire after delay.
static void Destroy()
Execute the events scheduled with ScheduleDestroy().
static void Run()
Run the simulation.
static void Stop()
Tell the Simulator the calling event should be the last one executed.
Hold variables of type string.
void AddTestCase(TestCase *testCase, Duration duration=Duration::QUICK)
Add an individual child TestCase to this test suite.
std::string GetName() const
Simulation virtual time values and global simulation resolution.
Hold an unsigned integer type.
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file,...
void SetGlobal(std::string name, const AttributeValue &value)
void Connect(std::string path, const CallbackBase &cb)
#define NS_FATAL_ERROR(msg)
Report a fatal error with a message and terminate.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
#define NS_LOG_INFO(msg)
Use NS_LOG to output a message of level LOG_INFO.
static LteCellSelectionTestSuite g_lteCellSelectionTestSuite
Static variable for test initialization.
Ptr< T > CreateObject(Args &&... args)
Create an object by type, with varying number of constructor parameters.
#define NS_TEST_ASSERT_MSG_EQ(actual, limit, msg)
Test that an actual and expected (limit) value are equal and report and abort if not.
Time Seconds(double value)
Construct a Time in the indicated unit.
Time MilliSeconds(uint64_t value)
Construct a Time in the indicated unit.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Callback< R, Args... > MakeCallback(R(T::*memPtr)(Args...), OBJ objPtr)
Build Callbacks for class method members which take varying numbers of arguments and potentially retu...
A set of input parameters for setting up a UE in the simulation.
UeSetup_t(double relPosX, double relPosY, bool isCsgMember, Time checkPoint, uint16_t expectedCellId1, uint16_t expectedCellId2)
UE test setup function.