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
409 m_ueDataVector.push_back(ueData);
410 }
411 }
412 else // (epc == false)
413 {
414 // for radio bearer activation purposes, consider together home UEs and macro UEs
415 for (uint32_t u = 0; u < ueDevices.GetN(); ++u)
416 {
417 Ptr<NetDevice> ueDev = ueDevices.Get(u);
418 for (uint32_t b = 0; b < m_nDedicatedBearers; ++b)
419 {
421 EpsBearer bearer(q);
422 m_lteHelper->ActivateDataRadioBearer(ueDev, bearer);
423 }
424 }
425 }
426
427 m_lteHelper->AddX2Interface(enbNodes);
428
429 // check initial RRC connection
430 const Time maxRrcConnectionEstablishmentDuration = Seconds(0.080);
431 for (auto it = ueDevices.Begin(); it != ueDevices.End(); ++it)
432 {
433 Simulator::Schedule(maxRrcConnectionEstablishmentDuration,
435 this,
436 *it,
437 enbDevices.Get(0));
438 }
439
440 // schedule handover events and corresponding checks
441
443 for (auto hoEventIt = m_handoverEventList.begin(); hoEventIt != m_handoverEventList.end();
444 ++hoEventIt)
445 {
446 // Teleport the UE between both eNBs just before the handover starts
447 Simulator::Schedule(hoEventIt->startTime - MilliSeconds(10),
449 this,
450 ueNodes.Get(hoEventIt->ueDeviceIndex));
451
452 Simulator::Schedule(hoEventIt->startTime,
454 this,
455 ueDevices.Get(hoEventIt->ueDeviceIndex),
456 enbDevices.Get(hoEventIt->sourceEnbDeviceIndex));
457
458 m_lteHelper->HandoverRequest(hoEventIt->startTime,
459 ueDevices.Get(hoEventIt->ueDeviceIndex),
460 enbDevices.Get(hoEventIt->sourceEnbDeviceIndex),
461 enbDevices.Get(hoEventIt->targetEnbDeviceIndex));
462
463 // Once the handover is finished, teleport the UE near the target eNB
464 Simulator::Schedule(hoEventIt->startTime + MilliSeconds(40),
466 this,
467 ueNodes.Get(hoEventIt->ueDeviceIndex),
468 enbNodes.Get(m_admitHo ? hoEventIt->targetEnbDeviceIndex
469 : hoEventIt->sourceEnbDeviceIndex));
470
471 Time hoEndTime = hoEventIt->startTime + m_maxHoDuration;
472 Simulator::Schedule(hoEndTime,
474 this,
475 ueDevices.Get(hoEventIt->ueDeviceIndex),
476 enbDevices.Get(m_admitHo ? hoEventIt->targetEnbDeviceIndex
477 : hoEventIt->sourceEnbDeviceIndex));
478 Simulator::Schedule(hoEndTime,
480 this,
481 hoEventIt->ueDeviceIndex);
482
483 Time checkStatsAfterHoTime = hoEndTime + m_statsDuration;
484 Simulator::Schedule(checkStatsAfterHoTime,
486 this,
487 hoEventIt->ueDeviceIndex);
488 if (stopTime <= checkStatsAfterHoTime)
489 {
490 stopTime = checkStatsAfterHoTime + MilliSeconds(1);
491 }
492 }
493
494 // m_lteHelper->EnableRlcTraces ();
495 // m_lteHelper->EnablePdcpTraces();
496
498
500
502
503 // Undo changes to default settings
505 // Restore the previous settings of RngSeed and RngRun
506 RngSeedManager::SetSeed(previousSeed);
507 RngSeedManager::SetRun(previousRun);
508}
509
510void
512{
513 Ptr<LteUeNetDevice> ueLteDevice = ueDevice->GetObject<LteUeNetDevice>();
514 Ptr<LteUeRrc> ueRrc = ueLteDevice->GetRrc();
515 NS_TEST_ASSERT_MSG_EQ(ueRrc->GetState(), LteUeRrc::CONNECTED_NORMALLY, "Wrong LteUeRrc state!");
516
517 Ptr<LteEnbNetDevice> enbLteDevice = enbDevice->GetObject<LteEnbNetDevice>();
518 Ptr<LteEnbRrc> enbRrc = enbLteDevice->GetRrc();
519 uint16_t rnti = ueRrc->GetRnti();
520 Ptr<UeManager> ueManager = enbRrc->GetUeManager(rnti);
521 NS_TEST_ASSERT_MSG_NE(ueManager, nullptr, "RNTI " << rnti << " not found in eNB");
522
523 UeManager::State ueManagerState = ueManager->GetState();
524 NS_TEST_ASSERT_MSG_EQ(ueManagerState, UeManager::CONNECTED_NORMALLY, "Wrong UeManager state!");
525 NS_ASSERT_MSG(ueManagerState == UeManager::CONNECTED_NORMALLY, "Wrong UeManager state!");
526
527 uint16_t ueCellId = ueRrc->GetCellId();
528 uint16_t enbCellId = enbLteDevice->GetCellId();
529 uint8_t ueDlBandwidth = ueRrc->GetDlBandwidth();
530 uint8_t enbDlBandwidth = enbLteDevice->GetDlBandwidth();
531 uint8_t ueUlBandwidth = ueRrc->GetUlBandwidth();
532 uint8_t enbUlBandwidth = enbLteDevice->GetUlBandwidth();
533 uint8_t ueDlEarfcn = ueRrc->GetDlEarfcn();
534 uint8_t enbDlEarfcn = enbLteDevice->GetDlEarfcn();
535 uint8_t ueUlEarfcn = ueRrc->GetUlEarfcn();
536 uint8_t enbUlEarfcn = enbLteDevice->GetUlEarfcn();
537 uint64_t ueImsi = ueLteDevice->GetImsi();
538 uint64_t enbImsi = ueManager->GetImsi();
539
540 NS_TEST_ASSERT_MSG_EQ(ueImsi, enbImsi, "inconsistent IMSI");
541 NS_TEST_ASSERT_MSG_EQ(ueCellId, enbCellId, "inconsistent CellId");
542 NS_TEST_ASSERT_MSG_EQ(ueDlBandwidth, enbDlBandwidth, "inconsistent DlBandwidth");
543 NS_TEST_ASSERT_MSG_EQ(ueUlBandwidth, enbUlBandwidth, "inconsistent UlBandwidth");
544 NS_TEST_ASSERT_MSG_EQ(ueDlEarfcn, enbDlEarfcn, "inconsistent DlEarfcn");
545 NS_TEST_ASSERT_MSG_EQ(ueUlEarfcn, enbUlEarfcn, "inconsistent UlEarfcn");
546
547 ObjectMapValue enbDataRadioBearerMapValue;
548 ueManager->GetAttribute("DataRadioBearerMap", enbDataRadioBearerMapValue);
549 NS_TEST_ASSERT_MSG_EQ(enbDataRadioBearerMapValue.GetN(),
551 "wrong num bearers at eNB");
552
553 ObjectMapValue ueDataRadioBearerMapValue;
554 ueRrc->GetAttribute("DataRadioBearerMap", ueDataRadioBearerMapValue);
555 NS_TEST_ASSERT_MSG_EQ(ueDataRadioBearerMapValue.GetN(),
557 "wrong num bearers at UE");
558
559 auto enbBearerIt = enbDataRadioBearerMapValue.Begin();
560 auto ueBearerIt = ueDataRadioBearerMapValue.Begin();
561 while (enbBearerIt != enbDataRadioBearerMapValue.End() &&
562 ueBearerIt != ueDataRadioBearerMapValue.End())
563 {
564 Ptr<LteDataRadioBearerInfo> enbDrbInfo =
565 enbBearerIt->second->GetObject<LteDataRadioBearerInfo>();
567 ueBearerIt->second->GetObject<LteDataRadioBearerInfo>();
568 // NS_TEST_ASSERT_MSG_EQ (enbDrbInfo->m_epsBearer, ueDrbInfo->m_epsBearer, "epsBearer
569 // differs");
570 NS_TEST_ASSERT_MSG_EQ((uint32_t)enbDrbInfo->m_epsBearerIdentity,
571 (uint32_t)ueDrbInfo->m_epsBearerIdentity,
572 "epsBearerIdentity differs");
573 NS_TEST_ASSERT_MSG_EQ((uint32_t)enbDrbInfo->m_drbIdentity,
574 (uint32_t)ueDrbInfo->m_drbIdentity,
575 "drbIdentity differs");
576 // NS_TEST_ASSERT_MSG_EQ (enbDrbInfo->m_rlcConfig, ueDrbInfo->m_rlcConfig, "rlcConfig
577 // differs");
578 NS_TEST_ASSERT_MSG_EQ((uint32_t)enbDrbInfo->m_logicalChannelIdentity,
579 (uint32_t)ueDrbInfo->m_logicalChannelIdentity,
580 "logicalChannelIdentity differs");
581 // NS_TEST_ASSERT_MSG_EQ (enbDrbInfo->m_logicalChannelConfig,
582 // ueDrbInfo->m_logicalChannelConfig, "logicalChannelConfig differs");
583
584 ++enbBearerIt;
585 ++ueBearerIt;
586 }
587 NS_ASSERT_MSG(enbBearerIt == enbDataRadioBearerMapValue.End(), "too many bearers at eNB");
588 NS_ASSERT_MSG(ueBearerIt == ueDataRadioBearerMapValue.End(), "too many bearers at UE");
589}
590
591void
593{
594 Ptr<MobilityModel> ueMobility = ueNode->GetObject<MobilityModel>();
595 ueMobility->SetPosition(Vector(0.0, 0.0, 0.0));
596}
597
598void
600{
601 Ptr<MobilityModel> enbMobility = enbNode->GetObject<MobilityModel>();
602 Vector pos = enbMobility->GetPosition();
603
604 Ptr<MobilityModel> ueMobility = ueNode->GetObject<MobilityModel>();
605 ueMobility->SetPosition(pos + Vector(0.0, 100.0, 0.0));
606}
607
608void
610{
611 for (auto it = m_ueDataVector.at(ueIndex).bearerDataList.begin();
612 it != m_ueDataVector.at(ueIndex).bearerDataList.end();
613 ++it)
614 {
615 it->dlOldTotalRx = it->dlSink->GetTotalRx();
616 it->ulOldTotalRx = it->ulSink->GetTotalRx();
617 }
618}
619
620void
622{
623 uint32_t b = 1;
624 for (auto it = m_ueDataVector.at(ueIndex).bearerDataList.begin();
625 it != m_ueDataVector.at(ueIndex).bearerDataList.end();
626 ++it)
627 {
628 uint32_t dlRx = it->dlSink->GetTotalRx() - it->dlOldTotalRx;
629 uint32_t ulRx = it->ulSink->GetTotalRx() - it->ulOldTotalRx;
630 uint32_t expectedBytes =
632
634 expectedBytes,
635 "too few RX bytes in DL, ue=" << ueIndex << ", b=" << b);
637 expectedBytes,
638 "too few RX bytes in UL, ue=" << ueIndex << ", b=" << b);
639 ++b;
640 }
641}
642
643/**
644 * @ingroup lte-test
645 *
646 * @brief LTE X2 Handover Test Suite.
647 *
648 * In this test suite, we use NoOpHandoverAlgorithm, i.e. "handover algorithm which does nothing"
649 * is used and handover is triggered manually. The automatic handover algorithms (A2A4, A3Rsrp)
650 * are not tested.
651 *
652 * The tests are designed to check that eNB-buffered data received while a handover is in progress
653 * is not lost but successfully forwarded. But the test suite doesn't test for possible loss of
654 * RLC-buffered data because "lossless" handover is not implemented, and there are other application
655 * send patterns (outside of the range tested here) that may incur losses.
656 */
658{
659 public:
661};
662
664 : TestSuite("lte-x2-handover", Type::SYSTEM)
665{
666 // in the following:
667 // fwd means handover from enb 0 to enb 1
668 // bwd means handover from enb 1 to enb 0
669
670 HandoverEvent ue1fwd;
671 ue1fwd.startTime = MilliSeconds(100);
672 ue1fwd.ueDeviceIndex = 0;
673 ue1fwd.sourceEnbDeviceIndex = 0;
674 ue1fwd.targetEnbDeviceIndex = 1;
675
676 HandoverEvent ue1bwd;
677 ue1bwd.startTime = MilliSeconds(400);
678 ue1bwd.ueDeviceIndex = 0;
679 ue1bwd.sourceEnbDeviceIndex = 1;
680 ue1bwd.targetEnbDeviceIndex = 0;
681
682 HandoverEvent ue1fwdagain;
683 ue1fwdagain.startTime = MilliSeconds(700);
684 ue1fwdagain.ueDeviceIndex = 0;
685 ue1fwdagain.sourceEnbDeviceIndex = 0;
686 ue1fwdagain.targetEnbDeviceIndex = 1;
687
688 HandoverEvent ue2fwd;
689 ue2fwd.startTime = MilliSeconds(110);
690 ue2fwd.ueDeviceIndex = 1;
691 ue2fwd.sourceEnbDeviceIndex = 0;
692 ue2fwd.targetEnbDeviceIndex = 1;
693
694 HandoverEvent ue2bwd;
695 ue2bwd.startTime = MilliSeconds(350);
696 ue2bwd.ueDeviceIndex = 1;
697 ue2bwd.sourceEnbDeviceIndex = 1;
698 ue2bwd.targetEnbDeviceIndex = 0;
699
700 std::string handoverEventList0name("none");
701 std::list<HandoverEvent> handoverEventList0;
702
703 std::string handoverEventList1name("1 fwd");
704 const std::list<HandoverEvent> handoverEventList1{
705 ue1fwd,
706 };
707
708 std::string handoverEventList2name("1 fwd & bwd");
709 const std::list<HandoverEvent> handoverEventList2{
710 ue1fwd,
711 ue1bwd,
712 };
713
714 std::string handoverEventList3name("1 fwd & bwd & fwd");
715 const std::list<HandoverEvent> handoverEventList3{
716 ue1fwd,
717 ue1bwd,
718 ue1fwdagain,
719 };
720
721 std::string handoverEventList4name("1+2 fwd");
722 const std::list<HandoverEvent> handoverEventList4{
723 ue1fwd,
724 ue2fwd,
725 };
726
727 std::string handoverEventList5name("1+2 fwd & bwd");
728 const std::list<HandoverEvent> handoverEventList5{
729 ue1fwd,
730 ue1bwd,
731 ue2fwd,
732 ue2bwd,
733 };
734
735 // std::string handoverEventList6name("2 fwd");
736 // const std::list<HandoverEvent> handoverEventList6{
737 // ue2fwd,
738 // };
739
740 // std::string handoverEventList7name("2 fwd & bwd");
741 // const std::list<HandoverEvent> handoverEventList7{
742 // ue2fwd,
743 // ue2bwd,
744 // };
745
746 std::vector<std::string> schedulers{
747 "ns3::RrFfMacScheduler",
748 "ns3::PfFfMacScheduler",
749 };
750
751 for (auto schedIt = schedulers.begin(); schedIt != schedulers.end(); ++schedIt)
752 {
753 for (auto useIdealRrc : {true, false})
754 {
755 // nUes, nDBearers, helist, name, sched, admitHo, idealRrc
757 0,
758 handoverEventList0,
759 handoverEventList0name,
760 *schedIt,
761 true,
762 useIdealRrc),
763 TestCase::Duration::EXTENSIVE);
765 0,
766 handoverEventList0,
767 handoverEventList0name,
768 *schedIt,
769 true,
770 useIdealRrc),
771 TestCase::Duration::EXTENSIVE);
773 5,
774 handoverEventList0,
775 handoverEventList0name,
776 *schedIt,
777 true,
778 useIdealRrc),
779 TestCase::Duration::EXTENSIVE);
781 5,
782 handoverEventList0,
783 handoverEventList0name,
784 *schedIt,
785 true,
786 useIdealRrc),
787 TestCase::Duration::EXTENSIVE);
789 0,
790 handoverEventList1,
791 handoverEventList1name,
792 *schedIt,
793 true,
794 useIdealRrc),
795 TestCase::Duration::EXTENSIVE);
797 1,
798 handoverEventList1,
799 handoverEventList1name,
800 *schedIt,
801 true,
802 useIdealRrc),
803 TestCase::Duration::EXTENSIVE);
805 2,
806 handoverEventList1,
807 handoverEventList1name,
808 *schedIt,
809 true,
810 useIdealRrc),
811 TestCase::Duration::EXTENSIVE);
813 0,
814 handoverEventList1,
815 handoverEventList1name,
816 *schedIt,
817 false,
818 useIdealRrc),
819 TestCase::Duration::EXTENSIVE);
821 1,
822 handoverEventList1,
823 handoverEventList1name,
824 *schedIt,
825 false,
826 useIdealRrc),
827 TestCase::Duration::EXTENSIVE);
829 2,
830 handoverEventList1,
831 handoverEventList1name,
832 *schedIt,
833 false,
834 useIdealRrc),
835 TestCase::Duration::EXTENSIVE);
837 0,
838 handoverEventList1,
839 handoverEventList1name,
840 *schedIt,
841 true,
842 useIdealRrc),
843 TestCase::Duration::EXTENSIVE);
845 1,
846 handoverEventList1,
847 handoverEventList1name,
848 *schedIt,
849 true,
850 useIdealRrc),
851 TestCase::Duration::EXTENSIVE);
853 2,
854 handoverEventList1,
855 handoverEventList1name,
856 *schedIt,
857 true,
858 useIdealRrc),
859 TestCase::Duration::EXTENSIVE);
861 0,
862 handoverEventList1,
863 handoverEventList1name,
864 *schedIt,
865 false,
866 useIdealRrc),
867 TestCase::Duration::EXTENSIVE);
869 1,
870 handoverEventList1,
871 handoverEventList1name,
872 *schedIt,
873 false,
874 useIdealRrc),
875 TestCase::Duration::EXTENSIVE);
877 2,
878 handoverEventList1,
879 handoverEventList1name,
880 *schedIt,
881 false,
882 useIdealRrc),
883 TestCase::Duration::EXTENSIVE);
885 0,
886 handoverEventList2,
887 handoverEventList2name,
888 *schedIt,
889 true,
890 useIdealRrc),
891 TestCase::Duration::EXTENSIVE);
893 1,
894 handoverEventList2,
895 handoverEventList2name,
896 *schedIt,
897 true,
898 useIdealRrc),
899 TestCase::Duration::EXTENSIVE);
901 2,
902 handoverEventList2,
903 handoverEventList2name,
904 *schedIt,
905 true,
906 useIdealRrc),
907 TestCase::Duration::EXTENSIVE);
909 0,
910 handoverEventList3,
911 handoverEventList3name,
912 *schedIt,
913 true,
914 useIdealRrc),
915 TestCase::Duration::EXTENSIVE);
917 1,
918 handoverEventList3,
919 handoverEventList3name,
920 *schedIt,
921 true,
922 useIdealRrc),
923 TestCase::Duration::EXTENSIVE);
925 2,
926 handoverEventList3,
927 handoverEventList3name,
928 *schedIt,
929 true,
930 useIdealRrc),
931 TestCase::Duration::EXTENSIVE);
933 0,
934 handoverEventList3,
935 handoverEventList3name,
936 *schedIt,
937 true,
938 useIdealRrc),
939 TestCase::Duration::EXTENSIVE);
941 1,
942 handoverEventList3,
943 handoverEventList3name,
944 *schedIt,
945 true,
946 useIdealRrc),
947 TestCase::Duration::EXTENSIVE);
949 2,
950 handoverEventList3,
951 handoverEventList3name,
952 *schedIt,
953 true,
954 useIdealRrc),
955 TestCase::Duration::QUICK);
957 0,
958 handoverEventList4,
959 handoverEventList4name,
960 *schedIt,
961 true,
962 useIdealRrc),
963 TestCase::Duration::EXTENSIVE);
965 1,
966 handoverEventList4,
967 handoverEventList4name,
968 *schedIt,
969 true,
970 useIdealRrc),
971 TestCase::Duration::EXTENSIVE);
973 2,
974 handoverEventList4,
975 handoverEventList4name,
976 *schedIt,
977 true,
978 useIdealRrc),
979 TestCase::Duration::EXTENSIVE);
981 0,
982 handoverEventList5,
983 handoverEventList5name,
984 *schedIt,
985 true,
986 useIdealRrc),
987 TestCase::Duration::EXTENSIVE);
989 1,
990 handoverEventList5,
991 handoverEventList5name,
992 *schedIt,
993 true,
994 useIdealRrc),
995 TestCase::Duration::EXTENSIVE);
997 2,
998 handoverEventList5,
999 handoverEventList5name,
1000 *schedIt,
1001 true,
1002 useIdealRrc),
1003 TestCase::Duration::EXTENSIVE);
1005 0,
1006 handoverEventList3,
1007 handoverEventList3name,
1008 *schedIt,
1009 true,
1010 useIdealRrc),
1011 TestCase::Duration::EXTENSIVE);
1013 1,
1014 handoverEventList3,
1015 handoverEventList3name,
1016 *schedIt,
1017 true,
1018 useIdealRrc),
1019 TestCase::Duration::EXTENSIVE);
1021 2,
1022 handoverEventList3,
1023 handoverEventList3name,
1024 *schedIt,
1025 true,
1026 useIdealRrc),
1027 TestCase::Duration::EXTENSIVE);
1029 0,
1030 handoverEventList4,
1031 handoverEventList4name,
1032 *schedIt,
1033 true,
1034 useIdealRrc),
1035 TestCase::Duration::EXTENSIVE);
1037 1,
1038 handoverEventList4,
1039 handoverEventList4name,
1040 *schedIt,
1041 true,
1042 useIdealRrc),
1043 TestCase::Duration::EXTENSIVE);
1045 2,
1046 handoverEventList4,
1047 handoverEventList4name,
1048 *schedIt,
1049 true,
1050 useIdealRrc),
1051 TestCase::Duration::EXTENSIVE);
1053 0,
1054 handoverEventList5,
1055 handoverEventList5name,
1056 *schedIt,
1057 true,
1058 useIdealRrc),
1059 TestCase::Duration::EXTENSIVE);
1061 1,
1062 handoverEventList5,
1063 handoverEventList5name,
1064 *schedIt,
1065 true,
1066 useIdealRrc),
1067 TestCase::Duration::EXTENSIVE);
1069 2,
1070 handoverEventList5,
1071 handoverEventList5name,
1072 *schedIt,
1073 true,
1074 useIdealRrc),
1075 TestCase::Duration::QUICK);
1076 }
1077 }
1078}
1079
1080/**
1081 * @ingroup lte-test
1082 * Static variable for test initialization
1083 */
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:561
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:1432
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:851
void SetDefault(std::string name, const AttributeValue &value)
Definition config.cc:886
#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:1345
Time MilliSeconds(uint64_t value)
Construct a Time in the indicated unit.
Definition nstime.h:1357
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