24 #include <ns3/simulator.h>
26 #include <ns3/boolean.h>
27 #include <ns3/double.h>
28 #include <ns3/integer.h>
30 #include <ns3/mobility-helper.h>
31 #include <ns3/lte-helper.h>
32 #include <ns3/point-to-point-epc-helper.h>
33 #include <ns3/internet-stack-helper.h>
34 #include <ns3/point-to-point-helper.h>
35 #include <ns3/ipv4-address-helper.h>
36 #include <ns3/ipv4-static-routing-helper.h>
38 #include <ns3/node-container.h>
39 #include <ns3/net-device-container.h>
40 #include <ns3/ipv4-interface-container.h>
42 #include <ns3/lte-ue-net-device.h>
43 #include <ns3/lte-ue-rrc.h>
44 #include <ns3/lte-enb-net-device.h>
57 :
TestSuite (
"lte-cell-selection", SYSTEM)
59 std::vector<LteCellSelectionTestCase::UeSetup_t>
w;
67 MilliSeconds (283), 1, 0));
69 MilliSeconds (283), 1, 0));
71 MilliSeconds (363), 1, 3));
73 MilliSeconds (283), 2, 4));
75 MilliSeconds (283), 3, 0));
77 MilliSeconds (283), 4, 0));
80 true,
false, 60.0, w, 1),
90 MilliSeconds (266), 1, 0));
92 MilliSeconds (266), 1, 0));
94 MilliSeconds (346), 1, 3));
96 MilliSeconds (266), 2, 4));
98 MilliSeconds (266), 3, 0));
100 MilliSeconds (266), 4, 0));
103 true,
true, 60.0, w, 1),
120 double relPosX,
double relPosY,
bool isCsgMember,
Time checkPoint,
121 uint16_t expectedCellId1, uint16_t expectedCellId2)
122 : position (
Vector (relPosX, relPosY, 0.0)),
123 isCsgMember (isCsgMember),
124 checkPoint (checkPoint),
125 expectedCellId1 (expectedCellId1),
126 expectedCellId2 (expectedCellId2)
132 std::string name,
bool isEpcMode,
bool isIdealRrc,
133 double interSiteDistance,
134 std::vector<UeSetup_t> ueSetupList, int64_t rngRun)
162 StringValue (
"ns3::FriisSpectrumPropagationLossModel"));
169 epcHelper = CreateObject<PointToPointEpcHelper> ();
197 positionAlloc->
Add (
Vector ( 0.0, 0.0, 0.0));
201 std::vector<UeSetup_t>::const_iterator itSetup;
209 positionAlloc->
Add (uePos);
243 Time lastCheckPoint = MilliSeconds (0);
250 if (itSetup->isCsgMember)
263 Simulator::Schedule (itSetup->checkPoint,
266 itSetup->expectedCellId1, itSetup->expectedCellId2);
268 if (lastCheckPoint < itSetup->checkPoint)
270 lastCheckPoint = itSetup->checkPoint;
294 remoteHostContainer.
Create (1);
297 internet.
Install (remoteHostContainer);
306 ipv4h.
SetBase (
"1.0.0.0",
"255.0.0.0");
320 for (uint32_t u = 0; u < ueNodes.
GetN (); ++u)
338 Config::Connect (
"/NodeList/*/DeviceList/*/LteUeRrc/InitialCellSelectionEndOk",
341 Config::Connect (
"/NodeList/*/DeviceList/*/LteUeRrc/InitialCellSelectionEndError",
344 Config::Connect (
"/NodeList/*/DeviceList/*/LteUeRrc/ConnectionEstablished",
349 lteHelper->
Attach (ueDevs);
352 Simulator::Stop (lastCheckPoint);
356 Simulator::Destroy ();
363 uint16_t expectedCellId1,
364 uint16_t expectedCellId2)
366 uint16_t actualCellId = ueDev->
GetRrc ()->GetCellId ();
368 if (expectedCellId2 == 0)
372 <<
" has attached to an unexpected cell");
376 bool pass = (actualCellId == expectedCellId1) ||
377 (actualCellId == expectedCellId2);
380 <<
" has attached to an unexpected cell"
381 <<
" (actual: " << actualCellId <<
","
382 <<
" expected: " << expectedCellId1
383 <<
" or " << expectedCellId2 <<
")");
386 if (expectedCellId1 > 0)
389 LteUeRrc::CONNECTED_NORMALLY,
391 <<
" is not at CONNECTED_NORMALLY state");
398 std::string context, uint64_t imsi, uint16_t cellId, uint16_t rnti,
401 NS_LOG_FUNCTION (
this << imsi << cellId << rnti << oldState << newState);
408 std::string context, uint64_t imsi, uint16_t cellId)
416 std::string context, uint64_t imsi, uint16_t cellId)
424 std::string context, uint64_t imsi, uint16_t cellId, uint16_t rnti)
Iterator Begin(void) const
Get an iterator which refers to the first NetDevice in the container.
Simulation virtual time values and global simulation resolution.
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by "...
NetDeviceContainer InstallEnbDevice(NodeContainer c)
create a set of eNB devices
void InitialCellSelectionEndOkCallback(std::string context, uint64_t imsi, uint16_t cellId)
holds a vector of std::pair of Ptr and interface index.
void SetDefaultRoute(Ipv4Address nextHop, uint32_t interface, uint32_t metric=0)
Add a default route to the static routing table.
std::vector< Ptr< Node > >::const_iterator Iterator
Node container iterator.
hold variables of type string
Ptr< NetDevice > Get(uint32_t i) const
Get the Ptr stored in this container at a given index.
NetDeviceContainer Install(NodeContainer c)
a class to represent an Ipv4 address mask
A set of input parameters for setting up a UE in the simulation.
virtual Ptr< Node > GetPgwNode()
Ptr< LteUeRrc > GetRrc() const
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file...
Hold a signed integer type.
void Attach(NetDeviceContainer ueDevices)
Enables automatic attachment of a set of UE devices to a suitable cell using Idle mode initial cell s...
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
aggregate IP/TCP/UDP functionality to existing Nodes.
Iterator End(void) const
Get an iterator which indicates past-the-last Node in the container.
void SetUeDeviceAttribute(std::string n, const AttributeValue &v)
set an attribute for the LteUeNetDevice to be created
#define NS_LOG_INFO(msg)
Use NS_LOG to output a message of level LOG_INFO.
#define NS_FATAL_ERROR(msg)
fatal error handling
double m_interSiteDistance
Build a set of PointToPointNetDevice objects.
int64_t AssignStreams(NetDeviceContainer c, int64_t stream)
Assign a fixed random variable stream number to the random variables used by this model...
void Connect(std::string path, const CallbackBase &cb)
void InitialCellSelectionEndErrorCallback(std::string context, uint64_t imsi, uint16_t cellId)
void SetDeviceAttribute(std::string name, const AttributeValue &value)
Set an attribute value to be propagated to each NetDevice created by the helper.
uint32_t GetN(void) const
Get the number of Ptr stored in this container.
uint32_t GetN(void) const
Get the number of Ptr stored in this container.
Class for representing data rates.
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 Install(Ptr< Node > node) const
"Layout" a single node according to the current position allocator type.
UeSetup_t(double relPosX, double relPosY, bool isCsgMember, Time checkPoint, uint16_t expectedCellId1, uint16_t expectedCellId2)
hold objects of type ns3::Time
void Add(NetDeviceContainer other)
Append the contents of another NetDeviceContainer to the end of this container.
Hold an unsigned integer type.
#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.
LteCellSelectionTestCase(std::string name, bool isEpcMode, bool isIdealRrc, double interSiteDistance, std::vector< UeSetup_t > ueSetupList, int64_t rngRun)
Creates an instance of the initial cell selection test case.
holds a vector of ns3::NetDevice pointers
Callback< R > MakeCallback(R(T::*memPtr)(void), OBJ objPtr)
LteCellSelectionTestSuite()
Access to the Ipv4 forwarding table, interfaces, and configuration.
Testing the initial cell selection procedure by UE at IDLE state in the beginning of simulation...
virtual Ipv4Address GetUeDefaultGatewayAddress()
keep track of a set of node pointers.
Iterator Begin(void) const
Get an iterator which refers to the first Node in the container.
void SetMobilityModel(std::string type, std::string n1="", const AttributeValue &v1=EmptyAttributeValue(), std::string n2="", const AttributeValue &v2=EmptyAttributeValue(), std::string n3="", const AttributeValue &v3=EmptyAttributeValue(), std::string n4="", const AttributeValue &v4=EmptyAttributeValue(), std::string n5="", const AttributeValue &v5=EmptyAttributeValue(), std::string n6="", const AttributeValue &v6=EmptyAttributeValue(), std::string n7="", const AttributeValue &v7=EmptyAttributeValue(), std::string n8="", const AttributeValue &v8=EmptyAttributeValue(), std::string n9="", const AttributeValue &v9=EmptyAttributeValue())
void Install(std::string nodeName) const
Aggregate implementations of the ns3::Ipv4, ns3::Ipv6, ns3::Udp, and ns3::Tcp classes onto the provid...
void AddTestCase(TestCase *testCase) NS_DEPRECATED
Add an individual child TestCase case to this TestCase.
static LteCellSelectionTestSuite g_lteCellSelectionTestSuite
void SetChannelAttribute(std::string name, const AttributeValue &value)
Set an attribute value to be propagated to each Channel created by the helper.
std::vector< UeSetup_t > m_ueSetupList
NetDeviceContainer InstallUeDevice(NodeContainer c)
create a set of UE devices
virtual Ipv4InterfaceContainer AssignUeIpv4Address(NetDeviceContainer ueDevices)
Assign IPv4 addresses to UE devices.
State
The states of the UE RRC entity.
Helper class used to assign positions and mobility models to nodes.
void AddNetworkRouteTo(Ipv4Address network, Ipv4Mask networkMask, Ipv4Address nextHop, uint32_t interface, uint32_t metric=0)
Add a network route to the static routing table.
Ipv4 addresses are stored in host order in this class.
virtual void DoRun()
Setup the simulation according to the configuration set by the class constructor, run it...
Ipv4InterfaceContainer Assign(const NetDeviceContainer &c)
Assign IP addresses to the net devices specified in the container based on the current network prefix...
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...
void SetEpcHelper(Ptr< EpcHelper > h)
Set the EpcHelper to be used to setup the EPC network in conjunction with the setup of the LTE radio ...
void ConnectionEstablishedCallback(std::string context, uint64_t imsi, uint16_t cellId, uint16_t rnti)
Helper class that adds ns3::Ipv4StaticRouting objects.
hold objects of type ns3::DataRate
Ptr< Node > Get(uint32_t i) const
Get the Ptr stored in this container at a given index.
std::vector< Ptr< NetDevice > >::const_iterator Iterator
NetDevice container iterator.
std::string GetName(void) const
A helper class to make life easier while doing simple IPv4 address assignment in scripts.
void Create(uint32_t n)
Create n nodes and append pointers to them to the end of this NodeContainer.
std::vector< LteUeRrc::State > m_lastState
The current UE RRC state.
Test suite for executing the cell selection test cases in without-EPC and with-EPC scenarios...
void SetPositionAllocator(Ptr< PositionAllocator > allocator)
Set the position allocator which will be used to allocate the initial position of every node initiali...
Iterator End(void) const
Get an iterator which indicates past-the-last NetDevice in the container.
void SetAttribute(std::string name, const AttributeValue &value)
Ptr< T > GetObject(void) const
void SetGlobal(std::string name, const AttributeValue &value)
void SetBase(Ipv4Address network, Ipv4Mask mask, Ipv4Address base="0.0.0.1")
Set the base network number, network mask and base address.
void StateTransitionCallback(std::string context, uint64_t imsi, uint16_t cellId, uint16_t rnti, LteUeRrc::State oldState, LteUeRrc::State newState)
void SetEnbDeviceAttribute(std::string n, const AttributeValue &v)
set an attribute for the LteEnbNetDevice to be created
virtual ~LteCellSelectionTestCase()
The LteUeNetDevice class implements the UE net device.