5G-LENA nr-v3.3-159-ga6832aa7
The 5G/NR module for the ns-3 simulator
Loading...
Searching...
No Matches
cttc-nr-cc-bwp-demo.cc
Go to the documentation of this file.
1// Copyright (c) 2019 Centre Tecnologic de Telecomunicacions de Catalunya (CTTC)
2//
3// SPDX-License-Identifier: GPL-2.0-only
4
5#include "ns3/antenna-module.h"
6#include "ns3/applications-module.h"
7#include "ns3/config-store-module.h"
8#include "ns3/config-store.h"
9#include "ns3/core-module.h"
10#include "ns3/flow-monitor-module.h"
11#include "ns3/ideal-beamforming-algorithm.h"
12#include "ns3/internet-apps-module.h"
13#include "ns3/internet-module.h"
14#include "ns3/ipv4-global-routing-helper.h"
15#include "ns3/log.h"
16#include "ns3/nr-helper.h"
17#include "ns3/nr-mac-scheduler-tdma-rr.h"
18#include "ns3/nr-module.h"
19#include "ns3/nr-point-to-point-epc-helper.h"
20#include "ns3/point-to-point-helper.h"
21#include "ns3/point-to-point-module.h"
22
65using namespace ns3;
66
67NS_LOG_COMPONENT_DEFINE("3gppChannelFdmComponentCarriersBandwidthPartsExample");
68
69int
70main(int argc, char* argv[])
71{
72 uint16_t gNbNum = 1;
73 uint16_t ueNumPergNb = 1;
74 uint16_t numFlowsUe = 3;
75
76 uint8_t numBands = 1;
77 double centralFrequencyBand = 28e9;
78 double bandwidthBand = 3e9;
79
80 bool contiguousCc = false;
81 uint16_t numerology = 3; // numerology for contiguous case
82
83 // non-contiguous case
84 double centralFrequencyCc0 = 28e9;
85 double centralFrequencyCc1 = 29e9;
86 double bandwidthCc0 = 400e6;
87 double bandwidthCc1 = 100e6;
88 uint16_t numerologyCc0Bwp0 = 3;
89 uint16_t numerologyCc0Bwp1 = 4;
90 uint16_t numerologyCc1Bwp0 = 3;
91
92 std::string pattern =
93 "F|F|F|F|F|F|F|F|F|F|"; // Pattern can be e.g. "DL|S|UL|UL|DL|DL|S|UL|UL|DL|"
94 double totalTxPower = 8;
95 bool cellScan = false;
96 double beamSearchAngleStep = 10.0;
97
98 bool udpFullBuffer = false;
99 uint32_t udpPacketSizeUll = 100;
100 uint32_t udpPacketSizeBe = 1252;
101 uint32_t lambdaUll = 10000;
102 uint32_t lambdaBe = 1000;
103
104 bool logging = false;
105
106 bool disableDl = false;
107 bool disableUl = true;
108
109 std::string simTag = "default";
110 std::string outputDir = "./";
111
112 double simTime = 1; // seconds
113 double udpAppStartTime = 0.4; // seconds
114
115 CommandLine cmd(__FILE__);
116
117 cmd.AddValue("simTime", "Simulation time", simTime);
118 cmd.AddValue("gNbNum", "The number of gNbs in multiple-ue topology", gNbNum);
119 cmd.AddValue("ueNumPergNb", "The number of UE per gNb in multiple-ue topology", ueNumPergNb);
120 cmd.AddValue("numBands",
121 "Number of operation bands. More than one implies non-contiguous CC",
122 numBands);
123 cmd.AddValue("centralFrequencyBand",
124 "The system frequency to be used in band 1",
125 centralFrequencyBand);
126 cmd.AddValue("bandwidthBand", "The system bandwidth to be used in band 1", bandwidthBand);
127 cmd.AddValue("contiguousCc",
128 "Simulate with contiguous CC or non-contiguous CC example",
129 contiguousCc);
130 cmd.AddValue("numerology", "Numerlogy to be used in contiguous case", numerology);
131 cmd.AddValue("centralFrequencyCc0",
132 "The system frequency to be used in CC 0",
133 centralFrequencyCc0);
134 cmd.AddValue("bandwidthBand", "The system bandwidth to be used in CC 0", bandwidthCc0);
135 cmd.AddValue("centralFrequencyCc1",
136 "The system frequency to be used in CC 1",
137 centralFrequencyCc1);
138 cmd.AddValue("bandwidthBand", "The system bandwidth to be used in CC 1", bandwidthCc1);
139 cmd.AddValue("numerologyCc0Bwp0", "Numerlogy to be used in CC 0, BWP 0", numerologyCc0Bwp0);
140 cmd.AddValue("numerologyCc0Bwp1", "Numerlogy to be used in CC 0, BWP 1", numerologyCc0Bwp1);
141 cmd.AddValue("numerologyCc1Bwp0", "Numerlogy to be used in CC 1, BWP 0", numerologyCc1Bwp0);
142 cmd.AddValue("tddPattern",
143 "LTE TDD pattern to use (e.g. --tddPattern=DL|S|UL|UL|UL|DL|S|UL|UL|UL|)",
144 pattern);
145 cmd.AddValue("totalTxPower",
146 "total tx power that will be proportionally assigned to"
147 " bandwidth parts depending on each BWP bandwidth ",
148 totalTxPower);
149 cmd.AddValue("cellScan",
150 "Use beam search method to determine beamforming vector,"
151 "true to use cell scanning method",
152 cellScan);
153 cmd.AddValue("beamSearchAngleStep",
154 "Beam search angle step for beam search method",
155 beamSearchAngleStep);
156 cmd.AddValue("udpFullBuffer",
157 "Whether to set the full buffer traffic; if this parameter is "
158 "set then the udpInterval parameter will be neglected.",
159 udpFullBuffer);
160 cmd.AddValue("packetSizeUll",
161 "packet size in bytes to be used by ultra low latency traffic",
162 udpPacketSizeUll);
163 cmd.AddValue("packetSizeBe",
164 "packet size in bytes to be used by best effort traffic",
165 udpPacketSizeBe);
166 cmd.AddValue("lambdaUll",
167 "Number of UDP packets in one second for ultra low latency traffic",
168 lambdaUll);
169 cmd.AddValue("lambdaBe",
170 "Number of UDP packets in one second for best effort traffic",
171 lambdaBe);
172 cmd.AddValue("logging", "Enable logging", logging);
173 cmd.AddValue("disableDl", "Disable DL flow", disableDl);
174 cmd.AddValue("disableUl", "Disable UL flow", disableUl);
175 cmd.AddValue("simTag",
176 "tag to be appended to output filenames to distinguish simulation campaigns",
177 simTag);
178 cmd.AddValue("outputDir", "directory where to store simulation results", outputDir);
179
180 cmd.Parse(argc, argv);
181
182 NS_ABORT_IF(numBands < 1);
183 NS_ABORT_MSG_IF(disableDl == true && disableUl == true, "Enable one of the flows");
184
185 // ConfigStore inputConfig;
186 // inputConfig.ConfigureDefaults ();
187
188 // enable logging or not
189 if (logging)
190 {
191 LogComponentEnable("Nr3gppPropagationLossModel", LOG_LEVEL_ALL);
192 LogComponentEnable("Nr3gppBuildingsPropagationLossModel", LOG_LEVEL_ALL);
193 LogComponentEnable("Nr3gppChannel", LOG_LEVEL_ALL);
194 LogComponentEnable("UdpClient", LOG_LEVEL_INFO);
195 LogComponentEnable("UdpServer", LOG_LEVEL_INFO);
196 LogComponentEnable("NrPdcp", LOG_LEVEL_INFO);
197 }
198
199 Config::SetDefault("ns3::NrRlcUm::MaxTxBufferSize", UintegerValue(999999999));
200
201 // create base stations and mobile terminals
202 NodeContainer gNbNodes;
203 NodeContainer ueNodes;
204 MobilityHelper mobility;
205
206 double gNbHeight = 10;
207 double ueHeight = 1.5;
208
209 gNbNodes.Create(gNbNum);
210 ueNodes.Create(ueNumPergNb * gNbNum);
211
212 Ptr<ListPositionAllocator> apPositionAlloc = CreateObject<ListPositionAllocator>();
213 Ptr<ListPositionAllocator> staPositionAlloc = CreateObject<ListPositionAllocator>();
214 int32_t yValue = 0.0;
215
216 for (uint32_t i = 1; i <= gNbNodes.GetN(); ++i)
217 {
218 // 2.0, -2.0, 6.0, -6.0, 10.0, -10.0, ....
219 if (i % 2 != 0)
220 {
221 yValue = static_cast<int>(i) * 30;
222 }
223 else
224 {
225 yValue = -yValue;
226 }
227
228 apPositionAlloc->Add(Vector(0.0, yValue, gNbHeight));
229
230 // 1.0, -1.0, 3.0, -3.0, 5.0, -5.0, ...
231 double xValue = 0.0;
232 for (uint32_t j = 1; j <= ueNumPergNb; ++j)
233 {
234 if (j % 2 != 0)
235 {
236 xValue = j;
237 }
238 else
239 {
240 xValue = -xValue;
241 }
242
243 if (yValue > 0)
244 {
245 staPositionAlloc->Add(Vector(xValue, 10, ueHeight));
246 }
247 else
248 {
249 staPositionAlloc->Add(Vector(xValue, -10, ueHeight));
250 }
251 }
252 }
253
254 mobility.SetMobilityModel("ns3::ConstantPositionMobilityModel");
255 mobility.SetPositionAllocator(apPositionAlloc);
256 mobility.Install(gNbNodes);
257
258 mobility.SetPositionAllocator(staPositionAlloc);
259 mobility.Install(ueNodes);
260
261 // setup the nr simulation
262 Ptr<NrPointToPointEpcHelper> nrEpcHelper = CreateObject<NrPointToPointEpcHelper>();
263 Ptr<IdealBeamformingHelper> idealBeamformingHelper = CreateObject<IdealBeamformingHelper>();
264 Ptr<NrHelper> nrHelper = CreateObject<NrHelper>();
265 Ptr<NrChannelHelper> channelHelper = CreateObject<NrChannelHelper>();
266
267 nrHelper->SetBeamformingHelper(idealBeamformingHelper);
268 nrHelper->SetEpcHelper(nrEpcHelper);
269 // Configure the factories with UMi scenario, LOS channel condition and 3GPP channel model
270 channelHelper->ConfigureFactories("UMi", "LOS", "ThreeGpp");
271
272 /*
273 * Setup the configuration of the spectrum. There is a contiguous and a non-contiguous
274 * example:
275 * 1) One operation band is deployed with 4 contiguous component carriers
276 * (CC)s, which are automatically generated by the ccBwpManager
277 * 2) One operation bands non-contiguous case. CCs and BWPs are manually created
278 */
279
281 CcBwpCreator ccBwpCreator;
282
284
285 // For the case of manual configuration of CCs and BWPs
286 std::unique_ptr<ComponentCarrierInfo> cc0(new ComponentCarrierInfo());
287 std::unique_ptr<BandwidthPartInfo> bwp0(new BandwidthPartInfo());
288 std::unique_ptr<BandwidthPartInfo> bwp1(new BandwidthPartInfo());
289
290 std::unique_ptr<ComponentCarrierInfo> cc1(new ComponentCarrierInfo());
291 std::unique_ptr<BandwidthPartInfo> bwp2(new BandwidthPartInfo());
292
293 if (contiguousCc)
294 {
295 /*
296 * CC band configuration n257F (NR Release 15): four contiguous CCs of
297 * 400MHz at maximum. In this automated example, each CC contains a single
298 * BWP occupying the whole CC bandwidth.
299 *
300 * The configured spectrum division is:
301 * ----------------------------- Band --------------------------------
302 * ------CC0------|------CC1-------|-------CC2-------|-------CC3-------
303 * ------BWP0-----|------BWP0------|-------BWP0------|-------BWP0------
304 */
305
306 const uint8_t numContiguousCcs = 4; // 4 CCs per Band
307
308 // Create the configuration for the CcBwpHelper
309 CcBwpCreator::SimpleOperationBandConf bandConf(centralFrequencyBand,
310 bandwidthBand,
311 numContiguousCcs);
312
313 bandConf.m_numBwp = 1; // 1 BWP per CC
314
315 // By using the configuration created, it is time to make the operation band
316 band = ccBwpCreator.CreateOperationBandContiguousCc(bandConf);
317 }
318 else
319 {
320 /*
321 * The configured spectrum division is:
322 * ----------------------------- Band ---------------------------------
323 * ---------------CC0--------------|----------------CC1----------------
324 * ------BWP0------|------BWP1-----|----------------BWP0---------------
325 */
326 band.m_centralFrequency = centralFrequencyBand;
327 band.m_channelBandwidth = bandwidthBand;
330 uint8_t bwpCount = 0;
331
332 // Component Carrier 0
333 cc0->m_ccId = 0;
334 cc0->m_centralFrequency = centralFrequencyCc0;
335 cc0->m_channelBandwidth = bandwidthCc0;
336 cc0->m_lowerFrequency = cc0->m_centralFrequency - cc0->m_channelBandwidth / 2;
337 cc0->m_higherFrequency = cc0->m_centralFrequency + cc0->m_channelBandwidth / 2;
338
339 // BWP 0
340 bwp0->m_bwpId = bwpCount;
341 bwp0->m_centralFrequency = cc0->m_lowerFrequency + 100e6;
342 bwp0->m_channelBandwidth = 200e6;
343 bwp0->m_lowerFrequency = bwp0->m_centralFrequency - bwp0->m_channelBandwidth / 2;
344 bwp0->m_higherFrequency = bwp0->m_centralFrequency + bwp0->m_channelBandwidth / 2;
345
346 cc0->AddBwp(std::move(bwp0));
347 ++bwpCount;
348
349 // BWP 01
350 bwp1->m_bwpId = bwpCount;
351 bwp1->m_centralFrequency = cc0->m_higherFrequency - 50e6;
352 bwp1->m_channelBandwidth = 100e6;
353 bwp1->m_lowerFrequency = bwp1->m_centralFrequency - bwp1->m_channelBandwidth / 2;
354 bwp1->m_higherFrequency = bwp1->m_centralFrequency + bwp1->m_channelBandwidth / 2;
355
356 cc0->AddBwp(std::move(bwp1));
357 ++bwpCount;
358
359 // Component Carrier 1
360 cc1->m_ccId = 1;
361 cc1->m_centralFrequency = centralFrequencyCc1;
362 cc1->m_channelBandwidth = bandwidthCc1;
363 cc1->m_lowerFrequency = cc1->m_centralFrequency - cc1->m_channelBandwidth / 2;
364 cc1->m_higherFrequency = cc1->m_centralFrequency + cc1->m_channelBandwidth / 2;
365
366 // BWP 2
367 bwp2->m_bwpId = bwpCount;
368 bwp2->m_centralFrequency = cc1->m_centralFrequency;
369 bwp2->m_channelBandwidth = cc1->m_channelBandwidth;
370 bwp2->m_lowerFrequency = cc1->m_lowerFrequency;
371 bwp2->m_higherFrequency = cc1->m_higherFrequency;
372
373 cc1->AddBwp(std::move(bwp2));
374 ++bwpCount;
375
376 // Add CC to the corresponding operation band.
377 band.AddCc(std::move(cc1));
378 band.AddCc(std::move(cc0));
379 }
380 /*else
381 {
382 nrHelper->SetAttribute ("UseCa", BooleanValue (false));
383 }*/
384
385 // NS_ABORT_MSG_IF (ccId < 1,"No CC created");
386 // Set the path loss configuration
387 channelHelper->SetPathlossAttribute("ShadowingEnabled", BooleanValue(false));
388 // Set and create the channel to be used in this band
389 channelHelper->AssignChannelsToBands({band});
390 nrEpcHelper->SetAttribute("S1uLinkDelay", TimeValue(MilliSeconds(0)));
391 nrHelper->SetSchedulerTypeId(TypeId::LookupByName("ns3::NrMacSchedulerTdmaRR"));
392 // Beamforming method
393 if (cellScan)
394 {
395 idealBeamformingHelper->SetAttribute("BeamformingMethod",
396 TypeIdValue(CellScanBeamforming::GetTypeId()));
397 idealBeamformingHelper->SetBeamformingAlgorithmAttribute("BeamSearchAngleStep",
398 DoubleValue(beamSearchAngleStep));
399 }
400 else
401 {
402 idealBeamformingHelper->SetAttribute("BeamformingMethod",
403 TypeIdValue(DirectPathBeamforming::GetTypeId()));
404 }
405 allBwps = CcBwpCreator::GetAllBwps({band});
406
407 double x = pow(10, totalTxPower / 10);
408
409 // Antennas for all the UEs
410 nrHelper->SetUeAntennaAttribute("NumRows", UintegerValue(2));
411 nrHelper->SetUeAntennaAttribute("NumColumns", UintegerValue(4));
412 nrHelper->SetUeAntennaAttribute("AntennaElement",
413 PointerValue(CreateObject<IsotropicAntennaModel>()));
414
415 // Antennas for all the gNbs
416 nrHelper->SetGnbAntennaAttribute("NumRows", UintegerValue(4));
417 nrHelper->SetGnbAntennaAttribute("NumColumns", UintegerValue(8));
418 nrHelper->SetGnbAntennaAttribute("AntennaElement",
419 PointerValue(CreateObject<IsotropicAntennaModel>()));
420
421 uint32_t bwpIdForLowLat = 0;
422 uint32_t bwpIdForVoice = 1;
423 uint32_t bwpIdForVideo = 2;
424 uint32_t bwpIdForVideoGaming = 3;
425
426 nrHelper->SetGnbBwpManagerAlgorithmAttribute("NGBR_LOW_LAT_EMBB",
427 UintegerValue(bwpIdForLowLat));
428 nrHelper->SetGnbBwpManagerAlgorithmAttribute("GBR_CONV_VOICE", UintegerValue(bwpIdForVoice));
429 nrHelper->SetGnbBwpManagerAlgorithmAttribute("NGBR_VIDEO_TCP_PREMIUM",
430 UintegerValue(bwpIdForVideo));
431 nrHelper->SetGnbBwpManagerAlgorithmAttribute("NGBR_VOICE_VIDEO_GAMING",
432 UintegerValue(bwpIdForVideoGaming));
433
434 // Install and get the pointers to the NetDevices
435 NetDeviceContainer gnbNetDev = nrHelper->InstallGnbDevice(gNbNodes, allBwps);
436 NetDeviceContainer ueNetDev = nrHelper->InstallUeDevice(ueNodes, allBwps);
437
438 int64_t randomStream = 1;
439 randomStream += nrHelper->AssignStreams(gnbNetDev, randomStream);
440 randomStream += nrHelper->AssignStreams(ueNetDev, randomStream);
441
442 if (contiguousCc)
443 {
444 // Manually set the attribute of the netdevice (gnbNetDev.Get (0)) and bandwidth part (0),
445 // (1), ...
446 nrHelper->GetGnbPhy(gnbNetDev.Get(0), 0)
447 ->SetAttribute("Numerology", UintegerValue(numerology));
448 nrHelper->GetGnbPhy(gnbNetDev.Get(0), 0)
449 ->SetAttribute("TxPower", DoubleValue(10 * log10(0.25 * x)));
450 nrHelper->GetGnbPhy(gnbNetDev.Get(0), 0)->SetAttribute("Pattern", StringValue(pattern));
451
452 nrHelper->GetGnbPhy(gnbNetDev.Get(0), 1)
453 ->SetAttribute("Numerology", UintegerValue(numerology));
454 nrHelper->GetGnbPhy(gnbNetDev.Get(0), 1)
455 ->SetAttribute("TxPower", DoubleValue(10 * log10(0.25 * x)));
456 nrHelper->GetGnbPhy(gnbNetDev.Get(0), 1)->SetAttribute("Pattern", StringValue(pattern));
457
458 nrHelper->GetGnbPhy(gnbNetDev.Get(0), 2)
459 ->SetAttribute("Numerology", UintegerValue(numerology));
460 nrHelper->GetGnbPhy(gnbNetDev.Get(0), 2)
461 ->SetAttribute("TxPower", DoubleValue(10 * log10(0.25 * x)));
462 nrHelper->GetGnbPhy(gnbNetDev.Get(0), 2)->SetAttribute("Pattern", StringValue(pattern));
463
464 nrHelper->GetGnbPhy(gnbNetDev.Get(0), 3)
465 ->SetAttribute("Numerology", UintegerValue(numerology));
466 nrHelper->GetGnbPhy(gnbNetDev.Get(0), 3)
467 ->SetAttribute("TxPower", DoubleValue(10 * log10(0.25 * x)));
468 nrHelper->GetGnbPhy(gnbNetDev.Get(0), 3)->SetAttribute("Pattern", StringValue(pattern));
469 }
470 else
471 {
472 // Set the attribute of the netdevice (gnbNetDev.Get (0)) and bandwidth part (0), (1), ...
473 nrHelper->GetGnbPhy(gnbNetDev.Get(0), 0)
474 ->SetAttribute("Numerology", UintegerValue(numerologyCc0Bwp0));
475 nrHelper->GetGnbPhy(gnbNetDev.Get(0), 0)
476 ->SetAttribute(
477 "TxPower",
478 DoubleValue(10 *
479 log10((band.GetBwpAt(0, 0)->m_channelBandwidth / bandwidthBand) * x)));
480 nrHelper->GetGnbPhy(gnbNetDev.Get(0), 0)->SetAttribute("Pattern", StringValue(pattern));
481
482 nrHelper->GetGnbPhy(gnbNetDev.Get(0), 1)
483 ->SetAttribute("Numerology", UintegerValue(numerologyCc0Bwp1));
484 nrHelper->GetGnbPhy(gnbNetDev.Get(0), 1)
485 ->SetAttribute(
486 "TxPower",
487 DoubleValue(10 *
488 log10((band.GetBwpAt(1, 0)->m_channelBandwidth / bandwidthBand) * x)));
489 nrHelper->GetGnbPhy(gnbNetDev.Get(0), 1)->SetAttribute("Pattern", StringValue(pattern));
490
491 nrHelper->GetGnbPhy(gnbNetDev.Get(0), 2)
492 ->SetAttribute("Numerology", UintegerValue(numerologyCc1Bwp0));
493 nrHelper->GetGnbPhy(gnbNetDev.Get(0), 2)
494 ->SetAttribute(
495 "TxPower",
496 DoubleValue(10 *
497 log10((band.GetBwpAt(1, 1)->m_channelBandwidth / bandwidthBand) * x)));
498 nrHelper->GetGnbPhy(gnbNetDev.Get(0), 2)->SetAttribute("Pattern", StringValue(pattern));
499 }
500
501 // create the internet and install the IP stack on the UEs
502 // get SGW/PGW and create a single RemoteHost
503 auto [remoteHost, remoteHostIpv4Address] =
504 nrEpcHelper->SetupRemoteHost("100Gb/s", 2500, Seconds(0.000));
505
506 InternetStackHelper internet;
507 internet.Install(ueNodes);
508 Ipv4InterfaceContainer ueIpIface;
509 ueIpIface = nrEpcHelper->AssignUeIpv4Address(NetDeviceContainer(ueNetDev));
510
511 // attach UEs to the closest gNB before creating the dedicated flows
512 nrHelper->AttachToClosestGnb(ueNetDev, gnbNetDev);
513
514 // install UDP applications
515 uint16_t dlPort = 1234;
516 uint16_t ulPort = dlPort + gNbNum * ueNumPergNb * numFlowsUe + 1;
517 ApplicationContainer clientApps;
518 ApplicationContainer serverApps;
519
520 for (uint32_t u = 0; u < ueNodes.GetN(); ++u)
521 {
522 for (uint16_t flow = 0; flow < numFlowsUe; ++flow)
523 {
524 if (!disableDl)
525 {
526 PacketSinkHelper dlPacketSinkHelper(
527 "ns3::UdpSocketFactory",
528 InetSocketAddress(Ipv4Address::GetAny(), dlPort));
529 serverApps.Add(dlPacketSinkHelper.Install(ueNodes.Get(u)));
530
531 UdpClientHelper dlClient(ueIpIface.GetAddress(u), dlPort);
532 dlClient.SetAttribute("PacketSize", UintegerValue(udpPacketSizeBe));
533 dlClient.SetAttribute("Interval", TimeValue(Seconds(1.0 / lambdaUll)));
534 dlClient.SetAttribute("MaxPackets", UintegerValue(0xFFFFFFFF));
535 clientApps.Add(dlClient.Install(remoteHost));
536
537 Ptr<NrEpcTft> tft = Create<NrEpcTft>();
539 dlpf.localPortStart = dlPort;
540 dlpf.localPortEnd = dlPort;
541 ++dlPort;
542 tft->Add(dlpf);
543
544 enum NrEpsBearer::Qci q;
545 if (flow == 0)
546 {
548 }
549 else if (flow == 1)
550 {
552 }
553 else if (flow == 2)
554 {
556 }
557 else if (flow == 3)
558 {
560 }
561 else
562 {
564 }
565 NrEpsBearer bearer(q);
566 nrHelper->ActivateDedicatedEpsBearer(ueNetDev.Get(u), bearer, tft);
567 }
568
569 if (!disableUl)
570 {
571 PacketSinkHelper ulPacketSinkHelper(
572 "ns3::UdpSocketFactory",
573 InetSocketAddress(Ipv4Address::GetAny(), ulPort));
574 serverApps.Add(ulPacketSinkHelper.Install(remoteHost));
575
576 UdpClientHelper ulClient(remoteHostIpv4Address, ulPort);
577 ulClient.SetAttribute("PacketSize", UintegerValue(udpPacketSizeBe));
578 ulClient.SetAttribute("Interval", TimeValue(Seconds(1.0 / lambdaUll)));
579 ulClient.SetAttribute("MaxPackets", UintegerValue(0xFFFFFFFF));
580 clientApps.Add(ulClient.Install(ueNodes.Get(u)));
581
582 Ptr<NrEpcTft> tft = Create<NrEpcTft>();
584 ulpf.remotePortStart = ulPort;
585 ulpf.remotePortEnd = ulPort;
586 ++ulPort;
587 tft->Add(ulpf);
588
589 enum NrEpsBearer::Qci q;
590 if (flow == 0)
591 {
593 }
594 else if (flow == 1)
595 {
597 }
598 else if (flow == 2)
599 {
601 }
602 else if (flow == 3)
603 {
605 }
606 else
607 {
609 }
610 NrEpsBearer bearer(q);
611 nrHelper->ActivateDedicatedEpsBearer(ueNetDev.Get(u), bearer, tft);
612 }
613 }
614 }
615
616 // start UDP server and client apps
617 serverApps.Start(Seconds(udpAppStartTime));
618 clientApps.Start(Seconds(udpAppStartTime));
619 serverApps.Stop(Seconds(simTime));
620 clientApps.Stop(Seconds(simTime));
621
622 // enable the traces provided by the nr module
623 // nrHelper->EnableTraces();
624
625 FlowMonitorHelper flowmonHelper;
626 NodeContainer endpointNodes;
627 endpointNodes.Add(remoteHost);
628 endpointNodes.Add(ueNodes);
629
630 Ptr<ns3::FlowMonitor> monitor = flowmonHelper.Install(endpointNodes);
631 monitor->SetAttribute("DelayBinWidth", DoubleValue(0.001));
632 monitor->SetAttribute("JitterBinWidth", DoubleValue(0.001));
633 monitor->SetAttribute("PacketSizeBinWidth", DoubleValue(20));
634
635 Simulator::Stop(Seconds(simTime));
636 Simulator::Run();
637
638 /*
639 * To check what was installed in the memory, i.e., BWPs of gNB Device, and its configuration.
640 * Example is: Node 1 -> Device 0 -> BandwidthPartMap -> {0,1} BWPs -> NrGnbPhy ->
641 NrPhyMacCommong-> Numerology, Bandwidth, ... GtkConfigStore config; config.ConfigureAttributes
642 ();
643 */
644
645 // Print per-flow statistics
646 monitor->CheckForLostPackets();
647 Ptr<Ipv4FlowClassifier> classifier =
648 DynamicCast<Ipv4FlowClassifier>(flowmonHelper.GetClassifier());
649 FlowMonitor::FlowStatsContainer stats = monitor->GetFlowStats();
650
651 double averageFlowThroughput = 0.0;
652 double averageFlowDelay = 0.0;
653
654 std::ofstream outFile;
655 std::string filename = outputDir + "/" + simTag;
656 outFile.open(filename.c_str(), std::ofstream::out | std::ofstream::trunc);
657 if (!outFile.is_open())
658 {
659 std::cerr << "Can't open file " << filename << std::endl;
660 return 1;
661 }
662
663 outFile.setf(std::ios_base::fixed);
664
665 for (std::map<FlowId, FlowMonitor::FlowStats>::const_iterator i = stats.begin();
666 i != stats.end();
667 ++i)
668 {
669 Ipv4FlowClassifier::FiveTuple t = classifier->FindFlow(i->first);
670 std::stringstream protoStream;
671 protoStream << (uint16_t)t.protocol;
672 if (t.protocol == 6)
673 {
674 protoStream.str("TCP");
675 }
676 if (t.protocol == 17)
677 {
678 protoStream.str("UDP");
679 }
680 outFile << "Flow " << i->first << " (" << t.sourceAddress << ":" << t.sourcePort << " -> "
681 << t.destinationAddress << ":" << t.destinationPort << ") proto "
682 << protoStream.str() << "\n";
683 outFile << " Tx Packets: " << i->second.txPackets << "\n";
684 outFile << " Tx Bytes: " << i->second.txBytes << "\n";
685 outFile << " TxOffered: "
686 << i->second.txBytes * 8.0 / (simTime - udpAppStartTime) / 1000 / 1000 << " Mbps\n";
687 outFile << " Rx Bytes: " << i->second.rxBytes << "\n";
688 if (i->second.rxPackets > 0)
689 {
690 // Measure the duration of the flow from receiver's perspective
691 // double rxDuration = i->second.timeLastRxPacket.GetSeconds () -
692 // i->second.timeFirstTxPacket.GetSeconds ();
693 double rxDuration = (simTime - udpAppStartTime);
694
695 averageFlowThroughput += i->second.rxBytes * 8.0 / rxDuration / 1000 / 1000;
696 averageFlowDelay += 1000 * i->second.delaySum.GetSeconds() / i->second.rxPackets;
697
698 outFile << " Throughput: " << i->second.rxBytes * 8.0 / rxDuration / 1000 / 1000
699 << " Mbps\n";
700 outFile << " Mean delay: "
701 << 1000 * i->second.delaySum.GetSeconds() / i->second.rxPackets << " ms\n";
702 // outFile << " Mean upt: " << i->second.uptSum / i->second.rxPackets / 1000/1000 << "
703 // Mbps \n";
704 outFile << " Mean jitter: "
705 << 1000 * i->second.jitterSum.GetSeconds() / i->second.rxPackets << " ms\n";
706 }
707 else
708 {
709 outFile << " Throughput: 0 Mbps\n";
710 outFile << " Mean delay: 0 ms\n";
711 outFile << " Mean jitter: 0 ms\n";
712 }
713 outFile << " Rx Packets: " << i->second.rxPackets << "\n";
714 }
715
716 outFile << "\n\n Mean flow throughput: " << averageFlowThroughput / stats.size() << "\n";
717 outFile << " Mean flow delay: " << averageFlowDelay / stats.size() << "\n";
718
719 outFile.close();
720
721 std::ifstream f(filename.c_str());
722
723 if (f.is_open())
724 {
725 std::cout << f.rdbuf();
726 }
727
728 Simulator::Destroy();
729 return 0;
730}
Manages the correct creation of operation bands, component carriers and bandwidth parts.
OperationBandInfo CreateOperationBandContiguousCc(const SimpleOperationBandConf &conf)
Create an operation band with the CC specified.
static BandwidthPartInfoPtrVector GetAllBwps(const std::vector< std::reference_wrapper< OperationBandInfo > > &operationBands)
Get all the BWP pointers from the specified vector of operation bands.
static TypeId GetTypeId()
Get the type id.
static TypeId GetTypeId()
Get the type id.
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_DEFAULT
Non-GBR TCP-based Video (Buffered Streaming, e.g., www, e-mail...)
@ 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
Minimum configuration requirements for a OperationBand.
Component carrier configuration element.
uint16_t remotePortEnd
end of the port number range of the remote host
Definition nr-epc-tft.h:117
uint16_t localPortStart
start of the port number range of the UE
Definition nr-epc-tft.h:118
uint16_t remotePortStart
start of the port number range of the remote host
Definition nr-epc-tft.h:116
uint16_t localPortEnd
end of the port number range of the UE
Definition nr-epc-tft.h:119
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.