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;
83 uint32_t udpPacketSizeUll = 915;
84 uint32_t udpPacketSizeBe = 915;
85 uint32_t lambdaUll = 10000;
86 uint32_t lambdaBe = 10000;
88 bool enableLowLat =
true;
89 bool enableVideo =
true;
90 bool enableVoice =
true;
91 bool enableGaming =
false;
95 std::string simTag =
"default";
96 std::string outputDir =
"./";
99 double udpAppStartTime = 0.4;
101 CommandLine cmd(__FILE__);
103 cmd.AddValue(
"simTime",
"Simulation time", simTime);
104 cmd.AddValue(
"gNbNum",
"The number of gNbs in multiple-ue topology", gNbNum);
105 cmd.AddValue(
"ueNumPergNb",
"The number of UE per gNb in multiple-ue topology", ueNumPergNb);
106 cmd.AddValue(
"numBands",
107 "Number of operation bands. More than one implies non-contiguous CC",
109 cmd.AddValue(
"bandwidthBand40",
"The system bandwidth to be used in band 1", bandwidthBand40);
110 cmd.AddValue(
"bandwidthBand38",
"The system bandwidth to be used in band 2", bandwidthBand38);
111 cmd.AddValue(
"bandwidth",
"The bandwidth of the CCs ", bandwidth);
112 cmd.AddValue(
"numerologyBwp0",
"The numerology to be used in bandwidth part 1", numerologyBwp0);
113 cmd.AddValue(
"numerologyBwp1",
"The numerology to be used in bandwidth part 1", numerologyBwp1);
114 cmd.AddValue(
"numerologyBwp2",
"The numerology to be used in bandwidth part 2", numerologyBwp2);
115 cmd.AddValue(
"numerologyBwpDl",
116 "The numerology to be used in bandwidth part 2",
118 cmd.AddValue(
"numerologyBwpUl",
119 "The numerology to be used in bandwidth part 2",
121 cmd.AddValue(
"totalTxPower",
122 "total tx power that will be proportionally assigned to"
123 " bandwidth parts depending on each BWP bandwidth ",
125 cmd.AddValue(
"tddPattern",
126 "LTE TDD pattern to use (e.g. --tddPattern=DL|S|UL|UL|UL|DL|S|UL|UL|UL|)",
128 cmd.AddValue(
"operationMode",
129 "The network operation mode can be TDD or FDD (In this case it"
130 "will be mixed TDD and FDD)",
132 cmd.AddValue(
"cellScan",
133 "Use beam search method to determine beamforming vector,"
134 "true to use cell scanning method",
136 cmd.AddValue(
"packetSizeUll",
137 "packet size in bytes to be used by ultra low latency traffic",
139 cmd.AddValue(
"packetSizeBe",
140 "packet size in bytes to be used by best effort traffic",
142 cmd.AddValue(
"lambdaUll",
143 "Number of UDP packets in one second for ultra low latency traffic",
145 cmd.AddValue(
"lambdaBe",
146 "Number of UDP packets in one second for best effort traffic",
148 cmd.AddValue(
"enableLowLat",
149 "If true, enables low latency traffic transmission (DL)",
151 cmd.AddValue(
"enableVideo",
"If true, enables video traffic transmission (DL)", enableVideo);
152 cmd.AddValue(
"enableVoice",
"If true, enables voice traffic transmission (UL)", enableVoice);
153 cmd.AddValue(
"enableGaming",
"If true, enables gaming traffic transmission (UL)", enableGaming);
154 cmd.AddValue(
"logging",
"Enable logging", logging);
155 cmd.AddValue(
"simTag",
156 "tag to be appended to output filenames to distinguish simulation campaigns",
158 cmd.AddValue(
"outputDir",
"directory where to store simulation results", outputDir);
160 cmd.Parse(argc, argv);
162 NS_ABORT_IF(numBands < 1);
163 NS_ABORT_MSG_IF(enableLowLat ==
false && enableVideo ==
false && enableVoice ==
false &&
164 enableGaming ==
false && operationMode ==
"TDD",
165 "For TDD enable one of the flows");
181 LogComponentEnable(
"NrGnbPhy", LOG_LEVEL_INFO);
182 LogComponentEnable(
"NrUePhy", LOG_LEVEL_INFO);
188 NodeContainer gNbNodes;
189 NodeContainer ueNodes;
190 MobilityHelper mobility;
192 double gNbHeight = 10;
193 double ueHeight = 1.5;
195 gNbNodes.Create(gNbNum);
196 ueNodes.Create(ueNumPergNb * gNbNum);
198 Ptr<ListPositionAllocator> apPositionAlloc = CreateObject<ListPositionAllocator>();
199 Ptr<ListPositionAllocator> staPositionAlloc = CreateObject<ListPositionAllocator>();
200 int32_t yValue = 0.0;
202 for (uint32_t i = 1; i <= gNbNodes.GetN(); ++i)
207 yValue =
static_cast<int>(i) * 30;
214 apPositionAlloc->Add(Vector(0.0, yValue, gNbHeight));
218 for (uint32_t j = 1; j <= ueNumPergNb; ++j)
231 staPositionAlloc->Add(Vector(xValue, 10, ueHeight));
235 staPositionAlloc->Add(Vector(xValue, -10, ueHeight));
240 mobility.SetMobilityModel(
"ns3::ConstantPositionMobilityModel");
241 mobility.SetPositionAllocator(apPositionAlloc);
242 mobility.Install(gNbNodes);
244 mobility.SetPositionAllocator(staPositionAlloc);
245 mobility.Install(ueNodes);
247 Ptr<NrPointToPointEpcHelper> nrEpcHelper = CreateObject<NrPointToPointEpcHelper>();
248 Ptr<IdealBeamformingHelper> idealBeamformingHelper = CreateObject<IdealBeamformingHelper>();
249 Ptr<NrHelper> nrHelper = CreateObject<NrHelper>();
250 nrHelper->SetBeamformingHelper(idealBeamformingHelper);
251 nrHelper->SetEpcHelper(nrEpcHelper);
252 nrEpcHelper->SetAttribute(
"S1uLinkDelay", TimeValue(MilliSeconds(0)));
255 idealBeamformingHelper->SetAttribute(
"BeamformingMethod",
260 idealBeamformingHelper->SetAttribute(
264 Config::SetDefault(
"ns3::NrRlcUm::MaxTxBufferSize", UintegerValue(999999999));
266 std::string errorModel =
"ns3::NrLteMiErrorModel";
268 nrHelper->SetSchedulerAttribute(
"FixedMcsDl", BooleanValue(
false));
269 nrHelper->SetSchedulerAttribute(
"FixedMcsUl", BooleanValue(
false));
272 nrHelper->SetUlErrorModel(errorModel);
273 nrHelper->SetDlErrorModel(errorModel);
276 nrHelper->SetGnbDlAmcAttribute(
279 nrHelper->SetGnbUlAmcAttribute(
287 nrHelper->SetGnbDlAmcAttribute(
"NumRefScPerRb", UintegerValue(2));
288 nrHelper->SetGnbUlAmcAttribute(
"NumRefScPerRb", UintegerValue(2));
289 nrHelper->SetGnbMacAttribute(
"NumRbPerRbg", UintegerValue(4));
290 nrHelper->SetSchedulerAttribute(
"DlCtrlSymbols", UintegerValue(1));
291 nrHelper->SetSchedulerTypeId(TypeId::LookupByName(
"ns3::NrMacSchedulerOfdmaPF"));
341 cc0->m_channelBandwidth = bandwidth;
342 cc0->m_lowerFrequency = cc0->m_centralFrequency - cc0->m_channelBandwidth / 2;
343 cc0->m_higherFrequency = cc0->m_centralFrequency + cc0->m_channelBandwidth / 2;
348 bwp0->m_centralFrequency = cc0->m_centralFrequency;
349 bwp0->m_channelBandwidth = cc0->m_channelBandwidth;
350 bwp0->m_lowerFrequency = cc0->m_lowerFrequency;
351 bwp0->m_higherFrequency = cc0->m_higherFrequency;
353 cc0->AddBwp(std::move(bwp0));
355 band40.
AddCc(std::move(cc0));
369 cc1->m_channelBandwidth = bandwidth;
370 cc1->m_lowerFrequency = cc1->m_centralFrequency - cc1->m_channelBandwidth / 2;
371 cc1->m_higherFrequency = cc1->m_centralFrequency + cc1->m_channelBandwidth / 2;
376 bwp1->m_centralFrequency = cc1->m_centralFrequency;
377 bwp1->m_channelBandwidth = cc1->m_channelBandwidth;
378 bwp1->m_lowerFrequency = cc1->m_lowerFrequency;
379 bwp1->m_higherFrequency = cc1->m_higherFrequency;
381 cc1->AddBwp(std::move(bwp1));
391 cc2->m_channelBandwidth = bandwidth;
392 cc2->m_lowerFrequency = cc2->m_centralFrequency - cc2->m_channelBandwidth / 2;
393 cc2->m_higherFrequency = cc2->m_centralFrequency + cc2->m_channelBandwidth / 2;
395 if (operationMode ==
"TDD")
398 bwp2->m_centralFrequency = cc2->m_centralFrequency;
399 bwp2->m_channelBandwidth = cc2->m_channelBandwidth;
400 bwp2->m_lowerFrequency = cc2->m_lowerFrequency;
401 bwp2->m_higherFrequency = cc2->m_higherFrequency;
403 cc2->AddBwp(std::move(bwp2));
409 bwpdl->m_channelBandwidth = cc2->m_channelBandwidth / 2;
410 bwpdl->m_lowerFrequency = cc2->m_lowerFrequency;
411 bwpdl->m_higherFrequency = bwpdl->m_lowerFrequency + bwpdl->m_channelBandwidth;
412 bwpdl->m_centralFrequency = bwpdl->m_lowerFrequency + bwpdl->m_channelBandwidth / 2;
414 cc2->AddBwp(std::move(bwpdl));
418 bwpul->m_channelBandwidth = cc2->m_channelBandwidth / 2;
419 bwpul->m_lowerFrequency = cc2->m_centralFrequency;
420 bwpul->m_higherFrequency = cc2->m_higherFrequency;
421 bwpul->m_centralFrequency = bwpul->m_lowerFrequency + bwpul->m_channelBandwidth / 2;
423 cc2->AddBwp(std::move(bwpul));
424 Config::SetDefault(
"ns3::NrUeNetDevice::PrimaryUlIndex", UintegerValue(1));
427 band38.
AddCc(std::move(cc1));
428 band38.
AddCc(std::move(cc2));
429 Ptr<NrChannelHelper> channelHelper = CreateObject<NrChannelHelper>();
431 channelHelper->ConfigureFactories(
"RMa",
"Default",
"ThreeGpp");
432 channelHelper->SetPathlossAttribute(
"ShadowingEnabled", BooleanValue(
false));
433 channelHelper->AssignChannelsToBands({band40, band38});
437 nrHelper->SetUeAntennaAttribute(
"NumRows", UintegerValue(1));
438 nrHelper->SetUeAntennaAttribute(
"NumColumns", UintegerValue(1));
439 nrHelper->SetUeAntennaAttribute(
"AntennaElement",
440 PointerValue(CreateObject<IsotropicAntennaModel>()));
443 nrHelper->SetGnbAntennaAttribute(
"NumRows", UintegerValue(2));
444 nrHelper->SetGnbAntennaAttribute(
"NumColumns", UintegerValue(2));
445 nrHelper->SetGnbAntennaAttribute(
"AntennaElement",
446 PointerValue(CreateObject<IsotropicAntennaModel>()));
449 uint32_t bwpIdForLowLat = 0;
450 uint32_t bwpIdForVoice = 1;
451 uint32_t bwpIdForVideo = 2;
452 uint32_t bwpIdForVideoGaming = 3;
454 nrHelper->SetGnbBwpManagerAlgorithmAttribute(
"NGBR_LOW_LAT_EMBB",
455 UintegerValue(bwpIdForLowLat));
456 nrHelper->SetGnbBwpManagerAlgorithmAttribute(
"GBR_CONV_VOICE", UintegerValue(bwpIdForVoice));
457 nrHelper->SetGnbBwpManagerAlgorithmAttribute(
"NGBR_VIDEO_TCP_PREMIUM",
458 UintegerValue(bwpIdForVideo));
459 nrHelper->SetGnbBwpManagerAlgorithmAttribute(
"NGBR_VOICE_VIDEO_GAMING",
460 UintegerValue(bwpIdForVideoGaming));
462 nrHelper->SetUeBwpManagerAlgorithmAttribute(
"NGBR_LOW_LAT_EMBB", UintegerValue(bwpIdForLowLat));
463 nrHelper->SetUeBwpManagerAlgorithmAttribute(
"GBR_CONV_VOICE", UintegerValue(bwpIdForVoice));
464 nrHelper->SetUeBwpManagerAlgorithmAttribute(
"NGBR_VIDEO_TCP_PREMIUM",
465 UintegerValue(bwpIdForVideo));
466 nrHelper->SetUeBwpManagerAlgorithmAttribute(
"NGBR_VOICE_VIDEO_GAMING",
467 UintegerValue(bwpIdForVideoGaming));
470 NetDeviceContainer gnbNetDev = nrHelper->InstallGnbDevice(gNbNodes, allBwps);
471 NetDeviceContainer ueNetDev = nrHelper->InstallUeDevice(ueNodes, allBwps);
473 int64_t randomStream = 1;
474 randomStream += nrHelper->AssignStreams(gnbNetDev, randomStream);
475 randomStream += nrHelper->AssignStreams(ueNetDev, randomStream);
478 double x = pow(10, totalTxPower / 10);
479 double totalBandwidth = numCcs * bandwidth;
482 nrHelper->GetGnbPhy(gnbNetDev.Get(0), 0)
483 ->SetAttribute(
"Numerology", UintegerValue(numerologyBwp0));
484 nrHelper->GetGnbPhy(gnbNetDev.Get(0), 0)
488 log10((band40.
GetBwpAt(0, 0)->m_channelBandwidth / totalBandwidth) * x)));
489 nrHelper->GetGnbPhy(gnbNetDev.Get(0), 0)->SetAttribute(
"Pattern", StringValue(pattern));
490 nrHelper->GetGnbPhy(gnbNetDev.Get(0), 0)->SetAttribute(
"RbOverhead", DoubleValue(0.1));
492 nrHelper->GetGnbPhy(gnbNetDev.Get(0), 1)
493 ->SetAttribute(
"Numerology", UintegerValue(numerologyBwp1));
494 nrHelper->GetGnbPhy(gnbNetDev.Get(0), 1)
498 log10((band38.
GetBwpAt(0, 0)->m_channelBandwidth / totalBandwidth) * x)));
499 nrHelper->GetGnbPhy(gnbNetDev.Get(0), 1)->SetAttribute(
"Pattern", StringValue(pattern));
500 nrHelper->GetGnbPhy(gnbNetDev.Get(0), 1)->SetAttribute(
"RbOverhead", DoubleValue(0.1));
503 if (operationMode ==
"TDD")
505 nrHelper->GetGnbPhy(gnbNetDev.Get(0), 2)
506 ->SetAttribute(
"Numerology", UintegerValue(numerologyBwp2));
507 nrHelper->GetGnbPhy(gnbNetDev.Get(0), 2)
511 10 * log10((band38.
GetBwpAt(1, 0)->m_channelBandwidth / totalBandwidth) * x)));
512 nrHelper->GetGnbPhy(gnbNetDev.Get(0), 2)->SetAttribute(
"Pattern", StringValue(pattern));
513 nrHelper->GetGnbPhy(gnbNetDev.Get(0), 2)->SetAttribute(
"RbOverhead", DoubleValue(0.1));
517 nrHelper->GetGnbPhy(gnbNetDev.Get(0), 2)
518 ->SetAttribute(
"Numerology", UintegerValue(numerologyBwpDl));
519 nrHelper->GetGnbPhy(gnbNetDev.Get(0), 2)
523 10 * log10((band38.
GetBwpAt(1, 0)->m_channelBandwidth / totalBandwidth) * x)));
524 nrHelper->GetGnbPhy(gnbNetDev.Get(0), 2)->SetAttribute(
"Pattern", StringValue(patternDL));
525 nrHelper->GetGnbPhy(gnbNetDev.Get(0), 2)->SetAttribute(
"RbOverhead", DoubleValue(0.1));
527 nrHelper->GetGnbPhy(gnbNetDev.Get(0), 3)
528 ->SetAttribute(
"Numerology", UintegerValue(numerologyBwpUl));
529 nrHelper->GetGnbPhy(gnbNetDev.Get(0), 3)->SetAttribute(
"Pattern", StringValue(patternUL));
530 nrHelper->GetGnbPhy(gnbNetDev.Get(0), 3)->SetAttribute(
"RbOverhead", DoubleValue(0.1));
533 nrHelper->GetBwpManagerGnb(gnbNetDev.Get(0))->SetOutputLink(3, 2);
536 for (uint32_t i = 0; i < ueNetDev.GetN(); i++)
538 nrHelper->GetBwpManagerUe(ueNetDev.Get(i))->SetOutputLink(2, 3);
547 auto [remoteHost, remoteHostIpv4Address] =
548 nrEpcHelper->SetupRemoteHost(
"100Gb/s", 2500, Seconds(0.000));
550 InternetStackHelper internet;
552 internet.Install(ueNodes);
553 Ipv4InterfaceContainer ueIpIface;
554 ueIpIface = nrEpcHelper->AssignUeIpv4Address(NetDeviceContainer(ueNetDev));
557 nrHelper->AttachToClosestGnb(ueNetDev, gnbNetDev);
560 uint16_t dlPortLowLat = 1234;
561 uint16_t ulPortVoice = 1235;
562 uint16_t dlPortVideo = 1236;
563 uint16_t ulPortGaming = 1237;
565 ApplicationContainer serverApps;
568 UdpServerHelper dlPacketSinkLowLat(dlPortLowLat);
569 UdpServerHelper ulPacketSinkVoice(ulPortVoice);
570 UdpServerHelper dlPacketSinkVideo(dlPortVideo);
571 UdpServerHelper ulPacketSinkGaming(ulPortGaming);
575 serverApps.Add(dlPacketSinkLowLat.Install(ueNodes));
576 serverApps.Add(ulPacketSinkVoice.Install(remoteHost));
577 serverApps.Add(dlPacketSinkVideo.Install(ueNodes));
578 serverApps.Add(ulPacketSinkGaming.Install(remoteHost));
586 UdpClientHelper dlClientLowLat;
587 dlClientLowLat.SetAttribute(
"MaxPackets", UintegerValue(0xFFFFFFFF));
588 dlClientLowLat.SetAttribute(
"PacketSize", UintegerValue(udpPacketSizeBe));
589 dlClientLowLat.SetAttribute(
"Interval", TimeValue(Seconds(1.0 / lambdaBe)));
595 Ptr<NrEpcTft> lowLatTft = Create<NrEpcTft>();
599 lowLatTft->Add(dlpfLowLat);
602 UdpClientHelper ulClientVoice;
603 ulClientVoice.SetAttribute(
"MaxPackets", UintegerValue(0xFFFFFFFF));
604 ulClientVoice.SetAttribute(
"PacketSize", UintegerValue(udpPacketSizeBe));
605 ulClientVoice.SetAttribute(
"Interval", TimeValue(Seconds(1.0 / lambdaBe)));
611 Ptr<NrEpcTft> voiceTft = Create<NrEpcTft>();
616 voiceTft->Add(ulpfVoice);
619 UdpClientHelper dlClientVideo;
620 dlClientVideo.SetAttribute(
"MaxPackets", UintegerValue(0xFFFFFFFF));
621 dlClientVideo.SetAttribute(
"PacketSize", UintegerValue(udpPacketSizeUll));
622 dlClientVideo.SetAttribute(
"Interval", TimeValue(Seconds(1.0 / lambdaUll)));
628 Ptr<NrEpcTft> videoTft = Create<NrEpcTft>();
632 videoTft->Add(dlpfVideo);
635 UdpClientHelper ulClientGaming;
636 ulClientGaming.SetAttribute(
"MaxPackets", UintegerValue(0xFFFFFFFF));
637 ulClientGaming.SetAttribute(
"PacketSize", UintegerValue(udpPacketSizeUll));
638 ulClientGaming.SetAttribute(
"Interval", TimeValue(Seconds(1.0 / lambdaUll)));
644 Ptr<NrEpcTft> gamingTft = Create<NrEpcTft>();
649 gamingTft->Add(ulpfGaming);
652 ApplicationContainer clientApps;
654 for (uint32_t i = 0; i < ueNodes.GetN(); ++i)
656 Ptr<Node> ue = ueNodes.Get(i);
657 Ptr<NetDevice> ueDevice = ueNetDev.Get(i);
658 Address ueAddress = ueIpIface.GetAddress(i);
664 dlClientLowLat.SetAttribute(
666 AddressValue(addressUtils::ConvertToSocketAddress(ueAddress, dlPortLowLat)));
667 clientApps.Add(dlClientLowLat.Install(remoteHost));
669 nrHelper->ActivateDedicatedEpsBearer(ueDevice, lowLatBearer, lowLatTft);
673 dlClientVideo.SetAttribute(
675 AddressValue(addressUtils::ConvertToSocketAddress(ueAddress, dlPortVideo)));
676 clientApps.Add(dlClientVideo.Install(remoteHost));
678 nrHelper->ActivateDedicatedEpsBearer(ueDevice, videoBearer, videoTft);
686 ulClientVoice.SetAttribute(
689 addressUtils::ConvertToSocketAddress(remoteHostIpv4Address, ulPortVoice)));
690 clientApps.Add(ulClientVoice.Install(ue));
692 nrHelper->ActivateDedicatedEpsBearer(ueDevice, voiceBearer, voiceTft);
697 ulClientGaming.SetAttribute(
700 addressUtils::ConvertToSocketAddress(remoteHostIpv4Address, ulPortGaming)));
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.