22 #include <ns3/core-module.h> 23 #include <ns3/network-module.h> 24 #include <ns3/mobility-module.h> 25 #include <ns3/lte-module.h> 26 #include <ns3/internet-module.h> 27 #include <ns3/applications-module.h> 28 #include <ns3/point-to-point-module.h> 70 LteX2HandoverTestCase (uint32_t nUes, uint32_t nDedicatedBearers, std::list<HandoverEvent> handoverEventList, std::string handoverEventListName, std::string schedulerType,
bool admitHo,
bool useIdealRrc);
83 static std::string BuildNameString (uint32_t nUes, uint32_t nDedicatedBearers, std::string handoverEventListName, std::string schedulerType,
bool admitHo,
bool useIdealRrc);
84 virtual void DoRun (
void);
96 void TeleportUeToMiddle (
Ptr<Node> ueNode);
147 void SaveStatsAfterHandover (uint32_t ueIndex);
152 void CheckStatsAWhileAfterHandover (uint32_t ueIndex);
166 std::ostringstream oss;
167 oss <<
" nUes=" << nUes
168 <<
" nDedicatedBearers=" << nDedicatedBearers
169 <<
" " << schedulerType
170 <<
" admitHo=" << admitHo
171 <<
" hoList: " << handoverEventListName;
174 oss <<
", ideal RRC";
184 :
TestCase (BuildNameString (nUes, nDedicatedBearers, handoverEventListName, schedulerType, admitHo, useIdealRrc)),
186 m_nDedicatedBearers (nDedicatedBearers),
187 m_handoverEventList (handoverEventList),
188 m_handoverEventListName (handoverEventListName),
190 m_schedulerType (schedulerType),
192 m_useIdealRrc (useIdealRrc),
193 m_maxHoDuration (
Seconds (0.1)),
194 m_statsDuration (
Seconds (0.1)),
195 m_udpClientInterval (
Seconds (0.01)),
196 m_udpClientPktSize (100)
229 m_epcHelper = CreateObject<PointToPointEpcHelper> ();
234 positionAlloc->
Add (Vector (-3000, 0, 0));
235 positionAlloc->
Add (Vector ( 3000, 0, 0));
236 for (uint16_t i = 0; i <
m_nUes; i++)
238 positionAlloc->
Add (Vector (-3000, 100, 0));
241 mobility.SetPositionAllocator (positionAlloc);
242 mobility.SetMobilityModel (
"ns3::ConstantPositionMobilityModel");
250 it != enbDevices.
End ();
269 remoteHostContainer.
Create (1);
270 remoteHost = remoteHostContainer.
Get (0);
272 internet.
Install (remoteHostContainer);
282 ipv4h.
SetBase (
"1.0.0.0",
"255.0.0.0");
285 remoteHostAddr = internetIpIfaces.
GetAddress (1);
308 uint16_t dlPort = 10000;
309 uint16_t ulPort = 20000;
319 for (uint32_t u = 0; u < ueNodes.
GetN (); ++u)
340 clientApps.Add (dlClientHelper.Install (remoteHost));
377 EpsBearer bearer (EpsBearer::NGBR_VIDEO_TCP_DEFAULT);
395 for (uint32_t u = 0; u < ueDevices.
GetN (); ++u)
411 const Time maxRrcConnectionEstablishmentDuration =
Seconds (0.080);
414 Simulator::Schedule (maxRrcConnectionEstablishmentDuration,
416 this, *it, enbDevices.
Get (0));
427 Simulator::Schedule (hoEventIt->startTime -
MilliSeconds (10),
430 ueNodes.
Get (hoEventIt->ueDeviceIndex));
432 Simulator::Schedule (hoEventIt->startTime,
435 ueDevices.
Get (hoEventIt->ueDeviceIndex),
436 enbDevices.
Get (hoEventIt->sourceEnbDeviceIndex));
439 ueDevices.
Get (hoEventIt->ueDeviceIndex),
440 enbDevices.
Get (hoEventIt->sourceEnbDeviceIndex),
441 enbDevices.
Get (hoEventIt->targetEnbDeviceIndex));
444 Simulator::Schedule (hoEventIt->startTime +
MilliSeconds (40),
447 ueNodes.
Get (hoEventIt->ueDeviceIndex),
448 enbNodes.
Get (
m_admitHo ? hoEventIt->targetEnbDeviceIndex
449 : hoEventIt->sourceEnbDeviceIndex));
452 Simulator::Schedule (hoEndTime,
455 ueDevices.
Get (hoEventIt->ueDeviceIndex),
456 enbDevices.
Get (
m_admitHo ? hoEventIt->targetEnbDeviceIndex : hoEventIt->sourceEnbDeviceIndex));
458 this, hoEventIt->ueDeviceIndex);
462 this, hoEventIt->ueDeviceIndex);
463 if (
stopTime <= checkStatsAfterHoTime)
477 Simulator::Destroy ();
491 uint16_t rnti = ueRrc->GetRnti ();
497 NS_ASSERT_MSG (ueManagerState == UeManager::CONNECTED_NORMALLY,
"Wrong UeManager state!");
499 uint16_t ueCellId = ueRrc->GetCellId ();
500 uint16_t enbCellId = enbLteDevice->GetCellId ();
501 uint8_t ueDlBandwidth = ueRrc->GetDlBandwidth ();
502 uint8_t enbDlBandwidth = enbLteDevice->GetDlBandwidth ();
503 uint8_t ueUlBandwidth = ueRrc->GetUlBandwidth ();
504 uint8_t enbUlBandwidth = enbLteDevice->GetUlBandwidth ();
505 uint8_t ueDlEarfcn = ueRrc->GetDlEarfcn ();
506 uint8_t enbDlEarfcn = enbLteDevice->GetDlEarfcn ();
507 uint8_t ueUlEarfcn = ueRrc->GetUlEarfcn ();
508 uint8_t enbUlEarfcn = enbLteDevice->GetUlEarfcn ();
509 uint64_t ueImsi = ueLteDevice->
GetImsi ();
510 uint64_t enbImsi = ueManager->
GetImsi ();
520 ueManager->
GetAttribute (
"DataRadioBearerMap", enbDataRadioBearerMapValue);
524 ueRrc->GetAttribute (
"DataRadioBearerMap", ueDataRadioBearerMapValue);
529 while (enbBearerIt != enbDataRadioBearerMapValue.
End ()
530 && ueBearerIt != ueDataRadioBearerMapValue.End ())
544 NS_ASSERT_MSG (enbBearerIt == enbDataRadioBearerMapValue.
End (),
"too many bearers at eNB");
545 NS_ASSERT_MSG (ueBearerIt == ueDataRadioBearerMapValue.End (),
"too many bearers at UE");
562 ueMobility->
SetPosition (pos + Vector (0.0, 100.0, 0.0));
568 for (std::list<BearerData>::iterator it =
m_ueDataVector.at (ueIndex).bearerDataList.begin ();
572 it->dlOldTotalRx = it->dlSink->GetTotalRx ();
573 it->ulOldTotalRx = it->ulSink->GetTotalRx ();
581 for (std::list<BearerData>::iterator it =
m_ueDataVector.at (ueIndex).bearerDataList.begin ();
585 uint32_t dlRx = it->dlSink->GetTotalRx () - it->dlOldTotalRx;
586 uint32_t ulRx = it->ulSink->GetTotalRx () - it->ulOldTotalRx;
589 NS_TEST_ASSERT_MSG_EQ (dlRx, expectedBytes,
"too few RX bytes in DL, ue=" << ueIndex <<
", b=" << b);
590 NS_TEST_ASSERT_MSG_EQ (ulRx, expectedBytes,
"too few RX bytes in UL, ue=" << ueIndex <<
", b=" << b);
655 std::string hel0name (
"none");
656 std::list<HandoverEvent> hel0;
658 std::string hel1name (
"1 fwd");
659 std::list<HandoverEvent> hel1;
660 hel1.push_back (ue1fwd);
662 std::string hel2name (
"1 fwd & bwd");
663 std::list<HandoverEvent> hel2;
664 hel2.push_back (ue1fwd);
665 hel2.push_back (ue1bwd);
667 std::string hel3name (
"1 fwd & bwd & fwd");
668 std::list<HandoverEvent> hel3;
669 hel3.push_back (ue1fwd);
670 hel3.push_back (ue1bwd);
671 hel3.push_back (ue1fwdagain);
673 std::string hel4name (
"1+2 fwd");
674 std::list<HandoverEvent> hel4;
675 hel4.push_back (ue1fwd);
676 hel4.push_back (ue2fwd);
678 std::string hel5name (
"1+2 fwd & bwd");
679 std::list<HandoverEvent> hel5;
680 hel5.push_back (ue1fwd);
681 hel5.push_back (ue1bwd);
682 hel5.push_back (ue2fwd);
683 hel5.push_back (ue2bwd);
685 std::string hel6name (
"2 fwd");
686 std::list<HandoverEvent> hel6;
687 hel6.push_back (ue2fwd);
689 std::string hel7name (
"2 fwd & bwd");
690 std::list<HandoverEvent> hel7;
691 hel7.push_back (ue2fwd);
692 hel7.push_back (ue2bwd);
694 std::vector<std::string> schedulers;
695 schedulers.push_back (
"ns3::RrFfMacScheduler");
696 schedulers.push_back (
"ns3::PfFfMacScheduler");
697 for (std::vector<std::string>::iterator schedIt = schedulers.begin (); schedIt != schedulers.end (); ++schedIt)
699 for (int32_t useIdealRrc = 1; useIdealRrc >= 0; --useIdealRrc)
Ptr< PacketSink > dlSink
DL sink.
holds a vector of ns3::Application pointers.
uint8_t Add(PacketFilter f)
add a PacketFilter to the Traffic Flow Template
Ptr< NetDevice > Get(uint32_t i) const
Get the Ptr<NetDevice> stored in this container at a given index.
uint32_t m_nDedicatedBearers
number of UEs in the test
Simulation virtual time values and global simulation resolution.
static std::string BuildNameString(uint32_t nUes, uint32_t nDedicatedBearers, std::string handoverEventListName, std::string schedulerType, bool admitHo, bool useIdealRrc)
Build name string.
std::list< BearerData > bearerDataList
bearer ID list
Smart pointer class similar to boost::intrusive_ptr.
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by "...
void SetStream(int64_t stream)
Specifies the stream number for the RngStream.
std::string m_handoverEventListName
handover event list name
State
The state of the UeManager at the eNB RRC.
AttributeValue implementation for Boolean.
NetDeviceContainer InstallEnbDevice(NodeContainer c)
Create a set of eNodeB devices.
const uint32_t m_udpClientPktSize
UDP client packet size.
Ptr< LteHelper > m_lteHelper
LTE helper.
holds a vector of std::pair of Ptr<Ipv4> and interface index.
void SetDefaultRoute(Ipv4Address nextHop, uint32_t interface, uint32_t metric=0)
Add a default route to the static routing table.
Iterator End(void) const
Get an iterator which indicates past-the-last NetDevice in the container.
LteX2HandoverTestCase(uint32_t nUes, uint32_t nDedicatedBearers, std::list< HandoverEvent > handoverEventList, std::string handoverEventListName, std::string schedulerType, bool admitHo, bool useIdealRrc)
Hold variables of type string.
void HandoverRequest(Time hoTime, Ptr< NetDevice > ueDev, Ptr< NetDevice > sourceEnbDev, Ptr< NetDevice > targetEnbDev)
Manually trigger an X2-based handover.
NetDeviceContainer Install(NodeContainer c)
a class to represent an Ipv4 address mask
Ptr< PacketSink > ulSink
UL sink.
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.
Time MilliSeconds(uint64_t value)
Construct a Time in the indicated unit.
ApplicationContainer Install(NodeContainer c) const
Install an ns3::PacketSinkApplication on each node of the input container configured with all the att...
aggregate IP/TCP/UDP functionality to existing Nodes.
uint16_t localPortEnd
end of the port number range of the UE
uint64_t GetImsi(void) const
A helper to make it easier to instantiate an ns3::PacketSinkApplication on a set of nodes...
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.
void ActivateDataRadioBearer(NetDeviceContainer ueDevices, EpsBearer bearer)
Activate a Data Radio Bearer on a given UE devices (for LTE-only simulation).
void SetDeviceAttribute(std::string name, const AttributeValue &value)
Set an attribute value to be propagated to each NetDevice created by the helper.
uint8_t ActivateDedicatedEpsBearer(NetDeviceContainer ueDevices, EpsBearer bearer, Ptr< EpcTft > tft)
Activate a dedicated EPS bearer on a given set of UE devices.
uint32_t targetEnbDeviceIndex
target ENB device index
void SetHandoverAlgorithmType(std::string type)
Set the type of handover algorithm to be used by eNodeB devices.
ApplicationContainer Install(NodeContainer c)
void SetSchedulerType(std::string type)
Set the type of scheduler to be used by eNodeB devices.
Class for representing data rates.
Keep track of the current position and velocity of an object.
uint64_t GetImsi() const
Get the IMSI.
virtual Ipv4InterfaceContainer AssignUeIpv4Address(NetDeviceContainer ueDevices)
Assign IPv4 addresses to UE devices.
void SaveStatsAfterHandover(uint32_t ueIndex)
Save stats after handover function.
store information on active data radio bearer instance
uint8_t m_logicalChannelIdentity
logical channel identity
Create a client application which sends UDP packets carrying a 32bit sequence number and a 64 bit tim...
uint32_t m_nUes
number of UEs in the test
AttributeValue implementation for Time.
uint32_t ueDeviceIndex
UE device index.
void AddTestCase(TestCase *testCase, TestDuration duration=QUICK)
Add an individual child TestCase to this test suite.
Ipv4Address GetAddress(uint32_t i, uint32_t j=0) const
LTE X2 Handover Test Suite.
Iterator Begin(void) const
Get an iterator which refers to the first NetDevice in the container.
Iterator Begin(void) const
Get an iterator to the first Object.
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.
std::map< std::size_t, Ptr< Object > >::const_iterator Iterator
Iterator type for traversing this container.
bool m_admitHo
whether to admit the handover request
std::string m_schedulerType
scheduler type
holds a vector of ns3::NetDevice pointers
Iterator End(void) const
Get an iterator to the past-the-end Object.
static LteX2HandoverTestSuite g_lteX2HandoverTestSuiteInstance
std::vector< UeData > m_ueDataVector
UE data vector.
const Time m_statsDuration
stats duration
std::size_t GetN(void) const
Get the number of Objects.
uint32_t sourceEnbDeviceIndex
source ENB device index
uint32_t GetN(void) const
Get the number of Ptr<Node> stored in this container.
Access to the IPv4 forwarding table, interfaces, and configuration.
Ptr< T > GetObject(void) const
Get a pointer to the requested aggregated Object.
std::list< HandoverEvent > m_handoverEventList
handover event list
uint16_t remotePortEnd
end of the port number range of the remote host
bool m_useIdealRrc
whether to use the ideal RRC
Every class exported by the ns3 library is enclosed in the ns3 namespace.
keep track of a set of node pointers.
const Time m_udpClientInterval
UDP client interval.
virtual void DoRun(void)
Implementation to actually run this TestCase.
void AddX2Interface(NodeContainer enbNodes)
Create an X2 interface between all the eNBs in a given set.
This class contains the specification of EPS Bearers.
Ptr< PointToPointEpcHelper > m_epcHelper
EPC helper.
void SetPosition(const Vector &position)
void Reset(void)
Reset the initial value of every attribute as well as the value of every global to what they were bef...
void SetChannelAttribute(std::string name, const AttributeValue &value)
Set an attribute value to be propagated to each Channel created by the helper.
#define NS_ASSERT_MSG(condition, message)
At runtime, in debugging builds, if this condition is not true, the program prints the message to out...
void Install(std::string nodeName) const
Aggregate implementations of the ns3::Ipv4, ns3::Ipv6, ns3::Udp, and ns3::Tcp classes onto the provid...
NetDeviceContainer InstallUeDevice(NodeContainer c)
Create a set of UE devices.
Vector GetPosition(void) const
void CheckConnected(Ptr< NetDevice > ueDevice, Ptr< NetDevice > enbDevice)
Check connected function.
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.
const Time m_maxHoDuration
maximum HO duration
void CheckStatsAWhileAfterHandover(uint32_t ueIndex)
Check stats a while after handover function.
Ipv4InterfaceContainer Assign(const NetDeviceContainer &c)
Assign IP addresses to the net devices specified in the container based on the current network prefix...
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 ...
#define NS_TEST_ASSERT_MSG_NE(actual, limit, msg)
Test that an actual and expected (limit) value are not equal and report and abort if not...
uint8_t m_drbIdentity
DRB identity.
Helper class that adds ns3::Ipv4StaticRouting objects.
AttributeValue implementation for DataRate.
virtual Ptr< Node > GetPgwNode() const
Get the PGW node.
std::vector< Ptr< NetDevice > >::const_iterator Iterator
NetDevice container iterator.
Time Seconds(double value)
Construct a Time in the indicated unit.
uint32_t GetN(void) const
Get the number of Ptr<NetDevice> stored in this container.
uint32_t dlOldTotalRx
DL old total receive.
void SetDefault(std::string name, const AttributeValue &value)
void Add(Vector v)
Add a position to the list of positions.
Ptr< LteUeRrc > GetRrc() const
Get the RRC.
Ptr< Node > Get(uint32_t i) const
Get the Ptr<Node> stored in this container at a given index.
void TeleportUeNearTargetEnb(Ptr< Node > ueNode, Ptr< Node > enbNode)
Teleport UE near the target eNB of the handover.
uint32_t ulOldTotalRx
UL old total receive.
bool m_epc
whether to use EPC
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.
Container for a set of ns3::Object pointers.
Receive and consume traffic generated to an IP address and port.
This class can be used to hold variables of floating point type such as 'double' or 'float'...
void SetAttribute(std::string name, const AttributeValue &value)
Set a single attribute, raising fatal errors if unsuccessful.
The eNodeB device implementation.
void GetAttribute(std::string name, AttributeValue &value) const
Get the value of an attribute, raising fatal errors if unsuccessful.
Ptr< Application > Get(uint32_t i) const
Get the Ptr<Application> stored in this container at a given index.
virtual Ipv4Address GetUeDefaultGatewayAddress()
uint16_t remotePortStart
start of the port number range of the remote host
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 SetBase(Ipv4Address network, Ipv4Mask mask, Ipv4Address base="0.0.0.1")
Set the base network number, network mask and base address.
void TeleportUeToMiddle(Ptr< Node > ueNode)
Teleport UE between both eNBs of the test.
Implement the data structure representing a TrafficFlowTemplate Packet Filter.
uint16_t localPortStart
start of the port number range of the UE
uint8_t m_epsBearerIdentity
EPS bearer identity.
The LteUeNetDevice class implements the UE net device.