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)
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 ();
503 uint8_t ueUlBandwidth = ueRrc->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)