33#include "ns3/antenna-module.h"
34#include "ns3/applications-module.h"
35#include "ns3/bandwidth-part-gnb.h"
36#include "ns3/config-store-module.h"
37#include "ns3/config-store.h"
38#include "ns3/core-module.h"
39#include "ns3/flow-monitor-module.h"
40#include "ns3/internet-apps-module.h"
41#include "ns3/internet-module.h"
42#include "ns3/ipv4-global-routing-helper.h"
44#include "ns3/mobility-module.h"
45#include "ns3/nr-helper.h"
46#include "ns3/nr-module.h"
47#include "ns3/nr-point-to-point-epc-helper.h"
48#include "ns3/point-to-point-helper.h"
52NS_LOG_COMPONENT_DEFINE(
"3gppChannelFdmNrComponentCarriersExample");
55main(
int argc,
char* argv[])
58 uint16_t ueNumPergNb = 1;
61 double centralFrequencyBand40 = 2350e6;
62 double bandwidthBand40 = 50e6;
63 double centralFrequencyBand38 = 2595e6;
64 double bandwidthBand38 = 100e6;
66 double bandwidth = 20e6;
68 uint16_t numerologyBwp0 = 0;
69 uint16_t numerologyBwp1 = 0;
70 uint16_t numerologyBwp2 = 0;
71 uint16_t numerologyBwpDl = 0;
72 uint16_t numerologyBwpUl = 0;
74 double totalTxPower = 13;
76 "DL|S|UL|UL|DL|DL|S|UL|UL|DL|";
77 std::string patternDL =
"DL|DL|DL|DL|DL|DL|DL|DL|DL|DL|";
78 std::string patternUL =
"UL|UL|UL|UL|UL|UL|UL|UL|UL|UL|";
79 std::string operationMode =
"TDD";
81 bool cellScan =
false;
82 double beamSearchAngleStep = 10.0;
84 uint32_t udpPacketSizeUll = 915;
85 uint32_t udpPacketSizeBe = 915;
86 uint32_t lambdaUll = 10000;
87 uint32_t lambdaBe = 10000;
89 bool enableLowLat =
true;
90 bool enableVideo =
true;
91 bool enableVoice =
true;
92 bool enableGaming =
false;
96 std::string simTag =
"default";
97 std::string outputDir =
"./";
100 double udpAppStartTime = 0.4;
102 CommandLine cmd(__FILE__);
104 cmd.AddValue(
"simTime",
"Simulation time", simTime);
105 cmd.AddValue(
"gNbNum",
"The number of gNbs in multiple-ue topology", gNbNum);
106 cmd.AddValue(
"ueNumPergNb",
"The number of UE per gNb in multiple-ue topology", ueNumPergNb);
107 cmd.AddValue(
"numBands",
108 "Number of operation bands. More than one implies non-contiguous CC",
110 cmd.AddValue(
"bandwidthBand40",
"The system bandwidth to be used in band 1", bandwidthBand40);
111 cmd.AddValue(
"bandwidthBand38",
"The system bandwidth to be used in band 2", bandwidthBand38);
112 cmd.AddValue(
"bandwidth",
"The bandwidth of the CCs ", bandwidth);
113 cmd.AddValue(
"numerologyBwp0",
"The numerology to be used in bandwidth part 1", numerologyBwp0);
114 cmd.AddValue(
"numerologyBwp1",
"The numerology to be used in bandwidth part 1", numerologyBwp1);
115 cmd.AddValue(
"numerologyBwp2",
"The numerology to be used in bandwidth part 2", numerologyBwp2);
116 cmd.AddValue(
"numerologyBwpDl",
117 "The numerology to be used in bandwidth part 2",
119 cmd.AddValue(
"numerologyBwpUl",
120 "The numerology to be used in bandwidth part 2",
122 cmd.AddValue(
"totalTxPower",
123 "total tx power that will be proportionally assigned to"
124 " bandwidth parts depending on each BWP bandwidth ",
126 cmd.AddValue(
"tddPattern",
127 "LTE TDD pattern to use (e.g. --tddPattern=DL|S|UL|UL|UL|DL|S|UL|UL|UL|)",
129 cmd.AddValue(
"operationMode",
130 "The network operation mode can be TDD or FDD (In this case it"
131 "will be mixed TDD and FDD)",
133 cmd.AddValue(
"cellScan",
134 "Use beam search method to determine beamforming vector,"
135 "true to use cell scanning method",
137 cmd.AddValue(
"beamSearchAngleStep",
138 "Beam search angle step for beam search method",
139 beamSearchAngleStep);
140 cmd.AddValue(
"packetSizeUll",
141 "packet size in bytes to be used by ultra low latency traffic",
143 cmd.AddValue(
"packetSizeBe",
144 "packet size in bytes to be used by best effort traffic",
146 cmd.AddValue(
"lambdaUll",
147 "Number of UDP packets in one second for ultra low latency traffic",
149 cmd.AddValue(
"lambdaBe",
150 "Number of UDP packets in one second for best effort traffic",
152 cmd.AddValue(
"enableLowLat",
153 "If true, enables low latency traffic transmission (DL)",
155 cmd.AddValue(
"enableVideo",
"If true, enables video traffic transmission (DL)", enableVideo);
156 cmd.AddValue(
"enableVoice",
"If true, enables voice traffic transmission (UL)", enableVoice);
157 cmd.AddValue(
"enableGaming",
"If true, enables gaming traffic transmission (UL)", enableGaming);
158 cmd.AddValue(
"logging",
"Enable logging", logging);
159 cmd.AddValue(
"simTag",
160 "tag to be appended to output filenames to distinguish simulation campaigns",
162 cmd.AddValue(
"outputDir",
"directory where to store simulation results", outputDir);
164 cmd.Parse(argc, argv);
166 NS_ABORT_IF(numBands < 1);
167 NS_ABORT_MSG_IF(enableLowLat ==
false && enableVideo ==
false && enableVoice ==
false &&
168 enableGaming ==
false && operationMode ==
"TDD",
169 "For TDD enable one of the flows");
185 LogComponentEnable(
"NrGnbPhy", LOG_LEVEL_INFO);
186 LogComponentEnable(
"NrUePhy", LOG_LEVEL_INFO);
192 NodeContainer gNbNodes;
193 NodeContainer ueNodes;
194 MobilityHelper mobility;
196 double gNbHeight = 10;
197 double ueHeight = 1.5;
199 gNbNodes.Create(gNbNum);
200 ueNodes.Create(ueNumPergNb * gNbNum);
202 Ptr<ListPositionAllocator> apPositionAlloc = CreateObject<ListPositionAllocator>();
203 Ptr<ListPositionAllocator> staPositionAlloc = CreateObject<ListPositionAllocator>();
204 int32_t yValue = 0.0;
206 for (uint32_t i = 1; i <= gNbNodes.GetN(); ++i)
211 yValue =
static_cast<int>(i) * 30;
218 apPositionAlloc->Add(Vector(0.0, yValue, gNbHeight));
222 for (uint32_t j = 1; j <= ueNumPergNb; ++j)
235 staPositionAlloc->Add(Vector(xValue, 10, ueHeight));
239 staPositionAlloc->Add(Vector(xValue, -10, ueHeight));
244 mobility.SetMobilityModel(
"ns3::ConstantPositionMobilityModel");
245 mobility.SetPositionAllocator(apPositionAlloc);
246 mobility.Install(gNbNodes);
248 mobility.SetPositionAllocator(staPositionAlloc);
249 mobility.Install(ueNodes);
251 Ptr<NrPointToPointEpcHelper> nrEpcHelper = CreateObject<NrPointToPointEpcHelper>();
252 Ptr<IdealBeamformingHelper> idealBeamformingHelper = CreateObject<IdealBeamformingHelper>();
253 Ptr<NrHelper> nrHelper = CreateObject<NrHelper>();
254 nrHelper->SetBeamformingHelper(idealBeamformingHelper);
255 nrHelper->SetEpcHelper(nrEpcHelper);
256 nrEpcHelper->SetAttribute(
"S1uLinkDelay", TimeValue(MilliSeconds(0)));
259 idealBeamformingHelper->SetAttribute(
"BeamformingMethod",
261 idealBeamformingHelper->SetBeamformingAlgorithmAttribute(
"BeamSearchAngleStep",
262 DoubleValue(beamSearchAngleStep));
266 idealBeamformingHelper->SetAttribute(
270 Config::SetDefault(
"ns3::NrRlcUm::MaxTxBufferSize", UintegerValue(999999999));
272 std::string errorModel =
"ns3::NrLteMiErrorModel";
274 nrHelper->SetSchedulerAttribute(
"FixedMcsDl", BooleanValue(
false));
275 nrHelper->SetSchedulerAttribute(
"FixedMcsUl", BooleanValue(
false));
278 nrHelper->SetUlErrorModel(errorModel);
279 nrHelper->SetDlErrorModel(errorModel);
282 nrHelper->SetGnbDlAmcAttribute(
285 nrHelper->SetGnbUlAmcAttribute(
293 nrHelper->SetGnbDlAmcAttribute(
"NumRefScPerRb", UintegerValue(2));
294 nrHelper->SetGnbUlAmcAttribute(
"NumRefScPerRb", UintegerValue(2));
295 nrHelper->SetGnbMacAttribute(
"NumRbPerRbg", UintegerValue(4));
296 nrHelper->SetSchedulerAttribute(
"DlCtrlSymbols", UintegerValue(1));
297 nrHelper->SetSchedulerTypeId(TypeId::LookupByName(
"ns3::NrMacSchedulerOfdmaPF"));
347 cc0->m_channelBandwidth = bandwidth;
348 cc0->m_lowerFrequency = cc0->m_centralFrequency - cc0->m_channelBandwidth / 2;
349 cc0->m_higherFrequency = cc0->m_centralFrequency + cc0->m_channelBandwidth / 2;
354 bwp0->m_centralFrequency = cc0->m_centralFrequency;
355 bwp0->m_channelBandwidth = cc0->m_channelBandwidth;
356 bwp0->m_lowerFrequency = cc0->m_lowerFrequency;
357 bwp0->m_higherFrequency = cc0->m_higherFrequency;
359 cc0->AddBwp(std::move(bwp0));
361 band40.
AddCc(std::move(cc0));
375 cc1->m_channelBandwidth = bandwidth;
376 cc1->m_lowerFrequency = cc1->m_centralFrequency - cc1->m_channelBandwidth / 2;
377 cc1->m_higherFrequency = cc1->m_centralFrequency + cc1->m_channelBandwidth / 2;
382 bwp1->m_centralFrequency = cc1->m_centralFrequency;
383 bwp1->m_channelBandwidth = cc1->m_channelBandwidth;
384 bwp1->m_lowerFrequency = cc1->m_lowerFrequency;
385 bwp1->m_higherFrequency = cc1->m_higherFrequency;
387 cc1->AddBwp(std::move(bwp1));
397 cc2->m_channelBandwidth = bandwidth;
398 cc2->m_lowerFrequency = cc2->m_centralFrequency - cc2->m_channelBandwidth / 2;
399 cc2->m_higherFrequency = cc2->m_centralFrequency + cc2->m_channelBandwidth / 2;
401 if (operationMode ==
"TDD")
404 bwp2->m_centralFrequency = cc2->m_centralFrequency;
405 bwp2->m_channelBandwidth = cc2->m_channelBandwidth;
406 bwp2->m_lowerFrequency = cc2->m_lowerFrequency;
407 bwp2->m_higherFrequency = cc2->m_higherFrequency;
409 cc2->AddBwp(std::move(bwp2));
415 bwpdl->m_channelBandwidth = cc2->m_channelBandwidth / 2;
416 bwpdl->m_lowerFrequency = cc2->m_lowerFrequency;
417 bwpdl->m_higherFrequency = bwpdl->m_lowerFrequency + bwpdl->m_channelBandwidth;
418 bwpdl->m_centralFrequency = bwpdl->m_lowerFrequency + bwpdl->m_channelBandwidth / 2;
420 cc2->AddBwp(std::move(bwpdl));
424 bwpul->m_channelBandwidth = cc2->m_channelBandwidth / 2;
425 bwpul->m_lowerFrequency = cc2->m_centralFrequency;
426 bwpul->m_higherFrequency = cc2->m_higherFrequency;
427 bwpul->m_centralFrequency = bwpul->m_lowerFrequency + bwpul->m_channelBandwidth / 2;
429 cc2->AddBwp(std::move(bwpul));
430 Config::SetDefault(
"ns3::NrUeNetDevice::PrimaryUlIndex", UintegerValue(1));
433 band38.
AddCc(std::move(cc1));
434 band38.
AddCc(std::move(cc2));
435 Ptr<NrChannelHelper> channelHelper = CreateObject<NrChannelHelper>();
437 channelHelper->ConfigureFactories(
"RMa",
"Default",
"ThreeGpp");
438 channelHelper->SetPathlossAttribute(
"ShadowingEnabled", BooleanValue(
false));
439 channelHelper->AssignChannelsToBands({band40, band38});
443 nrHelper->SetUeAntennaAttribute(
"NumRows", UintegerValue(1));
444 nrHelper->SetUeAntennaAttribute(
"NumColumns", UintegerValue(1));
445 nrHelper->SetUeAntennaAttribute(
"AntennaElement",
446 PointerValue(CreateObject<IsotropicAntennaModel>()));
449 nrHelper->SetGnbAntennaAttribute(
"NumRows", UintegerValue(2));
450 nrHelper->SetGnbAntennaAttribute(
"NumColumns", UintegerValue(2));
451 nrHelper->SetGnbAntennaAttribute(
"AntennaElement",
452 PointerValue(CreateObject<IsotropicAntennaModel>()));
455 uint32_t bwpIdForLowLat = 0;
456 uint32_t bwpIdForVoice = 1;
457 uint32_t bwpIdForVideo = 2;
458 uint32_t bwpIdForVideoGaming = 3;
460 nrHelper->SetGnbBwpManagerAlgorithmAttribute(
"NGBR_LOW_LAT_EMBB",
461 UintegerValue(bwpIdForLowLat));
462 nrHelper->SetGnbBwpManagerAlgorithmAttribute(
"GBR_CONV_VOICE", UintegerValue(bwpIdForVoice));
463 nrHelper->SetGnbBwpManagerAlgorithmAttribute(
"NGBR_VIDEO_TCP_PREMIUM",
464 UintegerValue(bwpIdForVideo));
465 nrHelper->SetGnbBwpManagerAlgorithmAttribute(
"NGBR_VOICE_VIDEO_GAMING",
466 UintegerValue(bwpIdForVideoGaming));
468 nrHelper->SetUeBwpManagerAlgorithmAttribute(
"NGBR_LOW_LAT_EMBB", UintegerValue(bwpIdForLowLat));
469 nrHelper->SetUeBwpManagerAlgorithmAttribute(
"GBR_CONV_VOICE", UintegerValue(bwpIdForVoice));
470 nrHelper->SetUeBwpManagerAlgorithmAttribute(
"NGBR_VIDEO_TCP_PREMIUM",
471 UintegerValue(bwpIdForVideo));
472 nrHelper->SetUeBwpManagerAlgorithmAttribute(
"NGBR_VOICE_VIDEO_GAMING",
473 UintegerValue(bwpIdForVideoGaming));
476 NetDeviceContainer gnbNetDev = nrHelper->InstallGnbDevice(gNbNodes, allBwps);
477 NetDeviceContainer ueNetDev = nrHelper->InstallUeDevice(ueNodes, allBwps);
479 int64_t randomStream = 1;
480 randomStream += nrHelper->AssignStreams(gnbNetDev, randomStream);
481 randomStream += nrHelper->AssignStreams(ueNetDev, randomStream);
484 double x = pow(10, totalTxPower / 10);
485 double totalBandwidth = numCcs * bandwidth;
488 nrHelper->GetGnbPhy(gnbNetDev.Get(0), 0)
489 ->SetAttribute(
"Numerology", UintegerValue(numerologyBwp0));
490 nrHelper->GetGnbPhy(gnbNetDev.Get(0), 0)
494 log10((band40.
GetBwpAt(0, 0)->m_channelBandwidth / totalBandwidth) * x)));
495 nrHelper->GetGnbPhy(gnbNetDev.Get(0), 0)->SetAttribute(
"Pattern", StringValue(pattern));
496 nrHelper->GetGnbPhy(gnbNetDev.Get(0), 0)->SetAttribute(
"RbOverhead", DoubleValue(0.1));
498 nrHelper->GetGnbPhy(gnbNetDev.Get(0), 1)
499 ->SetAttribute(
"Numerology", UintegerValue(numerologyBwp1));
500 nrHelper->GetGnbPhy(gnbNetDev.Get(0), 1)
504 log10((band38.
GetBwpAt(0, 0)->m_channelBandwidth / totalBandwidth) * x)));
505 nrHelper->GetGnbPhy(gnbNetDev.Get(0), 1)->SetAttribute(
"Pattern", StringValue(pattern));
506 nrHelper->GetGnbPhy(gnbNetDev.Get(0), 1)->SetAttribute(
"RbOverhead", DoubleValue(0.1));
509 if (operationMode ==
"TDD")
511 nrHelper->GetGnbPhy(gnbNetDev.Get(0), 2)
512 ->SetAttribute(
"Numerology", UintegerValue(numerologyBwp2));
513 nrHelper->GetGnbPhy(gnbNetDev.Get(0), 2)
517 10 * log10((band38.
GetBwpAt(1, 0)->m_channelBandwidth / totalBandwidth) * x)));
518 nrHelper->GetGnbPhy(gnbNetDev.Get(0), 2)->SetAttribute(
"Pattern", StringValue(pattern));
519 nrHelper->GetGnbPhy(gnbNetDev.Get(0), 2)->SetAttribute(
"RbOverhead", DoubleValue(0.1));
523 nrHelper->GetGnbPhy(gnbNetDev.Get(0), 2)
524 ->SetAttribute(
"Numerology", UintegerValue(numerologyBwpDl));
525 nrHelper->GetGnbPhy(gnbNetDev.Get(0), 2)
529 10 * log10((band38.
GetBwpAt(1, 0)->m_channelBandwidth / totalBandwidth) * x)));
530 nrHelper->GetGnbPhy(gnbNetDev.Get(0), 2)->SetAttribute(
"Pattern", StringValue(patternDL));
531 nrHelper->GetGnbPhy(gnbNetDev.Get(0), 2)->SetAttribute(
"RbOverhead", DoubleValue(0.1));
533 nrHelper->GetGnbPhy(gnbNetDev.Get(0), 3)
534 ->SetAttribute(
"Numerology", UintegerValue(numerologyBwpUl));
535 nrHelper->GetGnbPhy(gnbNetDev.Get(0), 3)->SetAttribute(
"Pattern", StringValue(patternUL));
536 nrHelper->GetGnbPhy(gnbNetDev.Get(0), 3)->SetAttribute(
"RbOverhead", DoubleValue(0.1));
539 nrHelper->GetBwpManagerGnb(gnbNetDev.Get(0))->SetOutputLink(3, 2);
542 for (uint32_t i = 0; i < ueNetDev.GetN(); i++)
544 nrHelper->GetBwpManagerUe(ueNetDev.Get(i))->SetOutputLink(2, 3);
553 auto [remoteHost, remoteHostIpv4Address] =
554 nrEpcHelper->SetupRemoteHost(
"100Gb/s", 2500, Seconds(0.000));
556 InternetStackHelper internet;
558 internet.Install(ueNodes);
559 Ipv4InterfaceContainer ueIpIface;
560 ueIpIface = nrEpcHelper->AssignUeIpv4Address(NetDeviceContainer(ueNetDev));
563 nrHelper->AttachToClosestGnb(ueNetDev, gnbNetDev);
566 uint16_t dlPortLowLat = 1234;
567 uint16_t ulPortVoice = 1235;
568 uint16_t dlPortVideo = 1236;
569 uint16_t ulPortGaming = 1237;
571 ApplicationContainer serverApps;
574 UdpServerHelper dlPacketSinkLowLat(dlPortLowLat);
575 UdpServerHelper ulPacketSinkVoice(ulPortVoice);
576 UdpServerHelper dlPacketSinkVideo(dlPortVideo);
577 UdpServerHelper ulPacketSinkGaming(ulPortGaming);
581 serverApps.Add(dlPacketSinkLowLat.Install(ueNodes));
582 serverApps.Add(ulPacketSinkVoice.Install(remoteHost));
583 serverApps.Add(dlPacketSinkVideo.Install(ueNodes));
584 serverApps.Add(ulPacketSinkGaming.Install(remoteHost));
592 UdpClientHelper dlClientLowLat;
593 dlClientLowLat.SetAttribute(
"RemotePort", UintegerValue(dlPortLowLat));
594 dlClientLowLat.SetAttribute(
"MaxPackets", UintegerValue(0xFFFFFFFF));
595 dlClientLowLat.SetAttribute(
"PacketSize", UintegerValue(udpPacketSizeBe));
596 dlClientLowLat.SetAttribute(
"Interval", TimeValue(Seconds(1.0 / lambdaBe)));
602 Ptr<NrEpcTft> lowLatTft = Create<NrEpcTft>();
606 lowLatTft->Add(dlpfLowLat);
609 UdpClientHelper ulClientVoice;
610 ulClientVoice.SetAttribute(
"RemotePort", UintegerValue(ulPortVoice));
611 ulClientVoice.SetAttribute(
"MaxPackets", UintegerValue(0xFFFFFFFF));
612 ulClientVoice.SetAttribute(
"PacketSize", UintegerValue(udpPacketSizeBe));
613 ulClientVoice.SetAttribute(
"Interval", TimeValue(Seconds(1.0 / lambdaBe)));
619 Ptr<NrEpcTft> voiceTft = Create<NrEpcTft>();
624 voiceTft->Add(ulpfVoice);
627 UdpClientHelper dlClientVideo;
628 dlClientVideo.SetAttribute(
"RemotePort", UintegerValue(dlPortVideo));
629 dlClientVideo.SetAttribute(
"MaxPackets", UintegerValue(0xFFFFFFFF));
630 dlClientVideo.SetAttribute(
"PacketSize", UintegerValue(udpPacketSizeUll));
631 dlClientVideo.SetAttribute(
"Interval", TimeValue(Seconds(1.0 / lambdaUll)));
637 Ptr<NrEpcTft> videoTft = Create<NrEpcTft>();
641 videoTft->Add(dlpfVideo);
644 UdpClientHelper ulClientGaming;
645 ulClientGaming.SetAttribute(
"RemotePort", UintegerValue(ulPortGaming));
646 ulClientGaming.SetAttribute(
"MaxPackets", UintegerValue(0xFFFFFFFF));
647 ulClientGaming.SetAttribute(
"PacketSize", UintegerValue(udpPacketSizeUll));
648 ulClientGaming.SetAttribute(
"Interval", TimeValue(Seconds(1.0 / lambdaUll)));
654 Ptr<NrEpcTft> gamingTft = Create<NrEpcTft>();
659 gamingTft->Add(ulpfGaming);
662 ApplicationContainer clientApps;
664 for (uint32_t i = 0; i < ueNodes.GetN(); ++i)
666 Ptr<Node> ue = ueNodes.Get(i);
667 Ptr<NetDevice> ueDevice = ueNetDev.Get(i);
668 Address ueAddress = ueIpIface.GetAddress(i);
674 dlClientLowLat.SetAttribute(
"RemoteAddress", AddressValue(ueAddress));
675 clientApps.Add(dlClientLowLat.Install(remoteHost));
677 nrHelper->ActivateDedicatedEpsBearer(ueDevice, lowLatBearer, lowLatTft);
681 dlClientVideo.SetAttribute(
"RemoteAddress", AddressValue(ueAddress));
682 clientApps.Add(dlClientVideo.Install(remoteHost));
684 nrHelper->ActivateDedicatedEpsBearer(ueDevice, videoBearer, videoTft);
692 ulClientVoice.SetAttribute(
"RemoteAddress", AddressValue(remoteHostIpv4Address));
693 clientApps.Add(ulClientVoice.Install(ue));
695 nrHelper->ActivateDedicatedEpsBearer(ueDevice, voiceBearer, voiceTft);
700 ulClientGaming.SetAttribute(
"RemoteAddress", AddressValue(remoteHostIpv4Address));
701 clientApps.Add(ulClientGaming.Install(ue));
703 nrHelper->ActivateDedicatedEpsBearer(ueDevice, gamingBearer, gamingTft);
708 serverApps.Start(Seconds(udpAppStartTime));
709 clientApps.Start(Seconds(udpAppStartTime));
710 serverApps.Stop(Seconds(simTime));
711 clientApps.Stop(Seconds(simTime));
714 nrHelper->EnableTraces();
716 FlowMonitorHelper flowmonHelper;
717 NodeContainer endpointNodes;
718 endpointNodes.Add(remoteHost);
719 endpointNodes.Add(ueNodes);
721 Ptr<ns3::FlowMonitor> monitor = flowmonHelper.Install(endpointNodes);
722 monitor->SetAttribute(
"DelayBinWidth", DoubleValue(0.001));
723 monitor->SetAttribute(
"JitterBinWidth", DoubleValue(0.001));
724 monitor->SetAttribute(
"PacketSizeBinWidth", DoubleValue(20));
726 Simulator::Stop(Seconds(simTime));
737 monitor->CheckForLostPackets();
738 Ptr<Ipv4FlowClassifier> classifier =
739 DynamicCast<Ipv4FlowClassifier>(flowmonHelper.GetClassifier());
740 FlowMonitor::FlowStatsContainer stats = monitor->GetFlowStats();
742 double averageFlowThroughput = 0.0;
743 double averageFlowDelay = 0.0;
745 std::ofstream outFile;
746 std::string filename = outputDir +
"/" + simTag;
747 outFile.open(filename.c_str(), std::ofstream::out | std::ofstream::trunc);
748 if (!outFile.is_open())
750 std::cerr <<
"Can't open file " << filename << std::endl;
754 outFile.setf(std::ios_base::fixed);
756 for (std::map<FlowId, FlowMonitor::FlowStats>::const_iterator i = stats.begin();
760 Ipv4FlowClassifier::FiveTuple t = classifier->FindFlow(i->first);
761 std::stringstream protoStream;
762 protoStream << (uint16_t)t.protocol;
765 protoStream.str(
"TCP");
767 if (t.protocol == 17)
769 protoStream.str(
"UDP");
771 outFile <<
"Flow " << i->first <<
" (" << t.sourceAddress <<
":" << t.sourcePort <<
" -> "
772 << t.destinationAddress <<
":" << t.destinationPort <<
") proto "
773 << protoStream.str() <<
"\n";
774 outFile <<
" Tx Packets: " << i->second.txPackets <<
"\n";
775 outFile <<
" Tx Bytes: " << i->second.txBytes <<
"\n";
776 outFile <<
" TxOffered: "
777 << i->second.txBytes * 8.0 / (simTime - udpAppStartTime) / 1000 / 1000 <<
" Mbps\n";
778 outFile <<
" Rx Bytes: " << i->second.rxBytes <<
"\n";
779 if (i->second.rxPackets > 0)
784 double rxDuration = (simTime - udpAppStartTime);
786 averageFlowThroughput += i->second.rxBytes * 8.0 / rxDuration / 1000 / 1000;
787 averageFlowDelay += 1000 * i->second.delaySum.GetSeconds() / i->second.rxPackets;
789 outFile <<
" Throughput: " << i->second.rxBytes * 8.0 / rxDuration / 1000 / 1000
791 outFile <<
" Mean delay: "
792 << 1000 * i->second.delaySum.GetSeconds() / i->second.rxPackets <<
" ms\n";
795 outFile <<
" Mean jitter: "
796 << 1000 * i->second.jitterSum.GetSeconds() / i->second.rxPackets <<
" ms\n";
800 outFile <<
" Throughput: 0 Mbps\n";
801 outFile <<
" Mean delay: 0 ms\n";
802 outFile <<
" Mean jitter: 0 ms\n";
804 outFile <<
" Rx Packets: " << i->second.rxPackets <<
"\n";
807 outFile <<
"\n\n Aggregated throughput: " << averageFlowThroughput <<
"\n";
808 outFile <<
" Mean flow throughput: " << averageFlowThroughput / stats.size() <<
"\n";
809 outFile <<
" Mean flow delay: " << averageFlowDelay / stats.size() <<
"\n";
813 std::ifstream f(filename.c_str());
817 std::cout << f.rdbuf();
820 Simulator::Destroy();
static BandwidthPartInfoPtrVector GetAllBwps(const std::vector< std::reference_wrapper< OperationBandInfo > > &operationBands)
Get all the BWP pointers from the specified vector of operation bands.
@ ErrorModel
Error Model version (can use different error models, see NrErrorModel)
This class contains the specification of EPS Bearers.
@ NGBR_LOW_LAT_EMBB
Non-GBR Low Latency eMBB applications.
@ GBR_CONV_VOICE
GBR Conversational Voice.
@ NGBR_VOICE_VIDEO_GAMING
Non-GBR Voice, Video, Interactive Streaming.
@ NGBR_VIDEO_TCP_PREMIUM
Non-GBR TCP-based Video (Buffered Streaming, e.g., www, e-mail...)
std::vector< std::reference_wrapper< BandwidthPartInfoPtr > > BandwidthPartInfoPtrVector
vector of unique_ptr of BandwidthPartInfo
Component carrier configuration element.
Direction direction
Whether the filter needs to be applied to uplink / downlink only, or in both cases.
uint16_t remotePortEnd
end of the port number range of the remote host
uint16_t localPortStart
start of the port number range of the UE
uint16_t remotePortStart
start of the port number range of the remote host
uint16_t localPortEnd
end of the port number range of the UE
Operation band information structure.
double m_channelBandwidth
Operation band bandwidth.
BandwidthPartInfoPtr & GetBwpAt(uint32_t ccId, uint32_t bwpId) const
Get the BWP at the cc/bwp specified.
bool AddCc(ComponentCarrierInfoPtr &&cc)
Adds the component carrier definition given as an input reference to the current operation band confi...
double m_lowerFrequency
Operation band lower frequency.
double m_centralFrequency
Operation band central frequency.
double m_higherFrequency
Operation band higher frequency.