A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
wifi-eht-network.cc
Go to the documentation of this file.
1/*
2 * Copyright (c) 2022
3 *
4 * SPDX-License-Identifier: GPL-2.0-only
5 *
6 * Author: Sebastien Deronne <sebastien.deronne@gmail.com>
7 */
8
9#include "ns3/boolean.h"
10#include "ns3/command-line.h"
11#include "ns3/config.h"
12#include "ns3/double.h"
13#include "ns3/eht-phy.h"
14#include "ns3/enum.h"
15#include "ns3/internet-stack-helper.h"
16#include "ns3/ipv4-address-helper.h"
17#include "ns3/log.h"
18#include "ns3/mobility-helper.h"
19#include "ns3/multi-model-spectrum-channel.h"
20#include "ns3/on-off-helper.h"
21#include "ns3/packet-sink-helper.h"
22#include "ns3/packet-sink.h"
23#include "ns3/spectrum-wifi-helper.h"
24#include "ns3/ssid.h"
25#include "ns3/string.h"
26#include "ns3/udp-client-server-helper.h"
27#include "ns3/udp-server.h"
28#include "ns3/uinteger.h"
29#include "ns3/wifi-acknowledgment.h"
30#include "ns3/yans-wifi-channel.h"
31#include "ns3/yans-wifi-helper.h"
32
33#include <array>
34#include <functional>
35#include <numeric>
36
37// This is a simple example in order to show how to configure an IEEE 802.11be Wi-Fi network.
38//
39// It outputs the UDP or TCP goodput for every EHT MCS value, which depends on the MCS value (0 to
40// 13), the channel width (20, 40, 80 or 160 MHz) and the guard interval (800ns, 1600ns or 3200ns).
41// The PHY bitrate is constant over all the simulation run. The user can also specify the distance
42// between the access point and the station: the larger the distance the smaller the goodput.
43//
44// The simulation assumes a configurable number of stations in an infrastructure network:
45//
46// STA AP
47// * *
48// | |
49// n1 n2
50//
51// Packets in this simulation belong to BestEffort Access Class (AC_BE).
52// By selecting an acknowledgment sequence for DL MU PPDUs, it is possible to aggregate a
53// Round Robin scheduler to the AP, so that DL MU PPDUs are sent by the AP via DL OFDMA.
54
55using namespace ns3;
56
57NS_LOG_COMPONENT_DEFINE("eht-wifi-network");
58
59/**
60 * \param udp true if UDP is used, false if TCP is used
61 * \param serverApp a container of server applications
62 * \param payloadSize the size in bytes of the packets
63 * \return the bytes received by each server application
64 */
65std::vector<uint64_t>
66GetRxBytes(bool udp, const ApplicationContainer& serverApp, uint32_t payloadSize)
67{
68 std::vector<uint64_t> rxBytes(serverApp.GetN(), 0);
69 if (udp)
70 {
71 for (uint32_t i = 0; i < serverApp.GetN(); i++)
72 {
73 rxBytes[i] = payloadSize * DynamicCast<UdpServer>(serverApp.Get(i))->GetReceived();
74 }
75 }
76 else
77 {
78 for (uint32_t i = 0; i < serverApp.GetN(); i++)
79 {
80 rxBytes[i] = DynamicCast<PacketSink>(serverApp.Get(i))->GetTotalRx();
81 }
82 }
83 return rxBytes;
84}
85
86/**
87 * Print average throughput over an intermediate time interval.
88 * \param rxBytes a vector of the amount of bytes received by each server application
89 * \param udp true if UDP is used, false if TCP is used
90 * \param serverApp a container of server applications
91 * \param payloadSize the size in bytes of the packets
92 * \param tputInterval the duration of an intermediate time interval
93 * \param simulationTime the simulation time in seconds
94 */
95void
96PrintIntermediateTput(std::vector<uint64_t>& rxBytes,
97 bool udp,
98 const ApplicationContainer& serverApp,
99 uint32_t payloadSize,
100 Time tputInterval,
101 Time simulationTime)
102{
103 auto newRxBytes = GetRxBytes(udp, serverApp, payloadSize);
104 Time now = Simulator::Now();
105
106 std::cout << "[" << (now - tputInterval).As(Time::S) << " - " << now.As(Time::S)
107 << "] Per-STA Throughput (Mbit/s):";
108
109 for (std::size_t i = 0; i < newRxBytes.size(); i++)
110 {
111 std::cout << "\t\t(" << i << ") "
112 << (newRxBytes[i] - rxBytes[i]) * 8. / tputInterval.GetMicroSeconds(); // Mbit/s
113 }
114 std::cout << std::endl;
115
116 rxBytes.swap(newRxBytes);
117
118 if (now < (simulationTime - NanoSeconds(1)))
119 {
120 Simulator::Schedule(Min(tputInterval, simulationTime - now - NanoSeconds(1)),
122 rxBytes,
123 udp,
124 serverApp,
125 payloadSize,
126 tputInterval,
127 simulationTime);
128 }
129}
130
131int
132main(int argc, char* argv[])
133{
134 bool udp{true};
135 bool downlink{true};
136 bool useRts{false};
137 bool use80Plus80{false};
138 uint16_t mpduBufferSize{512};
139 std::string emlsrLinks;
140 uint16_t paddingDelayUsec{32};
141 uint16_t transitionDelayUsec{128};
142 uint16_t channelSwitchDelayUsec{100};
143 bool switchAuxPhy{true};
144 uint16_t auxPhyChWidth{20};
145 bool auxPhyTxCapable{true};
146 Time simulationTime{"10s"};
147 meter_u distance{1.0};
148 double frequency{5}; // whether the first link operates in the 2.4, 5 or 6 GHz
149 double frequency2{0}; // whether the second link operates in the 2.4, 5 or 6 GHz (0 means no
150 // second link exists)
151 double frequency3{
152 0}; // whether the third link operates in the 2.4, 5 or 6 GHz (0 means no third link exists)
153 std::size_t nStations{1};
154 std::string dlAckSeqType{"NO-OFDMA"};
155 bool enableUlOfdma{false};
156 bool enableBsrp{false};
157 int mcs{-1}; // -1 indicates an unset value
158 uint32_t payloadSize =
159 700; // must fit in the max TX duration when transmitting at MCS 0 over an RU of 26 tones
160 Time tputInterval{0}; // interval for detailed throughput measurement
161 double minExpectedThroughput{0};
162 double maxExpectedThroughput{0};
163 Time accessReqInterval{0};
164
165 CommandLine cmd(__FILE__);
166 cmd.AddValue(
167 "frequency",
168 "Whether the first link operates in the 2.4, 5 or 6 GHz band (other values gets rejected)",
169 frequency);
170 cmd.AddValue(
171 "frequency2",
172 "Whether the second link operates in the 2.4, 5 or 6 GHz band (0 means the device has one "
173 "link, otherwise the band must be different than first link and third link)",
174 frequency2);
175 cmd.AddValue(
176 "frequency3",
177 "Whether the third link operates in the 2.4, 5 or 6 GHz band (0 means the device has up to "
178 "two links, otherwise the band must be different than first link and second link)",
179 frequency3);
180 cmd.AddValue("emlsrLinks",
181 "The comma separated list of IDs of EMLSR links (for MLDs only)",
182 emlsrLinks);
183 cmd.AddValue("emlsrPaddingDelay",
184 "The EMLSR padding delay in microseconds (0, 32, 64, 128 or 256)",
185 paddingDelayUsec);
186 cmd.AddValue("emlsrTransitionDelay",
187 "The EMLSR transition delay in microseconds (0, 16, 32, 64, 128 or 256)",
188 transitionDelayUsec);
189 cmd.AddValue("emlsrAuxSwitch",
190 "Whether Aux PHY should switch channel to operate on the link on which "
191 "the Main PHY was operating before moving to the link of the Aux PHY. ",
192 switchAuxPhy);
193 cmd.AddValue("emlsrAuxChWidth",
194 "The maximum channel width (MHz) supported by Aux PHYs.",
195 auxPhyChWidth);
196 cmd.AddValue("emlsrAuxTxCapable",
197 "Whether Aux PHYs are capable of transmitting.",
198 auxPhyTxCapable);
199 cmd.AddValue("channelSwitchDelay",
200 "The PHY channel switch delay in microseconds",
201 channelSwitchDelayUsec);
202 cmd.AddValue("distance",
203 "Distance in meters between the station and the access point",
204 distance);
205 cmd.AddValue("simulationTime", "Simulation time", simulationTime);
206 cmd.AddValue("udp", "UDP if set to 1, TCP otherwise", udp);
207 cmd.AddValue("downlink",
208 "Generate downlink flows if set to 1, uplink flows otherwise",
209 downlink);
210 cmd.AddValue("useRts", "Enable/disable RTS/CTS", useRts);
211 cmd.AddValue("use80Plus80", "Enable/disable use of 80+80 MHz", use80Plus80);
212 cmd.AddValue("mpduBufferSize",
213 "Size (in number of MPDUs) of the BlockAck buffer",
214 mpduBufferSize);
215 cmd.AddValue("nStations", "Number of non-AP EHT stations", nStations);
216 cmd.AddValue("dlAckType",
217 "Ack sequence type for DL OFDMA (NO-OFDMA, ACK-SU-FORMAT, MU-BAR, AGGR-MU-BAR)",
218 dlAckSeqType);
219 cmd.AddValue("enableUlOfdma",
220 "Enable UL OFDMA (useful if DL OFDMA is enabled and TCP is used)",
221 enableUlOfdma);
222 cmd.AddValue("enableBsrp",
223 "Enable BSRP (useful if DL and UL OFDMA are enabled and TCP is used)",
224 enableBsrp);
225 cmd.AddValue(
226 "muSchedAccessReqInterval",
227 "Duration of the interval between two requests for channel access made by the MU scheduler",
228 accessReqInterval);
229 cmd.AddValue("mcs", "if set, limit testing to a specific MCS (0-11)", mcs);
230 cmd.AddValue("payloadSize", "The application payload size in bytes", payloadSize);
231 cmd.AddValue("tputInterval", "duration of intervals for throughput measurement", tputInterval);
232 cmd.AddValue("minExpectedThroughput",
233 "if set, simulation fails if the lowest throughput is below this value",
234 minExpectedThroughput);
235 cmd.AddValue("maxExpectedThroughput",
236 "if set, simulation fails if the highest throughput is above this value",
237 maxExpectedThroughput);
238 cmd.Parse(argc, argv);
239
240 if (useRts)
241 {
242 Config::SetDefault("ns3::WifiRemoteStationManager::RtsCtsThreshold", StringValue("0"));
243 Config::SetDefault("ns3::WifiDefaultProtectionManager::EnableMuRts", BooleanValue(true));
244 }
245
246 if (dlAckSeqType == "ACK-SU-FORMAT")
247 {
248 Config::SetDefault("ns3::WifiDefaultAckManager::DlMuAckSequenceType",
250 }
251 else if (dlAckSeqType == "MU-BAR")
252 {
253 Config::SetDefault("ns3::WifiDefaultAckManager::DlMuAckSequenceType",
255 }
256 else if (dlAckSeqType == "AGGR-MU-BAR")
257 {
258 Config::SetDefault("ns3::WifiDefaultAckManager::DlMuAckSequenceType",
260 }
261 else if (dlAckSeqType != "NO-OFDMA")
262 {
263 NS_ABORT_MSG("Invalid DL ack sequence type (must be NO-OFDMA, ACK-SU-FORMAT, MU-BAR or "
264 "AGGR-MU-BAR)");
265 }
266
267 double prevThroughput[12] = {0};
268
269 std::cout << "MCS value"
270 << "\t\t"
271 << "Channel width"
272 << "\t\t"
273 << "GI"
274 << "\t\t\t"
275 << "Throughput" << '\n';
276 int minMcs = 0;
277 int maxMcs = 13;
278 if (mcs >= 0 && mcs <= 13)
279 {
280 minMcs = mcs;
281 maxMcs = mcs;
282 }
283 for (int mcs = minMcs; mcs <= maxMcs; mcs++)
284 {
285 uint8_t index = 0;
286 double previous = 0;
287 uint16_t maxChannelWidth =
288 (frequency != 2.4 && frequency2 != 2.4 && frequency3 != 2.4) ? 160 : 40;
289 int minGi = enableUlOfdma ? 1600 : 800;
290 for (int channelWidth = 20; channelWidth <= maxChannelWidth;) // MHz
291 {
292 const auto is80Plus80 = (use80Plus80 && (channelWidth == 160));
293 const std::string widthStr = is80Plus80 ? "80+80" : std::to_string(channelWidth);
294 const auto segmentWidthStr = is80Plus80 ? "80" : widthStr;
295 for (int gi = 3200; gi >= minGi;) // Nanoseconds
296 {
297 if (!udp)
298 {
299 Config::SetDefault("ns3::TcpSocket::SegmentSize", UintegerValue(payloadSize));
300 }
301
303 wifiStaNodes.Create(nStations);
305 wifiApNode.Create(1);
306
307 NetDeviceContainer apDevice;
311
312 wifi.SetStandard(WIFI_STANDARD_80211be);
313 std::array<std::string, 3> channelStr;
314 std::array<FrequencyRange, 3> freqRanges;
315 uint8_t nLinks = 0;
316 std::string dataModeStr = "EhtMcs" + std::to_string(mcs);
317 std::string ctrlRateStr;
318 uint64_t nonHtRefRateMbps = EhtPhy::GetNonHtReferenceRate(mcs) / 1e6;
319
320 if (frequency2 == frequency || frequency3 == frequency ||
321 (frequency3 != 0 && frequency3 == frequency2))
322 {
323 NS_FATAL_ERROR("Frequency values must be unique!");
324 }
325
326 for (auto freq : {frequency, frequency2, frequency3})
327 {
328 if (nLinks > 0 && freq == 0)
329 {
330 break;
331 }
332 channelStr[nLinks] = "{0, " + segmentWidthStr + ", ";
333 if (freq == 6)
334 {
335 channelStr[nLinks] += "BAND_6GHZ, 0}";
336 freqRanges[nLinks] = WIFI_SPECTRUM_6_GHZ;
337 Config::SetDefault("ns3::LogDistancePropagationLossModel::ReferenceLoss",
338 DoubleValue(48));
339 wifi.SetRemoteStationManager(nLinks,
340 "ns3::ConstantRateWifiManager",
341 "DataMode",
342 StringValue(dataModeStr),
343 "ControlMode",
344 StringValue(dataModeStr));
345 }
346 else if (freq == 5)
347 {
348 channelStr[nLinks] += "BAND_5GHZ, 0}";
349 freqRanges[nLinks] = WIFI_SPECTRUM_5_GHZ;
350 ctrlRateStr = "OfdmRate" + std::to_string(nonHtRefRateMbps) + "Mbps";
351 wifi.SetRemoteStationManager(nLinks,
352 "ns3::ConstantRateWifiManager",
353 "DataMode",
354 StringValue(dataModeStr),
355 "ControlMode",
356 StringValue(ctrlRateStr));
357 }
358 else if (freq == 2.4)
359 {
360 channelStr[nLinks] += "BAND_2_4GHZ, 0}";
361 freqRanges[nLinks] = WIFI_SPECTRUM_2_4_GHZ;
362 Config::SetDefault("ns3::LogDistancePropagationLossModel::ReferenceLoss",
363 DoubleValue(40));
364 ctrlRateStr = "ErpOfdmRate" + std::to_string(nonHtRefRateMbps) + "Mbps";
365 wifi.SetRemoteStationManager(nLinks,
366 "ns3::ConstantRateWifiManager",
367 "DataMode",
368 StringValue(dataModeStr),
369 "ControlMode",
370 StringValue(ctrlRateStr));
371 }
372 else
373 {
374 NS_FATAL_ERROR("Wrong frequency value!");
375 }
376
377 if (is80Plus80)
378 {
379 channelStr[nLinks] += std::string(";") + channelStr[nLinks];
380 }
381
382 nLinks++;
383 }
384
385 if (nLinks > 1 && !emlsrLinks.empty())
386 {
387 wifi.ConfigEhtOptions("EmlsrActivated", BooleanValue(true));
388 }
389
390 Ssid ssid = Ssid("ns3-80211be");
391
393 phy.SetPcapDataLinkType(WifiPhyHelper::DLT_IEEE802_11_RADIO);
394 phy.Set("ChannelSwitchDelay", TimeValue(MicroSeconds(channelSwitchDelayUsec)));
395
396 mac.SetType("ns3::StaWifiMac", "Ssid", SsidValue(ssid));
397 mac.SetEmlsrManager("ns3::DefaultEmlsrManager",
398 "EmlsrLinkSet",
399 StringValue(emlsrLinks),
400 "EmlsrPaddingDelay",
401 TimeValue(MicroSeconds(paddingDelayUsec)),
402 "EmlsrTransitionDelay",
403 TimeValue(MicroSeconds(transitionDelayUsec)),
404 "SwitchAuxPhy",
405 BooleanValue(switchAuxPhy),
406 "AuxPhyTxCapable",
407 BooleanValue(auxPhyTxCapable),
408 "AuxPhyChannelWidth",
409 UintegerValue(auxPhyChWidth));
410 for (uint8_t linkId = 0; linkId < nLinks; linkId++)
411 {
412 phy.Set(linkId, "ChannelSettings", StringValue(channelStr[linkId]));
413
414 auto spectrumChannel = CreateObject<MultiModelSpectrumChannel>();
416 spectrumChannel->AddPropagationLossModel(lossModel);
417 phy.AddChannel(spectrumChannel, freqRanges[linkId]);
418 }
419 staDevices = wifi.Install(phy, mac, wifiStaNodes);
420
421 if (dlAckSeqType != "NO-OFDMA")
422 {
423 mac.SetMultiUserScheduler("ns3::RrMultiUserScheduler",
424 "EnableUlOfdma",
425 BooleanValue(enableUlOfdma),
426 "EnableBsrp",
427 BooleanValue(enableBsrp),
428 "AccessReqInterval",
429 TimeValue(accessReqInterval));
430 }
431 mac.SetType("ns3::ApWifiMac",
432 "EnableBeaconJitter",
433 BooleanValue(false),
434 "Ssid",
435 SsidValue(ssid));
436 apDevice = wifi.Install(phy, mac, wifiApNode);
437
438 int64_t streamNumber = 100;
439 streamNumber += WifiHelper::AssignStreams(apDevice, streamNumber);
440 streamNumber += WifiHelper::AssignStreams(staDevices, streamNumber);
441
442 // Set guard interval and MPDU buffer size
444 "/NodeList/*/DeviceList/*/$ns3::WifiNetDevice/HeConfiguration/GuardInterval",
446 Config::Set("/NodeList/*/DeviceList/*/$ns3::WifiNetDevice/Mac/MpduBufferSize",
447 UintegerValue(mpduBufferSize));
448
449 // mobility.
452
453 positionAlloc->Add(Vector(0.0, 0.0, 0.0));
454 positionAlloc->Add(Vector(distance, 0.0, 0.0));
455 mobility.SetPositionAllocator(positionAlloc);
456
457 mobility.SetMobilityModel("ns3::ConstantPositionMobilityModel");
458
459 mobility.Install(wifiApNode);
460 mobility.Install(wifiStaNodes);
461
462 /* Internet stack*/
464 stack.Install(wifiApNode);
465 stack.Install(wifiStaNodes);
466 streamNumber += stack.AssignStreams(wifiApNode, streamNumber);
467 streamNumber += stack.AssignStreams(wifiStaNodes, streamNumber);
468
470 address.SetBase("192.168.1.0", "255.255.255.0");
471 Ipv4InterfaceContainer staNodeInterfaces;
472 Ipv4InterfaceContainer apNodeInterface;
473
474 staNodeInterfaces = address.Assign(staDevices);
475 apNodeInterface = address.Assign(apDevice);
476
477 /* Setting applications */
478 ApplicationContainer serverApp;
479 auto serverNodes = downlink ? std::ref(wifiStaNodes) : std::ref(wifiApNode);
481 NodeContainer clientNodes;
482 for (std::size_t i = 0; i < nStations; i++)
483 {
484 serverInterfaces.Add(downlink ? staNodeInterfaces.Get(i)
485 : apNodeInterface.Get(0));
486 clientNodes.Add(downlink ? wifiApNode.Get(0) : wifiStaNodes.Get(i));
487 }
488
489 const auto maxLoad =
490 nLinks * EhtPhy::GetDataRate(mcs, channelWidth, NanoSeconds(gi), 1) / nStations;
491 if (udp)
492 {
493 // UDP flow
494 uint16_t port = 9;
496 serverApp = server.Install(serverNodes.get());
497 streamNumber += server.AssignStreams(serverNodes.get(), streamNumber);
498
499 serverApp.Start(Seconds(0.0));
500 serverApp.Stop(simulationTime + Seconds(1.0));
501 const auto packetInterval = payloadSize * 8.0 / maxLoad;
502
503 for (std::size_t i = 0; i < nStations; i++)
504 {
506 client.SetAttribute("MaxPackets", UintegerValue(4294967295U));
507 client.SetAttribute("Interval", TimeValue(Seconds(packetInterval)));
508 client.SetAttribute("PacketSize", UintegerValue(payloadSize));
509 ApplicationContainer clientApp = client.Install(clientNodes.Get(i));
510 streamNumber += client.AssignStreams(clientNodes.Get(i), streamNumber);
511
512 clientApp.Start(Seconds(1.0));
513 clientApp.Stop(simulationTime + Seconds(1.0));
514 }
515 }
516 else
517 {
518 // TCP flow
519 uint16_t port = 50000;
521 PacketSinkHelper packetSinkHelper("ns3::TcpSocketFactory", localAddress);
522 serverApp = packetSinkHelper.Install(serverNodes.get());
523 streamNumber += packetSinkHelper.AssignStreams(serverNodes.get(), streamNumber);
524
525 serverApp.Start(Seconds(0.0));
526 serverApp.Stop(simulationTime + Seconds(1.0));
527
528 for (std::size_t i = 0; i < nStations; i++)
529 {
530 OnOffHelper onoff("ns3::TcpSocketFactory", Ipv4Address::GetAny());
531 onoff.SetAttribute("OnTime",
532 StringValue("ns3::ConstantRandomVariable[Constant=1]"));
533 onoff.SetAttribute("OffTime",
534 StringValue("ns3::ConstantRandomVariable[Constant=0]"));
535 onoff.SetAttribute("PacketSize", UintegerValue(payloadSize));
536 onoff.SetAttribute("DataRate", DataRateValue(maxLoad));
538 InetSocketAddress(serverInterfaces.GetAddress(i), port));
539 onoff.SetAttribute("Remote", remoteAddress);
540 ApplicationContainer clientApp = onoff.Install(clientNodes.Get(i));
541 streamNumber += onoff.AssignStreams(clientNodes.Get(i), streamNumber);
542
543 clientApp.Start(Seconds(1.0));
544 clientApp.Stop(simulationTime + Seconds(1.0));
545 }
546 }
547
548 // cumulative number of bytes received by each server application
549 std::vector<uint64_t> cumulRxBytes(nStations, 0);
550
551 if (tputInterval.IsStrictlyPositive())
552 {
553 Simulator::Schedule(Seconds(1) + tputInterval,
555 cumulRxBytes,
556 udp,
557 serverApp,
558 payloadSize,
559 tputInterval,
560 simulationTime + Seconds(1.0));
561 }
562
563 Simulator::Stop(simulationTime + Seconds(1.0));
565
566 // When multiple stations are used, there are chances that association requests
567 // collide and hence the throughput may be lower than expected. Therefore, we relax
568 // the check that the throughput cannot decrease by introducing a scaling factor (or
569 // tolerance)
570 auto tolerance = 0.10;
571 cumulRxBytes = GetRxBytes(udp, serverApp, payloadSize);
572 auto rxBytes = std::accumulate(cumulRxBytes.cbegin(), cumulRxBytes.cend(), 0.0);
573 auto throughput = (rxBytes * 8) / simulationTime.GetMicroSeconds(); // Mbit/s
574
576
577 std::cout << +mcs << "\t\t\t" << widthStr << " MHz\t\t"
578 << (widthStr.size() > 3 ? "" : "\t") << gi << " ns\t\t\t" << throughput
579 << " Mbit/s" << std::endl;
580
581 // test first element
582 if (mcs == minMcs && channelWidth == 20 && gi == 3200)
583 {
584 if (throughput * (1 + tolerance) < minExpectedThroughput)
585 {
586 NS_LOG_ERROR("Obtained throughput " << throughput << " is not expected!");
587 exit(1);
588 }
589 }
590 // test last element
591 if (mcs == maxMcs && channelWidth == maxChannelWidth && gi == 800)
592 {
593 if (maxExpectedThroughput > 0 &&
594 throughput > maxExpectedThroughput * (1 + tolerance))
595 {
596 NS_LOG_ERROR("Obtained throughput " << throughput << " is not expected!");
597 exit(1);
598 }
599 }
600 // test previous throughput is smaller (for the same mcs)
601 if (throughput * (1 + tolerance) > previous)
602 {
603 previous = throughput;
604 }
605 else if (throughput > 0)
606 {
607 NS_LOG_ERROR("Obtained throughput " << throughput << " is not expected!");
608 exit(1);
609 }
610 // test previous throughput is smaller (for the same channel width and GI)
611 if (throughput * (1 + tolerance) > prevThroughput[index])
612 {
613 prevThroughput[index] = throughput;
614 }
615 else if (throughput > 0)
616 {
617 NS_LOG_ERROR("Obtained throughput " << throughput << " is not expected!");
618 exit(1);
619 }
620 index++;
621 gi /= 2;
622 }
623 channelWidth *= 2;
624 }
625 }
626 return 0;
627}
#define Min(a, b)
a polymophic address class
Definition address.h:90
holds a vector of ns3::Application pointers.
void Start(Time start) const
Start all of the Applications in this container at the start time given as a parameter.
Ptr< Application > Get(uint32_t i) const
Get the Ptr<Application> stored in this container at a given index.
void Stop(Time stop) const
Arrange for all of the Applications in this container to Stop() at the Time given as a parameter.
uint32_t GetN() const
Get the number of Ptr<Application> stored in this container.
Parse command-line arguments.
This class can be used to hold variables of floating point type such as 'double' or 'float'.
Definition double.h:31
static uint64_t GetDataRate(uint8_t mcsValue, MHz_u channelWidth, Time guardInterval, uint8_t nss)
Return the data rate corresponding to the supplied EHT MCS index, channel width, guard interval,...
Definition eht-phy.cc:365
static uint64_t GetNonHtReferenceRate(uint8_t mcsValue)
Calculate the rate in bps of the non-HT Reference Rate corresponding to the supplied HE MCS index.
Definition eht-phy.cc:378
Hold variables of type enum.
Definition enum.h:52
an Inet address class
aggregate IP/TCP/UDP functionality to existing Nodes.
A helper class to make life easier while doing simple IPv4 address assignment in scripts.
static Ipv4Address GetAny()
holds a vector of std::pair of Ptr<Ipv4> and interface index.
std::pair< Ptr< Ipv4 >, uint32_t > Get(uint32_t i) const
Get the std::pair of an Ptr<Ipv4> and interface stored at the location specified by the index.
Helper class used to assign positions and mobility models to nodes.
holds a vector of ns3::NetDevice pointers
keep track of a set of node pointers.
void Add(const NodeContainer &nc)
Append the contents of another NodeContainer to the end of this container.
Ptr< Node > Get(uint32_t i) const
Get the Ptr<Node> stored in this container at a given index.
A helper to make it easier to instantiate an ns3::OnOffApplication on a set of nodes.
A helper to make it easier to instantiate an ns3::PacketSinkApplication on a set of nodes.
Smart pointer class similar to boost::intrusive_ptr.
static EventId Schedule(const Time &delay, FUNC f, Ts &&... args)
Schedule an event to expire after delay.
Definition simulator.h:560
static void Destroy()
Execute the events scheduled with ScheduleDestroy().
Definition simulator.cc:131
static Time Now()
Return the current simulation virtual time.
Definition simulator.cc:197
static void Run()
Run the simulation.
Definition simulator.cc:167
static void Stop()
Tell the Simulator the calling event should be the last one executed.
Definition simulator.cc:175
Make it easy to create and manage PHY objects for the spectrum model.
The IEEE 802.11 SSID Information Element.
Definition ssid.h:25
Hold variables of type string.
Definition string.h:45
Simulation virtual time values and global simulation resolution.
Definition nstime.h:94
TimeWithUnit As(const Unit unit=Time::AUTO) const
Attach a unit to a Time, to facilitate output in a specific unit.
Definition time.cc:404
@ S
second
Definition nstime.h:105
int64_t GetMicroSeconds() const
Get an approximation of the time stored in this instance in the indicated unit.
Definition nstime.h:402
Create a client application which sends UDP packets carrying a 32bit sequence number and a 64 bit tim...
Create a server application which waits for input UDP packets and uses the information carried into t...
Hold an unsigned integer type.
Definition uinteger.h:34
helps to create WifiNetDevice objects
static int64_t AssignStreams(NetDeviceContainer c, int64_t stream)
Assign a fixed random variable stream number to the random variables used by the PHY and MAC aspects ...
create MAC layers for a ns3::WifiNetDevice.
@ DLT_IEEE802_11_RADIO
Include Radiotap link layer information.
uint16_t port
Definition dsdv-manet.cc:33
void SetDefault(std::string name, const AttributeValue &value)
Definition config.cc:883
void Set(std::string path, const AttributeValue &value)
Definition config.cc:869
#define NS_FATAL_ERROR(msg)
Report a fatal error with a message and terminate.
#define NS_ABORT_MSG(msg)
Unconditional abnormal program termination with a message.
Definition abort.h:38
#define NS_LOG_ERROR(msg)
Use NS_LOG to output a message of level LOG_ERROR.
Definition log.h:243
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition log.h:191
Ptr< T > CreateObject(Args &&... args)
Create an object by type, with varying number of constructor parameters.
Definition object.h:619
Time MicroSeconds(uint64_t value)
Construct a Time in the indicated unit.
Definition nstime.h:1332
Time NanoSeconds(uint64_t value)
Construct a Time in the indicated unit.
Definition nstime.h:1344
Time Seconds(double value)
Construct a Time in the indicated unit.
Definition nstime.h:1308
@ WIFI_STANDARD_80211be
address
Definition first.py:36
stack
Definition first.py:33
Every class exported by the ns3 library is enclosed in the ns3 namespace.
constexpr FrequencyRange WIFI_SPECTRUM_6_GHZ
Identifier for the frequency range covering the wifi spectrum in the 6 GHz band.
Ptr< T1 > DynamicCast(const Ptr< T2 > &p)
Cast a Ptr.
Definition ptr.h:580
constexpr FrequencyRange WIFI_SPECTRUM_5_GHZ
Identifier for the frequency range covering the wifi spectrum in the 5 GHz band.
constexpr FrequencyRange WIFI_SPECTRUM_2_4_GHZ
Identifier for the frequency range covering the wifi spectrum in the 2.4 GHz band.
STL namespace.
staDevices
Definition third.py:87
ssid
Definition third.py:82
mac
Definition third.py:81
wifi
Definition third.py:84
wifiApNode
Definition third.py:75
mobility
Definition third.py:92
wifiStaNodes
Definition third.py:73
phy
Definition third.py:78
std::ofstream throughput
void PrintIntermediateTput(std::vector< uint64_t > &rxBytes, bool udp, const ApplicationContainer &serverApp, uint32_t payloadSize, Time tputInterval, Time simulationTime)
Print average throughput over an intermediate time interval.
std::vector< uint64_t > GetRxBytes(bool udp, const ApplicationContainer &serverApp, uint32_t payloadSize)