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/boolean.h"
10#include "ns3/config.h"
11#include "ns3/internet-stack-helper.h"
12#include "ns3/ipv4-static-routing-helper.h"
13#include "ns3/ipv4-static-routing.h"
14#include "ns3/lte-enb-net-device.h"
15#include "ns3/lte-enb-rrc.h"
16#include "ns3/lte-helper.h"
17#include "ns3/lte-radio-bearer-info.h"
18#include "ns3/lte-ue-net-device.h"
19#include "ns3/lte-ue-rrc.h"
20#include "ns3/mobility-helper.h"
21#include "ns3/object-map.h"
22#include "ns3/packet-sink-helper.h"
23#include "ns3/packet-sink.h"
24#include "ns3/point-to-point-epc-helper.h"
25#include "ns3/point-to-point-helper.h"
26#include "ns3/rng-seed-manager.h"
27#include "ns3/string.h"
28#include "ns3/test.h"
29#include "ns3/udp-client-server-helper.h"
30#include "ns3/uinteger.h"
31
32using namespace ns3;
33
34NS_LOG_COMPONENT_DEFINE("LteX2HandoverTest");
35
36/**
37 * @ingroup lte-test
38 *
39 * @brief HandoverEvent structure
40 */
42{
43 Time startTime; ///< start time
44 uint32_t ueDeviceIndex; ///< UE device index
45 uint32_t sourceEnbDeviceIndex; ///< source ENB device index
46 uint32_t targetEnbDeviceIndex; ///< target ENB device index
47};
48
49/**
50 * @ingroup lte-test
51 *
52 * @brief Test X2 Handover. In this test is used NoOpHandoverAlgorithm and
53 * the request for handover is generated manually, and it is not based on measurements.
54 */
56{
57 public:
58 /**
59 *
60 *
61 * @param nUes number of UEs in the test
62 * @param nDedicatedBearers number of bearers to be activated per UE
63 * @param handoverEventList
64 * @param handoverEventListName
65 * @param schedulerType the scheduler type
66 * @param admitHo
67 * @param useIdealRrc true if the ideal RRC should be used
68 */
70 uint32_t nDedicatedBearers,
71 std::list<HandoverEvent> handoverEventList,
72 std::string handoverEventListName,
73 std::string schedulerType,
74 bool admitHo,
75 bool useIdealRrc);
76
77 private:
78 /**
79 * Build name string
80 * @param nUes number of UEs in the test
81 * @param nDedicatedBearers number of bearers to be activated per UE
82 * @param handoverEventListName
83 * @param schedulerType the scheduler type
84 * @param admitHo
85 * @param useIdealRrc true if the ideal RRC should be used
86 * @returns the name string
87 */
88 static std::string BuildNameString(uint32_t nUes,
89 uint32_t nDedicatedBearers,
90 std::string handoverEventListName,
91 std::string schedulerType,
92 bool admitHo,
93 bool useIdealRrc);
94 void DoRun() override;
95 /**
96 * Check connected function
97 * @param ueDevice the UE device
98 * @param enbDevice the ENB device
99 */
100 void CheckConnected(Ptr<NetDevice> ueDevice, Ptr<NetDevice> enbDevice);
101
102 /**
103 * Teleport UE between both eNBs of the test
104 * @param ueNode the UE node
105 */
106 void TeleportUeToMiddle(Ptr<Node> ueNode);
107
108 /**
109 * Teleport UE near the target eNB of the handover
110 * @param ueNode the UE node
111 * @param enbNode the target eNB node
112 */
113 void TeleportUeNearTargetEnb(Ptr<Node> ueNode, Ptr<Node> enbNode);
114
115 uint32_t m_nUes; ///< number of UEs in the test
116 uint32_t m_nDedicatedBearers; ///< number of UEs in the test
117 std::list<HandoverEvent> m_handoverEventList; ///< handover event list
118 std::string m_handoverEventListName; ///< handover event list name
119 bool m_epc; ///< whether to use EPC
120 std::string m_schedulerType; ///< scheduler type
121 bool m_admitHo; ///< whether to admit the handover request
122 bool m_useIdealRrc; ///< whether to use the ideal RRC
125
126 /**
127 * @ingroup lte-test
128 *
129 * @brief BearerData structure
130 */
132 {
133 uint32_t bid; ///< BID
136 uint32_t dlOldTotalRx; ///< DL old total receive
137 uint32_t ulOldTotalRx; ///< UL old total receive
138 };
139
140 /**
141 * @ingroup lte-test
142 *
143 * @brief UeData structure
144 */
145 struct UeData
146 {
147 uint32_t id; ///< ID
148 std::list<BearerData> bearerDataList; ///< bearer ID list
149 };
150
151 /**
152 * @brief Save stats after handover function
153 * @param ueIndex the index of the UE
154 */
155 void SaveStatsAfterHandover(uint32_t ueIndex);
156 /**
157 * @brief Check stats a while after handover function
158 * @param ueIndex the index of the UE
159 */
161
162 std::vector<UeData> m_ueDataVector; ///< UE data vector
163
164 const Time m_maxHoDuration; ///< maximum HO duration
165 const Time m_statsDuration; ///< stats duration
166 const Time m_udpClientInterval; ///< UDP client interval
167 const uint32_t m_udpClientPktSize; ///< UDP client packet size
168};
169
170std::string
172 uint32_t nDedicatedBearers,
173 std::string handoverEventListName,
174 std::string schedulerType,
175 bool admitHo,
176 bool useIdealRrc)
177{
178 std::ostringstream oss;
179 oss << " nUes=" << nUes << " nDedicatedBearers=" << nDedicatedBearers << " " << schedulerType
180 << " admitHo=" << admitHo << " hoList: " << handoverEventListName;
181 if (useIdealRrc)
182 {
183 oss << ", ideal RRC";
184 }
185 else
186 {
187 oss << ", real RRC";
188 }
189 return oss.str();
190}
191
193 uint32_t nDedicatedBearers,
194 std::list<HandoverEvent> handoverEventList,
195 std::string handoverEventListName,
196 std::string schedulerType,
197 bool admitHo,
198 bool useIdealRrc)
200 nDedicatedBearers,
201 handoverEventListName,
202 schedulerType,
203 admitHo,
204 useIdealRrc)),
205 m_nUes(nUes),
206 m_nDedicatedBearers(nDedicatedBearers),
207 m_handoverEventList(handoverEventList),
208 m_handoverEventListName(handoverEventListName),
209 m_epc(true),
210 m_schedulerType(schedulerType),
211 m_admitHo(admitHo),
212 m_useIdealRrc(useIdealRrc),
217
218{
219}
220
221void
223{
228 m_admitHo,
230
231 uint32_t previousSeed = RngSeedManager::GetSeed();
232 uint64_t previousRun = RngSeedManager::GetRun();
234 // This test is sensitive to random variable stream assignments
237 Config::SetDefault("ns3::UdpClient::Interval", TimeValue(m_udpClientInterval));
238 Config::SetDefault("ns3::UdpClient::MaxPackets", UintegerValue(1000000));
239 Config::SetDefault("ns3::UdpClient::PacketSize", UintegerValue(m_udpClientPktSize));
240
241 // Disable Uplink Power Control
242 Config::SetDefault("ns3::LteUePhy::EnableUplinkPowerControl", BooleanValue(false));
243
244 int64_t stream = 1;
245
247 m_lteHelper->SetAttribute("PathlossModel",
248 StringValue("ns3::FriisSpectrumPropagationLossModel"));
249 m_lteHelper->SetSchedulerType(m_schedulerType);
250 m_lteHelper->SetHandoverAlgorithmType(
251 "ns3::NoOpHandoverAlgorithm"); // disable automatic handover
252 m_lteHelper->SetAttribute("UseIdealRrc", BooleanValue(m_useIdealRrc));
253
254 NodeContainer enbNodes;
255 enbNodes.Create(2);
256 NodeContainer ueNodes;
257 ueNodes.Create(m_nUes);
258
259 if (m_epc)
260 {
262 m_lteHelper->SetEpcHelper(m_epcHelper);
263 }
264
266 positionAlloc->Add(Vector(-3000, 0, 0)); // enb0
267 positionAlloc->Add(Vector(3000, 0, 0)); // enb1
268 for (uint32_t i = 0; i < m_nUes; i++)
269 {
270 positionAlloc->Add(Vector(-3000, 100, 0));
271 }
272 MobilityHelper mobility;
273 mobility.SetPositionAllocator(positionAlloc);
274 mobility.SetMobilityModel("ns3::ConstantPositionMobilityModel");
275 mobility.Install(enbNodes);
276 mobility.Install(ueNodes);
277
278 NetDeviceContainer enbDevices;
279 enbDevices = m_lteHelper->InstallEnbDevice(enbNodes);
280 // Call AssignStreams in the EpcHelper only once by setting 'assignEpcStreams' only once
281 // Then, increment the stream value by 1000 (a magic number that should ensure that there
282 // are no overlapping stream assignments) each time that AssignStreams is called,
283 // to lessen the possibility that random variable stream assignment changes propagate
284 // to other objects.
285 m_lteHelper->AssignStreams(enbDevices, stream, false);
286 stream += 1000;
287 for (auto it = enbDevices.Begin(); it != enbDevices.End(); ++it)
288 {
289 Ptr<LteEnbRrc> enbRrc = (*it)->GetObject<LteEnbNetDevice>()->GetRrc();
290 enbRrc->SetAttribute("AdmitHandoverRequest", BooleanValue(m_admitHo));
291 }
292
293 NetDeviceContainer ueDevices;
294 ueDevices = m_lteHelper->InstallUeDevice(ueNodes);
295 m_lteHelper->AssignStreams(ueDevices, stream, true);
296 stream += 1000;
297
298 Ipv4Address remoteHostAddr;
299 Ipv4StaticRoutingHelper ipv4RoutingHelper;
300 Ipv4InterfaceContainer ueIpIfaces;
301 Ptr<Node> remoteHost;
302 if (m_epc)
303 {
304 // Create a single RemoteHost
305 NodeContainer remoteHostContainer;
306 remoteHostContainer.Create(1);
307 remoteHost = remoteHostContainer.Get(0);
308 InternetStackHelper internet;
309 internet.Install(remoteHostContainer);
310
311 // Create the Internet
313 p2ph.SetDeviceAttribute("DataRate", DataRateValue(DataRate("100Gb/s")));
314 p2ph.SetDeviceAttribute("Mtu", UintegerValue(1500));
315 p2ph.SetChannelAttribute("Delay", TimeValue(Seconds(0.010)));
316 Ptr<Node> pgw = m_epcHelper->GetPgwNode();
317 NetDeviceContainer internetDevices = p2ph.Install(pgw, remoteHost);
318 Ipv4AddressHelper ipv4h;
319 ipv4h.SetBase("1.0.0.0", "255.0.0.0");
320 Ipv4InterfaceContainer internetIpIfaces = ipv4h.Assign(internetDevices);
321 // in this container, interface 0 is the pgw, 1 is the remoteHost
322 remoteHostAddr = internetIpIfaces.GetAddress(1);
323
324 Ipv4StaticRoutingHelper ipv4RoutingHelper;
325 Ptr<Ipv4StaticRouting> remoteHostStaticRouting =
326 ipv4RoutingHelper.GetStaticRouting(remoteHost->GetObject<Ipv4>());
327 remoteHostStaticRouting->AddNetworkRouteTo(Ipv4Address("7.0.0.0"),
328 Ipv4Mask("255.0.0.0"),
329 1);
330
331 // Install the IP stack on the UEs
332 internet.Install(ueNodes);
333 ueIpIfaces = m_epcHelper->AssignUeIpv4Address(NetDeviceContainer(ueDevices));
334 }
335
336 // attachment (needs to be done after IP stack configuration)
337 // all UEs attached to eNB 0 at the beginning
338 m_lteHelper->Attach(ueDevices, enbDevices.Get(0));
339
340 if (m_epc)
341 {
342 // always true: bool epcDl = true;
343 // always true: bool epcUl = true;
344 // the rest of this block is copied from lena-dual-stripe
345
346 // Install and start applications on UEs and remote host
347 uint16_t dlPort = 10000;
348 uint16_t ulPort = 20000;
349
350 // randomize a bit start times to avoid simulation artifacts
351 // (e.g., buffer overflows due to packet transmissions happening
352 // exactly at the same time)
354 startTimeSeconds->SetAttribute("Min", DoubleValue(0));
355 startTimeSeconds->SetAttribute("Max", DoubleValue(0.010));
356 startTimeSeconds->SetStream(stream++);
357
358 for (uint32_t u = 0; u < ueNodes.GetN(); ++u)
359 {
360 Ptr<Node> ue = ueNodes.Get(u);
361 // Set the default gateway for the UE
362 Ptr<Ipv4StaticRouting> ueStaticRouting =
363 ipv4RoutingHelper.GetStaticRouting(ue->GetObject<Ipv4>());
364 ueStaticRouting->SetDefaultRoute(m_epcHelper->GetUeDefaultGatewayAddress(), 1);
365
366 UeData ueData;
367
368 for (uint32_t b = 0; b < m_nDedicatedBearers; ++b)
369 {
370 ++dlPort;
371 ++ulPort;
372
373 ApplicationContainer clientApps;
374 ApplicationContainer serverApps;
375 BearerData bearerData = BearerData();
376
377 // always true: if (epcDl)
378 {
379 UdpClientHelper dlClientHelper(ueIpIfaces.GetAddress(u), dlPort);
380 clientApps.Add(dlClientHelper.Install(remoteHost));
381 PacketSinkHelper dlPacketSinkHelper(
382 "ns3::UdpSocketFactory",
384 ApplicationContainer sinkContainer = dlPacketSinkHelper.Install(ue);
385 bearerData.dlSink = sinkContainer.Get(0)->GetObject<PacketSink>();
386 serverApps.Add(sinkContainer);
387 }
388 // always true: if (epcUl)
389 {
390 UdpClientHelper ulClientHelper(remoteHostAddr, ulPort);
391 clientApps.Add(ulClientHelper.Install(ue));
392 PacketSinkHelper ulPacketSinkHelper(
393 "ns3::UdpSocketFactory",
395 ApplicationContainer sinkContainer = ulPacketSinkHelper.Install(remoteHost);
396 bearerData.ulSink = sinkContainer.Get(0)->GetObject<PacketSink>();
397 serverApps.Add(sinkContainer);
398 }
399
401 // always true: if (epcDl)
402 {
404 dlpf.localPortStart = dlPort;
405 dlpf.localPortEnd = dlPort;
406 tft->Add(dlpf);
407 }
408 // always true: if (epcUl)
409 {
411 ulpf.remotePortStart = ulPort;
412 ulpf.remotePortEnd = ulPort;
413 tft->Add(ulpf);
414 }
415
416 // always true: if (epcDl || epcUl)
417 {
419 m_lteHelper->ActivateDedicatedEpsBearer(ueDevices.Get(u), bearer, tft);
420 }
421 double d = startTimeSeconds->GetValue();
422 Time startTime = Seconds(d);
423 serverApps.Start(startTime);
424 clientApps.Start(startTime);
425
426 ueData.bearerDataList.push_back(bearerData);
427 }
428
429 m_ueDataVector.push_back(ueData);
430 }
431 }
432 else // (epc == false)
433 {
434 // for radio bearer activation purposes, consider together home UEs and macro UEs
435 for (uint32_t u = 0; u < ueDevices.GetN(); ++u)
436 {
437 Ptr<NetDevice> ueDev = ueDevices.Get(u);
438 for (uint32_t b = 0; b < m_nDedicatedBearers; ++b)
439 {
441 EpsBearer bearer(q);
442 m_lteHelper->ActivateDataRadioBearer(ueDev, bearer);
443 }
444 }
445 }
446
447 m_lteHelper->AddX2Interface(enbNodes);
448
449 // check initial RRC connection
450 const Time maxRrcConnectionEstablishmentDuration = Seconds(0.080);
451 for (auto it = ueDevices.Begin(); it != ueDevices.End(); ++it)
452 {
453 Simulator::Schedule(maxRrcConnectionEstablishmentDuration,
455 this,
456 *it,
457 enbDevices.Get(0));
458 }
459
460 // schedule handover events and corresponding checks
461
463 for (auto hoEventIt = m_handoverEventList.begin(); hoEventIt != m_handoverEventList.end();
464 ++hoEventIt)
465 {
466 // Teleport the UE between both eNBs just before the handover starts
467 Simulator::Schedule(hoEventIt->startTime - MilliSeconds(10),
469 this,
470 ueNodes.Get(hoEventIt->ueDeviceIndex));
471
472 Simulator::Schedule(hoEventIt->startTime,
474 this,
475 ueDevices.Get(hoEventIt->ueDeviceIndex),
476 enbDevices.Get(hoEventIt->sourceEnbDeviceIndex));
477
478 m_lteHelper->HandoverRequest(hoEventIt->startTime,
479 ueDevices.Get(hoEventIt->ueDeviceIndex),
480 enbDevices.Get(hoEventIt->sourceEnbDeviceIndex),
481 enbDevices.Get(hoEventIt->targetEnbDeviceIndex));
482
483 // Once the handover is finished, teleport the UE near the target eNB
484 Simulator::Schedule(hoEventIt->startTime + MilliSeconds(40),
486 this,
487 ueNodes.Get(hoEventIt->ueDeviceIndex),
488 enbNodes.Get(m_admitHo ? hoEventIt->targetEnbDeviceIndex
489 : hoEventIt->sourceEnbDeviceIndex));
490
491 Time hoEndTime = hoEventIt->startTime + m_maxHoDuration;
492 Simulator::Schedule(hoEndTime,
494 this,
495 ueDevices.Get(hoEventIt->ueDeviceIndex),
496 enbDevices.Get(m_admitHo ? hoEventIt->targetEnbDeviceIndex
497 : hoEventIt->sourceEnbDeviceIndex));
498 Simulator::Schedule(hoEndTime,
500 this,
501 hoEventIt->ueDeviceIndex);
502
503 Time checkStatsAfterHoTime = hoEndTime + m_statsDuration;
504 Simulator::Schedule(checkStatsAfterHoTime,
506 this,
507 hoEventIt->ueDeviceIndex);
508 if (stopTime <= checkStatsAfterHoTime)
509 {
510 stopTime = checkStatsAfterHoTime + MilliSeconds(1);
511 }
512 }
513
514 // m_lteHelper->EnableRlcTraces ();
515 // m_lteHelper->EnablePdcpTraces();
516
518
520
522
523 // Undo changes to default settings
525 // Restore the previous settings of RngSeed and RngRun
526 RngSeedManager::SetSeed(previousSeed);
527 RngSeedManager::SetRun(previousRun);
528}
529
530void
532{
533 Ptr<LteUeNetDevice> ueLteDevice = ueDevice->GetObject<LteUeNetDevice>();
534 Ptr<LteUeRrc> ueRrc = ueLteDevice->GetRrc();
535 NS_TEST_ASSERT_MSG_EQ(ueRrc->GetState(), LteUeRrc::CONNECTED_NORMALLY, "Wrong LteUeRrc state!");
536
537 Ptr<LteEnbNetDevice> enbLteDevice = enbDevice->GetObject<LteEnbNetDevice>();
538 Ptr<LteEnbRrc> enbRrc = enbLteDevice->GetRrc();
539 uint16_t rnti = ueRrc->GetRnti();
540 Ptr<UeManager> ueManager = enbRrc->GetUeManager(rnti);
541 NS_TEST_ASSERT_MSG_NE(ueManager, nullptr, "RNTI " << rnti << " not found in eNB");
542
543 UeManager::State ueManagerState = ueManager->GetState();
544 NS_TEST_ASSERT_MSG_EQ(ueManagerState, UeManager::CONNECTED_NORMALLY, "Wrong UeManager state!");
545
546 uint16_t ueCellId = ueRrc->GetCellId();
547 uint16_t enbCellId = enbLteDevice->GetCellId();
548 uint8_t ueDlBandwidth = ueRrc->GetDlBandwidth();
549 uint8_t enbDlBandwidth = enbLteDevice->GetDlBandwidth();
550 uint8_t ueUlBandwidth = ueRrc->GetUlBandwidth();
551 uint8_t enbUlBandwidth = enbLteDevice->GetUlBandwidth();
552 uint8_t ueDlEarfcn = ueRrc->GetDlEarfcn();
553 uint8_t enbDlEarfcn = enbLteDevice->GetDlEarfcn();
554 uint8_t ueUlEarfcn = ueRrc->GetUlEarfcn();
555 uint8_t enbUlEarfcn = enbLteDevice->GetUlEarfcn();
556 uint64_t ueImsi = ueLteDevice->GetImsi();
557 uint64_t enbImsi = ueManager->GetImsi();
558
559 NS_TEST_ASSERT_MSG_EQ(ueImsi, enbImsi, "inconsistent IMSI");
560 NS_TEST_ASSERT_MSG_EQ(ueCellId, enbCellId, "inconsistent CellId");
561 NS_TEST_ASSERT_MSG_EQ(ueDlBandwidth, enbDlBandwidth, "inconsistent DlBandwidth");
562 NS_TEST_ASSERT_MSG_EQ(ueUlBandwidth, enbUlBandwidth, "inconsistent UlBandwidth");
563 NS_TEST_ASSERT_MSG_EQ(ueDlEarfcn, enbDlEarfcn, "inconsistent DlEarfcn");
564 NS_TEST_ASSERT_MSG_EQ(ueUlEarfcn, enbUlEarfcn, "inconsistent UlEarfcn");
565
566 ObjectMapValue enbDataRadioBearerMapValue;
567 ueManager->GetAttribute("DataRadioBearerMap", enbDataRadioBearerMapValue);
568 NS_TEST_ASSERT_MSG_EQ(enbDataRadioBearerMapValue.GetN(),
570 "wrong num bearers at eNB");
571
572 ObjectMapValue ueDataRadioBearerMapValue;
573 ueRrc->GetAttribute("DataRadioBearerMap", ueDataRadioBearerMapValue);
574 NS_TEST_ASSERT_MSG_EQ(ueDataRadioBearerMapValue.GetN(),
576 "wrong num bearers at UE");
577
578 auto enbBearerIt = enbDataRadioBearerMapValue.Begin();
579 auto ueBearerIt = ueDataRadioBearerMapValue.Begin();
580 while (enbBearerIt != enbDataRadioBearerMapValue.End() &&
581 ueBearerIt != ueDataRadioBearerMapValue.End())
582 {
583 Ptr<LteDataRadioBearerInfo> enbDrbInfo =
584 enbBearerIt->second->GetObject<LteDataRadioBearerInfo>();
586 ueBearerIt->second->GetObject<LteDataRadioBearerInfo>();
587 // NS_TEST_ASSERT_MSG_EQ (enbDrbInfo->m_epsBearer, ueDrbInfo->m_epsBearer, "epsBearer
588 // differs");
589 NS_TEST_ASSERT_MSG_EQ((uint32_t)enbDrbInfo->m_epsBearerIdentity,
590 (uint32_t)ueDrbInfo->m_epsBearerIdentity,
591 "epsBearerIdentity differs");
592 NS_TEST_ASSERT_MSG_EQ((uint32_t)enbDrbInfo->m_drbIdentity,
593 (uint32_t)ueDrbInfo->m_drbIdentity,
594 "drbIdentity differs");
595 // NS_TEST_ASSERT_MSG_EQ (enbDrbInfo->m_rlcConfig, ueDrbInfo->m_rlcConfig, "rlcConfig
596 // differs");
597 NS_TEST_ASSERT_MSG_EQ((uint32_t)enbDrbInfo->m_logicalChannelIdentity,
598 (uint32_t)ueDrbInfo->m_logicalChannelIdentity,
599 "logicalChannelIdentity differs");
600 // NS_TEST_ASSERT_MSG_EQ (enbDrbInfo->m_logicalChannelConfig,
601 // ueDrbInfo->m_logicalChannelConfig, "logicalChannelConfig differs");
602
603 ++enbBearerIt;
604 ++ueBearerIt;
605 }
606 NS_ASSERT_MSG(enbBearerIt == enbDataRadioBearerMapValue.End(), "too many bearers at eNB");
607 NS_ASSERT_MSG(ueBearerIt == ueDataRadioBearerMapValue.End(), "too many bearers at UE");
608}
609
610void
612{
613 Ptr<MobilityModel> ueMobility = ueNode->GetObject<MobilityModel>();
614 ueMobility->SetPosition(Vector(0.0, 0.0, 0.0));
615}
616
617void
619{
620 Ptr<MobilityModel> enbMobility = enbNode->GetObject<MobilityModel>();
621 Vector pos = enbMobility->GetPosition();
622
623 Ptr<MobilityModel> ueMobility = ueNode->GetObject<MobilityModel>();
624 ueMobility->SetPosition(pos + Vector(0.0, 100.0, 0.0));
625}
626
627void
629{
630 for (auto it = m_ueDataVector.at(ueIndex).bearerDataList.begin();
631 it != m_ueDataVector.at(ueIndex).bearerDataList.end();
632 ++it)
633 {
634 it->dlOldTotalRx = it->dlSink->GetTotalRx();
635 it->ulOldTotalRx = it->ulSink->GetTotalRx();
636 }
637}
638
639void
641{
642 uint32_t b = 1;
643 for (auto it = m_ueDataVector.at(ueIndex).bearerDataList.begin();
644 it != m_ueDataVector.at(ueIndex).bearerDataList.end();
645 ++it)
646 {
647 uint32_t dlRx = it->dlSink->GetTotalRx() - it->dlOldTotalRx;
648 uint32_t ulRx = it->ulSink->GetTotalRx() - it->ulOldTotalRx;
649 uint32_t expectedBytes =
651
653 expectedBytes,
654 "too few RX bytes in DL, ue=" << ueIndex << ", b=" << b);
656 expectedBytes,
657 "too few RX bytes in UL, ue=" << ueIndex << ", b=" << b);
658 ++b;
659 }
660}
661
662/**
663 * @ingroup lte-test
664 *
665 * @brief LTE X2 Handover Test Suite.
666 *
667 * In this test suite, we use NoOpHandoverAlgorithm, i.e. "handover algorithm which does nothing"
668 * is used and handover is triggered manually. The automatic handover algorithms (A2A4, A3Rsrp)
669 * are not tested.
670 *
671 * The tests are designed to check that eNB-buffered data received while a handover is in progress
672 * is not lost but successfully forwarded. But the test suite doesn't test for possible loss of
673 * RLC-buffered data because "lossless" handover is not implemented, and there are other application
674 * send patterns (outside of the range tested here) that may incur losses.
675 */
677{
678 public:
680};
681
683 : TestSuite("lte-x2-handover", Type::SYSTEM)
684{
685 // in the following:
686 // fwd means handover from enb 0 to enb 1
687 // bwd means handover from enb 1 to enb 0
688
689 HandoverEvent ue1fwd;
690 ue1fwd.startTime = MilliSeconds(100);
691 ue1fwd.ueDeviceIndex = 0;
692 ue1fwd.sourceEnbDeviceIndex = 0;
693 ue1fwd.targetEnbDeviceIndex = 1;
694
695 HandoverEvent ue1bwd;
696 ue1bwd.startTime = MilliSeconds(400);
697 ue1bwd.ueDeviceIndex = 0;
698 ue1bwd.sourceEnbDeviceIndex = 1;
699 ue1bwd.targetEnbDeviceIndex = 0;
700
701 HandoverEvent ue1fwdagain;
702 ue1fwdagain.startTime = MilliSeconds(700);
703 ue1fwdagain.ueDeviceIndex = 0;
704 ue1fwdagain.sourceEnbDeviceIndex = 0;
705 ue1fwdagain.targetEnbDeviceIndex = 1;
706
707 HandoverEvent ue2fwd;
708 ue2fwd.startTime = MilliSeconds(110);
709 ue2fwd.ueDeviceIndex = 1;
710 ue2fwd.sourceEnbDeviceIndex = 0;
711 ue2fwd.targetEnbDeviceIndex = 1;
712
713 HandoverEvent ue2bwd;
714 ue2bwd.startTime = MilliSeconds(350);
715 ue2bwd.ueDeviceIndex = 1;
716 ue2bwd.sourceEnbDeviceIndex = 1;
717 ue2bwd.targetEnbDeviceIndex = 0;
718
719 std::string handoverEventList0name("none");
720 std::list<HandoverEvent> handoverEventList0;
721
722 std::string handoverEventList1name("1 fwd");
723 const std::list<HandoverEvent> handoverEventList1{
724 ue1fwd,
725 };
726
727 std::string handoverEventList2name("1 fwd & bwd");
728 const std::list<HandoverEvent> handoverEventList2{
729 ue1fwd,
730 ue1bwd,
731 };
732
733 std::string handoverEventList3name("1 fwd & bwd & fwd");
734 const std::list<HandoverEvent> handoverEventList3{
735 ue1fwd,
736 ue1bwd,
737 ue1fwdagain,
738 };
739
740 std::string handoverEventList4name("1+2 fwd");
741 const std::list<HandoverEvent> handoverEventList4{
742 ue1fwd,
743 ue2fwd,
744 };
745
746 std::string handoverEventList5name("1+2 fwd & bwd");
747 const std::list<HandoverEvent> handoverEventList5{
748 ue1fwd,
749 ue1bwd,
750 ue2fwd,
751 ue2bwd,
752 };
753
754 // std::string handoverEventList6name("2 fwd");
755 // const std::list<HandoverEvent> handoverEventList6{
756 // ue2fwd,
757 // };
758
759 // std::string handoverEventList7name("2 fwd & bwd");
760 // const std::list<HandoverEvent> handoverEventList7{
761 // ue2fwd,
762 // ue2bwd,
763 // };
764
765 std::vector<std::string> schedulers{
766 "ns3::RrFfMacScheduler",
767 "ns3::PfFfMacScheduler",
768 };
769
770 for (auto schedIt = schedulers.begin(); schedIt != schedulers.end(); ++schedIt)
771 {
772 for (auto useIdealRrc : {true, false})
773 {
774 // nUes, nDBearers, helist, name, sched, admitHo, idealRrc
776 0,
777 handoverEventList0,
778 handoverEventList0name,
779 *schedIt,
780 true,
781 useIdealRrc),
784 0,
785 handoverEventList0,
786 handoverEventList0name,
787 *schedIt,
788 true,
789 useIdealRrc),
792 5,
793 handoverEventList0,
794 handoverEventList0name,
795 *schedIt,
796 true,
797 useIdealRrc),
800 5,
801 handoverEventList0,
802 handoverEventList0name,
803 *schedIt,
804 true,
805 useIdealRrc),
808 0,
809 handoverEventList1,
810 handoverEventList1name,
811 *schedIt,
812 true,
813 useIdealRrc),
816 1,
817 handoverEventList1,
818 handoverEventList1name,
819 *schedIt,
820 true,
821 useIdealRrc),
824 2,
825 handoverEventList1,
826 handoverEventList1name,
827 *schedIt,
828 true,
829 useIdealRrc),
832 0,
833 handoverEventList1,
834 handoverEventList1name,
835 *schedIt,
836 false,
837 useIdealRrc),
840 1,
841 handoverEventList1,
842 handoverEventList1name,
843 *schedIt,
844 false,
845 useIdealRrc),
848 2,
849 handoverEventList1,
850 handoverEventList1name,
851 *schedIt,
852 false,
853 useIdealRrc),
856 0,
857 handoverEventList1,
858 handoverEventList1name,
859 *schedIt,
860 true,
861 useIdealRrc),
864 1,
865 handoverEventList1,
866 handoverEventList1name,
867 *schedIt,
868 true,
869 useIdealRrc),
872 2,
873 handoverEventList1,
874 handoverEventList1name,
875 *schedIt,
876 true,
877 useIdealRrc),
880 0,
881 handoverEventList1,
882 handoverEventList1name,
883 *schedIt,
884 false,
885 useIdealRrc),
888 1,
889 handoverEventList1,
890 handoverEventList1name,
891 *schedIt,
892 false,
893 useIdealRrc),
896 2,
897 handoverEventList1,
898 handoverEventList1name,
899 *schedIt,
900 false,
901 useIdealRrc),
904 0,
905 handoverEventList2,
906 handoverEventList2name,
907 *schedIt,
908 true,
909 useIdealRrc),
912 1,
913 handoverEventList2,
914 handoverEventList2name,
915 *schedIt,
916 true,
917 useIdealRrc),
920 2,
921 handoverEventList2,
922 handoverEventList2name,
923 *schedIt,
924 true,
925 useIdealRrc),
928 0,
929 handoverEventList3,
930 handoverEventList3name,
931 *schedIt,
932 true,
933 useIdealRrc),
936 1,
937 handoverEventList3,
938 handoverEventList3name,
939 *schedIt,
940 true,
941 useIdealRrc),
944 2,
945 handoverEventList3,
946 handoverEventList3name,
947 *schedIt,
948 true,
949 useIdealRrc),
952 0,
953 handoverEventList3,
954 handoverEventList3name,
955 *schedIt,
956 true,
957 useIdealRrc),
960 1,
961 handoverEventList3,
962 handoverEventList3name,
963 *schedIt,
964 true,
965 useIdealRrc),
968 2,
969 handoverEventList3,
970 handoverEventList3name,
971 *schedIt,
972 true,
973 useIdealRrc),
976 0,
977 handoverEventList4,
978 handoverEventList4name,
979 *schedIt,
980 true,
981 useIdealRrc),
984 1,
985 handoverEventList4,
986 handoverEventList4name,
987 *schedIt,
988 true,
989 useIdealRrc),
992 2,
993 handoverEventList4,
994 handoverEventList4name,
995 *schedIt,
996 true,
997 useIdealRrc),
1000 0,
1001 handoverEventList5,
1002 handoverEventList5name,
1003 *schedIt,
1004 true,
1005 useIdealRrc),
1008 1,
1009 handoverEventList5,
1010 handoverEventList5name,
1011 *schedIt,
1012 true,
1013 useIdealRrc),
1016 2,
1017 handoverEventList5,
1018 handoverEventList5name,
1019 *schedIt,
1020 true,
1021 useIdealRrc),
1024 0,
1025 handoverEventList3,
1026 handoverEventList3name,
1027 *schedIt,
1028 true,
1029 useIdealRrc),
1032 1,
1033 handoverEventList3,
1034 handoverEventList3name,
1035 *schedIt,
1036 true,
1037 useIdealRrc),
1040 2,
1041 handoverEventList3,
1042 handoverEventList3name,
1043 *schedIt,
1044 true,
1045 useIdealRrc),
1048 0,
1049 handoverEventList4,
1050 handoverEventList4name,
1051 *schedIt,
1052 true,
1053 useIdealRrc),
1056 1,
1057 handoverEventList4,
1058 handoverEventList4name,
1059 *schedIt,
1060 true,
1061 useIdealRrc),
1064 2,
1065 handoverEventList4,
1066 handoverEventList4name,
1067 *schedIt,
1068 true,
1069 useIdealRrc),
1072 0,
1073 handoverEventList5,
1074 handoverEventList5name,
1075 *schedIt,
1076 true,
1077 useIdealRrc),
1080 1,
1081 handoverEventList5,
1082 handoverEventList5name,
1083 *schedIt,
1084 true,
1085 useIdealRrc),
1088 2,
1089 handoverEventList5,
1090 handoverEventList5name,
1091 *schedIt,
1092 true,
1093 useIdealRrc),
1095 }
1096 }
1097}
1098
1099/**
1100 * @ingroup lte-test
1101 * Static variable for test initialization
1102 */
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...
Class for representing data rates.
Definition data-rate.h:78
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:70
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:580
static void Destroy()
Execute the events scheduled with ScheduleDestroy().
Definition simulator.cc:125
static void Run()
Run the simulation.
Definition simulator.cc:161
static void Stop()
Tell the Simulator the calling event should be the last one executed.
Definition simulator.cc:169
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:296
@ EXTENSIVE
Medium length test.
Definition test.h:1058
@ QUICK
Fast test.
Definition test.h:1057
TestCase(const TestCase &)=delete
Caller graph was not generated because of its size.
Type
Type of test.
Definition test.h:1271
TestSuite(std::string name, Type type=Type::UNIT)
Construct a new test suite.
Definition test.cc:494
Simulation virtual time values and global simulation resolution.
Definition nstime.h:95
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:76
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:201
#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:627
Ptr< T > Create(Ts &&... args)
Create class instances by constructors with varying numbers of arguments and return them by Ptr.
Definition ptr.h:492
#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:1313
Time MilliSeconds(uint64_t value)
Construct a Time in the indicated unit.
Definition nstime.h:1330
Every class exported by the ns3 library is enclosed in the ns3 namespace.
ObjectPtrContainerValue ObjectMapValue
ObjectMapValue is an alias for ObjectPtrContainerValue.
Definition object-map.h:29
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