A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
test-lte-x2-handover.cc
Go to the documentation of this file.
1/*
2 * Copyright (c) 2012 Centre Tecnologic de Telecomunicacions de Catalunya (CTTC)
3 *
4 * SPDX-License-Identifier: GPL-2.0-only
5 *
6 * Author: Nicola Baldo <nbaldo@cttc.es>
7 */
8
9#include <ns3/core-module.h>
10#include <ns3/internet-module.h>
11#include <ns3/lte-module.h>
12#include <ns3/mobility-module.h>
13#include <ns3/network-module.h>
14#include <ns3/packet-sink-helper.h>
15#include <ns3/packet-sink.h>
16#include <ns3/point-to-point-module.h>
17#include <ns3/udp-client-server-helper.h>
18
19using namespace ns3;
20
21NS_LOG_COMPONENT_DEFINE("LteX2HandoverTest");
22
23/**
24 * @ingroup lte-test
25 *
26 * @brief HandoverEvent structure
27 */
29{
30 Time startTime; ///< start time
31 uint32_t ueDeviceIndex; ///< UE device index
32 uint32_t sourceEnbDeviceIndex; ///< source ENB device index
33 uint32_t targetEnbDeviceIndex; ///< target ENB device index
34};
35
36/**
37 * @ingroup lte-test
38 *
39 * @brief Test X2 Handover. In this test is used NoOpHandoverAlgorithm and
40 * the request for handover is generated manually, and it is not based on measurements.
41 */
43{
44 public:
45 /**
46 *
47 *
48 * @param nUes number of UEs in the test
49 * @param nDedicatedBearers number of bearers to be activated per UE
50 * @param handoverEventList
51 * @param handoverEventListName
52 * @param schedulerType the scheduler type
53 * @param admitHo
54 * @param useIdealRrc true if the ideal RRC should be used
55 */
57 uint32_t nDedicatedBearers,
58 std::list<HandoverEvent> handoverEventList,
59 std::string handoverEventListName,
60 std::string schedulerType,
61 bool admitHo,
62 bool useIdealRrc);
63
64 private:
65 /**
66 * Build name string
67 * @param nUes number of UEs in the test
68 * @param nDedicatedBearers number of bearers to be activated per UE
69 * @param handoverEventListName
70 * @param schedulerType the scheduler type
71 * @param admitHo
72 * @param useIdealRrc true if the ideal RRC should be used
73 * @returns the name string
74 */
75 static std::string BuildNameString(uint32_t nUes,
76 uint32_t nDedicatedBearers,
77 std::string handoverEventListName,
78 std::string schedulerType,
79 bool admitHo,
80 bool useIdealRrc);
81 void DoRun() override;
82 /**
83 * Check connected function
84 * @param ueDevice the UE device
85 * @param enbDevice the ENB device
86 */
87 void CheckConnected(Ptr<NetDevice> ueDevice, Ptr<NetDevice> enbDevice);
88
89 /**
90 * Teleport UE between both eNBs of the test
91 * @param ueNode the UE node
92 */
93 void TeleportUeToMiddle(Ptr<Node> ueNode);
94
95 /**
96 * Teleport UE near the target eNB of the handover
97 * @param ueNode the UE node
98 * @param enbNode the target eNB node
99 */
100 void TeleportUeNearTargetEnb(Ptr<Node> ueNode, Ptr<Node> enbNode);
101
102 uint32_t m_nUes; ///< number of UEs in the test
103 uint32_t m_nDedicatedBearers; ///< number of UEs in the test
104 std::list<HandoverEvent> m_handoverEventList; ///< handover event list
105 std::string m_handoverEventListName; ///< handover event list name
106 bool m_epc; ///< whether to use EPC
107 std::string m_schedulerType; ///< scheduler type
108 bool m_admitHo; ///< whether to admit the handover request
109 bool m_useIdealRrc; ///< whether to use the ideal RRC
112
113 /**
114 * @ingroup lte-test
115 *
116 * @brief BearerData structure
117 */
119 {
120 uint32_t bid; ///< BID
123 uint32_t dlOldTotalRx; ///< DL old total receive
124 uint32_t ulOldTotalRx; ///< UL old total receive
125 };
126
127 /**
128 * @ingroup lte-test
129 *
130 * @brief UeData structure
131 */
132 struct UeData
133 {
134 uint32_t id; ///< ID
135 std::list<BearerData> bearerDataList; ///< bearer ID list
136 };
137
138 /**
139 * @brief Save stats after handover function
140 * @param ueIndex the index of the UE
141 */
142 void SaveStatsAfterHandover(uint32_t ueIndex);
143 /**
144 * @brief Check stats a while after handover function
145 * @param ueIndex the index of the UE
146 */
148
149 std::vector<UeData> m_ueDataVector; ///< UE data vector
150
151 const Time m_maxHoDuration; ///< maximum HO duration
152 const Time m_statsDuration; ///< stats duration
153 const Time m_udpClientInterval; ///< UDP client interval
154 const uint32_t m_udpClientPktSize; ///< UDP client packet size
155};
156
157std::string
159 uint32_t nDedicatedBearers,
160 std::string handoverEventListName,
161 std::string schedulerType,
162 bool admitHo,
163 bool useIdealRrc)
164{
165 std::ostringstream oss;
166 oss << " nUes=" << nUes << " nDedicatedBearers=" << nDedicatedBearers << " " << schedulerType
167 << " admitHo=" << admitHo << " hoList: " << handoverEventListName;
168 if (useIdealRrc)
169 {
170 oss << ", ideal RRC";
171 }
172 else
173 {
174 oss << ", real RRC";
175 }
176 return oss.str();
177}
178
180 uint32_t nDedicatedBearers,
181 std::list<HandoverEvent> handoverEventList,
182 std::string handoverEventListName,
183 std::string schedulerType,
184 bool admitHo,
185 bool useIdealRrc)
186 : TestCase(BuildNameString(nUes,
187 nDedicatedBearers,
188 handoverEventListName,
189 schedulerType,
190 admitHo,
191 useIdealRrc)),
192 m_nUes(nUes),
193 m_nDedicatedBearers(nDedicatedBearers),
194 m_handoverEventList(handoverEventList),
195 m_handoverEventListName(handoverEventListName),
196 m_epc(true),
197 m_schedulerType(schedulerType),
198 m_admitHo(admitHo),
199 m_useIdealRrc(useIdealRrc),
200 m_maxHoDuration(Seconds(0.1)),
201 m_statsDuration(Seconds(0.1)),
202 m_udpClientInterval(Seconds(0.01)),
203 m_udpClientPktSize(100)
204
205{
206}
207
208void
210{
215 m_admitHo,
217
218 uint32_t previousSeed = RngSeedManager::GetSeed();
219 uint64_t previousRun = RngSeedManager::GetRun();
221 // This test is sensitive to random variable stream assignments
224 Config::SetDefault("ns3::UdpClient::Interval", TimeValue(m_udpClientInterval));
225 Config::SetDefault("ns3::UdpClient::MaxPackets", UintegerValue(1000000));
226 Config::SetDefault("ns3::UdpClient::PacketSize", UintegerValue(m_udpClientPktSize));
227
228 // Disable Uplink Power Control
229 Config::SetDefault("ns3::LteUePhy::EnableUplinkPowerControl", BooleanValue(false));
230
231 int64_t stream = 1;
232
234 m_lteHelper->SetAttribute("PathlossModel",
235 StringValue("ns3::FriisSpectrumPropagationLossModel"));
236 m_lteHelper->SetSchedulerType(m_schedulerType);
237 m_lteHelper->SetHandoverAlgorithmType(
238 "ns3::NoOpHandoverAlgorithm"); // disable automatic handover
239 m_lteHelper->SetAttribute("UseIdealRrc", BooleanValue(m_useIdealRrc));
240
241 NodeContainer enbNodes;
242 enbNodes.Create(2);
243 NodeContainer ueNodes;
244 ueNodes.Create(m_nUes);
245
246 if (m_epc)
247 {
249 m_lteHelper->SetEpcHelper(m_epcHelper);
250 }
251
253 positionAlloc->Add(Vector(-3000, 0, 0)); // enb0
254 positionAlloc->Add(Vector(3000, 0, 0)); // enb1
255 for (uint32_t i = 0; i < m_nUes; i++)
256 {
257 positionAlloc->Add(Vector(-3000, 100, 0));
258 }
259 MobilityHelper mobility;
260 mobility.SetPositionAllocator(positionAlloc);
261 mobility.SetMobilityModel("ns3::ConstantPositionMobilityModel");
262 mobility.Install(enbNodes);
263 mobility.Install(ueNodes);
264
265 NetDeviceContainer enbDevices;
266 enbDevices = m_lteHelper->InstallEnbDevice(enbNodes);
267 stream += m_lteHelper->AssignStreams(enbDevices, stream);
268 for (auto it = enbDevices.Begin(); it != enbDevices.End(); ++it)
269 {
270 Ptr<LteEnbRrc> enbRrc = (*it)->GetObject<LteEnbNetDevice>()->GetRrc();
271 enbRrc->SetAttribute("AdmitHandoverRequest", BooleanValue(m_admitHo));
272 }
273
274 NetDeviceContainer ueDevices;
275 ueDevices = m_lteHelper->InstallUeDevice(ueNodes);
276 stream += m_lteHelper->AssignStreams(ueDevices, stream);
277
278 Ipv4Address remoteHostAddr;
279 Ipv4StaticRoutingHelper ipv4RoutingHelper;
280 Ipv4InterfaceContainer ueIpIfaces;
281 Ptr<Node> remoteHost;
282 if (m_epc)
283 {
284 // Create a single RemoteHost
285 NodeContainer remoteHostContainer;
286 remoteHostContainer.Create(1);
287 remoteHost = remoteHostContainer.Get(0);
288 InternetStackHelper internet;
289 internet.Install(remoteHostContainer);
290
291 // Create the Internet
293 p2ph.SetDeviceAttribute("DataRate", DataRateValue(DataRate("100Gb/s")));
294 p2ph.SetDeviceAttribute("Mtu", UintegerValue(1500));
295 p2ph.SetChannelAttribute("Delay", TimeValue(Seconds(0.010)));
296 Ptr<Node> pgw = m_epcHelper->GetPgwNode();
297 NetDeviceContainer internetDevices = p2ph.Install(pgw, remoteHost);
298 Ipv4AddressHelper ipv4h;
299 ipv4h.SetBase("1.0.0.0", "255.0.0.0");
300 Ipv4InterfaceContainer internetIpIfaces = ipv4h.Assign(internetDevices);
301 // in this container, interface 0 is the pgw, 1 is the remoteHost
302 remoteHostAddr = internetIpIfaces.GetAddress(1);
303
304 Ipv4StaticRoutingHelper ipv4RoutingHelper;
305 Ptr<Ipv4StaticRouting> remoteHostStaticRouting =
306 ipv4RoutingHelper.GetStaticRouting(remoteHost->GetObject<Ipv4>());
307 remoteHostStaticRouting->AddNetworkRouteTo(Ipv4Address("7.0.0.0"),
308 Ipv4Mask("255.0.0.0"),
309 1);
310
311 // Install the IP stack on the UEs
312 internet.Install(ueNodes);
313 ueIpIfaces = m_epcHelper->AssignUeIpv4Address(NetDeviceContainer(ueDevices));
314 }
315
316 // attachment (needs to be done after IP stack configuration)
317 // all UEs attached to eNB 0 at the beginning
318 m_lteHelper->Attach(ueDevices, enbDevices.Get(0));
319
320 if (m_epc)
321 {
322 // always true: bool epcDl = true;
323 // always true: bool epcUl = true;
324 // the rest of this block is copied from lena-dual-stripe
325
326 // Install and start applications on UEs and remote host
327 uint16_t dlPort = 10000;
328 uint16_t ulPort = 20000;
329
330 // randomize a bit start times to avoid simulation artifacts
331 // (e.g., buffer overflows due to packet transmissions happening
332 // exactly at the same time)
334 startTimeSeconds->SetAttribute("Min", DoubleValue(0));
335 startTimeSeconds->SetAttribute("Max", DoubleValue(0.010));
336 startTimeSeconds->SetStream(stream++);
337
338 for (uint32_t u = 0; u < ueNodes.GetN(); ++u)
339 {
340 Ptr<Node> ue = ueNodes.Get(u);
341 // Set the default gateway for the UE
342 Ptr<Ipv4StaticRouting> ueStaticRouting =
343 ipv4RoutingHelper.GetStaticRouting(ue->GetObject<Ipv4>());
344 ueStaticRouting->SetDefaultRoute(m_epcHelper->GetUeDefaultGatewayAddress(), 1);
345
346 UeData ueData;
347
348 for (uint32_t b = 0; b < m_nDedicatedBearers; ++b)
349 {
350 ++dlPort;
351 ++ulPort;
352
353 ApplicationContainer clientApps;
354 ApplicationContainer serverApps;
355 BearerData bearerData = BearerData();
356
357 // always true: if (epcDl)
358 {
359 UdpClientHelper dlClientHelper(ueIpIfaces.GetAddress(u), dlPort);
360 clientApps.Add(dlClientHelper.Install(remoteHost));
361 PacketSinkHelper dlPacketSinkHelper(
362 "ns3::UdpSocketFactory",
364 ApplicationContainer sinkContainer = dlPacketSinkHelper.Install(ue);
365 bearerData.dlSink = sinkContainer.Get(0)->GetObject<PacketSink>();
366 serverApps.Add(sinkContainer);
367 }
368 // always true: if (epcUl)
369 {
370 UdpClientHelper ulClientHelper(remoteHostAddr, ulPort);
371 clientApps.Add(ulClientHelper.Install(ue));
372 PacketSinkHelper ulPacketSinkHelper(
373 "ns3::UdpSocketFactory",
375 ApplicationContainer sinkContainer = ulPacketSinkHelper.Install(remoteHost);
376 bearerData.ulSink = sinkContainer.Get(0)->GetObject<PacketSink>();
377 serverApps.Add(sinkContainer);
378 }
379
381 // always true: if (epcDl)
382 {
384 dlpf.localPortStart = dlPort;
385 dlpf.localPortEnd = dlPort;
386 tft->Add(dlpf);
387 }
388 // always true: if (epcUl)
389 {
391 ulpf.remotePortStart = ulPort;
392 ulpf.remotePortEnd = ulPort;
393 tft->Add(ulpf);
394 }
395
396 // always true: if (epcDl || epcUl)
397 {
399 m_lteHelper->ActivateDedicatedEpsBearer(ueDevices.Get(u), bearer, tft);
400 }
401 double d = startTimeSeconds->GetValue();
402 Time startTime = Seconds(d);
403 serverApps.Start(startTime);
404 clientApps.Start(startTime);
405
406 ueData.bearerDataList.push_back(bearerData);
407
408 } // end for b
409
410 m_ueDataVector.push_back(ueData);
411 }
412 }
413 else // (epc == false)
414 {
415 // for radio bearer activation purposes, consider together home UEs and macro UEs
416 for (uint32_t u = 0; u < ueDevices.GetN(); ++u)
417 {
418 Ptr<NetDevice> ueDev = ueDevices.Get(u);
419 for (uint32_t b = 0; b < m_nDedicatedBearers; ++b)
420 {
422 EpsBearer bearer(q);
423 m_lteHelper->ActivateDataRadioBearer(ueDev, bearer);
424 }
425 }
426 }
427
428 m_lteHelper->AddX2Interface(enbNodes);
429
430 // check initial RRC connection
431 const Time maxRrcConnectionEstablishmentDuration = Seconds(0.080);
432 for (auto it = ueDevices.Begin(); it != ueDevices.End(); ++it)
433 {
434 Simulator::Schedule(maxRrcConnectionEstablishmentDuration,
436 this,
437 *it,
438 enbDevices.Get(0));
439 }
440
441 // schedule handover events and corresponding checks
442
444 for (auto hoEventIt = m_handoverEventList.begin(); hoEventIt != m_handoverEventList.end();
445 ++hoEventIt)
446 {
447 // Teleport the UE between both eNBs just before the handover starts
448 Simulator::Schedule(hoEventIt->startTime - MilliSeconds(10),
450 this,
451 ueNodes.Get(hoEventIt->ueDeviceIndex));
452
453 Simulator::Schedule(hoEventIt->startTime,
455 this,
456 ueDevices.Get(hoEventIt->ueDeviceIndex),
457 enbDevices.Get(hoEventIt->sourceEnbDeviceIndex));
458
459 m_lteHelper->HandoverRequest(hoEventIt->startTime,
460 ueDevices.Get(hoEventIt->ueDeviceIndex),
461 enbDevices.Get(hoEventIt->sourceEnbDeviceIndex),
462 enbDevices.Get(hoEventIt->targetEnbDeviceIndex));
463
464 // Once the handover is finished, teleport the UE near the target eNB
465 Simulator::Schedule(hoEventIt->startTime + MilliSeconds(40),
467 this,
468 ueNodes.Get(hoEventIt->ueDeviceIndex),
469 enbNodes.Get(m_admitHo ? hoEventIt->targetEnbDeviceIndex
470 : hoEventIt->sourceEnbDeviceIndex));
471
472 Time hoEndTime = hoEventIt->startTime + m_maxHoDuration;
473 Simulator::Schedule(hoEndTime,
475 this,
476 ueDevices.Get(hoEventIt->ueDeviceIndex),
477 enbDevices.Get(m_admitHo ? hoEventIt->targetEnbDeviceIndex
478 : hoEventIt->sourceEnbDeviceIndex));
479 Simulator::Schedule(hoEndTime,
481 this,
482 hoEventIt->ueDeviceIndex);
483
484 Time checkStatsAfterHoTime = hoEndTime + m_statsDuration;
485 Simulator::Schedule(checkStatsAfterHoTime,
487 this,
488 hoEventIt->ueDeviceIndex);
489 if (stopTime <= checkStatsAfterHoTime)
490 {
491 stopTime = checkStatsAfterHoTime + MilliSeconds(1);
492 }
493 }
494
495 // m_lteHelper->EnableRlcTraces ();
496 // m_lteHelper->EnablePdcpTraces();
497
499
501
503
504 // Undo changes to default settings
506 // Restore the previous settings of RngSeed and RngRun
507 RngSeedManager::SetSeed(previousSeed);
508 RngSeedManager::SetRun(previousRun);
509}
510
511void
513{
514 Ptr<LteUeNetDevice> ueLteDevice = ueDevice->GetObject<LteUeNetDevice>();
515 Ptr<LteUeRrc> ueRrc = ueLteDevice->GetRrc();
516 NS_TEST_ASSERT_MSG_EQ(ueRrc->GetState(), LteUeRrc::CONNECTED_NORMALLY, "Wrong LteUeRrc state!");
517
518 Ptr<LteEnbNetDevice> enbLteDevice = enbDevice->GetObject<LteEnbNetDevice>();
519 Ptr<LteEnbRrc> enbRrc = enbLteDevice->GetRrc();
520 uint16_t rnti = ueRrc->GetRnti();
521 Ptr<UeManager> ueManager = enbRrc->GetUeManager(rnti);
522 NS_TEST_ASSERT_MSG_NE(ueManager, nullptr, "RNTI " << rnti << " not found in eNB");
523
524 UeManager::State ueManagerState = ueManager->GetState();
525 NS_TEST_ASSERT_MSG_EQ(ueManagerState, UeManager::CONNECTED_NORMALLY, "Wrong UeManager state!");
526 NS_ASSERT_MSG(ueManagerState == UeManager::CONNECTED_NORMALLY, "Wrong UeManager state!");
527
528 uint16_t ueCellId = ueRrc->GetCellId();
529 uint16_t enbCellId = enbLteDevice->GetCellId();
530 uint8_t ueDlBandwidth = ueRrc->GetDlBandwidth();
531 uint8_t enbDlBandwidth = enbLteDevice->GetDlBandwidth();
532 uint8_t ueUlBandwidth = ueRrc->GetUlBandwidth();
533 uint8_t enbUlBandwidth = enbLteDevice->GetUlBandwidth();
534 uint8_t ueDlEarfcn = ueRrc->GetDlEarfcn();
535 uint8_t enbDlEarfcn = enbLteDevice->GetDlEarfcn();
536 uint8_t ueUlEarfcn = ueRrc->GetUlEarfcn();
537 uint8_t enbUlEarfcn = enbLteDevice->GetUlEarfcn();
538 uint64_t ueImsi = ueLteDevice->GetImsi();
539 uint64_t enbImsi = ueManager->GetImsi();
540
541 NS_TEST_ASSERT_MSG_EQ(ueImsi, enbImsi, "inconsistent IMSI");
542 NS_TEST_ASSERT_MSG_EQ(ueCellId, enbCellId, "inconsistent CellId");
543 NS_TEST_ASSERT_MSG_EQ(ueDlBandwidth, enbDlBandwidth, "inconsistent DlBandwidth");
544 NS_TEST_ASSERT_MSG_EQ(ueUlBandwidth, enbUlBandwidth, "inconsistent UlBandwidth");
545 NS_TEST_ASSERT_MSG_EQ(ueDlEarfcn, enbDlEarfcn, "inconsistent DlEarfcn");
546 NS_TEST_ASSERT_MSG_EQ(ueUlEarfcn, enbUlEarfcn, "inconsistent UlEarfcn");
547
548 ObjectMapValue enbDataRadioBearerMapValue;
549 ueManager->GetAttribute("DataRadioBearerMap", enbDataRadioBearerMapValue);
550 NS_TEST_ASSERT_MSG_EQ(enbDataRadioBearerMapValue.GetN(),
552 "wrong num bearers at eNB");
553
554 ObjectMapValue ueDataRadioBearerMapValue;
555 ueRrc->GetAttribute("DataRadioBearerMap", ueDataRadioBearerMapValue);
556 NS_TEST_ASSERT_MSG_EQ(ueDataRadioBearerMapValue.GetN(),
558 "wrong num bearers at UE");
559
560 auto enbBearerIt = enbDataRadioBearerMapValue.Begin();
561 auto ueBearerIt = ueDataRadioBearerMapValue.Begin();
562 while (enbBearerIt != enbDataRadioBearerMapValue.End() &&
563 ueBearerIt != ueDataRadioBearerMapValue.End())
564 {
565 Ptr<LteDataRadioBearerInfo> enbDrbInfo =
566 enbBearerIt->second->GetObject<LteDataRadioBearerInfo>();
568 ueBearerIt->second->GetObject<LteDataRadioBearerInfo>();
569 // NS_TEST_ASSERT_MSG_EQ (enbDrbInfo->m_epsBearer, ueDrbInfo->m_epsBearer, "epsBearer
570 // differs");
571 NS_TEST_ASSERT_MSG_EQ((uint32_t)enbDrbInfo->m_epsBearerIdentity,
572 (uint32_t)ueDrbInfo->m_epsBearerIdentity,
573 "epsBearerIdentity differs");
574 NS_TEST_ASSERT_MSG_EQ((uint32_t)enbDrbInfo->m_drbIdentity,
575 (uint32_t)ueDrbInfo->m_drbIdentity,
576 "drbIdentity differs");
577 // NS_TEST_ASSERT_MSG_EQ (enbDrbInfo->m_rlcConfig, ueDrbInfo->m_rlcConfig, "rlcConfig
578 // differs");
579 NS_TEST_ASSERT_MSG_EQ((uint32_t)enbDrbInfo->m_logicalChannelIdentity,
580 (uint32_t)ueDrbInfo->m_logicalChannelIdentity,
581 "logicalChannelIdentity differs");
582 // NS_TEST_ASSERT_MSG_EQ (enbDrbInfo->m_logicalChannelConfig,
583 // ueDrbInfo->m_logicalChannelConfig, "logicalChannelConfig differs");
584
585 ++enbBearerIt;
586 ++ueBearerIt;
587 }
588 NS_ASSERT_MSG(enbBearerIt == enbDataRadioBearerMapValue.End(), "too many bearers at eNB");
589 NS_ASSERT_MSG(ueBearerIt == ueDataRadioBearerMapValue.End(), "too many bearers at UE");
590}
591
592void
594{
595 Ptr<MobilityModel> ueMobility = ueNode->GetObject<MobilityModel>();
596 ueMobility->SetPosition(Vector(0.0, 0.0, 0.0));
597}
598
599void
601{
602 Ptr<MobilityModel> enbMobility = enbNode->GetObject<MobilityModel>();
603 Vector pos = enbMobility->GetPosition();
604
605 Ptr<MobilityModel> ueMobility = ueNode->GetObject<MobilityModel>();
606 ueMobility->SetPosition(pos + Vector(0.0, 100.0, 0.0));
607}
608
609void
611{
612 for (auto it = m_ueDataVector.at(ueIndex).bearerDataList.begin();
613 it != m_ueDataVector.at(ueIndex).bearerDataList.end();
614 ++it)
615 {
616 it->dlOldTotalRx = it->dlSink->GetTotalRx();
617 it->ulOldTotalRx = it->ulSink->GetTotalRx();
618 }
619}
620
621void
623{
624 uint32_t b = 1;
625 for (auto it = m_ueDataVector.at(ueIndex).bearerDataList.begin();
626 it != m_ueDataVector.at(ueIndex).bearerDataList.end();
627 ++it)
628 {
629 uint32_t dlRx = it->dlSink->GetTotalRx() - it->dlOldTotalRx;
630 uint32_t ulRx = it->ulSink->GetTotalRx() - it->ulOldTotalRx;
631 uint32_t expectedBytes =
633
635 expectedBytes,
636 "too few RX bytes in DL, ue=" << ueIndex << ", b=" << b);
638 expectedBytes,
639 "too few RX bytes in UL, ue=" << ueIndex << ", b=" << b);
640 ++b;
641 }
642}
643
644/**
645 * @ingroup lte-test
646 *
647 * @brief LTE X2 Handover Test Suite.
648 *
649 * In this test suite, we use NoOpHandoverAlgorithm, i.e. "handover algorithm which does nothing"
650 * is used and handover is triggered manually. The automatic handover algorithms (A2A4, A3Rsrp)
651 * are not tested.
652 *
653 * The tests are designed to check that eNB-buffered data received while a handover is in progress
654 * is not lost but successfully forwarded. But the test suite doesn't test for possible loss of
655 * RLC-buffered data because "lossless" handover is not implemented, and there are other application
656 * send patterns (outside of the range tested here) that may incur losses.
657 */
659{
660 public:
662};
663
665 : TestSuite("lte-x2-handover", Type::SYSTEM)
666{
667 // in the following:
668 // fwd means handover from enb 0 to enb 1
669 // bwd means handover from enb 1 to enb 0
670
671 HandoverEvent ue1fwd;
672 ue1fwd.startTime = MilliSeconds(100);
673 ue1fwd.ueDeviceIndex = 0;
674 ue1fwd.sourceEnbDeviceIndex = 0;
675 ue1fwd.targetEnbDeviceIndex = 1;
676
677 HandoverEvent ue1bwd;
678 ue1bwd.startTime = MilliSeconds(400);
679 ue1bwd.ueDeviceIndex = 0;
680 ue1bwd.sourceEnbDeviceIndex = 1;
681 ue1bwd.targetEnbDeviceIndex = 0;
682
683 HandoverEvent ue1fwdagain;
684 ue1fwdagain.startTime = MilliSeconds(700);
685 ue1fwdagain.ueDeviceIndex = 0;
686 ue1fwdagain.sourceEnbDeviceIndex = 0;
687 ue1fwdagain.targetEnbDeviceIndex = 1;
688
689 HandoverEvent ue2fwd;
690 ue2fwd.startTime = MilliSeconds(110);
691 ue2fwd.ueDeviceIndex = 1;
692 ue2fwd.sourceEnbDeviceIndex = 0;
693 ue2fwd.targetEnbDeviceIndex = 1;
694
695 HandoverEvent ue2bwd;
696 ue2bwd.startTime = MilliSeconds(350);
697 ue2bwd.ueDeviceIndex = 1;
698 ue2bwd.sourceEnbDeviceIndex = 1;
699 ue2bwd.targetEnbDeviceIndex = 0;
700
701 std::string handoverEventList0name("none");
702 std::list<HandoverEvent> handoverEventList0;
703
704 std::string handoverEventList1name("1 fwd");
705 const std::list<HandoverEvent> handoverEventList1{
706 ue1fwd,
707 };
708
709 std::string handoverEventList2name("1 fwd & bwd");
710 const std::list<HandoverEvent> handoverEventList2{
711 ue1fwd,
712 ue1bwd,
713 };
714
715 std::string handoverEventList3name("1 fwd & bwd & fwd");
716 const std::list<HandoverEvent> handoverEventList3{
717 ue1fwd,
718 ue1bwd,
719 ue1fwdagain,
720 };
721
722 std::string handoverEventList4name("1+2 fwd");
723 const std::list<HandoverEvent> handoverEventList4{
724 ue1fwd,
725 ue2fwd,
726 };
727
728 std::string handoverEventList5name("1+2 fwd & bwd");
729 const std::list<HandoverEvent> handoverEventList5{
730 ue1fwd,
731 ue1bwd,
732 ue2fwd,
733 ue2bwd,
734 };
735
736 // std::string handoverEventList6name("2 fwd");
737 // const std::list<HandoverEvent> handoverEventList6{
738 // ue2fwd,
739 // };
740
741 // std::string handoverEventList7name("2 fwd & bwd");
742 // const std::list<HandoverEvent> handoverEventList7{
743 // ue2fwd,
744 // ue2bwd,
745 // };
746
747 std::vector<std::string> schedulers{
748 "ns3::RrFfMacScheduler",
749 "ns3::PfFfMacScheduler",
750 };
751
752 for (auto schedIt = schedulers.begin(); schedIt != schedulers.end(); ++schedIt)
753 {
754 for (auto useIdealRrc : {true, false})
755 {
756 // nUes, nDBearers, helist, name, sched, admitHo, idealRrc
758 0,
759 handoverEventList0,
760 handoverEventList0name,
761 *schedIt,
762 true,
763 useIdealRrc),
764 TestCase::Duration::EXTENSIVE);
766 0,
767 handoverEventList0,
768 handoverEventList0name,
769 *schedIt,
770 true,
771 useIdealRrc),
772 TestCase::Duration::EXTENSIVE);
774 5,
775 handoverEventList0,
776 handoverEventList0name,
777 *schedIt,
778 true,
779 useIdealRrc),
780 TestCase::Duration::EXTENSIVE);
782 5,
783 handoverEventList0,
784 handoverEventList0name,
785 *schedIt,
786 true,
787 useIdealRrc),
788 TestCase::Duration::EXTENSIVE);
790 0,
791 handoverEventList1,
792 handoverEventList1name,
793 *schedIt,
794 true,
795 useIdealRrc),
796 TestCase::Duration::EXTENSIVE);
798 1,
799 handoverEventList1,
800 handoverEventList1name,
801 *schedIt,
802 true,
803 useIdealRrc),
804 TestCase::Duration::EXTENSIVE);
806 2,
807 handoverEventList1,
808 handoverEventList1name,
809 *schedIt,
810 true,
811 useIdealRrc),
812 TestCase::Duration::EXTENSIVE);
814 0,
815 handoverEventList1,
816 handoverEventList1name,
817 *schedIt,
818 false,
819 useIdealRrc),
820 TestCase::Duration::EXTENSIVE);
822 1,
823 handoverEventList1,
824 handoverEventList1name,
825 *schedIt,
826 false,
827 useIdealRrc),
828 TestCase::Duration::EXTENSIVE);
830 2,
831 handoverEventList1,
832 handoverEventList1name,
833 *schedIt,
834 false,
835 useIdealRrc),
836 TestCase::Duration::EXTENSIVE);
838 0,
839 handoverEventList1,
840 handoverEventList1name,
841 *schedIt,
842 true,
843 useIdealRrc),
844 TestCase::Duration::EXTENSIVE);
846 1,
847 handoverEventList1,
848 handoverEventList1name,
849 *schedIt,
850 true,
851 useIdealRrc),
852 TestCase::Duration::EXTENSIVE);
854 2,
855 handoverEventList1,
856 handoverEventList1name,
857 *schedIt,
858 true,
859 useIdealRrc),
860 TestCase::Duration::EXTENSIVE);
862 0,
863 handoverEventList1,
864 handoverEventList1name,
865 *schedIt,
866 false,
867 useIdealRrc),
868 TestCase::Duration::EXTENSIVE);
870 1,
871 handoverEventList1,
872 handoverEventList1name,
873 *schedIt,
874 false,
875 useIdealRrc),
876 TestCase::Duration::EXTENSIVE);
878 2,
879 handoverEventList1,
880 handoverEventList1name,
881 *schedIt,
882 false,
883 useIdealRrc),
884 TestCase::Duration::EXTENSIVE);
886 0,
887 handoverEventList2,
888 handoverEventList2name,
889 *schedIt,
890 true,
891 useIdealRrc),
892 TestCase::Duration::EXTENSIVE);
894 1,
895 handoverEventList2,
896 handoverEventList2name,
897 *schedIt,
898 true,
899 useIdealRrc),
900 TestCase::Duration::EXTENSIVE);
902 2,
903 handoverEventList2,
904 handoverEventList2name,
905 *schedIt,
906 true,
907 useIdealRrc),
908 TestCase::Duration::EXTENSIVE);
910 0,
911 handoverEventList3,
912 handoverEventList3name,
913 *schedIt,
914 true,
915 useIdealRrc),
916 TestCase::Duration::EXTENSIVE);
918 1,
919 handoverEventList3,
920 handoverEventList3name,
921 *schedIt,
922 true,
923 useIdealRrc),
924 TestCase::Duration::EXTENSIVE);
926 2,
927 handoverEventList3,
928 handoverEventList3name,
929 *schedIt,
930 true,
931 useIdealRrc),
932 TestCase::Duration::EXTENSIVE);
934 0,
935 handoverEventList3,
936 handoverEventList3name,
937 *schedIt,
938 true,
939 useIdealRrc),
940 TestCase::Duration::EXTENSIVE);
942 1,
943 handoverEventList3,
944 handoverEventList3name,
945 *schedIt,
946 true,
947 useIdealRrc),
948 TestCase::Duration::EXTENSIVE);
950 2,
951 handoverEventList3,
952 handoverEventList3name,
953 *schedIt,
954 true,
955 useIdealRrc),
956 TestCase::Duration::QUICK);
958 0,
959 handoverEventList4,
960 handoverEventList4name,
961 *schedIt,
962 true,
963 useIdealRrc),
964 TestCase::Duration::EXTENSIVE);
966 1,
967 handoverEventList4,
968 handoverEventList4name,
969 *schedIt,
970 true,
971 useIdealRrc),
972 TestCase::Duration::EXTENSIVE);
974 2,
975 handoverEventList4,
976 handoverEventList4name,
977 *schedIt,
978 true,
979 useIdealRrc),
980 TestCase::Duration::EXTENSIVE);
982 0,
983 handoverEventList5,
984 handoverEventList5name,
985 *schedIt,
986 true,
987 useIdealRrc),
988 TestCase::Duration::EXTENSIVE);
990 1,
991 handoverEventList5,
992 handoverEventList5name,
993 *schedIt,
994 true,
995 useIdealRrc),
996 TestCase::Duration::EXTENSIVE);
998 2,
999 handoverEventList5,
1000 handoverEventList5name,
1001 *schedIt,
1002 true,
1003 useIdealRrc),
1004 TestCase::Duration::EXTENSIVE);
1006 0,
1007 handoverEventList3,
1008 handoverEventList3name,
1009 *schedIt,
1010 true,
1011 useIdealRrc),
1012 TestCase::Duration::EXTENSIVE);
1014 1,
1015 handoverEventList3,
1016 handoverEventList3name,
1017 *schedIt,
1018 true,
1019 useIdealRrc),
1020 TestCase::Duration::EXTENSIVE);
1022 2,
1023 handoverEventList3,
1024 handoverEventList3name,
1025 *schedIt,
1026 true,
1027 useIdealRrc),
1028 TestCase::Duration::EXTENSIVE);
1030 0,
1031 handoverEventList4,
1032 handoverEventList4name,
1033 *schedIt,
1034 true,
1035 useIdealRrc),
1036 TestCase::Duration::EXTENSIVE);
1038 1,
1039 handoverEventList4,
1040 handoverEventList4name,
1041 *schedIt,
1042 true,
1043 useIdealRrc),
1044 TestCase::Duration::EXTENSIVE);
1046 2,
1047 handoverEventList4,
1048 handoverEventList4name,
1049 *schedIt,
1050 true,
1051 useIdealRrc),
1052 TestCase::Duration::EXTENSIVE);
1054 0,
1055 handoverEventList5,
1056 handoverEventList5name,
1057 *schedIt,
1058 true,
1059 useIdealRrc),
1060 TestCase::Duration::EXTENSIVE);
1062 1,
1063 handoverEventList5,
1064 handoverEventList5name,
1065 *schedIt,
1066 true,
1067 useIdealRrc),
1068 TestCase::Duration::EXTENSIVE);
1070 2,
1071 handoverEventList5,
1072 handoverEventList5name,
1073 *schedIt,
1074 true,
1075 useIdealRrc),
1076 TestCase::Duration::QUICK);
1077 }
1078 }
1079}
1080
1081/**
1082 * @ingroup lte-test
1083 * Static variable for test initialization
1084 */
static std::string BuildNameString(uint32_t nUes, uint32_t nDedicatedBearers, std::string handoverEventListName, std::string schedulerType, bool admitHo, bool useIdealRrc)
Build name string.
void DoRun() override
Implementation to actually run this TestCase.
Ptr< PointToPointEpcHelper > m_epcHelper
EPC helper.
uint32_t m_nUes
number of UEs in the test
std::string m_handoverEventListName
handover event list name
std::string m_schedulerType
scheduler type
const uint32_t m_udpClientPktSize
UDP client packet size.
bool m_useIdealRrc
whether to use the ideal RRC
const Time m_statsDuration
stats duration
std::vector< UeData > m_ueDataVector
UE data vector.
void CheckConnected(Ptr< NetDevice > ueDevice, Ptr< NetDevice > enbDevice)
Check connected function.
LteX2HandoverTestCase(uint32_t nUes, uint32_t nDedicatedBearers, std::list< HandoverEvent > handoverEventList, std::string handoverEventListName, std::string schedulerType, bool admitHo, bool useIdealRrc)
void TeleportUeNearTargetEnb(Ptr< Node > ueNode, Ptr< Node > enbNode)
Teleport UE near the target eNB of the handover.
bool m_admitHo
whether to admit the handover request
bool m_epc
whether to use EPC
void SaveStatsAfterHandover(uint32_t ueIndex)
Save stats after handover function.
const Time m_maxHoDuration
maximum HO duration
std::list< HandoverEvent > m_handoverEventList
handover event list
void CheckStatsAWhileAfterHandover(uint32_t ueIndex)
Check stats a while after handover function.
uint32_t m_nDedicatedBearers
number of UEs in the test
const Time m_udpClientInterval
UDP client interval.
void TeleportUeToMiddle(Ptr< Node > ueNode)
Teleport UE between both eNBs of the test.
Ptr< LteHelper > m_lteHelper
LTE helper.
LTE X2 Handover Test Suite.
holds a vector of ns3::Application pointers.
Ptr< Application > Get(uint32_t i) const
Get the Ptr<Application> stored in this container at a given index.
ApplicationContainer Install(NodeContainer c)
Install an application on each node of the input container configured with all the attributes set wit...
AttributeValue implementation for Boolean.
Definition boolean.h:26
Class for representing data rates.
Definition data-rate.h:78
AttributeValue implementation for DataRate.
Definition data-rate.h:285
This class can be used to hold variables of floating point type such as 'double' or 'float'.
Definition double.h:31
This class contains the specification of EPS Bearers.
Definition eps-bearer.h:80
Qci
QoS Class Indicator.
Definition eps-bearer.h:95
@ NGBR_VIDEO_TCP_DEFAULT
Non-GBR TCP-based Video (Buffered Streaming, e.g., www, e-mail...)
Definition eps-bearer.h:115
an Inet address class
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.
static Ipv4Address GetAny()
Access to the IPv4 forwarding table, interfaces, and configuration.
Definition ipv4.h:69
holds a vector of std::pair of Ptr<Ipv4> and interface index.
Ipv4Address GetAddress(uint32_t i, uint32_t j=0) const
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...
store information on active data radio bearer instance
The eNodeB device implementation.
The LteUeNetDevice class implements the UE net device.
Helper class used to assign positions and mobility models to nodes.
Keep track of the current position and velocity of an object.
holds a vector of ns3::NetDevice pointers
uint32_t GetN() const
Get the number of Ptr<NetDevice> stored in this container.
Iterator Begin() const
Get an iterator which refers to the first NetDevice in the 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.
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.
Ptr< Node > Get(uint32_t i) const
Get the Ptr<Node> stored in this container at a given index.
Container for a set of ns3::Object pointers.
std::size_t GetN() const
Get the number of Objects.
Iterator End() const
Get an iterator to the past-the-end Object.
Iterator Begin() const
Get an iterator to the first Object.
A helper to make it easier to instantiate an ns3::PacketSinkApplication on a set of nodes.
Receive and consume traffic generated to an IP address and port.
Definition packet-sink.h:62
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 void SetRun(uint64_t run)
Set the run number of simulation.
static void SetSeed(uint32_t seed)
Set the seed.
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.
Definition simulator.h:560
static void Destroy()
Execute the events scheduled with ScheduleDestroy().
Definition simulator.cc:131
static void Run()
Run the simulation.
Definition simulator.cc:167
static void Stop()
Tell the Simulator the calling event should be the last one executed.
Definition simulator.cc:175
Hold variables of type string.
Definition string.h:45
encapsulates test code
Definition test.h:1050
void AddTestCase(TestCase *testCase, Duration duration=Duration::QUICK)
Add an individual child TestCase to this test suite.
Definition test.cc:292
A suite of tests to run.
Definition test.h:1267
Type
Type of test.
Definition test.h:1274
Simulation virtual time values and global simulation resolution.
Definition nstime.h:94
AttributeValue implementation for Time.
Definition nstime.h:1431
Create a client application which sends UDP packets carrying a 32bit sequence number and a 64 bit tim...
State
The state of the UeManager at the eNB RRC.
Definition lte-enb-rrc.h:67
Hold an unsigned integer type.
Definition uinteger.h:34
Time stopTime
#define NS_ASSERT_MSG(condition, message)
At runtime, in debugging builds, if this condition is not true, the program prints the message to out...
Definition assert.h:75
void Reset()
Reset the initial value of every attribute as well as the value of every global to what they were bef...
Definition config.cc:848
void SetDefault(std::string name, const AttributeValue &value)
Definition config.cc:883
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition log.h:191
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
static LteX2HandoverTestSuite g_lteX2HandoverTestSuiteInstance
Static variable for test initialization.
Ptr< T > CreateObject(Args &&... args)
Create an object by type, with varying number of constructor parameters.
Definition object.h:619
Ptr< T > Create(Ts &&... args)
Create class instances by constructors with varying numbers of arguments and return them by Ptr.
Definition ptr.h:436
#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.
Definition test.h:134
#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.
Definition test.h:554
Time Seconds(double value)
Construct a Time in the indicated unit.
Definition nstime.h:1344
Time MilliSeconds(uint64_t value)
Construct a Time in the indicated unit.
Definition nstime.h:1356
Every class exported by the ns3 library is enclosed in the ns3 namespace.
HandoverEvent structure.
uint32_t ueDeviceIndex
UE device index.
Time startTime
start time
uint32_t targetEnbDeviceIndex
target ENB device index
uint32_t sourceEnbDeviceIndex
source ENB device index
uint32_t dlOldTotalRx
DL old total receive.
uint32_t ulOldTotalRx
UL old total receive.
std::list< BearerData > bearerDataList
bearer ID list
Implement the data structure representing a TrafficFlowTemplate Packet Filter.
Definition epc-tft.h:60
uint16_t localPortEnd
end of the port number range of the UE
Definition epc-tft.h:121
uint16_t remotePortEnd
end of the port number range of the remote host
Definition epc-tft.h:119
uint16_t remotePortStart
start of the port number range of the remote host
Definition epc-tft.h:118
uint16_t localPortStart
start of the port number range of the UE
Definition epc-tft.h:120