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)
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),
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
526 uint16_t ueCellId = ueRrc->GetCellId();
527 uint16_t enbCellId = enbLteDevice->GetCellId();
528 uint8_t ueDlBandwidth = ueRrc->GetDlBandwidth();
529 uint8_t enbDlBandwidth = enbLteDevice->GetDlBandwidth();
530 uint8_t ueUlBandwidth = ueRrc->GetUlBandwidth();
531 uint8_t enbUlBandwidth = enbLteDevice->GetUlBandwidth();
532 uint8_t ueDlEarfcn = ueRrc->GetDlEarfcn();
533 uint8_t enbDlEarfcn = enbLteDevice->GetDlEarfcn();
534 uint8_t ueUlEarfcn = ueRrc->GetUlEarfcn();
535 uint8_t enbUlEarfcn = enbLteDevice->GetUlEarfcn();
536 uint64_t ueImsi = ueLteDevice->GetImsi();
537 uint64_t enbImsi = ueManager->GetImsi();
538
539 NS_TEST_ASSERT_MSG_EQ(ueImsi, enbImsi, "inconsistent IMSI");
540 NS_TEST_ASSERT_MSG_EQ(ueCellId, enbCellId, "inconsistent CellId");
541 NS_TEST_ASSERT_MSG_EQ(ueDlBandwidth, enbDlBandwidth, "inconsistent DlBandwidth");
542 NS_TEST_ASSERT_MSG_EQ(ueUlBandwidth, enbUlBandwidth, "inconsistent UlBandwidth");
543 NS_TEST_ASSERT_MSG_EQ(ueDlEarfcn, enbDlEarfcn, "inconsistent DlEarfcn");
544 NS_TEST_ASSERT_MSG_EQ(ueUlEarfcn, enbUlEarfcn, "inconsistent UlEarfcn");
545
546 ObjectMapValue enbDataRadioBearerMapValue;
547 ueManager->GetAttribute("DataRadioBearerMap", enbDataRadioBearerMapValue);
548 NS_TEST_ASSERT_MSG_EQ(enbDataRadioBearerMapValue.GetN(),
550 "wrong num bearers at eNB");
551
552 ObjectMapValue ueDataRadioBearerMapValue;
553 ueRrc->GetAttribute("DataRadioBearerMap", ueDataRadioBearerMapValue);
554 NS_TEST_ASSERT_MSG_EQ(ueDataRadioBearerMapValue.GetN(),
556 "wrong num bearers at UE");
557
558 auto enbBearerIt = enbDataRadioBearerMapValue.Begin();
559 auto ueBearerIt = ueDataRadioBearerMapValue.Begin();
560 while (enbBearerIt != enbDataRadioBearerMapValue.End() &&
561 ueBearerIt != ueDataRadioBearerMapValue.End())
562 {
563 Ptr<LteDataRadioBearerInfo> enbDrbInfo =
564 enbBearerIt->second->GetObject<LteDataRadioBearerInfo>();
566 ueBearerIt->second->GetObject<LteDataRadioBearerInfo>();
567 // NS_TEST_ASSERT_MSG_EQ (enbDrbInfo->m_epsBearer, ueDrbInfo->m_epsBearer, "epsBearer
568 // differs");
569 NS_TEST_ASSERT_MSG_EQ((uint32_t)enbDrbInfo->m_epsBearerIdentity,
570 (uint32_t)ueDrbInfo->m_epsBearerIdentity,
571 "epsBearerIdentity differs");
572 NS_TEST_ASSERT_MSG_EQ((uint32_t)enbDrbInfo->m_drbIdentity,
573 (uint32_t)ueDrbInfo->m_drbIdentity,
574 "drbIdentity differs");
575 // NS_TEST_ASSERT_MSG_EQ (enbDrbInfo->m_rlcConfig, ueDrbInfo->m_rlcConfig, "rlcConfig
576 // differs");
577 NS_TEST_ASSERT_MSG_EQ((uint32_t)enbDrbInfo->m_logicalChannelIdentity,
578 (uint32_t)ueDrbInfo->m_logicalChannelIdentity,
579 "logicalChannelIdentity differs");
580 // NS_TEST_ASSERT_MSG_EQ (enbDrbInfo->m_logicalChannelConfig,
581 // ueDrbInfo->m_logicalChannelConfig, "logicalChannelConfig differs");
582
583 ++enbBearerIt;
584 ++ueBearerIt;
585 }
586 NS_ASSERT_MSG(enbBearerIt == enbDataRadioBearerMapValue.End(), "too many bearers at eNB");
587 NS_ASSERT_MSG(ueBearerIt == ueDataRadioBearerMapValue.End(), "too many bearers at UE");
588}
589
590void
592{
593 Ptr<MobilityModel> ueMobility = ueNode->GetObject<MobilityModel>();
594 ueMobility->SetPosition(Vector(0.0, 0.0, 0.0));
595}
596
597void
599{
600 Ptr<MobilityModel> enbMobility = enbNode->GetObject<MobilityModel>();
601 Vector pos = enbMobility->GetPosition();
602
603 Ptr<MobilityModel> ueMobility = ueNode->GetObject<MobilityModel>();
604 ueMobility->SetPosition(pos + Vector(0.0, 100.0, 0.0));
605}
606
607void
609{
610 for (auto it = m_ueDataVector.at(ueIndex).bearerDataList.begin();
611 it != m_ueDataVector.at(ueIndex).bearerDataList.end();
612 ++it)
613 {
614 it->dlOldTotalRx = it->dlSink->GetTotalRx();
615 it->ulOldTotalRx = it->ulSink->GetTotalRx();
616 }
617}
618
619void
621{
622 uint32_t b = 1;
623 for (auto it = m_ueDataVector.at(ueIndex).bearerDataList.begin();
624 it != m_ueDataVector.at(ueIndex).bearerDataList.end();
625 ++it)
626 {
627 uint32_t dlRx = it->dlSink->GetTotalRx() - it->dlOldTotalRx;
628 uint32_t ulRx = it->ulSink->GetTotalRx() - it->ulOldTotalRx;
629 uint32_t expectedBytes =
631
633 expectedBytes,
634 "too few RX bytes in DL, ue=" << ueIndex << ", b=" << b);
636 expectedBytes,
637 "too few RX bytes in UL, ue=" << ueIndex << ", b=" << b);
638 ++b;
639 }
640}
641
642/**
643 * @ingroup lte-test
644 *
645 * @brief LTE X2 Handover Test Suite.
646 *
647 * In this test suite, we use NoOpHandoverAlgorithm, i.e. "handover algorithm which does nothing"
648 * is used and handover is triggered manually. The automatic handover algorithms (A2A4, A3Rsrp)
649 * are not tested.
650 *
651 * The tests are designed to check that eNB-buffered data received while a handover is in progress
652 * is not lost but successfully forwarded. But the test suite doesn't test for possible loss of
653 * RLC-buffered data because "lossless" handover is not implemented, and there are other application
654 * send patterns (outside of the range tested here) that may incur losses.
655 */
657{
658 public:
660};
661
663 : TestSuite("lte-x2-handover", Type::SYSTEM)
664{
665 // in the following:
666 // fwd means handover from enb 0 to enb 1
667 // bwd means handover from enb 1 to enb 0
668
669 HandoverEvent ue1fwd;
670 ue1fwd.startTime = MilliSeconds(100);
671 ue1fwd.ueDeviceIndex = 0;
672 ue1fwd.sourceEnbDeviceIndex = 0;
673 ue1fwd.targetEnbDeviceIndex = 1;
674
675 HandoverEvent ue1bwd;
676 ue1bwd.startTime = MilliSeconds(400);
677 ue1bwd.ueDeviceIndex = 0;
678 ue1bwd.sourceEnbDeviceIndex = 1;
679 ue1bwd.targetEnbDeviceIndex = 0;
680
681 HandoverEvent ue1fwdagain;
682 ue1fwdagain.startTime = MilliSeconds(700);
683 ue1fwdagain.ueDeviceIndex = 0;
684 ue1fwdagain.sourceEnbDeviceIndex = 0;
685 ue1fwdagain.targetEnbDeviceIndex = 1;
686
687 HandoverEvent ue2fwd;
688 ue2fwd.startTime = MilliSeconds(110);
689 ue2fwd.ueDeviceIndex = 1;
690 ue2fwd.sourceEnbDeviceIndex = 0;
691 ue2fwd.targetEnbDeviceIndex = 1;
692
693 HandoverEvent ue2bwd;
694 ue2bwd.startTime = MilliSeconds(350);
695 ue2bwd.ueDeviceIndex = 1;
696 ue2bwd.sourceEnbDeviceIndex = 1;
697 ue2bwd.targetEnbDeviceIndex = 0;
698
699 std::string handoverEventList0name("none");
700 std::list<HandoverEvent> handoverEventList0;
701
702 std::string handoverEventList1name("1 fwd");
703 const std::list<HandoverEvent> handoverEventList1{
704 ue1fwd,
705 };
706
707 std::string handoverEventList2name("1 fwd & bwd");
708 const std::list<HandoverEvent> handoverEventList2{
709 ue1fwd,
710 ue1bwd,
711 };
712
713 std::string handoverEventList3name("1 fwd & bwd & fwd");
714 const std::list<HandoverEvent> handoverEventList3{
715 ue1fwd,
716 ue1bwd,
717 ue1fwdagain,
718 };
719
720 std::string handoverEventList4name("1+2 fwd");
721 const std::list<HandoverEvent> handoverEventList4{
722 ue1fwd,
723 ue2fwd,
724 };
725
726 std::string handoverEventList5name("1+2 fwd & bwd");
727 const std::list<HandoverEvent> handoverEventList5{
728 ue1fwd,
729 ue1bwd,
730 ue2fwd,
731 ue2bwd,
732 };
733
734 // std::string handoverEventList6name("2 fwd");
735 // const std::list<HandoverEvent> handoverEventList6{
736 // ue2fwd,
737 // };
738
739 // std::string handoverEventList7name("2 fwd & bwd");
740 // const std::list<HandoverEvent> handoverEventList7{
741 // ue2fwd,
742 // ue2bwd,
743 // };
744
745 std::vector<std::string> schedulers{
746 "ns3::RrFfMacScheduler",
747 "ns3::PfFfMacScheduler",
748 };
749
750 for (auto schedIt = schedulers.begin(); schedIt != schedulers.end(); ++schedIt)
751 {
752 for (auto useIdealRrc : {true, false})
753 {
754 // nUes, nDBearers, helist, name, sched, admitHo, idealRrc
756 0,
757 handoverEventList0,
758 handoverEventList0name,
759 *schedIt,
760 true,
761 useIdealRrc),
764 0,
765 handoverEventList0,
766 handoverEventList0name,
767 *schedIt,
768 true,
769 useIdealRrc),
772 5,
773 handoverEventList0,
774 handoverEventList0name,
775 *schedIt,
776 true,
777 useIdealRrc),
780 5,
781 handoverEventList0,
782 handoverEventList0name,
783 *schedIt,
784 true,
785 useIdealRrc),
788 0,
789 handoverEventList1,
790 handoverEventList1name,
791 *schedIt,
792 true,
793 useIdealRrc),
796 1,
797 handoverEventList1,
798 handoverEventList1name,
799 *schedIt,
800 true,
801 useIdealRrc),
804 2,
805 handoverEventList1,
806 handoverEventList1name,
807 *schedIt,
808 true,
809 useIdealRrc),
812 0,
813 handoverEventList1,
814 handoverEventList1name,
815 *schedIt,
816 false,
817 useIdealRrc),
820 1,
821 handoverEventList1,
822 handoverEventList1name,
823 *schedIt,
824 false,
825 useIdealRrc),
828 2,
829 handoverEventList1,
830 handoverEventList1name,
831 *schedIt,
832 false,
833 useIdealRrc),
836 0,
837 handoverEventList1,
838 handoverEventList1name,
839 *schedIt,
840 true,
841 useIdealRrc),
844 1,
845 handoverEventList1,
846 handoverEventList1name,
847 *schedIt,
848 true,
849 useIdealRrc),
852 2,
853 handoverEventList1,
854 handoverEventList1name,
855 *schedIt,
856 true,
857 useIdealRrc),
860 0,
861 handoverEventList1,
862 handoverEventList1name,
863 *schedIt,
864 false,
865 useIdealRrc),
868 1,
869 handoverEventList1,
870 handoverEventList1name,
871 *schedIt,
872 false,
873 useIdealRrc),
876 2,
877 handoverEventList1,
878 handoverEventList1name,
879 *schedIt,
880 false,
881 useIdealRrc),
884 0,
885 handoverEventList2,
886 handoverEventList2name,
887 *schedIt,
888 true,
889 useIdealRrc),
892 1,
893 handoverEventList2,
894 handoverEventList2name,
895 *schedIt,
896 true,
897 useIdealRrc),
900 2,
901 handoverEventList2,
902 handoverEventList2name,
903 *schedIt,
904 true,
905 useIdealRrc),
908 0,
909 handoverEventList3,
910 handoverEventList3name,
911 *schedIt,
912 true,
913 useIdealRrc),
916 1,
917 handoverEventList3,
918 handoverEventList3name,
919 *schedIt,
920 true,
921 useIdealRrc),
924 2,
925 handoverEventList3,
926 handoverEventList3name,
927 *schedIt,
928 true,
929 useIdealRrc),
932 0,
933 handoverEventList3,
934 handoverEventList3name,
935 *schedIt,
936 true,
937 useIdealRrc),
940 1,
941 handoverEventList3,
942 handoverEventList3name,
943 *schedIt,
944 true,
945 useIdealRrc),
948 2,
949 handoverEventList3,
950 handoverEventList3name,
951 *schedIt,
952 true,
953 useIdealRrc),
956 0,
957 handoverEventList4,
958 handoverEventList4name,
959 *schedIt,
960 true,
961 useIdealRrc),
964 1,
965 handoverEventList4,
966 handoverEventList4name,
967 *schedIt,
968 true,
969 useIdealRrc),
972 2,
973 handoverEventList4,
974 handoverEventList4name,
975 *schedIt,
976 true,
977 useIdealRrc),
980 0,
981 handoverEventList5,
982 handoverEventList5name,
983 *schedIt,
984 true,
985 useIdealRrc),
988 1,
989 handoverEventList5,
990 handoverEventList5name,
991 *schedIt,
992 true,
993 useIdealRrc),
996 2,
997 handoverEventList5,
998 handoverEventList5name,
999 *schedIt,
1000 true,
1001 useIdealRrc),
1004 0,
1005 handoverEventList3,
1006 handoverEventList3name,
1007 *schedIt,
1008 true,
1009 useIdealRrc),
1012 1,
1013 handoverEventList3,
1014 handoverEventList3name,
1015 *schedIt,
1016 true,
1017 useIdealRrc),
1020 2,
1021 handoverEventList3,
1022 handoverEventList3name,
1023 *schedIt,
1024 true,
1025 useIdealRrc),
1028 0,
1029 handoverEventList4,
1030 handoverEventList4name,
1031 *schedIt,
1032 true,
1033 useIdealRrc),
1036 1,
1037 handoverEventList4,
1038 handoverEventList4name,
1039 *schedIt,
1040 true,
1041 useIdealRrc),
1044 2,
1045 handoverEventList4,
1046 handoverEventList4name,
1047 *schedIt,
1048 true,
1049 useIdealRrc),
1052 0,
1053 handoverEventList5,
1054 handoverEventList5name,
1055 *schedIt,
1056 true,
1057 useIdealRrc),
1060 1,
1061 handoverEventList5,
1062 handoverEventList5name,
1063 *schedIt,
1064 true,
1065 useIdealRrc),
1068 2,
1069 handoverEventList5,
1070 handoverEventList5name,
1071 *schedIt,
1072 true,
1073 useIdealRrc),
1075 }
1076 }
1077}
1078
1079/**
1080 * @ingroup lte-test
1081 * Static variable for test initialization
1082 */
uint32_t q
uint32_t u
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.
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:61
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.
Definition ptr.h:67
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
void AddTestCase(TestCase *testCase, Duration duration=Duration::QUICK)
Add an individual child TestCase to this test suite.
Definition test.cc:293
@ EXTENSIVE
Medium length test.
Definition test.h:1055
@ QUICK
Fast test.
Definition test.h:1054
TestCase(const TestCase &)=delete
Type
Type of test.
Definition test.h:1257
TestSuite(std::string name, Type type=Type::UNIT)
Construct a new test suite.
Definition test.cc:491
Simulation virtual time values and global simulation resolution.
Definition nstime.h:96
AttributeValue implementation for Time.
Definition nstime.h:1456
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
ObjectPtrContainerValue ObjectMapValue
ObjectMapValue is an alias for ObjectPtrContainerValue.
Definition object-map.h:29
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:439
#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:133
#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:553
Time Seconds(double value)
Construct a Time in the indicated unit.
Definition nstime.h:1369
Time MilliSeconds(uint64_t value)
Construct a Time in the indicated unit.
Definition nstime.h:1381
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