5G-LENA nr-v3.3-159-ga6832aa7
The 5G/NR module for the ns-3 simulator
Loading...
Searching...
No Matches
cttc-3gpp-channel-nums-fdm.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
28#include "ns3/antenna-module.h"
29#include "ns3/applications-module.h"
30#include "ns3/config-store-module.h"
31#include "ns3/config-store.h"
32#include "ns3/core-module.h"
33#include "ns3/flow-monitor-module.h"
34#include "ns3/internet-apps-module.h"
35#include "ns3/internet-module.h"
36#include "ns3/mobility-module.h"
37#include "ns3/nr-module.h"
38#include "ns3/point-to-point-module.h"
39
40using namespace ns3;
41
42NS_LOG_COMPONENT_DEFINE("3gppChannelNumsFdm");
43
44int
45main(int argc, char* argv[])
46{
47 uint16_t gNbNum = 4;
48 uint16_t ueNum = 4;
49
50 uint32_t udpPacketSizeVideo = 100;
51 uint32_t udpPacketSizeVoice = 1252;
52 uint32_t udpPacketSizeGaming = 500;
53 uint32_t lambdaVideo = 50;
54 uint32_t lambdaVoice = 100;
55 uint32_t lambdaGaming = 250;
56
57 uint32_t simTimeMs = 1400;
58 uint32_t udpAppStartTimeMs = 400;
59
60 double centralFrequencyBand1 = 28e9;
61 double bandwidthBand1 = 100e6;
62 double centralFrequencyBand2 = 28.2e9;
63 double bandwidthBand2 = 100e6;
64 double totalTxPower = 4;
65 std::string simTag = "default";
66 std::string outputDir = "./";
67 bool enableVideo = true;
68 bool enableVoice = true;
69 bool enableGaming = true;
70
71 CommandLine cmd(__FILE__);
72
73 cmd.AddValue("packetSizeVideo",
74 "packet size in bytes to be used by video traffic",
75 udpPacketSizeVideo);
76 cmd.AddValue("packetSizeVoice",
77 "packet size in bytes to be used by voice traffic",
78 udpPacketSizeVoice);
79 cmd.AddValue("packetSizeGaming",
80 "packet size in bytes to be used by gaming traffic",
81 udpPacketSizeGaming);
82 cmd.AddValue("lambdaVideo",
83 "Number of UDP packets in one second for video traffic",
84 lambdaVideo);
85 cmd.AddValue("lambdaVoice",
86 "Number of UDP packets in one second for voice traffic",
87 lambdaVoice);
88 cmd.AddValue("lambdaGaming",
89 "Number of UDP packets in one second for gaming traffic",
90 lambdaGaming);
91 cmd.AddValue("enableVideo", "If true, enables video traffic transmission (DL)", enableVideo);
92 cmd.AddValue("enableVoice", "If true, enables voice traffic transmission (DL)", enableVoice);
93 cmd.AddValue("enableGaming", "If true, enables gaming traffic transmission (UL)", enableGaming);
94 cmd.AddValue("simTimeMs", "Simulation time", simTimeMs);
95 cmd.AddValue("centralFrequencyBand1",
96 "The system frequency to be used in band 1",
97 centralFrequencyBand1);
98 cmd.AddValue("bandwidthBand1", "The system bandwidth to be used in band 1", bandwidthBand1);
99 cmd.AddValue("centralFrequencyBand2",
100 "The system frequency to be used in band 2",
101 centralFrequencyBand2);
102 cmd.AddValue("bandwidthBand2", "The system bandwidth to be used in band 2", bandwidthBand2);
103 cmd.AddValue("totalTxPower",
104 "total tx power that will be proportionally assigned to"
105 " bands, CCs and bandwidth parts depending on each BWP bandwidth ",
106 totalTxPower);
107 cmd.AddValue("simTag",
108 "tag to be appended to output filenames to distinguish simulation campaigns",
109 simTag);
110 cmd.AddValue("outputDir", "directory where to store simulation results", outputDir);
111
112 cmd.Parse(argc, argv);
113
114 NS_ABORT_IF(centralFrequencyBand1 > 100e9);
115 NS_ABORT_IF(centralFrequencyBand2 > 100e9);
116
117 Config::SetDefault("ns3::NrRlcUm::MaxTxBufferSize", UintegerValue(999999999));
118
119 int64_t randomStream = 1;
120
121 GridScenarioHelper gridScenario;
122 gridScenario.SetRows(gNbNum / 2);
123 gridScenario.SetColumns(gNbNum);
124 gridScenario.SetHorizontalBsDistance(5.0);
125 gridScenario.SetBsHeight(10.0);
126 gridScenario.SetUtHeight(1.5);
127 // must be set before BS number
128 gridScenario.SetSectorization(GridScenarioHelper::SINGLE);
129 gridScenario.SetBsNumber(gNbNum);
130 gridScenario.SetUtNumber(ueNum);
131 gridScenario.SetScenarioHeight(3); // Create a 3x3 scenario where the UE will
132 gridScenario.SetScenarioLength(3); // be distributed.
133 randomStream += gridScenario.AssignStreams(randomStream);
134 gridScenario.CreateScenario();
135
136 /*
137 * TODO: Add a print, or a plot, that shows the scenario.
138 */
139 Ptr<NrPointToPointEpcHelper> nrEpcHelper = CreateObject<NrPointToPointEpcHelper>();
140 Ptr<IdealBeamformingHelper> idealBeamformingHelper = CreateObject<IdealBeamformingHelper>();
141 Ptr<NrHelper> nrHelper = CreateObject<NrHelper>();
142 Ptr<NrChannelHelper> channelHelper = CreateObject<NrChannelHelper>();
143
144 // Put the pointers inside nrHelper
145 nrHelper->SetBeamformingHelper(idealBeamformingHelper);
146 nrHelper->SetEpcHelper(nrEpcHelper);
147 // Create the spectrum channel
148 channelHelper->ConfigureFactories("UMi", "Default", "ThreeGpp");
149 Config::SetDefault("ns3::ThreeGppChannelModel::UpdatePeriod", TimeValue(MilliSeconds(0)));
150 channelHelper->SetChannelConditionModelAttribute("UpdatePeriod", TimeValue(MilliSeconds(0)));
151 channelHelper->SetPathlossAttribute("ShadowingEnabled", BooleanValue(false));
152
154 CcBwpCreator ccBwpCreator;
155 const uint8_t numCcPerBand = 1; // in this example, both bands have a single CC
156
157 CcBwpCreator::SimpleOperationBandConf bandConfTdd(centralFrequencyBand1,
158 bandwidthBand1,
159 numCcPerBand);
160
161 CcBwpCreator::SimpleOperationBandConf bandConfFdd(centralFrequencyBand2,
162 bandwidthBand2,
163 numCcPerBand);
164
165 bandConfFdd.m_numBwp = 2; // Here, bandFdd will have 2 BWPs
166
167 // By using the configuration created, it is time to make the operation bands
168 OperationBandInfo bandTdd = ccBwpCreator.CreateOperationBandContiguousCc(bandConfTdd);
169 OperationBandInfo bandFdd = ccBwpCreator.CreateOperationBandContiguousCc(bandConfFdd);
170 // Create the same spectrum channel for both bands with different frequencies
171 channelHelper->AssignChannelsToBands({bandTdd, bandFdd});
172
173 /*
174 * The configured spectrum division is:
175 * |------------BandTdd--------------|--------------BandFdd---------------|
176 * |------------CC0------------------|--------------CC1-------------------|
177 * |------------BWP0-----------------|------BWP1-------|-------BWP2-------|
178 *
179 * We will configure BWP0 as TDD, BWP1 as FDD-DL, BWP2 as FDD-UL.
180 */
181 allBwps = CcBwpCreator::GetAllBwps({bandTdd, bandFdd});
182 // Beamforming method
183 idealBeamformingHelper->SetAttribute("BeamformingMethod",
184 TypeIdValue(DirectPathBeamforming::GetTypeId()));
185
186 // Core latency
187 nrEpcHelper->SetAttribute("S1uLinkDelay", TimeValue(MilliSeconds(0)));
188
189 // Antennas for all the UEs
190 nrHelper->SetUeAntennaAttribute("NumRows", UintegerValue(2));
191 nrHelper->SetUeAntennaAttribute("NumColumns", UintegerValue(4));
192 nrHelper->SetUeAntennaAttribute("AntennaElement",
193 PointerValue(CreateObject<IsotropicAntennaModel>()));
194
195 // Antennas for all the gNbs
196 nrHelper->SetGnbAntennaAttribute("NumRows", UintegerValue(4));
197 nrHelper->SetGnbAntennaAttribute("NumColumns", UintegerValue(8));
198 nrHelper->SetGnbAntennaAttribute("AntennaElement",
199 PointerValue(CreateObject<IsotropicAntennaModel>()));
200
201 nrHelper->SetGnbPhyAttribute("TxPower", DoubleValue(4.0));
202
203 uint32_t bwpIdForVoice = 0;
204 uint32_t bwpIdForVideo = 1;
205 uint32_t bwpIdForGaming = 2;
206
207 nrHelper->SetGnbBwpManagerAlgorithmAttribute("GBR_CONV_VOICE", UintegerValue(bwpIdForVoice));
208 nrHelper->SetGnbBwpManagerAlgorithmAttribute("GBR_CONV_VIDEO", UintegerValue(bwpIdForVideo));
209 nrHelper->SetGnbBwpManagerAlgorithmAttribute("GBR_GAMING", UintegerValue(bwpIdForGaming));
210
211 nrHelper->SetUeBwpManagerAlgorithmAttribute("GBR_CONV_VOICE", UintegerValue(bwpIdForVoice));
212 nrHelper->SetUeBwpManagerAlgorithmAttribute("GBR_CONV_VIDEO", UintegerValue(bwpIdForVideo));
213 nrHelper->SetUeBwpManagerAlgorithmAttribute("GBR_GAMING", UintegerValue(bwpIdForGaming));
214
215 NetDeviceContainer gnbNetDev =
216 nrHelper->InstallGnbDevice(gridScenario.GetBaseStations(), allBwps);
217 NetDeviceContainer ueNetDev =
218 nrHelper->InstallUeDevice(gridScenario.GetUserTerminals(), allBwps);
219
220 randomStream += nrHelper->AssignStreams(gnbNetDev, randomStream);
221 randomStream += nrHelper->AssignStreams(ueNetDev, randomStream);
222
223 NS_ASSERT(gnbNetDev.GetN() == 4);
224
225 // -------------- First GNB:
226
227 // BWP0, the TDD one
228 nrHelper->GetGnbPhy(gnbNetDev.Get(0), 0)->SetAttribute("Numerology", UintegerValue(0));
229 nrHelper->GetGnbPhy(gnbNetDev.Get(0), 0)
230 ->SetAttribute("Pattern", StringValue("F|F|F|F|F|F|F|F|F|F|"));
231 nrHelper->GetGnbPhy(gnbNetDev.Get(0), 0)->SetAttribute("TxPower", DoubleValue(4.0));
232
233 // BWP1, FDD-DL
234 nrHelper->GetGnbPhy(gnbNetDev.Get(0), 1)->SetAttribute("Numerology", UintegerValue(0));
235 nrHelper->GetGnbPhy(gnbNetDev.Get(0), 1)
236 ->SetAttribute("Pattern", StringValue("DL|DL|DL|DL|DL|DL|DL|DL|DL|DL|"));
237 nrHelper->GetGnbPhy(gnbNetDev.Get(0), 1)->SetAttribute("TxPower", DoubleValue(4.0));
238
239 // BWP2, FDD-UL
240 nrHelper->GetGnbPhy(gnbNetDev.Get(0), 2)->SetAttribute("Numerology", UintegerValue(0));
241 nrHelper->GetGnbPhy(gnbNetDev.Get(0), 2)
242 ->SetAttribute("Pattern", StringValue("UL|UL|UL|UL|UL|UL|UL|UL|UL|UL|"));
243 nrHelper->GetGnbPhy(gnbNetDev.Get(0), 2)->SetAttribute("TxPower", DoubleValue(0.0));
244
245 // Link the two FDD BWP:
246 nrHelper->GetBwpManagerGnb(gnbNetDev.Get(0))->SetOutputLink(2, 1);
247
248 // -------------- Second GNB:
249
250 // BWP0, the TDD one
251 nrHelper->GetGnbPhy(gnbNetDev.Get(1), 0)->SetAttribute("Numerology", UintegerValue(1));
252 nrHelper->GetGnbPhy(gnbNetDev.Get(1), 0)
253 ->SetAttribute("Pattern", StringValue("F|F|F|F|F|F|F|F|F|F|"));
254 nrHelper->GetGnbPhy(gnbNetDev.Get(1), 0)->SetAttribute("TxPower", DoubleValue(4.0));
255
256 // BWP1, FDD-DL
257 nrHelper->GetGnbPhy(gnbNetDev.Get(1), 1)->SetAttribute("Numerology", UintegerValue(1));
258 nrHelper->GetGnbPhy(gnbNetDev.Get(1), 1)
259 ->SetAttribute("Pattern", StringValue("DL|DL|DL|DL|DL|DL|DL|DL|DL|DL|"));
260 nrHelper->GetGnbPhy(gnbNetDev.Get(1), 1)->SetAttribute("TxPower", DoubleValue(4.0));
261
262 // BWP2, FDD-UL
263 nrHelper->GetGnbPhy(gnbNetDev.Get(1), 2)->SetAttribute("Numerology", UintegerValue(1));
264 nrHelper->GetGnbPhy(gnbNetDev.Get(1), 2)
265 ->SetAttribute("Pattern", StringValue("UL|UL|UL|UL|UL|UL|UL|UL|UL|UL|"));
266 nrHelper->GetGnbPhy(gnbNetDev.Get(1), 2)->SetAttribute("TxPower", DoubleValue(0.0));
267
268 // Link the two FDD BWP:
269 nrHelper->GetBwpManagerGnb(gnbNetDev.Get(1))->SetOutputLink(2, 1);
270
271 // -------------- Third GNB:
272
273 // BWP0, the TDD one
274 nrHelper->GetGnbPhy(gnbNetDev.Get(2), 0)->SetAttribute("Numerology", UintegerValue(2));
275 nrHelper->GetGnbPhy(gnbNetDev.Get(2), 0)
276 ->SetAttribute("Pattern", StringValue("F|F|F|F|F|F|F|F|F|F|"));
277 nrHelper->GetGnbPhy(gnbNetDev.Get(2), 0)->SetAttribute("TxPower", DoubleValue(4.0));
278
279 // BWP1, FDD-DL
280 nrHelper->GetGnbPhy(gnbNetDev.Get(2), 1)->SetAttribute("Numerology", UintegerValue(2));
281 nrHelper->GetGnbPhy(gnbNetDev.Get(2), 1)
282 ->SetAttribute("Pattern", StringValue("DL|DL|DL|DL|DL|DL|DL|DL|DL|DL|"));
283 nrHelper->GetGnbPhy(gnbNetDev.Get(2), 1)->SetAttribute("TxPower", DoubleValue(4.0));
284
285 // BWP2, FDD-UL
286 nrHelper->GetGnbPhy(gnbNetDev.Get(2), 2)->SetAttribute("Numerology", UintegerValue(2));
287 nrHelper->GetGnbPhy(gnbNetDev.Get(2), 2)
288 ->SetAttribute("Pattern", StringValue("UL|UL|UL|UL|UL|UL|UL|UL|UL|UL|"));
289 nrHelper->GetGnbPhy(gnbNetDev.Get(2), 2)->SetAttribute("TxPower", DoubleValue(0.0));
290
291 // Link the two FDD BWP:
292 nrHelper->GetBwpManagerGnb(gnbNetDev.Get(2))->SetOutputLink(2, 1);
293
294 // -------------- Fourth GNB:
295
296 // BWP0, the TDD one
297 nrHelper->GetGnbPhy(gnbNetDev.Get(3), 0)->SetAttribute("Numerology", UintegerValue(3));
298 nrHelper->GetGnbPhy(gnbNetDev.Get(3), 0)
299 ->SetAttribute("Pattern", StringValue("F|F|F|F|F|F|F|F|F|F|"));
300 nrHelper->GetGnbPhy(gnbNetDev.Get(3), 0)->SetAttribute("TxPower", DoubleValue(4.0));
301
302 // BWP1, FDD-DL
303 nrHelper->GetGnbPhy(gnbNetDev.Get(3), 1)->SetAttribute("Numerology", UintegerValue(3));
304 nrHelper->GetGnbPhy(gnbNetDev.Get(3), 1)
305 ->SetAttribute("Pattern", StringValue("DL|DL|DL|DL|DL|DL|DL|DL|DL|DL|"));
306 nrHelper->GetGnbPhy(gnbNetDev.Get(3), 1)->SetAttribute("TxPower", DoubleValue(4.0));
307
308 // BWP2, FDD-UL
309 nrHelper->GetGnbPhy(gnbNetDev.Get(3), 2)->SetAttribute("Numerology", UintegerValue(3));
310 nrHelper->GetGnbPhy(gnbNetDev.Get(3), 2)
311 ->SetAttribute("Pattern", StringValue("UL|UL|UL|UL|UL|UL|UL|UL|UL|UL|"));
312 nrHelper->GetGnbPhy(gnbNetDev.Get(3), 2)->SetAttribute("TxPower", DoubleValue(0.0));
313
314 // Link the two FDD BWP:
315 nrHelper->GetBwpManagerGnb(gnbNetDev.Get(3))->SetOutputLink(2, 1);
316
317 // Set the UE routing:
318
319 for (uint32_t i = 0; i < ueNetDev.GetN(); i++)
320 {
321 nrHelper->GetBwpManagerUe(ueNetDev.Get(i))->SetOutputLink(1, 2);
322 }
323
324 // From here, it is standard NS3. In the future, we will create helpers
325 // for this part as well.
326
327 auto [remoteHost, remoteHostIpv4Address] =
328 nrEpcHelper->SetupRemoteHost("100Gb/s", 2500, Seconds(0.000));
329
330 InternetStackHelper internet;
331
332 internet.Install(gridScenario.GetUserTerminals());
333
334 Ipv4InterfaceContainer ueIpIface =
335 nrEpcHelper->AssignUeIpv4Address(NetDeviceContainer(ueNetDev));
336
337 // Fix the attachment of the UEs: UE_i attached to GNB_i
338 for (uint32_t i = 0; i < ueNetDev.GetN(); ++i)
339 {
340 auto gnbDev = DynamicCast<NrGnbNetDevice>(gnbNetDev.Get(i));
341 auto ueDev = DynamicCast<NrUeNetDevice>(ueNetDev.Get(i));
342 NS_ASSERT(gnbDev != nullptr);
343 NS_ASSERT(ueDev != nullptr);
344 nrHelper->AttachToGnb(ueDev, gnbDev);
345 }
346
347 /*
348 * Traffic part. Install two kind of traffic: low-latency and voice, each
349 * identified by a particular source port.
350 */
351 uint16_t dlPortVideo = 1234;
352 uint16_t dlPortVoice = 1235;
353 uint16_t ulPortGaming = 1236;
354
355 ApplicationContainer serverApps;
356
357 // The sink will always listen to the specified ports
358 UdpServerHelper dlPacketSinkVideo(dlPortVideo);
359 UdpServerHelper dlPacketSinkVoice(dlPortVoice);
360 UdpServerHelper ulPacketSinkVoice(ulPortGaming);
361
362 // The server, that is the application which is listening, is installed in the UE
363 // for the DL traffic, and in the remote host for the UL traffic
364 serverApps.Add(dlPacketSinkVideo.Install(gridScenario.GetUserTerminals()));
365 serverApps.Add(dlPacketSinkVoice.Install(gridScenario.GetUserTerminals()));
366 serverApps.Add(ulPacketSinkVoice.Install(remoteHost));
367
368 /*
369 * Configure attributes for the different generators, using user-provided
370 * parameters for generating a CBR traffic
371 *
372 * Low-Latency configuration and object creation:
373 */
374 UdpClientHelper dlClientVideo;
375 dlClientVideo.SetAttribute("RemotePort", UintegerValue(dlPortVideo));
376 dlClientVideo.SetAttribute("MaxPackets", UintegerValue(0xFFFFFFFF));
377 dlClientVideo.SetAttribute("PacketSize", UintegerValue(udpPacketSizeVideo));
378 dlClientVideo.SetAttribute("Interval", TimeValue(Seconds(1.0 / lambdaVideo)));
379
380 // The bearer that will carry low latency traffic
382
383 // The filter for the low-latency traffic
384 Ptr<NrEpcTft> videoTft = Create<NrEpcTft>();
385 NrEpcTft::PacketFilter dlpfVideo;
386 dlpfVideo.localPortStart = dlPortVideo;
387 dlpfVideo.localPortEnd = dlPortVideo;
388 videoTft->Add(dlpfVideo);
389
390 // Voice configuration and object creation:
391 UdpClientHelper dlClientVoice;
392 dlClientVoice.SetAttribute("RemotePort", UintegerValue(dlPortVoice));
393 dlClientVoice.SetAttribute("MaxPackets", UintegerValue(0xFFFFFFFF));
394 dlClientVoice.SetAttribute("PacketSize", UintegerValue(udpPacketSizeVoice));
395 dlClientVoice.SetAttribute("Interval", TimeValue(Seconds(1.0 / lambdaVoice)));
396
397 // The bearer that will carry voice traffic
399
400 // The filter for the voice traffic
401 Ptr<NrEpcTft> voiceTft = Create<NrEpcTft>();
402 NrEpcTft::PacketFilter dlpfVoice;
403 dlpfVoice.localPortStart = dlPortVoice;
404 dlpfVoice.localPortEnd = dlPortVoice;
405 voiceTft->Add(dlpfVoice);
406
407 // Gaming configuration and object creation:
408 UdpClientHelper ulClientGaming;
409 ulClientGaming.SetAttribute("RemotePort", UintegerValue(ulPortGaming));
410 ulClientGaming.SetAttribute("MaxPackets", UintegerValue(0xFFFFFFFF));
411 ulClientGaming.SetAttribute("PacketSize", UintegerValue(udpPacketSizeGaming));
412 ulClientGaming.SetAttribute("Interval", TimeValue(Seconds(1.0 / lambdaGaming)));
413
414 // The bearer that will carry gaming traffic
416
417 // The filter for the gaming traffic
418 Ptr<NrEpcTft> gamingTft = Create<NrEpcTft>();
419 NrEpcTft::PacketFilter ulpfGaming;
420 ulpfGaming.remotePortStart = ulPortGaming;
421 ulpfGaming.remotePortEnd = ulPortGaming;
422 ulpfGaming.direction = NrEpcTft::UPLINK;
423 gamingTft->Add(ulpfGaming);
424
425 /*
426 * Let's install the applications!
427 */
428 ApplicationContainer clientApps;
429
430 for (uint32_t i = 0; i < gridScenario.GetUserTerminals().GetN(); ++i)
431 {
432 Ptr<Node> ue = gridScenario.GetUserTerminals().Get(i);
433 Ptr<NetDevice> ueDevice = ueNetDev.Get(i);
434 Address ueAddress = ueIpIface.GetAddress(i);
435
436 // The client, who is transmitting, is installed in the remote host,
437 // with destination address set to the address of the UE
438 if (enableVoice)
439 {
440 dlClientVoice.SetAttribute("RemoteAddress", AddressValue(ueAddress));
441 clientApps.Add(dlClientVoice.Install(remoteHost));
442
443 nrHelper->ActivateDedicatedEpsBearer(ueDevice, voiceBearer, voiceTft);
444 }
445
446 if (enableVideo)
447 {
448 dlClientVideo.SetAttribute("RemoteAddress", AddressValue(ueAddress));
449 clientApps.Add(dlClientVideo.Install(remoteHost));
450
451 nrHelper->ActivateDedicatedEpsBearer(ueDevice, videoBearer, videoTft);
452 }
453
454 // For the uplink, the installation happens in the UE, and the remote address
455 // is the one of the remote host
456
457 if (enableGaming)
458 {
459 ulClientGaming.SetAttribute("RemoteAddress", AddressValue(remoteHostIpv4Address));
460 clientApps.Add(ulClientGaming.Install(ue));
461
462 nrHelper->ActivateDedicatedEpsBearer(ueDevice, gamingBearer, gamingTft);
463 }
464 }
465
466 // start UDP server and client apps
467 serverApps.Start(MilliSeconds(udpAppStartTimeMs));
468 clientApps.Start(MilliSeconds(udpAppStartTimeMs));
469 serverApps.Stop(MilliSeconds(simTimeMs));
470 clientApps.Stop(MilliSeconds(simTimeMs));
471
472 // enable the traces provided by the nr module
473 // nrHelper->EnableTraces();
474
475 FlowMonitorHelper flowmonHelper;
476 NodeContainer endpointNodes;
477 endpointNodes.Add(remoteHost);
478 endpointNodes.Add(gridScenario.GetUserTerminals());
479
480 Ptr<ns3::FlowMonitor> monitor = flowmonHelper.Install(endpointNodes);
481 monitor->SetAttribute("DelayBinWidth", DoubleValue(0.001));
482 monitor->SetAttribute("JitterBinWidth", DoubleValue(0.001));
483 monitor->SetAttribute("PacketSizeBinWidth", DoubleValue(20));
484
485 Simulator::Stop(MilliSeconds(simTimeMs));
486 Simulator::Run();
487
488 /*
489 * To check what was installed in the memory, i.e., BWPs of gNB Device, and its configuration.
490 * Example is: Node 1 -> Device 0 -> BandwidthPartMap -> {0,1} BWPs -> NrGnbPhy -> Numerology,
491 GtkConfigStore config;
492 config.ConfigureAttributes ();
493 */
494
495 // Print per-flow statistics
496 monitor->CheckForLostPackets();
497 Ptr<Ipv4FlowClassifier> classifier =
498 DynamicCast<Ipv4FlowClassifier>(flowmonHelper.GetClassifier());
499 FlowMonitor::FlowStatsContainer stats = monitor->GetFlowStats();
500
501 double averageFlowThroughput = 0.0;
502 double averageFlowDelay = 0.0;
503
504 std::ofstream outFile;
505 std::string filename = outputDir + "/" + simTag;
506 outFile.open(filename.c_str(), std::ofstream::out | std::ofstream::trunc);
507 if (!outFile.is_open())
508 {
509 std::cerr << "Can't open file " << filename << std::endl;
510 return 1;
511 }
512
513 outFile.setf(std::ios_base::fixed);
514
515 for (std::map<FlowId, FlowMonitor::FlowStats>::const_iterator i = stats.begin();
516 i != stats.end();
517 ++i)
518 {
519 Ipv4FlowClassifier::FiveTuple t = classifier->FindFlow(i->first);
520 std::stringstream protoStream;
521 protoStream << (uint16_t)t.protocol;
522 if (t.protocol == 6)
523 {
524 protoStream.str("TCP");
525 }
526 if (t.protocol == 17)
527 {
528 protoStream.str("UDP");
529 }
530 outFile << "Flow " << i->first << " (" << t.sourceAddress << ":" << t.sourcePort << " -> "
531 << t.destinationAddress << ":" << t.destinationPort << ") proto "
532 << protoStream.str() << "\n";
533 outFile << " Tx Packets: " << i->second.txPackets << "\n";
534 outFile << " Tx Bytes: " << i->second.txBytes << "\n";
535 outFile << " TxOffered: "
536 << i->second.txBytes * 8.0 / ((simTimeMs - udpAppStartTimeMs) / 1000.0) / 1000.0 /
537 1000.0
538 << " Mbps\n";
539 outFile << " Rx Bytes: " << i->second.rxBytes << "\n";
540 if (i->second.rxPackets > 0)
541 {
542 // Measure the duration of the flow from receiver's perspective
543 // double rxDuration = i->second.timeLastRxPacket.GetSeconds () -
544 // i->second.timeFirstTxPacket.GetSeconds ();
545 double rxDuration = (simTimeMs - udpAppStartTimeMs) / 1000.0;
546
547 averageFlowThroughput += i->second.rxBytes * 8.0 / rxDuration / 1000 / 1000;
548 averageFlowDelay += 1000 * i->second.delaySum.GetSeconds() / i->second.rxPackets;
549
550 outFile << " Throughput: " << i->second.rxBytes * 8.0 / rxDuration / 1000 / 1000
551 << " Mbps\n";
552 outFile << " Mean delay: "
553 << 1000 * i->second.delaySum.GetSeconds() / i->second.rxPackets << " ms\n";
554 // outFile << " Mean upt: " << i->second.uptSum / i->second.rxPackets / 1000/1000 << "
555 // Mbps \n";
556 outFile << " Mean jitter: "
557 << 1000 * i->second.jitterSum.GetSeconds() / i->second.rxPackets << " ms\n";
558 }
559 else
560 {
561 outFile << " Throughput: 0 Mbps\n";
562 outFile << " Mean delay: 0 ms\n";
563 outFile << " Mean jitter: 0 ms\n";
564 }
565 outFile << " Rx Packets: " << i->second.rxPackets << "\n";
566 }
567
568 double meanFlowThroughput = averageFlowThroughput / stats.size();
569 double meanFlowDelay = averageFlowDelay / stats.size();
570 double throughputTolerance = meanFlowThroughput * 0.001;
571
572 outFile << "\n\n Mean flow throughput: " << meanFlowThroughput << "\n";
573 outFile << " Mean flow delay: " << meanFlowDelay << "\n";
574
575 outFile.close();
576
577 std::ifstream f(filename.c_str());
578
579 if (f.is_open())
580 {
581 std::cout << f.rdbuf();
582 }
583
584 Simulator::Destroy();
585
586 // called from examples-to-run.py with all default parameters
587 if (argc == 0 && (meanFlowThroughput < 0.709696 - throughputTolerance ||
588 meanFlowThroughput > 0.709696 + throughputTolerance))
589 {
590 return EXIT_FAILURE;
591 }
592 else
593 {
594 return EXIT_SUCCESS;
595 }
596}
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.
The GridScenarioHelper class.
void SetRows(uint32_t r)
SetRows.
void SetHorizontalBsDistance(double d)
SetHorizontalBsDistance.
void CreateScenario() override
Create the scenario, with the configured parameter.
int64_t AssignStreams(int64_t stream)
void SetColumns(uint32_t c)
SetColumns.
const NodeContainer & GetUserTerminals() const
Get the list of user nodes.
void SetBsNumber(std::size_t n)
Set the number of base stations.
void SetUtNumber(std::size_t n)
Set the number of UT/UE.
const NodeContainer & GetBaseStations() const
Get the list of gnb/base station nodes.
This class contains the specification of EPS Bearers.
@ GBR_CONV_VOICE
GBR Conversational Voice.
@ GBR_GAMING
GBR Real Time Gaming.
@ GBR_CONV_VIDEO
GBR Conversational Video (Live streaming)
void SetBsHeight(double h)
SetGnbHeight.
void SetUtHeight(double h)
SetUeHeight.
void SetSectorization(SiteSectorizationType numSectors)
Sets the number of sectors of every site.
std::vector< std::reference_wrapper< BandwidthPartInfoPtr > > BandwidthPartInfoPtrVector
vector of unique_ptr of BandwidthPartInfo
Minimum configuration requirements for a OperationBand.
Direction direction
Whether the filter needs to be applied to uplink / downlink only, or in both cases.
Definition nr-epc-tft.h:104
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.