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>
37 uint32_t ueDeviceIndex;
38 uint32_t sourceEnbDeviceIndex;
39 uint32_t targetEnbDeviceIndex;
58 LteX2HandoverTestCase (uint32_t nUes, uint32_t nDedicatedBearers, std::list<HandoverEvent> handoverEventList, std::string handoverEventListName,
bool useUdp, std::string schedulerType,
bool admitHo,
bool useIdealRrc);
61 static std::string BuildNameString (uint32_t nUes, uint32_t nDedicatedBearers, std::string handoverEventListName,
bool useUdp, std::string schedulerType,
bool admitHo,
bool useIdealRrc);
62 virtual void DoRun (
void);
66 uint32_t m_nDedicatedBearers;
67 std::list<HandoverEvent> m_handoverEventList;
68 std::string m_handoverEventListName;
71 std::string m_schedulerType;
82 uint32_t dlOldTotalRx;
83 uint32_t ulOldTotalRx;
89 std::list<BearerData> bearerDataList;
92 void SaveStatsAfterHandover (uint32_t ueIndex);
93 void CheckStatsAWhileAfterHandover (uint32_t ueIndex);
95 std::vector<UeData> m_ueDataVector;
97 const Time m_maxHoDuration;
98 const Time m_statsDuration;
103 std::string LteX2HandoverTestCase::BuildNameString (uint32_t nUes, uint32_t nDedicatedBearers, std::string handoverEventListName,
bool useUdp, std::string schedulerType,
bool admitHo,
bool useIdealRrc)
105 std::ostringstream oss;
106 oss <<
" nUes=" << nUes
107 <<
" nDedicatedBearers=" << nDedicatedBearers
109 <<
" " << schedulerType
110 <<
" admitHo=" << admitHo
111 <<
" hoList: " << handoverEventListName;
114 oss <<
", ideal RRC";
123 LteX2HandoverTestCase::LteX2HandoverTestCase (uint32_t nUes, uint32_t nDedicatedBearers, std::list<HandoverEvent> handoverEventList, std::string handoverEventListName,
bool useUdp, std::string schedulerType,
bool admitHo,
bool useIdealRrc)
124 :
TestCase (BuildNameString (nUes, nDedicatedBearers, handoverEventListName, useUdp, schedulerType, admitHo, useIdealRrc)),
126 m_nDedicatedBearers (nDedicatedBearers),
127 m_handoverEventList (handoverEventList),
128 m_handoverEventListName (handoverEventListName),
131 m_schedulerType (schedulerType),
133 m_useIdealRrc (useIdealRrc),
134 m_maxHoDuration (
Seconds (0.1)),
135 m_statsDuration (
Seconds (0.5))
142 NS_LOG_FUNCTION (
this << BuildNameString (m_nUes, m_nDedicatedBearers, m_handoverEventListName, m_useUdp, m_schedulerType, m_admitHo, m_useIdealRrc));
151 m_lteHelper = CreateObject<LteHelper> ();
152 m_lteHelper->SetAttribute (
"PathlossModel",
StringValue (
"ns3::FriisSpectrumPropagationLossModel"));
153 m_lteHelper->SetSchedulerType (m_schedulerType);
154 m_lteHelper->SetAttribute (
"UseIdealRrc",
BooleanValue (m_useIdealRrc));
164 m_epcHelper = CreateObject<EpcHelper> ();
165 m_lteHelper->SetEpcHelper (m_epcHelper);
169 positionAlloc->Add (
Vector (-3000, 0, 0));
170 positionAlloc->Add (
Vector ( 3000, 0, 0));
171 for (uint16_t i = 0; i < m_nUes; i++)
173 positionAlloc->Add (
Vector (0, 0, 0));
182 enbDevices = m_lteHelper->InstallEnbDevice (enbNodes);
183 stream += m_lteHelper->AssignStreams (enbDevices, stream);
184 for (NetDeviceContainer::Iterator it = enbDevices.
Begin ();
185 it != enbDevices.
End ();
189 enbRrc->SetAttribute (
"AdmitHandoverRequest",
BooleanValue (m_admitHo));
193 ueDevices = m_lteHelper->InstallUeDevice (ueNodes);
194 stream += m_lteHelper->AssignStreams (ueDevices, stream);
204 remoteHostContainer.
Create (1);
205 remoteHost = remoteHostContainer.
Get (0);
207 internet.
Install (remoteHostContainer);
214 Ptr<Node> pgw = m_epcHelper->GetPgwNode ();
217 ipv4h.
SetBase (
"1.0.0.0",
"255.0.0.0");
220 remoteHostAddr = internetIpIfaces.
GetAddress (1);
224 remoteHostStaticRouting->AddNetworkRouteTo (
Ipv4Address (
"7.0.0.0"),
Ipv4Mask (
"255.0.0.0"), 1);
233 m_lteHelper->Attach (ueDevices, enbDevices.
Get (0));
243 uint16_t dlPort = 10000;
244 uint16_t ulPort = 20000;
254 for (uint32_t u = 0; u < ueNodes.
GetN (); ++u)
259 ueStaticRouting->SetDefaultRoute (m_epcHelper->GetUeDefaultGatewayAddress (), 1);
263 for (uint32_t b = 0; b < m_nDedicatedBearers; ++b)
277 clientApps.
Add (dlClientHelper.Install (remoteHost));
281 bearerData.dlSink = sinkContainer.
Get (0)->GetObject<
PacketSink> ();
282 serverApps.
Add (sinkContainer);
292 bearerData.ulSink = sinkContainer.
Get (0)->GetObject<
PacketSink> ();
293 serverApps.
Add (sinkContainer);
303 clientApps.
Add (dlClientHelper.
Install (remoteHost));
307 bearerData.dlSink = sinkContainer.
Get (0)->GetObject<
PacketSink> ();
308 serverApps.
Add (sinkContainer);
319 bearerData.ulSink = sinkContainer.
Get (0)->GetObject<
PacketSink> ();
320 serverApps.
Add (sinkContainer);
342 EpsBearer bearer (EpsBearer::NGBR_VIDEO_TCP_DEFAULT);
343 m_lteHelper->ActivateDedicatedEpsBearer (ueDevices.
Get (u), bearer, tft);
346 serverApps.
Start (startTime);
347 clientApps.
Start (startTime);
349 ueData.bearerDataList.push_back (bearerData);
353 m_ueDataVector.push_back (ueData);
360 for (uint32_t u = 0; u < ueDevices.
GetN (); ++u)
363 for (uint32_t b = 0; b < m_nDedicatedBearers; ++b)
367 m_lteHelper->ActivateDataRadioBearer (ueDev, bearer);
373 m_lteHelper->AddX2Interface (enbNodes);
376 const Time maxRrcConnectionEstablishmentDuration =
Seconds (0.080);
377 for (NetDeviceContainer::Iterator it = ueDevices.
Begin (); it != ueDevices.
End (); ++it)
380 &LteX2HandoverTestCase::CheckConnected,
381 this, *it, enbDevices.
Get (0));
387 for (std::list<HandoverEvent>::iterator hoEventIt = m_handoverEventList.begin ();
388 hoEventIt != m_handoverEventList.end ();
392 &LteX2HandoverTestCase::CheckConnected,
394 ueDevices.
Get (hoEventIt->ueDeviceIndex),
395 enbDevices.
Get (hoEventIt->sourceEnbDeviceIndex));
396 m_lteHelper->HandoverRequest (hoEventIt->startTime,
397 ueDevices.
Get (hoEventIt->ueDeviceIndex),
398 enbDevices.
Get (hoEventIt->sourceEnbDeviceIndex),
399 enbDevices.
Get (hoEventIt->targetEnbDeviceIndex));
400 Time hoEndTime = hoEventIt->startTime + m_maxHoDuration;
402 &LteX2HandoverTestCase::CheckConnected,
404 ueDevices.
Get (hoEventIt->ueDeviceIndex),
405 enbDevices.
Get (m_admitHo ? hoEventIt->targetEnbDeviceIndex : hoEventIt->sourceEnbDeviceIndex));
407 this, hoEventIt->ueDeviceIndex);
408 Time checkStatsAfterHoTime = hoEndTime + m_statsDuration;
409 Simulator::Schedule (checkStatsAfterHoTime, &LteX2HandoverTestCase::CheckStatsAWhileAfterHandover,
410 this, hoEventIt->ueDeviceIndex);
411 if (stopTime <= hoEndTime)
417 m_lteHelper->EnableRlcTraces ();
421 m_lteHelper->EnablePdcpTraces();
437 NS_TEST_ASSERT_MSG_EQ (ueRrc->GetState (), LteUeRrc::CONNECTED_NORMALLY,
"Wrong LteUeRrc state!");
442 uint16_t rnti = ueRrc->GetRnti ();
444 NS_TEST_ASSERT_MSG_NE (ueManager, 0,
"RNTI " << rnti <<
" not found in eNB");
447 NS_TEST_ASSERT_MSG_EQ (ueManagerState, UeManager::CONNECTED_NORMALLY,
"Wrong UeManager state!");
448 NS_ASSERT_MSG (ueManagerState == UeManager::CONNECTED_NORMALLY,
"Wrong UeManager state!");
450 uint16_t ueCellId = ueRrc->GetCellId ();
451 uint16_t enbCellId = enbLteDevice->GetCellId ();
452 uint8_t ueDlBandwidth = ueRrc->GetDlBandwidth ();
453 uint8_t enbDlBandwidth = enbLteDevice->GetDlBandwidth ();
454 uint8_t ueUlBandwidth = ueRrc->GetUlBandwidth ();
455 uint8_t enbUlBandwidth = enbLteDevice->GetUlBandwidth ();
456 uint8_t ueDlEarfcn = ueRrc->GetDlEarfcn ();
457 uint8_t enbDlEarfcn = enbLteDevice->GetDlEarfcn ();
458 uint8_t ueUlEarfcn = ueRrc->GetUlEarfcn ();
459 uint8_t enbUlEarfcn = enbLteDevice->GetUlEarfcn ();
460 uint64_t ueImsi = ueLteDevice->GetImsi ();
461 uint64_t enbImsi = ueManager->GetImsi ();
463 NS_TEST_ASSERT_MSG_EQ (ueImsi, enbImsi,
"inconsistent IMSI");
464 NS_TEST_ASSERT_MSG_EQ (ueCellId, enbCellId,
"inconsistent CellId");
465 NS_TEST_ASSERT_MSG_EQ (ueDlBandwidth, enbDlBandwidth,
"inconsistent DlBandwidth");
466 NS_TEST_ASSERT_MSG_EQ (ueUlBandwidth, enbUlBandwidth,
"inconsistent UlBandwidth");
467 NS_TEST_ASSERT_MSG_EQ (ueDlEarfcn, enbDlEarfcn,
"inconsistent DlEarfcn");
468 NS_TEST_ASSERT_MSG_EQ (ueUlEarfcn, enbUlEarfcn,
"inconsistent UlEarfcn");
471 ueManager->GetAttribute (
"DataRadioBearerMap", enbDataRadioBearerMapValue);
472 NS_TEST_ASSERT_MSG_EQ (enbDataRadioBearerMapValue.
GetN (), m_nDedicatedBearers + 1,
"wrong num bearers at eNB");
475 ueRrc->GetAttribute (
"DataRadioBearerMap", ueDataRadioBearerMapValue);
476 NS_TEST_ASSERT_MSG_EQ (ueDataRadioBearerMapValue.GetN (), m_nDedicatedBearers + 1,
"wrong num bearers at UE");
478 ObjectMapValue::Iterator enbBearerIt = enbDataRadioBearerMapValue.
Begin ();
479 ObjectMapValue::Iterator ueBearerIt = ueDataRadioBearerMapValue.Begin ();
480 while (enbBearerIt != enbDataRadioBearerMapValue.
End () &&
481 ueBearerIt != ueDataRadioBearerMapValue.End ())
486 NS_TEST_ASSERT_MSG_EQ ((uint32_t) enbDrbInfo->m_epsBearerIdentity, (uint32_t) ueDrbInfo->m_epsBearerIdentity,
"epsBearerIdentity differs");
487 NS_TEST_ASSERT_MSG_EQ ((uint32_t) enbDrbInfo->m_drbIdentity, (uint32_t) ueDrbInfo->m_drbIdentity,
"drbIdentity differs");
489 NS_TEST_ASSERT_MSG_EQ ((uint32_t) enbDrbInfo->m_logicalChannelIdentity, (uint32_t) ueDrbInfo->m_logicalChannelIdentity,
"logicalChannelIdentity differs");
495 NS_ASSERT_MSG (enbBearerIt == enbDataRadioBearerMapValue.
End (),
"too many bearers at eNB");
496 NS_ASSERT_MSG (ueBearerIt == ueDataRadioBearerMapValue.End (),
"too many bearers at UE");
500 LteX2HandoverTestCase::SaveStatsAfterHandover (uint32_t ueIndex)
502 for (std::list<BearerData>::iterator it = m_ueDataVector.at (ueIndex).bearerDataList.begin ();
503 it != m_ueDataVector.at (ueIndex).bearerDataList.end ();
506 it->dlOldTotalRx = it->dlSink->GetTotalRx ();
507 it->ulOldTotalRx = it->ulSink->GetTotalRx ();
512 LteX2HandoverTestCase::CheckStatsAWhileAfterHandover (uint32_t ueIndex)
515 for (std::list<BearerData>::iterator it = m_ueDataVector.at (ueIndex).bearerDataList.begin ();
516 it != m_ueDataVector.at (ueIndex).bearerDataList.end ();
519 uint32_t dlRx = it->dlSink->GetTotalRx () - it->dlOldTotalRx;
520 uint32_t ulRx = it->ulSink->GetTotalRx () - it->ulOldTotalRx;
522 uint32_t expectedBytes = 100.0 * (0.100 / m_statsDuration.
GetSeconds ());
524 NS_TEST_ASSERT_MSG_GT (dlRx, 0.500 * expectedBytes,
"too few RX bytes in DL, ue=" << ueIndex <<
", b=" << b);
525 NS_TEST_ASSERT_MSG_GT (ulRx, 0.500 * expectedBytes,
"too few RX bytes in UL, ue=" << ueIndex <<
", b=" << b);
538 LteX2HandoverTestSuite::LteX2HandoverTestSuite ()
547 ue1fwd.ueDeviceIndex = 0;
548 ue1fwd.sourceEnbDeviceIndex = 0;
549 ue1fwd.targetEnbDeviceIndex = 1;
553 ue1bwd.ueDeviceIndex = 0;
554 ue1bwd.sourceEnbDeviceIndex = 1;
555 ue1bwd.targetEnbDeviceIndex = 0;
559 ue1fwdagain.ueDeviceIndex = 0;
560 ue1fwdagain.sourceEnbDeviceIndex = 0;
561 ue1fwdagain.targetEnbDeviceIndex = 1;
565 ue2fwd.ueDeviceIndex = 1;
566 ue2fwd.sourceEnbDeviceIndex = 0;
567 ue2fwd.targetEnbDeviceIndex = 1;
571 ue2bwd.ueDeviceIndex = 1;
572 ue2bwd.sourceEnbDeviceIndex = 1;
573 ue2bwd.targetEnbDeviceIndex = 0;
575 std::string hel0name (
"none");
576 std::list<HandoverEvent> hel0;
578 std::string hel1name (
"1 fwd");
579 std::list<HandoverEvent> hel1;
580 hel1.push_back (ue1fwd);
582 std::string hel2name (
"1 fwd & bwd");
583 std::list<HandoverEvent> hel2;
584 hel2.push_back (ue1fwd);
585 hel2.push_back (ue1bwd);
587 std::string hel3name (
"1 fwd & bwd & fwd");
588 std::list<HandoverEvent> hel3;
589 hel3.push_back (ue1fwd);
590 hel3.push_back (ue1bwd);
591 hel3.push_back (ue1fwdagain);
593 std::string hel4name (
"1+2 fwd");
594 std::list<HandoverEvent> hel4;
595 hel4.push_back (ue1fwd);
596 hel4.push_back (ue2fwd);
598 std::string hel5name (
"1+2 fwd & bwd");
599 std::list<HandoverEvent> hel5;
600 hel5.push_back (ue1fwd);
601 hel5.push_back (ue1bwd);
602 hel5.push_back (ue2fwd);
603 hel5.push_back (ue2bwd);
605 std::string hel6name (
"2 fwd");
606 std::list<HandoverEvent> hel6;
607 hel6.push_back (ue2fwd);
609 std::string hel7name (
"2 fwd & bwd");
610 std::list<HandoverEvent> hel7;
611 hel7.push_back (ue2fwd);
612 hel7.push_back (ue2bwd);
614 std::vector<std::string> schedulers;
615 schedulers.push_back (
"ns3::RrFfMacScheduler");
616 schedulers.push_back (
"ns3::PfFfMacScheduler");
617 for (std::vector<std::string>::iterator schedIt = schedulers.begin (); schedIt != schedulers.end (); ++schedIt)
619 for (int32_t useIdealRrc = 1; useIdealRrc >= 0; --useIdealRrc)
667 static LteX2HandoverTestSuite g_lteX2HandoverTestSuiteInstance;
holds a vector of ns3::Application pointers.
Iterator Begin(void) const
Get an iterator which refers to the first NetDevice in the container.
static Ipv4Address GetAny(void)
smart pointer class similar to boost::intrusive_ptr
#define NS_LOG_FUNCTION(parameters)
void SetStream(int64_t stream)
Specifies the stream number for this RNG stream.
A helper to make it easier to instantiate an ns3::BulkSendApplication on a set of nodes...
holds a vector of std::pair of Ptr<Ipv4> and interface index.
hold variables of type string
Ptr< NetDevice > Get(uint32_t i) const
Get the Ptr<NetDevice> stored in this container at a given index.
NetDeviceContainer Install(NodeContainer c)
a class to represent an Ipv4 address mask
void Add(ApplicationContainer other)
Append the contents of another ApplicationContainer to the end of this container. ...
#define NS_LOG_COMPONENT_DEFINE(name)
aggregate IP/TCP/UDP functionality to existing Nodes.
A helper to make it easier to instantiate an ns3::PacketSinkApplication on a set of nodes...
Build a set of PointToPointNetDevice objects.
static EventId Schedule(Time const &time, MEM mem_ptr, OBJ obj)
void SetDeviceAttribute(std::string name, const AttributeValue &value)
ApplicationContainer Install(NodeContainer c)
uint32_t GetN(void) const
Get the number of Ptr<Node> stored in this container.
uint32_t GetN(void) const
Get the number of Ptr<NetDevice> stored in this container.
Class for representing data rates.
double GetSeconds(void) const
ApplicationContainer Install(NodeContainer c) const
void Install(Ptr< Node > node) const
"Layout" a single node according to the current position allocator type.
Create a client application which sends udp packets carrying a 32bit sequence number and a 64 bit tim...
hold objects of type ns3::Time
Hold an unsigned integer type.
holds a vector of ns3::NetDevice pointers
void Start(Time start)
Arrange for all of the Applications in this container to Start() at the Time given as a parameter...
virtual void DoRun(void)
Implementation to actually run this test case.
static void Destroy(void)
Access to the Ipv4 forwarding table, interfaces, and configuration.
void SetDefault(std::string name, const AttributeValue &value)
keep track of a set of node pointers.
Ptr< Application > Get(uint32_t i) const
Get the Ptr<Application> stored in this container at a given index.
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
Iterator Begin(void) const
void AddTestCase(TestCase *testCase) NS_DEPRECATED
Add an individual test case to this test suite.
void SetChannelAttribute(std::string name, const AttributeValue &value)
#define NS_ASSERT_MSG(condition, message)
Helper class used to assign positions and mobility models to nodes.
Ipv4 addresses are stored in host order in this class.
Ipv4InterfaceContainer Assign(const NetDeviceContainer &c)
Assign IP addresses to the net devices specified in the container based on the current network prefix...
Time Seconds(double seconds)
create ns3::Time instances in units of seconds.
Ptr< Ipv4StaticRouting > GetStaticRouting(Ptr< Ipv4 > ipv4) const
Helper class that adds ns3::Ipv4StaticRouting objects.
hold objects of type ns3::DataRate
Ptr< Node > Get(uint32_t i) const
Get the Ptr<Node> stored in this container at a given index.
LteX2HandoverTestCase(uint32_t nUes, uint32_t nDedicatedBearers, std::list< HandoverEvent > handoverEventList, std::string handoverEventListName, bool useUdp, std::string schedulerType, bool admitHo, bool useIdealRrc)
ApplicationContainer Install(NodeContainer c) const
Time MilliSeconds(uint64_t ms)
create ns3::Time instances in units of milliseconds.
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.
void SetAttribute(std::string name, const AttributeValue &value)
uint32_t GetN(void) const
contain a set of ns3::Object pointers.
Receive and consume traffic generated to an IP address and port.
void SetPositionAllocator(Ptr< PositionAllocator > allocator)
Iterator End(void) const
Get an iterator which indicates past-the-last NetDevice in the container.
Hold an floating point type.
void SetAttribute(std::string name, const AttributeValue &value)
Ptr< T > GetObject(void) const
void SetBase(Ipv4Address network, Ipv4Mask mask, Ipv4Address base="0.0.0.1")
Set the base network number, network mask and base address.
Ipv4Address GetAddress(uint32_t i, uint32_t j=0) const