A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
test-lte-x2-handover-measures.cc
Go to the documentation of this file.
1/*
2 * Copyright (c) 2013 Centre Tecnologic de Telecomunicacions de Catalunya (CTTC)
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation;
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 *
17 * Authors: Nicola Baldo <nbaldo@cttc.es>
18 * Manuel Requena <manuel.requena@cttc.es>
19 */
20
21#include <ns3/bulk-send-helper.h>
22#include <ns3/core-module.h>
23#include <ns3/internet-module.h>
24#include <ns3/lte-module.h>
25#include <ns3/mobility-module.h>
26#include <ns3/network-module.h>
27#include <ns3/packet-sink-helper.h>
28#include <ns3/packet-sink.h>
29#include <ns3/point-to-point-module.h>
30#include <ns3/udp-client-server-helper.h>
31
32using namespace ns3;
33
34NS_LOG_COMPONENT_DEFINE("LteX2HandoverMeasuresTest");
35
42{
48
58 CheckPointEvent(Time start, Time stop, Time interval, uint32_t ueIndex, uint32_t enbIndex)
59 : checkStartTime(start),
60 checkStopTime(stop),
61 checkInterval(interval),
62 ueDeviceIndex(ueIndex),
63 enbDeviceIndex(enbIndex)
64 {
65 }
66};
67
75{
76 public:
93 uint32_t nUes,
94 uint32_t nDedicatedBearers,
95 std::list<CheckPointEvent> checkPointEventList,
96 std::string checkPointEventListName,
97 bool useUdp,
98 std::string schedulerType,
99 std::string handoverAlgorithmType,
100 bool admitHo,
101 bool useIdealRrc);
102
103 private:
118 static std::string BuildNameString(uint32_t nEnbs,
119 uint32_t nUes,
120 uint32_t nDedicatedBearers,
121 std::string checkPointEventListName,
122 bool useUdp,
123 std::string schedulerType,
124 std::string handoverAlgorithmType,
125 bool admitHo,
126 bool useIdealRrc);
127 void DoRun() override;
133 void CheckConnected(Ptr<NetDevice> ueDevice, Ptr<NetDevice> enbDevice);
134
138 std::list<CheckPointEvent> m_checkPointEventList;
140 bool m_epc;
141 bool m_useUdp;
142 std::string m_schedulerType;
148
155 {
161 };
162
168 struct UeData
169 {
171 std::list<BearerData> bearerDataList;
172 };
173
178 void SaveStats(uint32_t ueIndex);
183 void CheckStats(uint32_t ueIndex);
184
185 std::vector<UeData> m_ueDataVector;
186
191};
192
193std::string
195 uint32_t nUes,
196 uint32_t nDedicatedBearers,
197 std::string checkPointEventListName,
198 bool useUdp,
199 std::string schedulerType,
200 std::string handoverAlgorithmType,
201 bool admitHo,
202 bool useIdealRrc)
203{
204 std::ostringstream oss;
205 oss << "nEnbs=" << nEnbs << " nUes=" << nUes << " nDedicatedBearers=" << nDedicatedBearers
206 << " udp=" << useUdp << " " << schedulerType << " " << handoverAlgorithmType
207 << " admitHo=" << admitHo << " hoList: " << checkPointEventListName;
208 if (useIdealRrc)
209 {
210 oss << ", ideal RRC";
211 }
212 else
213 {
214 oss << ", real RRC";
215 }
216 return oss.str();
217}
218
220 uint32_t nEnbs,
221 uint32_t nUes,
222 uint32_t nDedicatedBearers,
223 std::list<CheckPointEvent> checkPointEventList,
224 std::string checkPointEventListName,
225 bool useUdp,
226 std::string schedulerType,
227 std::string handoverAlgorithmType,
228 bool admitHo,
229 bool useIdealRrc)
230 : TestCase(BuildNameString(nEnbs,
231 nUes,
232 nDedicatedBearers,
233 checkPointEventListName,
234 useUdp,
235 schedulerType,
236 handoverAlgorithmType,
237 admitHo,
238 useIdealRrc)),
239 m_nEnbs(nEnbs),
240 m_nUes(nUes),
241 m_nDedicatedBearers(nDedicatedBearers),
242 m_checkPointEventList(checkPointEventList),
243 m_checkPointEventListName(checkPointEventListName),
244 m_epc(true),
245 m_useUdp(useUdp),
246 m_schedulerType(schedulerType),
247 m_handoverAlgorithmType(handoverAlgorithmType),
248 m_admitHo(admitHo),
249 m_useIdealRrc(useIdealRrc),
250 m_maxHoDuration(Seconds(0.1)),
251 m_statsDuration(Seconds(0.5)),
252 m_udpClientInterval(Seconds(0.01)),
253 m_udpClientPktSize(100)
254{
255}
256
257void
259{
261 m_nUes,
264 m_useUdp,
267 m_admitHo,
269
271 Config::SetDefault("ns3::UdpClient::Interval", TimeValue(m_udpClientInterval));
272 Config::SetDefault("ns3::UdpClient::MaxPackets", UintegerValue(1000000));
273 Config::SetDefault("ns3::UdpClient::PacketSize", UintegerValue(m_udpClientPktSize));
274 Config::SetDefault("ns3::LteEnbRrc::HandoverJoiningTimeoutDuration",
275 TimeValue(MilliSeconds(200)));
276 Config::SetDefault("ns3::LteEnbPhy::TxPower", DoubleValue(20));
277
278 // Disable Uplink Power Control
279 Config::SetDefault("ns3::LteUePhy::EnableUplinkPowerControl", BooleanValue(false));
280
281 int64_t stream = 1;
282
283 m_lteHelper = CreateObject<LteHelper>();
284 m_lteHelper->SetAttribute("PathlossModel",
285 StringValue("ns3::FriisSpectrumPropagationLossModel"));
288
289 if (m_handoverAlgorithmType == "ns3::A2A4RsrqHandoverAlgorithm")
290 {
291 m_lteHelper->SetHandoverAlgorithmType("ns3::A2A4RsrqHandoverAlgorithm");
292 m_lteHelper->SetHandoverAlgorithmAttribute("ServingCellThreshold", UintegerValue(30));
293 m_lteHelper->SetHandoverAlgorithmAttribute("NeighbourCellOffset", UintegerValue(1));
294 }
295 else if (m_handoverAlgorithmType == "ns3::A3RsrpHandoverAlgorithm")
296 {
297 m_lteHelper->SetHandoverAlgorithmType("ns3::A3RsrpHandoverAlgorithm");
300 }
301 else
302 {
303 NS_FATAL_ERROR("Unknown handover algorithm " << m_handoverAlgorithmType);
304 }
305
306 double distance = 1000.0; // m
307 double speed = 150; // m/s
308
309 NodeContainer enbNodes;
310 enbNodes.Create(m_nEnbs);
311 NodeContainer ueNodes;
312 ueNodes.Create(m_nUes);
313
314 if (m_epc)
315 {
316 m_epcHelper = CreateObject<PointToPointEpcHelper>();
318 }
319
320 // Install Mobility Model in eNBs
321 // eNBs are located along a line in the X axis
322 Ptr<ListPositionAllocator> enbPositionAlloc = CreateObject<ListPositionAllocator>();
323 for (uint32_t i = 0; i < m_nEnbs; i++)
324 {
325 Vector enbPosition(distance * (i + 1), 0, 0);
326 enbPositionAlloc->Add(enbPosition);
327 }
328 MobilityHelper enbMobility;
329 enbMobility.SetMobilityModel("ns3::ConstantPositionMobilityModel");
330 enbMobility.SetPositionAllocator(enbPositionAlloc);
331 enbMobility.Install(enbNodes);
332
333 // Install Mobility Model in UE
334 // UE moves with a constant speed along the X axis
335 MobilityHelper ueMobility;
336 ueMobility.SetMobilityModel("ns3::ConstantVelocityMobilityModel");
337 ueMobility.Install(ueNodes);
338 for (uint32_t i = 0; i < m_nUes; i++)
339 {
340 ueNodes.Get(i)->GetObject<MobilityModel>()->SetPosition(Vector(0, 0, 0));
341 ueNodes.Get(i)->GetObject<ConstantVelocityMobilityModel>()->SetVelocity(
342 Vector(speed, 0, 0));
343 }
344
345 NetDeviceContainer enbDevices;
346 enbDevices = m_lteHelper->InstallEnbDevice(enbNodes);
347 stream += m_lteHelper->AssignStreams(enbDevices, stream);
348 for (auto it = enbDevices.Begin(); it != enbDevices.End(); ++it)
349 {
350 Ptr<LteEnbRrc> enbRrc = (*it)->GetObject<LteEnbNetDevice>()->GetRrc();
351 enbRrc->SetAttribute("AdmitHandoverRequest", BooleanValue(m_admitHo));
352 }
353
354 NetDeviceContainer ueDevices;
355 ueDevices = m_lteHelper->InstallUeDevice(ueNodes);
356 stream += m_lteHelper->AssignStreams(ueDevices, stream);
357
358 Ipv4Address remoteHostAddr;
359 Ipv4StaticRoutingHelper ipv4RoutingHelper;
360 Ipv4InterfaceContainer ueIpIfaces;
361 Ptr<Node> remoteHost;
362 if (m_epc)
363 {
364 // Create a single RemoteHost
365 NodeContainer remoteHostContainer;
366 remoteHostContainer.Create(1);
367 remoteHost = remoteHostContainer.Get(0);
368 InternetStackHelper internet;
369 internet.Install(remoteHostContainer);
370
371 // Create the Internet
373 p2ph.SetDeviceAttribute("DataRate", DataRateValue(DataRate("100Gb/s")));
374 p2ph.SetDeviceAttribute("Mtu", UintegerValue(1500));
375 p2ph.SetChannelAttribute("Delay", TimeValue(Seconds(0.010)));
377 NetDeviceContainer internetDevices = p2ph.Install(pgw, remoteHost);
378 Ipv4AddressHelper ipv4h;
379 ipv4h.SetBase("1.0.0.0", "255.0.0.0");
380 Ipv4InterfaceContainer internetIpIfaces = ipv4h.Assign(internetDevices);
381 // in this container, interface 0 is the pgw, 1 is the remoteHost
382 remoteHostAddr = internetIpIfaces.GetAddress(1);
383
384 Ipv4StaticRoutingHelper ipv4RoutingHelper;
385 Ptr<Ipv4StaticRouting> remoteHostStaticRouting =
386 ipv4RoutingHelper.GetStaticRouting(remoteHost->GetObject<Ipv4>());
387 remoteHostStaticRouting->AddNetworkRouteTo(Ipv4Address("7.0.0.0"),
388 Ipv4Mask("255.0.0.0"),
389 1);
390
391 // Install the IP stack on the UEs
392 internet.Install(ueNodes);
393 ueIpIfaces = m_epcHelper->AssignUeIpv4Address(NetDeviceContainer(ueDevices));
394 }
395
396 // attachment (needs to be done after IP stack configuration)
397 // all UEs attached to eNB 0 at the beginning
398 m_lteHelper->Attach(ueDevices, enbDevices.Get(0));
399
400 if (m_epc)
401 {
402 bool epcDl = true;
403 bool epcUl = false;
404 // the rest of this block is copied from lena-dual-stripe
405
406 // Install and start applications on UEs and remote host
407 uint16_t dlPort = 10000;
408 uint16_t ulPort = 20000;
409
410 // randomize a bit start times to avoid simulation artifacts
411 // (e.g., buffer overflows due to packet transmissions happening
412 // exactly at the same time)
413 Ptr<UniformRandomVariable> startTimeSeconds = CreateObject<UniformRandomVariable>();
414 startTimeSeconds->SetAttribute("Min", DoubleValue(0));
415 startTimeSeconds->SetAttribute("Max", DoubleValue(0.010));
416 startTimeSeconds->SetStream(stream++);
417
418 for (uint32_t u = 0; u < ueNodes.GetN(); ++u)
419 {
420 Ptr<Node> ue = ueNodes.Get(u);
421 // Set the default gateway for the UE
422 Ptr<Ipv4StaticRouting> ueStaticRouting =
423 ipv4RoutingHelper.GetStaticRouting(ue->GetObject<Ipv4>());
424 ueStaticRouting->SetDefaultRoute(m_epcHelper->GetUeDefaultGatewayAddress(), 1);
425
426 UeData ueData;
427
428 for (uint32_t b = 0; b < m_nDedicatedBearers; ++b)
429 {
430 ++dlPort;
431 ++ulPort;
432
433 ApplicationContainer clientApps;
434 ApplicationContainer serverApps;
435 BearerData bearerData = BearerData();
436
437 if (m_useUdp)
438 {
439 if (epcDl)
440 {
441 UdpClientHelper dlClientHelper(ueIpIfaces.GetAddress(u), dlPort);
442 clientApps.Add(dlClientHelper.Install(remoteHost));
443 PacketSinkHelper dlPacketSinkHelper(
444 "ns3::UdpSocketFactory",
446 ApplicationContainer sinkContainer = dlPacketSinkHelper.Install(ue);
447 bearerData.dlSink = sinkContainer.Get(0)->GetObject<PacketSink>();
448 serverApps.Add(sinkContainer);
449 }
450 if (epcUl)
451 {
452 UdpClientHelper ulClientHelper(remoteHostAddr, ulPort);
453 clientApps.Add(ulClientHelper.Install(ue));
454 PacketSinkHelper ulPacketSinkHelper(
455 "ns3::UdpSocketFactory",
457 ApplicationContainer sinkContainer = ulPacketSinkHelper.Install(remoteHost);
458 bearerData.ulSink = sinkContainer.Get(0)->GetObject<PacketSink>();
459 serverApps.Add(sinkContainer);
460 }
461 }
462 else // use TCP
463 {
464 if (epcDl)
465 {
466 BulkSendHelper dlClientHelper(
467 "ns3::TcpSocketFactory",
468 InetSocketAddress(ueIpIfaces.GetAddress(u), dlPort));
469 dlClientHelper.SetAttribute("MaxBytes", UintegerValue(0));
470 clientApps.Add(dlClientHelper.Install(remoteHost));
471 PacketSinkHelper dlPacketSinkHelper(
472 "ns3::TcpSocketFactory",
474 ApplicationContainer sinkContainer = dlPacketSinkHelper.Install(ue);
475 bearerData.dlSink = sinkContainer.Get(0)->GetObject<PacketSink>();
476 serverApps.Add(sinkContainer);
477 }
478 if (epcUl)
479 {
480 BulkSendHelper ulClientHelper("ns3::TcpSocketFactory",
481 InetSocketAddress(remoteHostAddr, ulPort));
482 ulClientHelper.SetAttribute("MaxBytes", UintegerValue(0));
483 clientApps.Add(ulClientHelper.Install(ue));
484 PacketSinkHelper ulPacketSinkHelper(
485 "ns3::TcpSocketFactory",
487 ApplicationContainer sinkContainer = ulPacketSinkHelper.Install(remoteHost);
488 bearerData.ulSink = sinkContainer.Get(0)->GetObject<PacketSink>();
489 serverApps.Add(sinkContainer);
490 }
491 } // end if (useUdp)
492
493 Ptr<EpcTft> tft = Create<EpcTft>();
494 if (epcDl)
495 {
497 dlpf.localPortStart = dlPort;
498 dlpf.localPortEnd = dlPort;
499 tft->Add(dlpf);
500 }
501 if (epcUl)
502 {
504 ulpf.remotePortStart = ulPort;
505 ulpf.remotePortEnd = ulPort;
506 tft->Add(ulpf);
507 }
508
509 if (epcDl || epcUl)
510 {
512 m_lteHelper->ActivateDedicatedEpsBearer(ueDevices.Get(u), bearer, tft);
513 }
514 Time startTime = Seconds(startTimeSeconds->GetValue());
515 serverApps.Start(startTime);
516 clientApps.Start(startTime);
517
518 ueData.bearerDataList.push_back(bearerData);
519
520 } // end for b
521
522 m_ueDataVector.push_back(ueData);
523 }
524 }
525 else // (epc == false)
526 {
527 // for radio bearer activation purposes, consider together home UEs and macro UEs
528 for (uint32_t u = 0; u < ueDevices.GetN(); ++u)
529 {
530 Ptr<NetDevice> ueDev = ueDevices.Get(u);
531 for (uint32_t b = 0; b < m_nDedicatedBearers; ++b)
532 {
534 EpsBearer bearer(q);
535 m_lteHelper->ActivateDataRadioBearer(ueDev, bearer);
536 }
537 }
538 }
539
540 m_lteHelper->AddX2Interface(enbNodes);
541
542 // check initial RRC connection
543 const Time maxRrcConnectionEstablishmentDuration = Seconds(0.080);
544 for (auto it = ueDevices.Begin(); it != ueDevices.End(); ++it)
545 {
546 NS_LOG_FUNCTION(maxRrcConnectionEstablishmentDuration);
547 Simulator::Schedule(maxRrcConnectionEstablishmentDuration,
549 this,
550 *it,
551 enbDevices.Get(0));
552 }
553
554 // schedule the checkpoint events
555
556 Time stopTime = Seconds(0);
557 for (auto checkPointEventIt = m_checkPointEventList.begin();
558 checkPointEventIt != m_checkPointEventList.end();
559 ++checkPointEventIt)
560 {
561 for (Time checkPointTime = checkPointEventIt->checkStartTime;
562 checkPointTime < checkPointEventIt->checkStopTime;
563 checkPointTime += checkPointEventIt->checkInterval)
564 {
565 Simulator::Schedule(checkPointTime,
567 this,
568 ueDevices.Get(checkPointEventIt->ueDeviceIndex),
569 enbDevices.Get(checkPointEventIt->enbDeviceIndex));
570
571 Simulator::Schedule(checkPointTime,
573 this,
574 checkPointEventIt->ueDeviceIndex);
575
576 Time checkStats = checkPointTime + m_statsDuration;
577 Simulator::Schedule(checkStats,
579 this,
580 checkPointEventIt->ueDeviceIndex);
581
582 if (stopTime <= checkStats)
583 {
584 stopTime = checkStats + Seconds(1);
585 }
586 }
587 }
588
592}
593
594void
596{
597 NS_LOG_FUNCTION(ueDevice << enbDevice);
598
599 Ptr<LteUeNetDevice> ueLteDevice = ueDevice->GetObject<LteUeNetDevice>();
600 Ptr<LteUeRrc> ueRrc = ueLteDevice->GetRrc();
601 NS_TEST_ASSERT_MSG_EQ(ueRrc->GetState(), LteUeRrc::CONNECTED_NORMALLY, "Wrong LteUeRrc state!");
602
603 Ptr<LteEnbNetDevice> enbLteDevice = enbDevice->GetObject<LteEnbNetDevice>();
604 Ptr<LteEnbRrc> enbRrc = enbLteDevice->GetRrc();
605 uint16_t rnti = ueRrc->GetRnti();
606 Ptr<UeManager> ueManager = enbRrc->GetUeManager(rnti);
607 NS_TEST_ASSERT_MSG_NE(ueManager, nullptr, "RNTI " << rnti << " not found in eNB");
608
609 UeManager::State ueManagerState = ueManager->GetState();
610 NS_TEST_ASSERT_MSG_EQ(ueManagerState, UeManager::CONNECTED_NORMALLY, "Wrong UeManager state!");
611 NS_ASSERT_MSG(ueManagerState == UeManager::CONNECTED_NORMALLY, "Wrong UeManager state!");
612
613 uint16_t ueCellId = ueRrc->GetCellId();
614 uint16_t enbCellId = enbLteDevice->GetCellId();
615 uint8_t ueDlBandwidth = ueRrc->GetDlBandwidth();
616 uint8_t enbDlBandwidth = enbLteDevice->GetDlBandwidth();
617 uint8_t ueUlBandwidth = ueRrc->GetUlBandwidth();
618 uint8_t enbUlBandwidth = enbLteDevice->GetUlBandwidth();
619 uint8_t ueDlEarfcn = ueRrc->GetDlEarfcn();
620 uint8_t enbDlEarfcn = enbLteDevice->GetDlEarfcn();
621 uint8_t ueUlEarfcn = ueRrc->GetUlEarfcn();
622 uint8_t enbUlEarfcn = enbLteDevice->GetUlEarfcn();
623 uint64_t ueImsi = ueLteDevice->GetImsi();
624 uint64_t enbImsi = ueManager->GetImsi();
625
626 NS_TEST_ASSERT_MSG_EQ(ueImsi, enbImsi, "inconsistent IMSI");
627 NS_TEST_ASSERT_MSG_EQ(ueCellId, enbCellId, "inconsistent CellId");
628 NS_TEST_ASSERT_MSG_EQ(ueDlBandwidth, enbDlBandwidth, "inconsistent DlBandwidth");
629 NS_TEST_ASSERT_MSG_EQ(ueUlBandwidth, enbUlBandwidth, "inconsistent UlBandwidth");
630 NS_TEST_ASSERT_MSG_EQ(ueDlEarfcn, enbDlEarfcn, "inconsistent DlEarfcn");
631 NS_TEST_ASSERT_MSG_EQ(ueUlEarfcn, enbUlEarfcn, "inconsistent UlEarfcn");
632
633 ObjectMapValue enbDataRadioBearerMapValue;
634 ueManager->GetAttribute("DataRadioBearerMap", enbDataRadioBearerMapValue);
635 NS_TEST_ASSERT_MSG_EQ(enbDataRadioBearerMapValue.GetN(),
637 "wrong num bearers at eNB");
638
639 ObjectMapValue ueDataRadioBearerMapValue;
640 ueRrc->GetAttribute("DataRadioBearerMap", ueDataRadioBearerMapValue);
641 NS_TEST_ASSERT_MSG_EQ(ueDataRadioBearerMapValue.GetN(),
643 "wrong num bearers at UE");
644
645 auto enbBearerIt = enbDataRadioBearerMapValue.Begin();
646 auto ueBearerIt = ueDataRadioBearerMapValue.Begin();
647 while (enbBearerIt != enbDataRadioBearerMapValue.End() &&
648 ueBearerIt != ueDataRadioBearerMapValue.End())
649 {
650 Ptr<LteDataRadioBearerInfo> enbDrbInfo =
651 enbBearerIt->second->GetObject<LteDataRadioBearerInfo>();
653 ueBearerIt->second->GetObject<LteDataRadioBearerInfo>();
654 // NS_TEST_ASSERT_MSG_EQ (enbDrbInfo->m_epsBearer, ueDrbInfo->m_epsBearer, "epsBearer
655 // differs");
656 NS_TEST_ASSERT_MSG_EQ((uint32_t)enbDrbInfo->m_epsBearerIdentity,
657 (uint32_t)ueDrbInfo->m_epsBearerIdentity,
658 "epsBearerIdentity differs");
659 NS_TEST_ASSERT_MSG_EQ((uint32_t)enbDrbInfo->m_drbIdentity,
660 (uint32_t)ueDrbInfo->m_drbIdentity,
661 "drbIdentity differs");
662 // NS_TEST_ASSERT_MSG_EQ (enbDrbInfo->m_rlcConfig, ueDrbInfo->m_rlcConfig, "rlcConfig
663 // differs");
664 NS_TEST_ASSERT_MSG_EQ((uint32_t)enbDrbInfo->m_logicalChannelIdentity,
665 (uint32_t)ueDrbInfo->m_logicalChannelIdentity,
666 "logicalChannelIdentity differs");
667 // NS_TEST_ASSERT_MSG_EQ (enbDrbInfo->m_logicalChannelConfig,
668 // ueDrbInfo->m_logicalChannelConfig, "logicalChannelConfig differs");
669
670 ++enbBearerIt;
671 ++ueBearerIt;
672 }
673 NS_ASSERT_MSG(enbBearerIt == enbDataRadioBearerMapValue.End(), "too many bearers at eNB");
674 NS_ASSERT_MSG(ueBearerIt == ueDataRadioBearerMapValue.End(), "too many bearers at UE");
675}
676
677void
679{
680 NS_LOG_FUNCTION(ueIndex);
681 for (auto it = m_ueDataVector.at(ueIndex).bearerDataList.begin();
682 it != m_ueDataVector.at(ueIndex).bearerDataList.end();
683 ++it)
684 {
685 if (it->dlSink)
686 {
687 it->dlOldTotalRx = it->dlSink->GetTotalRx();
688 }
689 if (it->ulSink)
690 {
691 it->ulOldTotalRx = it->ulSink->GetTotalRx();
692 }
693 }
694}
695
696void
698{
699 NS_LOG_FUNCTION(ueIndex);
700 uint32_t b = 1;
701 for (auto it = m_ueDataVector.at(ueIndex).bearerDataList.begin();
702 it != m_ueDataVector.at(ueIndex).bearerDataList.end();
703 ++it)
704 {
705 uint32_t dlRx = 0;
706 uint32_t ulRx = 0;
707
708 if (it->dlSink)
709 {
710 dlRx = it->dlSink->GetTotalRx() - it->dlOldTotalRx;
711 }
712
713 if (it->ulSink)
714 {
715 ulRx = it->ulSink->GetTotalRx() - it->ulOldTotalRx;
716 }
717 double expectedBytes =
719
720 NS_LOG_LOGIC("expBytes " << expectedBytes << " dlRx " << dlRx << " ulRx " << ulRx);
721
722 // tolerance
723 if (it->dlSink)
724 {
726 0.500 * expectedBytes,
727 "too few RX bytes in DL, ue=" << ueIndex << ", b=" << b);
728 }
729 if (it->ulSink)
730 {
732 0.500 * expectedBytes,
733 "too few RX bytes in UL, ue=" << ueIndex << ", b=" << b);
734 }
735 ++b;
736 }
737}
738
745{
746 public:
748};
749
751 : TestSuite("lte-x2-handover-measures", SYSTEM)
752{
753 Time checkInterval = Seconds(1);
754
755 std::string cel1name("ho: 0 -> 1");
756 const std::list<CheckPointEvent> cel1{
757 CheckPointEvent(Seconds(1), Seconds(10.1), checkInterval, 0, 0),
758 CheckPointEvent(Seconds(11), Seconds(17), checkInterval, 0, 1),
759 };
760
761 std::string cel2name("ho: 0 -> 1 -> 2");
762 const std::list<CheckPointEvent> cel2{
763 CheckPointEvent(Seconds(1), Seconds(10.1), checkInterval, 0, 0),
764 CheckPointEvent(Seconds(11), Seconds(17.1), checkInterval, 0, 1),
765 CheckPointEvent(Seconds(18), Seconds(24), checkInterval, 0, 2),
766 };
767
768 std::string cel3name("ho: 0 -> 1 -> 2 -> 3");
769 const std::list<CheckPointEvent> cel3{
770 CheckPointEvent(Seconds(1), Seconds(10.1), checkInterval, 0, 0),
771 CheckPointEvent(Seconds(11), Seconds(17.1), checkInterval, 0, 1),
772 CheckPointEvent(Seconds(18), Seconds(24.1), checkInterval, 0, 2),
773 CheckPointEvent(Seconds(25), Seconds(37), checkInterval, 0, 3),
774 };
775
776 std::string sched = "ns3::PfFfMacScheduler";
777 std::string ho = "ns3::A2A4RsrqHandoverAlgorithm";
778 for (auto useIdealRrc : {true, false})
779 {
780 // nEnbs, nUes, nDBearers, celist, name, useUdp, sched, ho, admitHo, idealRrc
782 1,
783 0,
784 cel1,
785 cel1name,
786 true,
787 sched,
788 ho,
789 true,
790 useIdealRrc),
793 1,
794 1,
795 cel1,
796 cel1name,
797 true,
798 sched,
799 ho,
800 true,
801 useIdealRrc),
804 1,
805 2,
806 cel1,
807 cel1name,
808 true,
809 sched,
810 ho,
811 true,
812 useIdealRrc),
815 1,
816 0,
817 cel2,
818 cel2name,
819 true,
820 sched,
821 ho,
822 true,
823 useIdealRrc),
826 1,
827 1,
828 cel2,
829 cel2name,
830 true,
831 sched,
832 ho,
833 true,
834 useIdealRrc),
837 1,
838 2,
839 cel2,
840 cel2name,
841 true,
842 sched,
843 ho,
844 true,
845 useIdealRrc),
848 1,
849 0,
850 cel3,
851 cel3name,
852 true,
853 sched,
854 ho,
855 true,
856 useIdealRrc),
859 1,
860 1,
861 cel3,
862 cel3name,
863 true,
864 sched,
865 ho,
866 true,
867 useIdealRrc),
870 1,
871 2,
872 cel3,
873 cel3name,
874 true,
875 sched,
876 ho,
877 true,
878 useIdealRrc),
880 }
881
882 sched = "ns3::RrFfMacScheduler";
883 for (auto useIdealRrc : {true, false})
884 {
885 // nEnbs, nUes, nDBearers, celist, name, useUdp, sched, admitHo, idealRrc
887 1,
888 0,
889 cel1,
890 cel1name,
891 true,
892 sched,
893 ho,
894 true,
895 useIdealRrc),
898 1,
899 0,
900 cel2,
901 cel2name,
902 true,
903 sched,
904 ho,
905 true,
906 useIdealRrc),
909 1,
910 0,
911 cel3,
912 cel3name,
913 true,
914 sched,
915 ho,
916 true,
917 useIdealRrc),
919 }
920
921 ho = "ns3::A3RsrpHandoverAlgorithm";
922 sched = "ns3::PfFfMacScheduler";
923 for (auto useIdealRrc : {true, false})
924 {
925 // nEnbs, nUes, nDBearers, celist, name, useUdp, sched, admitHo, idealRrc
927 1,
928 0,
929 cel1,
930 cel1name,
931 true,
932 sched,
933 ho,
934 true,
935 useIdealRrc),
938 1,
939 0,
940 cel2,
941 cel2name,
942 true,
943 sched,
944 ho,
945 true,
946 useIdealRrc),
949 1,
950 0,
951 cel3,
952 cel3name,
953 true,
954 sched,
955 ho,
956 true,
957 useIdealRrc),
959 }
960
961 sched = "ns3::RrFfMacScheduler";
962 for (auto useIdealRrc : {true, false})
963 {
964 // nEnbs, nUes, nDBearers, celist, name, useUdp, sched, admitHo, idealRrc
966 1,
967 0,
968 cel1,
969 cel1name,
970 true,
971 sched,
972 ho,
973 true,
974 useIdealRrc),
977 1,
978 0,
979 cel2,
980 cel2name,
981 true,
982 sched,
983 ho,
984 true,
985 useIdealRrc),
988 1,
989 0,
990 cel3,
991 cel3name,
992 true,
993 sched,
994 ho,
995 true,
996 useIdealRrc),
998 }
999
1000} // end of LteX2HandoverMeasuresTestSuite ()
1001
Test different X2 handover measures and algorithms, e.g.
Ptr< PointToPointEpcHelper > m_epcHelper
EPC helper.
std::list< CheckPointEvent > m_checkPointEventList
check point event list
std::string m_handoverAlgorithmType
handover algorithm type
bool m_admitHo
whether to configure to admit handover
bool m_useUdp
whether to use UDP traffic
const Time m_udpClientInterval
UDP client interval.
void CheckStats(uint32_t ueIndex)
Check stats function.
LteX2HandoverMeasuresTestCase(uint32_t nEnbs, uint32_t nUes, uint32_t nDedicatedBearers, std::list< CheckPointEvent > checkPointEventList, std::string checkPointEventListName, bool useUdp, std::string schedulerType, std::string handoverAlgorithmType, bool admitHo, bool useIdealRrc)
Constructor.
bool m_useIdealRrc
whether to use ideal RRC
uint32_t m_nEnbs
number of eNBs in the test
static std::string BuildNameString(uint32_t nEnbs, uint32_t nUes, uint32_t nDedicatedBearers, std::string checkPointEventListName, bool useUdp, std::string schedulerType, std::string handoverAlgorithmType, bool admitHo, bool useIdealRrc)
Build name string.
std::string m_checkPointEventListName
check point event list name
void DoRun() override
Implementation to actually run this TestCase.
void SaveStats(uint32_t ueIndex)
Save stats function.
uint32_t m_nDedicatedBearers
number of UEs in the test
uint32_t m_nUes
number of UEs in the test
std::vector< UeData > m_ueDataVector
UE data vector.
const uint32_t m_udpClientPktSize
UDP client packet size.
const Time m_maxHoDuration
maximum HO duration
void CheckConnected(Ptr< NetDevice > ueDevice, Ptr< NetDevice > enbDevice)
Check connected function.
Lte X2 Handover Measures 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.
AttributeValue implementation for Boolean.
Definition: boolean.h:37
A helper to make it easier to instantiate an ns3::BulkSendApplication on a set of nodes.
void SetAttribute(std::string name, const AttributeValue &value)
Helper function used to set the underlying application attributes, not the socket attributes.
ApplicationContainer Install(NodeContainer c) const
Install an ns3::BulkSendApplication on each node of the input container configured with all the attri...
Mobility model for which the current speed does not change once it has been set and until it is set a...
Class for representing data rates.
Definition: data-rate.h:89
AttributeValue implementation for DataRate.
This class can be used to hold variables of floating point type such as 'double' or 'float'.
Definition: double.h:42
This class contains the specification of EPS Bearers.
Definition: eps-bearer.h:91
Qci
QoS Class Indicator.
Definition: eps-bearer.h:106
@ NGBR_VIDEO_TCP_DEFAULT
Non-GBR TCP-based Video (Buffered Streaming, e.g., www, e-mail...)
Definition: eps-bearer.h:126
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.
Definition: ipv4-address.h:42
static Ipv4Address GetAny()
Access to the IPv4 forwarding table, interfaces, and configuration.
Definition: ipv4.h:79
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
Definition: ipv4-address.h:257
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.
void SetEpcHelper(Ptr< EpcHelper > h)
Set the EpcHelper to be used to setup the EPC network in conjunction with the setup of the LTE radio ...
Definition: lte-helper.cc:285
void SetHandoverAlgorithmAttribute(std::string n, const AttributeValue &v)
Set an attribute for the handover algorithm to be created.
Definition: lte-helper.cc:348
NetDeviceContainer InstallEnbDevice(NodeContainer c)
Create a set of eNodeB devices.
Definition: lte-helper.cc:485
void SetHandoverAlgorithmType(std::string type)
Set the type of handover algorithm to be used by eNodeB devices.
Definition: lte-helper.cc:340
void SetSchedulerType(std::string type)
Set the type of scheduler to be used by eNodeB devices.
Definition: lte-helper.cc:292
void Attach(NetDeviceContainer ueDevices)
Enables automatic attachment of a set of UE devices to a suitable cell using Idle mode initial cell s...
Definition: lte-helper.cc:1039
void ActivateDataRadioBearer(NetDeviceContainer ueDevices, EpsBearer bearer)
Activate a Data Radio Bearer on a given UE devices (for LTE-only simulation).
Definition: lte-helper.cc:1436
NetDeviceContainer InstallUeDevice(NodeContainer c)
Create a set of UE devices.
Definition: lte-helper.cc:500
void AddX2Interface(NodeContainer enbNodes)
Create an X2 interface between all the eNBs in a given set.
Definition: lte-helper.cc:1313
int64_t AssignStreams(NetDeviceContainer c, int64_t stream)
Assign a fixed random variable stream number to the random variables used.
Definition: lte-helper.cc:1567
uint8_t ActivateDedicatedEpsBearer(NetDeviceContainer ueDevices, EpsBearer bearer, Ptr< EpcTft > tft)
Activate a dedicated EPS bearer on a given set of UE devices.
Definition: lte-helper.cc:1154
The LteUeNetDevice class implements the UE net device.
Helper class used to assign positions and mobility models to nodes.
void Install(Ptr< Node > node) const
"Layout" a single node according to the current position allocator type.
void SetMobilityModel(std::string type, Ts &&... args)
void SetPositionAllocator(Ptr< PositionAllocator > allocator)
Set the position allocator which will be used to allocate the initial position of every node initiali...
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.
Ptr< Node > GetPgwNode() const override
Get the PGW node.
Ipv4Address GetUeDefaultGatewayAddress() override
Ipv4InterfaceContainer AssignUeIpv4Address(NetDeviceContainer ueDevices) override
Assign IPv4 addresses to UE devices.
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.
void SetAttribute(std::string name, const AttributeValue &value)
Set a single attribute, raising fatal errors if unsuccessful.
Definition: object-base.cc:204
Ptr< T > GetObject() const
Get a pointer to the requested aggregated Object.
Definition: object.h:471
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.
ApplicationContainer Install(NodeContainer c) const
Install an ns3::PacketSinkApplication on each node of the input container configured with all the att...
Receive and consume traffic generated to an IP address and port.
Definition: packet-sink.h:75
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:78
static EventId Schedule(const Time &delay, FUNC f, Ts &&... args)
Schedule an event to expire after delay.
Definition: simulator.h:558
static void Destroy()
Execute the events scheduled with ScheduleDestroy().
Definition: simulator.cc:140
static void Run()
Run the simulation.
Definition: simulator.cc:176
static void Stop()
Tell the Simulator the calling event should be the last one executed.
Definition: simulator.cc:184
Hold variables of type string.
Definition: string.h:56
encapsulates test code
Definition: test.h:1060
@ EXTENSIVE
Medium length test.
Definition: test.h:1066
@ TAKES_FOREVER
Very long running test.
Definition: test.h:1067
@ QUICK
Fast test.
Definition: test.h:1065
void AddTestCase(TestCase *testCase, TestDuration duration=QUICK)
Add an individual child TestCase to this test suite.
Definition: test.cc:301
A suite of tests to run.
Definition: test.h:1256
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:105
AttributeValue implementation for Time.
Definition: nstime.h:1412
Create a client application which sends UDP packets carrying a 32bit sequence number and a 64 bit tim...
ApplicationContainer Install(NodeContainer c)
State
The state of the UeManager at the eNB RRC.
Definition: lte-enb-rrc.h:77
Hold an unsigned integer type.
Definition: uinteger.h:45
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:86
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:855
void SetDefault(std::string name, const AttributeValue &value)
Definition: config.cc:890
#define NS_FATAL_ERROR(msg)
Report a fatal error with a message and terminate.
Definition: fatal-error.h:179
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:202
#define NS_LOG_LOGIC(msg)
Use NS_LOG to output a message of level LOG_LOGIC.
Definition: log.h:282
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
static LteX2HandoverMeasuresTestSuite g_lteX2HandoverMeasuresTestSuiteInstance
Static variable for test initialization.
#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:144
#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:564
#define NS_TEST_ASSERT_MSG_GT(actual, limit, msg)
Test that an actual value is greater than a limit and report and abort if not.
Definition: test.h:874
Time Seconds(double value)
Construct a Time in the indicated unit.
Definition: nstime.h:1325
Time MilliSeconds(uint64_t value)
Construct a Time in the indicated unit.
Definition: nstime.h:1337
Every class exported by the ns3 library is enclosed in the ns3 namespace.
CheckPointEvent structure.
CheckPointEvent(Time start, Time stop, Time interval, uint32_t ueIndex, uint32_t enbIndex)
Constructor.
Time checkStopTime
check stop time
uint32_t enbDeviceIndex
ENB device index.
Time checkStartTime
check start time
Time checkInterval
check interval
uint32_t ueDeviceIndex
UE device index.
std::list< BearerData > bearerDataList
bearer ID list
Implement the data structure representing a TrafficFlowTemplate Packet Filter.
Definition: epc-tft.h:71
uint16_t localPortEnd
end of the port number range of the UE
Definition: epc-tft.h:132
uint16_t remotePortEnd
end of the port number range of the remote host
Definition: epc-tft.h:130
uint16_t remotePortStart
start of the port number range of the remote host
Definition: epc-tft.h:129
uint16_t localPortStart
start of the port number range of the UE
Definition: epc-tft.h:131