A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
wifi-bianchi.cc
Go to the documentation of this file.
1/*
2 * Copyright (c) 2012 The Boeing Company
3 *
4 * SPDX-License-Identifier: GPL-2.0-only
5 *
6 * Author: Gary Pei <guangyu.pei@boeing.com>
7 *
8 * Updated by Tom Henderson, Rohan Patidar, Hao Yin and Sébastien Deronne
9 */
10
11// This program conducts a Bianchi analysis of a wifi network.
12// Bianchi analysis involves saturating the network and observing how
13// the maximum achievable throughput is governed by the DCF or ECDA
14// channel access mechanisms. This program offers many configurable
15// options, traces, and a validation option; the main output is a Gnuplot
16// plot file plotting throughput vs. number of nodes.
17
18#include "ns3/ampdu-subframe-header.h"
19#include "ns3/application-container.h"
20#include "ns3/boolean.h"
21#include "ns3/command-line.h"
22#include "ns3/config.h"
23#include "ns3/double.h"
24#include "ns3/gnuplot.h"
25#include "ns3/integer.h"
26#include "ns3/log.h"
27#include "ns3/mobility-helper.h"
28#include "ns3/node-list.h"
29#include "ns3/packet-socket-client.h"
30#include "ns3/packet-socket-helper.h"
31#include "ns3/packet-socket-server.h"
32#include "ns3/propagation-delay-model.h"
33#include "ns3/propagation-loss-model.h"
34#include "ns3/queue-size.h"
35#include "ns3/ssid.h"
36#include "ns3/string.h"
37#include "ns3/uinteger.h"
38#include "ns3/wifi-mac-header.h"
39#include "ns3/wifi-mac.h"
40#include "ns3/wifi-net-device.h"
41#include "ns3/wifi-phy-rx-trace-helper.h"
42#include "ns3/wifi-tx-stats-helper.h"
43#include "ns3/yans-wifi-helper.h"
44
45#include <fstream>
46#include <iomanip>
47#include <numbers>
48#include <vector>
49
50/**
51 * @file
52 * Example comparing ns-3 to the Bianchi model.
53 *
54 * See the Wi-Fi Module documentation in the Models chapter.
55 */
56
57NS_LOG_COMPONENT_DEFINE("WifiBianchi");
58
59using namespace ns3;
60
61/** Unnamed namespace, to disambiguate class Experiment. */
62namespace
63{
64
65std::ofstream cwTraceFile; ///< File that traces CW over time
66std::ofstream backoffTraceFile; ///< File that traces backoff over time
67std::ofstream phyTxTraceFile; ///< File that traces PHY transmissions over time
68std::ofstream macTxTraceFile; ///< File that traces MAC transmissions over time
69std::ofstream macRxTraceFile; ///< File that traces MAC receptions over time
70std::ofstream
71 socketSendTraceFile; ///< File that traces packets transmitted by the application over time
72
73std::map<Mac48Address, uint64_t> packetsReceived; ///< Map that stores the total packets received
74 ///< per STA (and addressed to that STA)
75std::map<Mac48Address, uint64_t>
76 bytesReceived; ///< Map that stores the total bytes received per STA (and addressed to that STA)
77std::map<Mac48Address, uint64_t>
78 packetsTransmitted; ///< Map that stores the total packets transmitted per STA
79std::map<Mac48Address, uint64_t>
80 psduFailed; ///< Map that stores the total number of unsuccessfully received PSDUS (for which
81 ///< the PHY header was successfully received) per STA (including PSDUs not
82 ///< addressed to that STA)
83std::map<Mac48Address, uint64_t>
84 psduSucceeded; ///< Map that stores the total number of successfully received PSDUs per STA
85 ///< (including PSDUs not addressed to that STA)
86std::map<Mac48Address, uint64_t> phyHeaderFailed; ///< Map that stores the total number of
87 ///< unsuccessfully received PHY headers per STA
88std::map<Mac48Address, uint64_t>
89 rxEventWhileTxing; ///< Map that stores the number of reception events per STA that occurred
90 ///< while PHY was already transmitting a PPDU
91std::map<Mac48Address, uint64_t>
92 rxEventWhileRxing; ///< Map that stores the number of reception events per STA that occurred
93 ///< while PHY was already receiving a PPDU
94std::map<Mac48Address, uint64_t>
95 rxEventWhileDecodingPreamble; ///< Map that stores the number of reception events per STA that
96 ///< occurred while PHY was already decoding a preamble
97std::map<Mac48Address, uint64_t>
98 rxEventAbortedByTx; ///< Map that stores the number of reception events aborted per STA because
99 ///< the PHY has started to transmit
100
101std::map<Mac48Address, Time>
102 timeFirstReceived; ///< Map that stores the time at which the first packet was received per STA
103 ///< (and the packet is addressed to that STA)
104std::map<Mac48Address, Time>
105 timeLastReceived; ///< Map that stores the time at which the last packet was received per STA
106 ///< (and the packet is addressed to that STA)
107std::map<Mac48Address, Time> timeFirstTransmitted; ///< Map that stores the time at which the first
108 ///< packet was transmitted per STA
109std::map<Mac48Address, Time> timeLastTransmitted; ///< Map that stores the time at which the last
110 ///< packet was transmitted per STA
111
112std::set<uint32_t> associated; ///< Contains the IDs of the STAs that successfully associated to the
113 ///< access point (in infrastructure mode only)
114
115bool tracing = false; ///< Flag to enable/disable generation of tracing files
116uint32_t pktSize = 1500; ///< packet size used for the simulation (in bytes)
117uint8_t maxMpdus = 0; ///< The maximum number of MPDUs in A-MPDUs (0 to disable MPDU aggregation)
118bool useTxHelper = false; ///< Flag to get MPDU statistics with WifiTxStatsHelper
119bool useRxHelper = false; ///< Flag to get PPDU statistics with WifiPhyRxTraceHelper
120
121/// Table of the expected values for EIFS
122std::map<std::string /* mode */,
123 std::map<unsigned int /* number of nodes */, double /* calculated throughput */>>
125 /* 11b */
126 {"DsssRate1Mbps",
127 {
128 {5, 0.8418},
129 {10, 0.7831},
130 {15, 0.7460},
131 {20, 0.7186},
132 {25, 0.6973},
133 {30, 0.6802},
134 {35, 0.6639},
135 {40, 0.6501},
136 {45, 0.6386},
137 {50, 0.6285},
138 }},
139 {"DsssRate2Mbps",
140 {
141 {5, 1.6170},
142 {10, 1.5075},
143 {15, 1.4371},
144 {20, 1.3849},
145 {25, 1.3442},
146 {30, 1.3115},
147 {35, 1.2803},
148 {40, 1.2538},
149 {45, 1.2317},
150 {50, 1.2124},
151 }},
152 {"DsssRate5_5Mbps",
153 {
154 {5, 3.8565},
155 {10, 3.6170},
156 {15, 3.4554},
157 {20, 3.3339},
158 {25, 3.2385},
159 {30, 3.1613},
160 {35, 3.0878},
161 {40, 3.0249},
162 {45, 2.9725},
163 {50, 2.9266},
164 }},
165 {"DsssRate11Mbps",
166 {
167 {5, 6.3821},
168 {10, 6.0269},
169 {15, 5.7718},
170 {20, 5.5765},
171 {25, 5.4217},
172 {30, 5.2958},
173 {35, 5.1755},
174 {40, 5.0722},
175 {45, 4.9860},
176 {50, 4.9103},
177 }},
178 /* 11a */
179 {"OfdmRate6Mbps",
180 {
181 {5, 4.6899},
182 {10, 4.3197},
183 {15, 4.1107},
184 {20, 3.9589},
185 {25, 3.8478},
186 {30, 3.7490},
187 {35, 3.6618},
188 {40, 3.5927},
189 {45, 3.5358},
190 {50, 3.4711},
191 }},
192 {"OfdmRate9Mbps",
193 {
194 {5, 6.8188},
195 {10, 6.2885},
196 {15, 5.9874},
197 {20, 5.7680},
198 {25, 5.6073},
199 {30, 5.4642},
200 {35, 5.3378},
201 {40, 5.2376},
202 {45, 5.1551},
203 {50, 5.0612},
204 }},
205 {"OfdmRate12Mbps",
206 {
207 {5, 8.8972},
208 {10, 8.2154},
209 {15, 7.8259},
210 {20, 7.5415},
211 {25, 7.3329},
212 {30, 7.1469},
213 {35, 6.9825},
214 {40, 6.8521},
215 {45, 6.7447},
216 {50, 6.6225},
217 }},
218 {"OfdmRate18Mbps",
219 {
220 {5, 12.6719},
221 {10, 11.7273},
222 {15, 11.1814},
223 {20, 10.7810},
224 {25, 10.4866},
225 {30, 10.2237},
226 {35, 9.9910},
227 {40, 9.8061},
228 {45, 9.6538},
229 {50, 9.4804},
230 }},
231 {"OfdmRate24Mbps",
232 {
233 {5, 16.0836},
234 {10, 14.9153},
235 {15, 14.2327},
236 {20, 13.7300},
237 {25, 13.3595},
238 {30, 13.0281},
239 {35, 12.7343},
240 {40, 12.5008},
241 {45, 12.3083},
242 {50, 12.0889},
243 }},
244 {"OfdmRate36Mbps",
245 {
246 {5, 22.0092},
247 {10, 20.4836},
248 {15, 19.5743},
249 {20, 18.8997},
250 {25, 18.4002},
251 {30, 17.9524},
252 {35, 17.5545},
253 {40, 17.2377},
254 {45, 16.9760},
255 {50, 16.6777},
256 }},
257 {"OfdmRate48Mbps",
258 {
259 {5, 26.8382},
260 {10, 25.0509},
261 {15, 23.9672},
262 {20, 23.1581},
263 {25, 22.5568},
264 {30, 22.0165},
265 {35, 21.5355},
266 {40, 21.1519},
267 {45, 20.8348},
268 {50, 20.4729},
269 }},
270 {"OfdmRate54Mbps",
271 {
272 {5, 29.2861},
273 {10, 27.3763},
274 {15, 26.2078},
275 {20, 25.3325},
276 {25, 24.6808},
277 {30, 24.0944},
278 {35, 23.5719},
279 {40, 23.1549},
280 {45, 22.8100},
281 {50, 22.4162},
282 }},
283 /* 11g */
284 {"ErpOfdmRate6Mbps",
285 {
286 {5, 4.6899},
287 {10, 4.3197},
288 {15, 4.1107},
289 {20, 3.9589},
290 {25, 3.8478},
291 {30, 3.7490},
292 {35, 3.6618},
293 {40, 3.5927},
294 {45, 3.5358},
295 {50, 3.4711},
296 }},
297 {"ErpOfdmRate9Mbps",
298 {
299 {5, 6.8188},
300 {10, 6.2885},
301 {15, 5.9874},
302 {20, 5.7680},
303 {25, 5.6073},
304 {30, 5.4642},
305 {35, 5.3378},
306 {40, 5.2376},
307 {45, 5.1551},
308 {50, 5.0612},
309 }},
310 {"ErpOfdmRate12Mbps",
311 {
312 {5, 8.8972},
313 {10, 8.2154},
314 {15, 7.8259},
315 {20, 7.5415},
316 {25, 7.3329},
317 {30, 7.1469},
318 {35, 6.9825},
319 {40, 6.8521},
320 {45, 6.7447},
321 {50, 6.6225},
322 }},
323 {"ErpOfdmRate18Mbps",
324 {
325 {5, 12.6719},
326 {10, 11.7273},
327 {15, 11.1814},
328 {20, 10.7810},
329 {25, 10.4866},
330 {30, 10.2237},
331 {35, 9.9910},
332 {40, 9.8061},
333 {45, 9.6538},
334 {50, 9.4804},
335 }},
336 {"ErpOfdmRate24Mbps",
337 {
338 {5, 16.0836},
339 {10, 14.9153},
340 {15, 14.2327},
341 {20, 13.7300},
342 {25, 13.3595},
343 {30, 13.0281},
344 {35, 12.7343},
345 {40, 12.5008},
346 {45, 12.3083},
347 {50, 12.0889},
348 }},
349 {"ErpOfdmRate36Mbps",
350 {
351 {5, 22.0092},
352 {10, 20.4836},
353 {15, 19.5743},
354 {20, 18.8997},
355 {25, 18.4002},
356 {30, 17.9524},
357 {35, 17.5545},
358 {40, 17.2377},
359 {45, 16.9760},
360 {50, 16.6777},
361 }},
362 {"ErpOfdmRate48Mbps",
363 {
364 {5, 26.8382},
365 {10, 25.0509},
366 {15, 23.9672},
367 {20, 23.1581},
368 {25, 22.5568},
369 {30, 22.0165},
370 {35, 21.5355},
371 {40, 21.1519},
372 {45, 20.8348},
373 {50, 20.4729},
374 }},
375 {"ErpOfdmRate54Mbps",
376 {
377 {5, 29.2861},
378 {10, 27.3763},
379 {15, 26.2078},
380 {20, 25.3325},
381 {25, 24.6808},
382 {30, 24.0944},
383 {35, 23.5719},
384 {40, 23.1549},
385 {45, 22.8100},
386 {50, 22.4162},
387 }},
388 /* 11ax, no frame aggregation */
389 {"HeMcs0_20MHz",
390 {
391 {5, 6.3381},
392 {10, 5.8172},
393 {15, 5.5223},
394 {20, 5.3146},
395 {25, 5.1525},
396 {30, 5.0187},
397 {35, 4.9039},
398 {40, 4.8034},
399 {45, 4.7134},
400 {50, 4.6317},
401 }},
402 {"HeMcs1_20MHz",
403 {
404 {5, 11.6580},
405 {10, 10.7369},
406 {15, 10.2068},
407 {20, 9.8309},
408 {25, 9.5365},
409 {30, 9.2930},
410 {35, 9.0837},
411 {40, 8.9001},
412 {45, 8.7355},
413 {50, 8.5860},
414 }},
415 {"HeMcs2_20MHz",
416 {
417 {5, 15.8572},
418 {10, 14.6445},
419 {15, 13.9367},
420 {20, 13.4323},
421 {25, 13.0361},
422 {30, 12.7076},
423 {35, 12.4249},
424 {40, 12.1766},
425 {45, 11.9538},
426 {50, 11.7511},
427 }},
428 {"HeMcs3_20MHz",
429 {
430 {5, 19.7457},
431 {10, 18.2820},
432 {15, 17.4163},
433 {20, 16.7963},
434 {25, 16.3078},
435 {30, 15.9021},
436 {35, 15.5524},
437 {40, 15.2449},
438 {45, 14.9687},
439 {50, 14.7173},
440 }},
441 {"HeMcs4_20MHz",
442 {
443 {5, 25.8947},
444 {10, 24.0721},
445 {15, 22.9698},
446 {20, 22.1738},
447 {25, 21.5437},
448 {30, 21.0186},
449 {35, 20.5650},
450 {40, 20.1654},
451 {45, 19.8059},
452 {50, 19.4784},
453 }},
454 {"HeMcs5_20MHz",
455 {
456 {5, 30.0542},
457 {10, 28.0155},
458 {15, 26.7625},
459 {20, 25.8523},
460 {25, 25.1295},
461 {30, 24.5258},
462 {35, 24.0034},
463 {40, 23.5426},
464 {45, 23.1277},
465 {50, 22.7492},
466 }},
467 {"HeMcs6_20MHz",
468 {
469 {5, 32.6789},
470 {10, 30.5150},
471 {15, 29.1708},
472 {20, 28.1907},
473 {25, 27.4107},
474 {30, 26.7583},
475 {35, 26.1931},
476 {40, 25.6941},
477 {45, 25.2446},
478 {50, 24.8343},
479 }},
480 {"HeMcs7_20MHz",
481 {
482 {5, 34.1710},
483 {10, 31.9398},
484 {15, 30.5451},
485 {20, 29.5261},
486 {25, 28.7140},
487 {30, 28.0342},
488 {35, 27.4449},
489 {40, 26.9245},
490 {45, 26.4554},
491 {50, 26.0271},
492 }},
493 {"HeMcs8_20MHz",
494 {
495 {5, 37.6051},
496 {10, 35.2296},
497 {15, 33.7228},
498 {20, 32.6160},
499 {25, 31.7314},
500 {30, 30.9895},
501 {35, 30.3455},
502 {40, 29.7760},
503 {45, 29.2623},
504 {50, 28.7929},
505 }},
506 {"HeMcs9_20MHz",
507 {
508 {5, 39.5947},
509 {10, 37.1424},
510 {15, 35.5731},
511 {20, 34.4169},
512 {25, 33.4911},
513 {30, 32.7138},
514 {35, 32.0385},
515 {40, 31.4410},
516 {45, 30.9016},
517 {50, 30.4086},
518 }},
519 {"HeMcs10_20MHz",
520 {
521 {5, 39.5947},
522 {10, 37.1424},
523 {15, 35.5731},
524 {20, 34.4169},
525 {25, 33.4911},
526 {30, 32.7138},
527 {35, 32.0385},
528 {40, 31.4410},
529 {45, 30.9016},
530 {50, 30.4086},
531 }},
532 {"HeMcs11_20MHz",
533 {
534 {5, 41.8065},
535 {10, 39.2749},
536 {15, 37.6383},
537 {20, 36.4282},
538 {25, 35.4575},
539 {30, 34.6414},
540 {35, 33.9316},
541 {40, 33.3031},
542 {45, 32.7355},
543 {50, 32.2164},
544 }},
545 {"HeMcs0_40MHz",
546 {
547 {5, 11.4999},
548 {10, 10.5902},
549 {15, 10.0669},
550 {20, 9.6960},
551 {25, 9.4055},
552 {30, 9.1652},
553 {35, 8.9587},
554 {40, 8.7775},
555 {45, 8.6151},
556 {50, 8.4676},
557 }},
558 {"HeMcs1_40MHz",
559 {
560 {5, 19.5937},
561 {10, 18.1394},
562 {15, 17.2798},
563 {20, 16.6642},
564 {25, 16.1793},
565 {30, 15.7766},
566 {35, 15.4295},
567 {40, 15.1242},
568 {45, 14.8502},
569 {50, 14.6007},
570 }},
571 {"HeMcs2_40MHz",
572 {
573 {5, 25.6338},
574 {10, 23.8255},
575 {15, 22.7329},
576 {20, 21.9442},
577 {25, 21.3200},
578 {30, 20.7999},
579 {35, 20.3506},
580 {40, 19.9549},
581 {45, 19.5990},
582 {50, 19.2746},
583 }},
584 {"HeMcs3_40MHz",
585 {
586 {5, 30.0542},
587 {10, 28.0155},
588 {15, 26.7625},
589 {20, 25.8523},
590 {25, 25.1295},
591 {30, 24.5258},
592 {35, 24.0034},
593 {40, 23.5426},
594 {45, 23.1277},
595 {50, 22.7492},
596 }},
597 {"HeMcs4_40MHz",
598 {
599 {5, 37.6051},
600 {10, 35.2296},
601 {15, 33.7228},
602 {20, 32.6160},
603 {25, 31.7314},
604 {30, 30.9895},
605 {35, 30.3455},
606 {40, 29.7760},
607 {45, 29.2623},
608 {50, 28.7929},
609 }},
610 {"HeMcs5_40MHz",
611 {
612 {5, 41.8065},
613 {10, 39.2749},
614 {15, 37.6383},
615 {20, 36.4282},
616 {25, 35.4575},
617 {30, 34.6414},
618 {35, 33.9316},
619 {40, 33.3031},
620 {45, 32.7355},
621 {50, 32.2164},
622 }},
623 {"HeMcs6_40MHz",
624 {
625 {5, 44.2801},
626 {10, 41.6672},
627 {15, 39.9580},
628 {20, 38.6892},
629 {25, 37.6692},
630 {30, 36.8103},
631 {35, 36.0625},
632 {40, 35.3998},
633 {45, 34.8008},
634 {50, 34.2528},
635 }},
636 {"HeMcs7_40MHz",
637 {
638 {5, 44.2801},
639 {10, 41.6672},
640 {15, 39.9580},
641 {20, 38.6892},
642 {25, 37.6692},
643 {30, 36.8103},
644 {35, 36.0625},
645 {40, 35.3998},
646 {45, 34.8008},
647 {50, 34.2528},
648 }},
649 {"HeMcs8_40MHz",
650 {
651 {5, 47.0648},
652 {10, 44.3699},
653 {15, 42.5825},
654 {20, 41.2495},
655 {25, 40.1751},
656 {30, 39.2689},
657 {35, 38.4790},
658 {40, 37.7781},
659 {45, 37.1443},
660 {50, 36.5639},
661 }},
662 {"HeMcs9_40MHz",
663 {
664 {5, 50.2233},
665 {10, 47.4474},
666 {15, 45.5760},
667 {20, 44.1727},
668 {25, 43.0382},
669 {30, 42.0794},
670 {35, 41.2425},
671 {40, 40.4991},
672 {45, 39.8262},
673 {50, 39.2095},
674 }},
675 {"HeMcs10_40MHz",
676 {
677 {5, 50.2233},
678 {10, 47.4474},
679 {15, 45.5760},
680 {20, 44.1727},
681 {25, 43.0382},
682 {30, 42.0794},
683 {35, 41.2425},
684 {40, 40.4991},
685 {45, 39.8262},
686 {50, 39.2095},
687 }},
688 {"HeMcs11_40MHz",
689 {
690 {5, 50.2233},
691 {10, 47.4474},
692 {15, 45.5760},
693 {20, 44.1727},
694 {25, 43.0382},
695 {30, 42.0794},
696 {35, 41.2425},
697 {40, 40.4991},
698 {45, 39.8262},
699 {50, 39.2095},
700 }},
701 {"HeMcs0_80MHz",
702 {
703 {5, 19.6542},
704 {10, 18.1962},
705 {15, 17.3342},
706 {20, 16.7168},
707 {25, 16.2305},
708 {30, 15.8265},
709 {35, 15.4784},
710 {40, 15.1723},
711 {45, 14.8973},
712 {50, 14.6471},
713 }},
714 {"HeMcs1_80MHz",
715 {
716 {5, 30.9311},
717 {10, 28.8495},
718 {15, 27.5657},
719 {20, 26.6320},
720 {25, 25.8899},
721 {30, 25.2699},
722 {35, 24.7332},
723 {40, 24.2595},
724 {45, 23.8330},
725 {50, 23.4439},
726 }},
727 {"HeMcs2_80MHz",
728 {
729 {5, 37.0575},
730 {10, 34.7039},
731 {15, 33.2146},
732 {20, 32.1216},
733 {25, 31.2485},
734 {30, 30.5164},
735 {35, 29.8811},
736 {40, 29.3194},
737 {45, 28.8127},
738 {50, 28.3499},
739 }},
740 {"HeMcs3_80MHz",
741 {
742 {5, 41.8065},
743 {10, 39.2749},
744 {15, 37.6383},
745 {20, 36.4282},
746 {25, 35.4575},
747 {30, 34.6414},
748 {35, 33.9316},
749 {40, 33.3031},
750 {45, 32.7355},
751 {50, 32.2164},
752 }},
753 {"HeMcs4_80MHz",
754 {
755 {5, 47.0648},
756 {10, 44.3699},
757 {15, 42.5825},
758 {20, 41.2495},
759 {25, 40.1751},
760 {30, 39.2689},
761 {35, 38.4790},
762 {40, 37.7781},
763 {45, 37.1443},
764 {50, 36.5639},
765 }},
766 {"HeMcs5_80MHz",
767 {
768 {5, 50.2233},
769 {10, 47.4474},
770 {15, 45.5760},
771 {20, 44.1727},
772 {25, 43.0382},
773 {30, 42.0794},
774 {35, 41.2425},
775 {40, 40.4991},
776 {45, 39.8262},
777 {50, 39.2095},
778 }},
779 {"HeMcs6_80MHz",
780 {
781 {5, 53.8362},
782 {10, 50.9837},
783 {15, 49.0221},
784 {20, 47.5418},
785 {25, 46.3407},
786 {30, 45.3233},
787 {35, 44.4337},
788 {40, 43.6425},
789 {45, 42.9255},
790 {50, 42.2678},
791 }},
792 {"HeMcs7_80MHz",
793 {
794 {5, 53.8362},
795 {10, 50.9837},
796 {15, 49.0221},
797 {20, 47.5418},
798 {25, 46.3407},
799 {30, 45.3233},
800 {35, 44.4337},
801 {40, 43.6425},
802 {45, 42.9255},
803 {50, 42.2678},
804 }},
805 {"HeMcs8_80MHz",
806 {
807 {5, 53.8362},
808 {10, 50.9837},
809 {15, 49.0221},
810 {20, 47.5418},
811 {25, 46.3407},
812 {30, 45.3233},
813 {35, 44.4337},
814 {40, 43.6425},
815 {45, 42.9255},
816 {50, 42.2678},
817 }},
818 {"HeMcs9_80MHz",
819 {
820 {5, 58.0092},
821 {10, 55.0896},
822 {15, 53.0321},
823 {20, 51.4672},
824 {25, 50.1922},
825 {30, 49.1091},
826 {35, 48.1601},
827 {40, 47.3148},
828 {45, 46.5478},
829 {50, 45.8436},
830 }},
831 {"HeMcs10_80MHz",
832 {
833 {5, 58.0092},
834 {10, 55.0896},
835 {15, 53.0321},
836 {20, 51.4672},
837 {25, 50.1922},
838 {30, 49.1091},
839 {35, 48.1601},
840 {40, 47.3148},
841 {45, 46.5478},
842 {50, 45.8436},
843 }},
844 {"HeMcs11_80MHz",
845 {
846 {5, 58.0092},
847 {10, 55.0896},
848 {15, 53.0321},
849 {20, 51.4672},
850 {25, 50.1922},
851 {30, 49.1091},
852 {35, 48.1601},
853 {40, 47.3148},
854 {45, 46.5478},
855 {50, 45.8436},
856 }},
857 {"HeMcs0_160MHz",
858 {
859 {5, 29.8428},
860 {10, 27.8145},
861 {15, 26.5689},
862 {20, 25.6645},
863 {25, 24.9463},
864 {30, 24.3466},
865 {35, 23.8276},
866 {40, 23.3699},
867 {45, 22.9578},
868 {50, 22.5819},
869 }},
870 {"HeMcs1_160MHz",
871 {
872 {5, 41.1308},
873 {10, 38.6227},
874 {15, 37.0064},
875 {20, 35.8126},
876 {25, 34.8556},
877 {30, 34.0513},
878 {35, 33.3520},
879 {40, 32.7329},
880 {45, 32.1739},
881 {50, 31.6628},
882 }},
883 {"HeMcs2_160MHz",
884 {
885 {5, 46.2101},
886 {10, 43.5393},
887 {15, 41.7755},
888 {20, 40.4620},
889 {25, 39.4041},
890 {30, 38.5123},
891 {35, 37.7353},
892 {40, 37.0461},
893 {45, 36.4229},
894 {50, 35.8524},
895 }},
896 {"HeMcs3_160MHz",
897 {
898 {5, 50.2233},
899 {10, 47.4474},
900 {15, 45.5760},
901 {20, 44.1727},
902 {25, 43.0382},
903 {30, 42.0794},
904 {35, 41.2425},
905 {40, 40.4991},
906 {45, 39.8262},
907 {50, 39.2095},
908 }},
909 {"HeMcs4_160MHz",
910 {
911 {5, 53.8362},
912 {10, 50.9837},
913 {15, 49.0221},
914 {20, 47.5418},
915 {25, 46.3407},
916 {30, 45.3233},
917 {35, 44.4337},
918 {40, 43.6425},
919 {45, 42.9255},
920 {50, 42.2678},
921 }},
922 {"HeMcs5_160MHz",
923 {
924 {5, 58.0092},
925 {10, 55.0896},
926 {15, 53.0321},
927 {20, 51.4672},
928 {25, 50.1922},
929 {30, 49.1091},
930 {35, 48.1601},
931 {40, 47.3148},
932 {45, 46.5478},
933 {50, 45.8436},
934 }},
935 {"HeMcs6_160MHz",
936 {
937 {5, 58.0092},
938 {10, 55.0896},
939 {15, 53.0321},
940 {20, 51.4672},
941 {25, 50.1922},
942 {30, 49.1091},
943 {35, 48.1601},
944 {40, 47.3148},
945 {45, 46.5478},
946 {50, 45.8436},
947 }},
948 {"HeMcs7_160MHz",
949 {
950 {5, 58.0092},
951 {10, 55.0896},
952 {15, 53.0321},
953 {20, 51.4672},
954 {25, 50.1922},
955 {30, 49.1091},
956 {35, 48.1601},
957 {40, 47.3148},
958 {45, 46.5478},
959 {50, 45.8436},
960 }},
961 {"HeMcs8_160MHz",
962 {
963 {5, 58.0092},
964 {10, 55.0896},
965 {15, 53.0321},
966 {20, 51.4672},
967 {25, 50.1922},
968 {30, 49.1091},
969 {35, 48.1601},
970 {40, 47.3148},
971 {45, 46.5478},
972 {50, 45.8436},
973 }},
974 {"HeMcs9_160MHz",
975 {
976 {5, 62.8834},
977 {10, 59.9147},
978 {15, 57.7564},
979 {20, 56.0992},
980 {25, 54.7419},
981 {30, 53.5850},
982 {35, 52.5689},
983 {40, 51.6620},
984 {45, 50.8379},
985 {50, 50.0803},
986 }},
987 {"HeMcs10_160MHz",
988 {
989 {5, 62.8834},
990 {10, 59.9147},
991 {15, 57.7564},
992 {20, 56.0992},
993 {25, 54.7419},
994 {30, 53.5850},
995 {35, 52.5689},
996 {40, 51.6620},
997 {45, 50.8379},
998 {50, 50.0803},
999 }},
1000 {"HeMcs11_160MHz",
1001 {
1002 {5, 62.8834},
1003 {10, 59.9147},
1004 {15, 57.7564},
1005 {20, 56.0992},
1006 {25, 54.7419},
1007 {30, 53.5850},
1008 {35, 52.5689},
1009 {40, 51.6620},
1010 {45, 50.8379},
1011 {50, 50.0803},
1012 }},
1013};
1014
1015/// Table of the expected values for DIFS
1016std::map<std::string /* mode */,
1017 std::map<unsigned int /* number of nodes */, double /* calculated throughput */>>
1019 /* 11b */
1020 {"DsssRate1Mbps",
1021 {
1022 {5, 0.8437},
1023 {10, 0.7861},
1024 {15, 0.7496},
1025 {20, 0.7226},
1026 {25, 0.7016},
1027 {30, 0.6847},
1028 {35, 0.6686},
1029 {40, 0.6549},
1030 {45, 0.6435},
1031 {50, 0.6336},
1032 }},
1033 {"DsssRate2Mbps",
1034 {
1035 {5, 1.6228},
1036 {10, 1.5168},
1037 {15, 1.4482},
1038 {20, 1.3972},
1039 {25, 1.3574},
1040 {30, 1.3253},
1041 {35, 1.2947},
1042 {40, 1.2687},
1043 {45, 1.2469},
1044 {50, 1.2279},
1045 }},
1046 {"DsssRate5_5Mbps",
1047 {
1048 {5, 3.8896},
1049 {10, 3.6707},
1050 {15, 3.5203},
1051 {20, 3.4063},
1052 {25, 3.3161},
1053 {30, 3.2429},
1054 {35, 3.1729},
1055 {40, 3.1128},
1056 {45, 3.0625},
1057 {50, 3.0184},
1058 }},
1059 {"DsssRate11Mbps",
1060 {
1061 {5, 6.4734},
1062 {10, 6.1774},
1063 {15, 5.9553},
1064 {20, 5.7819},
1065 {25, 5.6429},
1066 {30, 5.5289},
1067 {35, 5.4191},
1068 {40, 5.3243},
1069 {45, 5.2446},
1070 {50, 5.1745},
1071 }},
1072 /* 11a */
1073 {"OfdmRate6Mbps",
1074 {
1075 {5, 4.7087},
1076 {10, 4.3453},
1077 {15, 4.1397},
1078 {20, 3.9899},
1079 {25, 3.8802},
1080 {30, 3.7824},
1081 {35, 3.6961},
1082 {40, 3.6276},
1083 {45, 3.5712},
1084 {50, 3.5071},
1085 }},
1086 {"OfdmRate9Mbps",
1087 {
1088 {5, 6.8586},
1089 {10, 6.3431},
1090 {15, 6.0489},
1091 {20, 5.8340},
1092 {25, 5.6762},
1093 {30, 5.5355},
1094 {35, 5.4110},
1095 {40, 5.3122},
1096 {45, 5.2307},
1097 {50, 5.1380},
1098 }},
1099 {"OfdmRate12Mbps",
1100 {
1101 {5, 8.9515},
1102 {10, 8.2901},
1103 {15, 7.9102},
1104 {20, 7.6319},
1105 {25, 7.4274},
1106 {30, 7.2447},
1107 {35, 7.0829},
1108 {40, 6.9544},
1109 {45, 6.8485},
1110 {50, 6.7278},
1111 }},
1112 {"OfdmRate18Mbps",
1113 {
1114 {5, 12.7822},
1115 {10, 11.8801},
1116 {15, 11.3543},
1117 {20, 10.9668},
1118 {25, 10.6809},
1119 {30, 10.4249},
1120 {35, 10.1978},
1121 {40, 10.0171},
1122 {45, 9.8679},
1123 {50, 9.6978},
1124 }},
1125 {"OfdmRate24Mbps",
1126 {
1127 {5, 16.2470},
1128 {10, 15.1426},
1129 {15, 14.4904},
1130 {20, 14.0072},
1131 {25, 13.6496},
1132 {30, 13.3288},
1133 {35, 13.0436},
1134 {40, 12.8164},
1135 {45, 12.6286},
1136 {50, 12.4144},
1137 }},
1138 {"OfdmRate36Mbps",
1139 {
1140 {5, 22.3164},
1141 {10, 20.9147},
1142 {15, 20.0649},
1143 {20, 19.4289},
1144 {25, 18.9552},
1145 {30, 18.5284},
1146 {35, 18.1476},
1147 {40, 17.8434},
1148 {45, 17.5915},
1149 {50, 17.3036},
1150 }},
1151 {"OfdmRate48Mbps",
1152 {
1153 {5, 27.2963},
1154 {10, 25.6987},
1155 {15, 24.7069},
1156 {20, 23.9578},
1157 {25, 23.3965},
1158 {30, 22.8891},
1159 {35, 22.4350},
1160 {40, 22.0713},
1161 {45, 21.7696},
1162 {50, 21.4243},
1163 }},
1164 {"OfdmRate54Mbps",
1165 {
1166 {5, 29.8324},
1167 {10, 28.1519},
1168 {15, 27.0948},
1169 {20, 26.2925},
1170 {25, 25.6896},
1171 {30, 25.1434},
1172 {35, 24.6539},
1173 {40, 24.2613},
1174 {45, 23.9353},
1175 {50, 23.5618},
1176 }},
1177 /* 11g */
1178 {"ErpOfdmRate6Mbps",
1179 {
1180 {5, 4.7087},
1181 {10, 4.3453},
1182 {15, 4.1397},
1183 {20, 3.9899},
1184 {25, 3.8802},
1185 {30, 3.7824},
1186 {35, 3.6961},
1187 {40, 3.6276},
1188 {45, 3.5712},
1189 {50, 3.5071},
1190 }},
1191 {"ErpOfdmRate9Mbps",
1192 {
1193 {5, 6.8586},
1194 {10, 6.3431},
1195 {15, 6.0489},
1196 {20, 5.8340},
1197 {25, 5.6762},
1198 {30, 5.5355},
1199 {35, 5.4110},
1200 {40, 5.3122},
1201 {45, 5.2307},
1202 {50, 5.1380},
1203 }},
1204 {"ErpOfdmRate12Mbps",
1205 {
1206 {5, 8.9515},
1207 {10, 8.2901},
1208 {15, 7.9102},
1209 {20, 7.6319},
1210 {25, 7.4274},
1211 {30, 7.2447},
1212 {35, 7.0829},
1213 {40, 6.9544},
1214 {45, 6.8485},
1215 {50, 6.7278},
1216 }},
1217 {"ErpOfdmRate18Mbps",
1218 {
1219 {5, 12.7822},
1220 {10, 11.8801},
1221 {15, 11.3543},
1222 {20, 10.9668},
1223 {25, 10.6809},
1224 {30, 10.4249},
1225 {35, 10.1978},
1226 {40, 10.0171},
1227 {45, 9.8679},
1228 {50, 9.6978},
1229 }},
1230 {"ErpOfdmRate24Mbps",
1231 {
1232 {5, 16.2470},
1233 {10, 15.1426},
1234 {15, 14.4904},
1235 {20, 14.0072},
1236 {25, 13.6496},
1237 {30, 13.3288},
1238 {35, 13.0436},
1239 {40, 12.8164},
1240 {45, 12.6286},
1241 {50, 12.4144},
1242 }},
1243 {"ErpOfdmRate36Mbps",
1244 {
1245 {5, 22.3164},
1246 {10, 20.9147},
1247 {15, 20.0649},
1248 {20, 19.4289},
1249 {25, 18.9552},
1250 {30, 18.5284},
1251 {35, 18.1476},
1252 {40, 17.8434},
1253 {45, 17.5915},
1254 {50, 17.3036},
1255 }},
1256 {"ErpOfdmRate48Mbps",
1257 {
1258 {5, 27.2963},
1259 {10, 25.6987},
1260 {15, 24.7069},
1261 {20, 23.9578},
1262 {25, 23.3965},
1263 {30, 22.8891},
1264 {35, 22.4350},
1265 {40, 22.0713},
1266 {45, 21.7696},
1267 {50, 21.4243},
1268 }},
1269 {"ErpOfdmRate54Mbps",
1270 {
1271 {5, 29.8324},
1272 {10, 28.1519},
1273 {15, 27.0948},
1274 {20, 26.2925},
1275 {25, 25.6896},
1276 {30, 25.1434},
1277 {35, 24.6539},
1278 {40, 24.2613},
1279 {45, 23.9353},
1280 {50, 23.5618},
1281 }},
1282 /* 11ax, no frame aggregation */
1283 {"HeMcs0_20MHz",
1284 {
1285 {5, 6.3746},
1286 {10, 5.8670},
1287 {15, 5.5782},
1288 {20, 5.3742},
1289 {25, 5.2147},
1290 {30, 5.0829},
1291 {35, 4.9696},
1292 {40, 4.8703},
1293 {45, 4.7813},
1294 {50, 4.7004},
1295 }},
1296 {"HeMcs1_20MHz",
1297 {
1298 {5, 11.7574},
1299 {10, 10.8735},
1300 {15, 10.3606},
1301 {20, 9.9954},
1302 {25, 9.7084},
1303 {30, 9.4704},
1304 {35, 9.2654},
1305 {40, 9.0853},
1306 {45, 8.9235},
1307 {50, 8.7763},
1308 }},
1309 {"HeMcs2_20MHz",
1310 {
1311 {5, 16.0419},
1312 {10, 14.8998},
1313 {15, 14.2252},
1314 {20, 13.7413},
1315 {25, 13.3594},
1316 {30, 13.0417},
1317 {35, 12.7674},
1318 {40, 12.5258},
1319 {45, 12.3086},
1320 {50, 12.1107},
1321 }},
1322 {"HeMcs3_20MHz",
1323 {
1324 {5, 20.0089},
1325 {10, 18.6480},
1326 {15, 17.8309},
1327 {20, 17.2410},
1328 {25, 16.7736},
1329 {30, 16.3837},
1330 {35, 16.0465},
1331 {40, 15.7491},
1332 {45, 15.4813},
1333 {50, 15.2369},
1334 }},
1335 {"HeMcs4_20MHz",
1336 {
1337 {5, 26.3492},
1338 {10, 24.7107},
1339 {15, 23.6964},
1340 {20, 22.9553},
1341 {25, 22.3640},
1342 {30, 21.8683},
1343 {35, 21.4379},
1344 {40, 21.0571},
1345 {45, 20.7134},
1346 {50, 20.3991},
1347 }},
1348 {"HeMcs5_20MHz",
1349 {
1350 {5, 30.6683},
1351 {10, 28.8843},
1352 {15, 27.7540},
1353 {20, 26.9210},
1354 {25, 26.2528},
1355 {30, 25.6906},
1356 {35, 25.2012},
1357 {40, 24.7671},
1358 {45, 24.3746},
1359 {50, 24.0151},
1360 }},
1361 {"HeMcs6_20MHz",
1362 {
1363 {5, 33.4062},
1364 {10, 31.5485},
1365 {15, 30.3527},
1366 {20, 29.4662},
1367 {25, 28.7527},
1368 {30, 28.1508},
1369 {35, 27.6259},
1370 {40, 27.1597},
1371 {45, 26.7376},
1372 {50, 26.3507},
1373 }},
1374 {"HeMcs7_20MHz",
1375 {
1376 {5, 34.9671},
1377 {10, 33.0739},
1378 {15, 31.8436},
1379 {20, 30.9282},
1380 {25, 30.1900},
1381 {30, 29.5665},
1382 {35, 29.0221},
1383 {40, 28.5382},
1384 {45, 28.0997},
1385 {50, 27.6975},
1386 }},
1387 {"HeMcs8_20MHz",
1388 {
1389 {5, 38.5714},
1390 {10, 36.6144},
1391 {15, 35.3124},
1392 {20, 34.3355},
1393 {25, 33.5438},
1394 {30, 32.8728},
1395 {35, 32.2854},
1396 {40, 31.7623},
1397 {45, 31.2874},
1398 {50, 30.8512},
1399 }},
1400 {"HeMcs9_20MHz",
1401 {
1402 {5, 40.6674},
1403 {10, 38.6851},
1404 {15, 37.3466},
1405 {20, 36.3371},
1406 {25, 35.5165},
1407 {30, 34.8197},
1408 {35, 34.2087},
1409 {40, 33.6638},
1410 {45, 33.1688},
1411 {50, 32.7137},
1412 }},
1413 {"HeMcs10_20MHz",
1414 {
1415 {5, 40.6674},
1416 {10, 38.6851},
1417 {15, 37.3466},
1418 {20, 36.3371},
1419 {25, 35.5165},
1420 {30, 34.8197},
1421 {35, 34.2087},
1422 {40, 33.6638},
1423 {45, 33.1688},
1424 {50, 32.7137},
1425 }},
1426 {"HeMcs11_20MHz",
1427 {
1428 {5, 43.0043},
1429 {10, 41.0039},
1430 {15, 39.6294},
1431 {20, 38.5865},
1432 {25, 37.7358},
1433 {30, 37.0116},
1434 {35, 36.3756},
1435 {40, 35.8076},
1436 {45, 35.2909},
1437 {50, 34.8154},
1438 }},
1439 {"HeMcs0_40MHz",
1440 {
1441 {5, 11.6208},
1442 {10, 10.7566},
1443 {15, 10.2544},
1444 {20, 9.8965},
1445 {25, 9.6151},
1446 {30, 9.3815},
1447 {35, 9.1804},
1448 {40, 9.0035},
1449 {45, 8.8446},
1450 {50, 8.7000},
1451 }},
1452 {"HeMcs1_40MHz",
1453 {
1454 {5, 19.8764},
1455 {10, 18.5328},
1456 {15, 17.7255},
1457 {20, 17.1424},
1458 {25, 16.6803},
1459 {30, 16.2947},
1460 {35, 15.9612},
1461 {40, 15.6668},
1462 {45, 15.4018},
1463 {50, 15.1599},
1464 }},
1465 {"HeMcs2_40MHz",
1466 {
1467 {5, 26.1198},
1468 {10, 24.5088},
1469 {15, 23.5107},
1470 {20, 22.7810},
1471 {25, 22.1986},
1472 {30, 21.7101},
1473 {35, 21.2858},
1474 {40, 20.9104},
1475 {45, 20.5714},
1476 {50, 20.2613},
1477 }},
1478 {"HeMcs3_40MHz",
1479 {
1480 {5, 30.6683},
1481 {10, 28.8843},
1482 {15, 27.7540},
1483 {20, 26.9210},
1484 {25, 26.2528},
1485 {30, 25.6906},
1486 {35, 25.2012},
1487 {40, 24.7671},
1488 {45, 24.3746},
1489 {50, 24.0151},
1490 }},
1491 {"HeMcs4_40MHz",
1492 {
1493 {5, 38.5714},
1494 {10, 36.6144},
1495 {15, 35.3124},
1496 {20, 34.3355},
1497 {25, 33.5438},
1498 {30, 32.8728},
1499 {35, 32.2854},
1500 {40, 31.7623},
1501 {45, 31.2874},
1502 {50, 30.8512},
1503 }},
1504 {"HeMcs5_40MHz",
1505 {
1506 {5, 43.0043},
1507 {10, 41.0039},
1508 {15, 39.6294},
1509 {20, 38.5865},
1510 {25, 37.7358},
1511 {30, 37.0116},
1512 {35, 36.3756},
1513 {40, 35.8076},
1514 {45, 35.2909},
1515 {50, 34.8154},
1516 }},
1517 {"HeMcs6_40MHz",
1518 {
1519 {5, 45.6261},
1520 {10, 43.6185},
1521 {15, 42.2095},
1522 {20, 41.1328},
1523 {25, 40.2509},
1524 {30, 39.4981},
1525 {35, 38.8356},
1526 {40, 38.2430},
1527 {45, 37.7032},
1528 {50, 37.2058},
1529 }},
1530 {"HeMcs7_40MHz",
1531 {
1532 {5, 45.6261},
1533 {10, 43.6185},
1534 {15, 42.2095},
1535 {20, 41.1328},
1536 {25, 40.2509},
1537 {30, 39.4981},
1538 {35, 38.8356},
1539 {40, 38.2430},
1540 {45, 37.7032},
1541 {50, 37.2058},
1542 }},
1543 {"HeMcs8_40MHz",
1544 {
1545 {5, 48.5883},
1546 {10, 46.5892},
1547 {15, 45.1489},
1548 {20, 44.0388},
1549 {25, 43.1252},
1550 {30, 42.3428},
1551 {35, 41.6525},
1552 {40, 41.0338},
1553 {45, 40.4694},
1554 {50, 39.9486},
1555 }},
1556 {"HeMcs9_40MHz",
1557 {
1558 {5, 51.9619},
1559 {10, 49.9941},
1560 {15, 48.5284},
1561 {20, 47.3867},
1562 {25, 46.4416},
1563 {30, 45.6290},
1564 {35, 44.9099},
1565 {40, 44.2640},
1566 {45, 43.6736},
1567 {50, 43.1279},
1568 }},
1569 {"HeMcs10_40MHz",
1570 {
1571 {5, 51.9619},
1572 {10, 49.9941},
1573 {15, 48.5284},
1574 {20, 47.3867},
1575 {25, 46.4416},
1576 {30, 45.6290},
1577 {35, 44.9099},
1578 {40, 44.2640},
1579 {45, 43.6736},
1580 {50, 43.1279},
1581 }},
1582 {"HeMcs11_40MHz",
1583 {
1584 {5, 51.9619},
1585 {10, 49.9941},
1586 {15, 48.5284},
1587 {20, 47.3867},
1588 {25, 46.4416},
1589 {30, 45.6290},
1590 {35, 44.9099},
1591 {40, 44.2640},
1592 {45, 43.6736},
1593 {50, 43.1279},
1594 }},
1595 {"HeMcs0_80MHz",
1596 {
1597 {5, 20.0101},
1598 {10, 18.6928},
1599 {15, 17.8976},
1600 {20, 17.3219},
1601 {25, 16.8648},
1602 {30, 16.4830},
1603 {35, 16.1523},
1604 {40, 15.8603},
1605 {45, 15.5971},
1606 {50, 15.3567},
1607 }},
1608 {"HeMcs1_80MHz",
1609 {
1610 {5, 31.6415},
1611 {10, 29.8575},
1612 {15, 28.7177},
1613 {20, 27.8747},
1614 {25, 27.1971},
1615 {30, 26.6261},
1616 {35, 26.1283},
1617 {40, 25.6865},
1618 {45, 25.2866},
1619 {50, 24.9200},
1620 }},
1621 {"HeMcs2_80MHz",
1622 {
1623 {5, 38.0818},
1624 {10, 36.1730},
1625 {15, 34.9016},
1626 {20, 33.9470},
1627 {25, 33.1729},
1628 {30, 32.5165},
1629 {35, 31.9417},
1630 {40, 31.4295},
1631 {45, 30.9645},
1632 {50, 30.5372},
1633 }},
1634 {"HeMcs3_80MHz",
1635 {
1636 {5, 43.0043},
1637 {10, 41.0039},
1638 {15, 39.6294},
1639 {20, 38.5865},
1640 {25, 37.7358},
1641 {30, 37.0116},
1642 {35, 36.3756},
1643 {40, 35.8076},
1644 {45, 35.2909},
1645 {50, 34.8154},
1646 }},
1647 {"HeMcs4_80MHz",
1648 {
1649 {5, 48.5883},
1650 {10, 46.5892},
1651 {15, 45.1489},
1652 {20, 44.0388},
1653 {25, 43.1252},
1654 {30, 42.3428},
1655 {35, 41.6525},
1656 {40, 41.0338},
1657 {45, 40.4694},
1658 {50, 39.9486},
1659 }},
1660 {"HeMcs5_80MHz",
1661 {
1662 {5, 51.9619},
1663 {10, 49.9941},
1664 {15, 48.5284},
1665 {20, 47.3867},
1666 {25, 46.4416},
1667 {30, 45.6290},
1668 {35, 44.9099},
1669 {40, 44.2640},
1670 {45, 43.6736},
1671 {50, 43.1279},
1672 }},
1673 {"HeMcs6_80MHz",
1674 {
1675 {5, 55.8389},
1676 {10, 53.9360},
1677 {15, 52.4548},
1678 {20, 51.2855},
1679 {25, 50.3106},
1680 {30, 49.4682},
1681 {35, 48.7201},
1682 {40, 48.0462},
1683 {45, 47.4288},
1684 {50, 46.8571},
1685 }},
1686 {"HeMcs7_80MHz",
1687 {
1688 {5, 55.8389},
1689 {10, 53.9360},
1690 {15, 52.4548},
1691 {20, 51.2855},
1692 {25, 50.3106},
1693 {30, 49.4682},
1694 {35, 48.7201},
1695 {40, 48.0462},
1696 {45, 47.4288},
1697 {50, 46.8571},
1698 }},
1699 {"HeMcs8_80MHz",
1700 {
1701 {5, 55.8389},
1702 {10, 53.9360},
1703 {15, 52.4548},
1704 {20, 51.2855},
1705 {25, 50.3106},
1706 {30, 49.4682},
1707 {35, 48.7201},
1708 {40, 48.0462},
1709 {45, 47.4288},
1710 {50, 46.8571},
1711 }},
1712 {"HeMcs9_80MHz",
1713 {
1714 {5, 60.3411},
1715 {10, 58.5527},
1716 {15, 57.0724},
1717 {20, 55.8834},
1718 {25, 54.8827},
1719 {30, 54.0128},
1720 {35, 53.2368},
1721 {40, 52.5352},
1722 {45, 51.8906},
1723 {50, 51.2922},
1724 }},
1725 {"HeMcs10_80MHz",
1726 {
1727 {5, 60.3411},
1728 {10, 58.5527},
1729 {15, 57.0724},
1730 {20, 55.8834},
1731 {25, 54.8827},
1732 {30, 54.0128},
1733 {35, 53.2368},
1734 {40, 52.5352},
1735 {45, 51.8906},
1736 {50, 51.2922},
1737 }},
1738 {"HeMcs11_80MHz",
1739 {
1740 {5, 60.3411},
1741 {10, 58.5527},
1742 {15, 57.0724},
1743 {20, 55.8834},
1744 {25, 54.8827},
1745 {30, 54.0128},
1746 {35, 53.2368},
1747 {40, 52.5352},
1748 {45, 51.8906},
1749 {50, 51.2922},
1750 }},
1751 {"HeMcs0_160MHz",
1752 {
1753 {5, 30.6710},
1754 {10, 28.9919},
1755 {15, 27.9160},
1756 {20, 27.1188},
1757 {25, 26.4770},
1758 {30, 25.9355},
1759 {35, 25.4630},
1760 {40, 25.0432},
1761 {45, 24.6629},
1762 {50, 24.3141},
1763 }},
1764 {"HeMcs1_160MHz",
1765 {
1766 {5, 42.3965},
1767 {10, 40.4510},
1768 {15, 39.1127},
1769 {20, 38.0965},
1770 {25, 37.2670},
1771 {30, 36.5606},
1772 {35, 35.9398},
1773 {40, 35.3852},
1774 {45, 34.8806},
1775 {50, 34.4160},
1776 }},
1777 {"HeMcs2_160MHz",
1778 {
1779 {5, 47.8139},
1780 {10, 45.8767},
1781 {15, 44.4795},
1782 {20, 43.4017},
1783 {25, 42.5141},
1784 {30, 41.7535},
1785 {35, 41.0821},
1786 {40, 40.4801},
1787 {45, 39.9307},
1788 {50, 39.4236},
1789 }},
1790 {"HeMcs3_160MHz",
1791 {
1792 {5, 51.9619},
1793 {10, 49.9941},
1794 {15, 48.5284},
1795 {20, 47.3867},
1796 {25, 46.4416},
1797 {30, 45.6290},
1798 {35, 44.9099},
1799 {40, 44.2640},
1800 {45, 43.6736},
1801 {50, 43.1279},
1802 }},
1803 {"HeMcs4_160MHz",
1804 {
1805 {5, 55.8389},
1806 {10, 53.9360},
1807 {15, 52.4548},
1808 {20, 51.2855},
1809 {25, 50.3106},
1810 {30, 49.4682},
1811 {35, 48.7201},
1812 {40, 48.0462},
1813 {45, 47.4288},
1814 {50, 46.8571},
1815 }},
1816 {"HeMcs5_160MHz",
1817 {
1818 {5, 60.3411},
1819 {10, 58.5527},
1820 {15, 57.0724},
1821 {20, 55.8834},
1822 {25, 54.8827},
1823 {30, 54.0128},
1824 {35, 53.2368},
1825 {40, 52.5352},
1826 {45, 51.8906},
1827 {50, 51.2922},
1828 }},
1829 {"HeMcs6_160MHz",
1830 {
1831 {5, 60.3411},
1832 {10, 58.5527},
1833 {15, 57.0724},
1834 {20, 55.8834},
1835 {25, 54.8827},
1836 {30, 54.0128},
1837 {35, 53.2368},
1838 {40, 52.5352},
1839 {45, 51.8906},
1840 {50, 51.2922},
1841 }},
1842 {"HeMcs7_160MHz",
1843 {
1844 {5, 60.3411},
1845 {10, 58.5527},
1846 {15, 57.0724},
1847 {20, 55.8834},
1848 {25, 54.8827},
1849 {30, 54.0128},
1850 {35, 53.2368},
1851 {40, 52.5352},
1852 {45, 51.8906},
1853 {50, 51.2922},
1854 }},
1855 {"HeMcs8_160MHz",
1856 {
1857 {5, 60.3411},
1858 {10, 58.5527},
1859 {15, 57.0724},
1860 {20, 55.8834},
1861 {25, 54.8827},
1862 {30, 54.0128},
1863 {35, 53.2368},
1864 {40, 52.5352},
1865 {45, 51.8906},
1866 {50, 51.2922},
1867 }},
1868 {"HeMcs9_160MHz",
1869 {
1870 {5, 65.6329},
1871 {10, 64.0336},
1872 {15, 62.5814},
1873 {20, 61.3869},
1874 {25, 60.3690},
1875 {30, 59.4769},
1876 {35, 58.6764},
1877 {40, 57.9495},
1878 {45, 57.2790},
1879 {50, 56.6548},
1880 }},
1881 {"HeMcs10_160MHz",
1882 {
1883 {5, 65.6329},
1884 {10, 64.0336},
1885 {15, 62.5814},
1886 {20, 61.3869},
1887 {25, 60.3690},
1888 {30, 59.4769},
1889 {35, 58.6764},
1890 {40, 57.9495},
1891 {45, 57.2790},
1892 {50, 56.6548},
1893 }},
1894 {"HeMcs11_160MHz",
1895 {
1896 {5, 65.6329},
1897 {10, 64.0336},
1898 {15, 62.5814},
1899 {20, 61.3869},
1900 {25, 60.3690},
1901 {30, 59.4769},
1902 {35, 58.6764},
1903 {40, 57.9495},
1904 {45, 57.2790},
1905 {50, 56.6548},
1906 }},
1907};
1908
1909/**
1910 * Parse context strings of the form "/NodeList/x/DeviceList/x/..." to extract the NodeId integer
1911 *
1912 * @param context The context to parse.
1913 * @return the NodeId
1914 */
1916ContextToNodeId(std::string context)
1917{
1918 std::string sub = context.substr(10);
1919 uint32_t pos = sub.find("/Device");
1920 return std::stoi(sub.substr(0, pos));
1921}
1922
1923/**
1924 * Parse context strings of the form "/NodeList/x/DeviceList/x/..." and fetch the Mac address
1925 *
1926 * @param context The context to parse.
1927 * @return the device MAC address
1928 */
1930ContextToMac(std::string context)
1931{
1932 std::string sub = context.substr(10);
1933 uint32_t pos = sub.find("/Device");
1934 uint32_t nodeId = std::stoi(sub.substr(0, pos));
1935 Ptr<Node> n = NodeList::GetNode(nodeId);
1937 for (uint32_t i = 0; i < n->GetNDevices(); i++)
1938 {
1939 d = n->GetDevice(i)->GetObject<WifiNetDevice>();
1940 if (d)
1941 {
1942 break;
1943 }
1944 }
1945 return Mac48Address::ConvertFrom(d->GetAddress());
1946}
1947
1948// Functions for tracing.
1949
1950/**
1951 * Increment the counter for a given address.
1952 *
1953 * @param [out] counter The counter to increment.
1954 * @param addr The address to increment the counter for.
1955 * @param increment The increment (1 if omitted).
1956 */
1957void
1958IncrementCounter(std::map<Mac48Address, uint64_t>& counter,
1959 Mac48Address addr,
1960 uint64_t increment = 1)
1961{
1962 auto it = counter.find(addr);
1963 if (it != counter.end())
1964 {
1965 it->second += increment;
1966 }
1967 else
1968 {
1969 counter.insert(std::make_pair(addr, increment));
1970 }
1971}
1972
1973/**
1974 * Trace a packet reception.
1975 *
1976 * @param context The context.
1977 * @param p The packet.
1978 * @param channelFreqMhz The channel frequqncy.
1979 * @param txVector The TX vector.
1980 * @param aMpdu The AMPDU.
1981 * @param signalNoise The signal and noise dBm.
1982 * @param staId The STA ID.
1983 */
1984void
1985TracePacketReception(std::string context,
1987 uint16_t channelFreqMhz,
1988 WifiTxVector txVector,
1989 MpduInfo aMpdu,
1990 SignalNoiseDbm signalNoise,
1991 uint16_t staId)
1992{
1993 Ptr<Packet> packet = p->Copy();
1994 if (txVector.IsAggregation())
1995 {
1996 AmpduSubframeHeader subHdr;
1997 uint32_t extractedLength;
1998 packet->RemoveHeader(subHdr);
1999 extractedLength = subHdr.GetLength();
2000 packet = packet->CreateFragment(0, static_cast<uint32_t>(extractedLength));
2001 }
2002 WifiMacHeader hdr;
2003 packet->PeekHeader(hdr);
2004 // hdr.GetAddr1() is the receiving MAC address
2005 if (hdr.GetAddr1() != ContextToMac(context))
2006 {
2007 return;
2008 }
2009 // hdr.GetAddr2() is the sending MAC address
2010 if (packet->GetSize() >= pktSize) // ignore non-data frames
2011 {
2014 auto itTimeFirstReceived = timeFirstReceived.find(hdr.GetAddr2());
2015 if (itTimeFirstReceived == timeFirstReceived.end())
2016 {
2017 timeFirstReceived.insert(std::make_pair(hdr.GetAddr2(), Simulator::Now()));
2018 }
2019 auto itTimeLastReceived = timeLastReceived.find(hdr.GetAddr2());
2020 if (itTimeLastReceived != timeLastReceived.end())
2021 {
2022 itTimeLastReceived->second = Simulator::Now();
2023 }
2024 else
2025 {
2026 timeLastReceived.insert(std::make_pair(hdr.GetAddr2(), Simulator::Now()));
2027 }
2028 }
2029}
2030
2031/**
2032 * Contention window trace.
2033 *
2034 * @param context The context.
2035 * @param cw The contention window.
2036 */
2037void
2038CwTrace(std::string context, uint32_t cw, uint8_t /* linkId */)
2039{
2040 NS_LOG_INFO("CW time=" << Simulator::Now() << " node=" << ContextToNodeId(context)
2041 << " val=" << cw);
2042 if (tracing)
2043 {
2044 cwTraceFile << Simulator::Now().GetSeconds() << " " << ContextToNodeId(context) << " " << cw
2045 << std::endl;
2046 }
2047}
2048
2049/**
2050 * Backoff trace.
2051 *
2052 * @param context The context.
2053 * @param newVal The backoff value.
2054 */
2055void
2056BackoffTrace(std::string context, uint32_t newVal, uint8_t /* linkId */)
2057{
2058 NS_LOG_INFO("Backoff time=" << Simulator::Now() << " node=" << ContextToNodeId(context)
2059 << " val=" << newVal);
2060 if (tracing)
2061 {
2062 backoffTraceFile << Simulator::Now().GetSeconds() << " " << ContextToNodeId(context) << " "
2063 << newVal << std::endl;
2064 }
2065}
2066
2067/**
2068 * PHY Rx trace.
2069 *
2070 * @param context The context.
2071 * @param p The packet.
2072 * @param power The Rx power.
2073 */
2074void
2076{
2077 NS_LOG_INFO("PHY-RX-START time=" << Simulator::Now() << " node=" << ContextToNodeId(context)
2078 << " size=" << p->GetSize());
2079}
2080
2081/**
2082 * PHY Rx trace.
2083 *
2084 * @param context The context.
2085 * @param txVector The TX vector.
2086 * @param psduDuration The PDSU diration.
2087 */
2088void
2089PhyRxPayloadTrace(std::string context, WifiTxVector txVector, Time psduDuration)
2090{
2091 NS_LOG_INFO("PHY-RX-PAYLOAD-START time=" << Simulator::Now()
2092 << " node=" << ContextToNodeId(context)
2093 << " psduDuration=" << psduDuration);
2094}
2095
2096/**
2097 * PHY Drop trace.
2098 *
2099 * @param context The context.
2100 * @param p The packet.
2101 * @param reason The drop reason.
2102 */
2103void
2105{
2106 NS_LOG_INFO("PHY-RX-DROP time=" << Simulator::Now() << " node=" << ContextToNodeId(context)
2107 << " size=" << p->GetSize() << " reason=" << reason);
2108 Mac48Address addr = ContextToMac(context);
2109 switch (reason)
2110 {
2112 NS_FATAL_ERROR("RX packet with unsupported settings!");
2113 break;
2114 case CHANNEL_SWITCHING:
2115 NS_FATAL_ERROR("Channel is switching!");
2116 break;
2118 if (p->GetSize() >= pktSize) // ignore non-data frames
2119 {
2121 }
2122 break;
2123 }
2124 case RXING: {
2125 if (p->GetSize() >= pktSize) // ignore non-data frames
2126 {
2128 }
2129 break;
2130 }
2131 case TXING: {
2132 if (p->GetSize() >= pktSize) // ignore non-data frames
2133 {
2135 }
2136 break;
2137 }
2138 case SLEEPING:
2139 NS_FATAL_ERROR("Device is sleeping!");
2140 break;
2142 NS_FATAL_ERROR("Preamble should always be detected!");
2143 break;
2145 if (p->GetSize() >= pktSize) // ignore non-data frames
2146 {
2148 }
2149 break;
2150 }
2151 case L_SIG_FAILURE: {
2152 if (p->GetSize() >= pktSize) // ignore non-data frames
2153 {
2155 }
2156 break;
2157 }
2158 case HT_SIG_FAILURE:
2159 case SIG_A_FAILURE:
2160 case SIG_B_FAILURE:
2161 NS_FATAL_ERROR("Unexpected PHY header failure!");
2163 NS_FATAL_ERROR("All devices should send with same power, so no packet switch during "
2164 "preamble detection should occur!");
2165 break;
2167 NS_FATAL_ERROR("Frame capture should be disabled!");
2168 break;
2169 case OBSS_PD_CCA_RESET:
2170 NS_FATAL_ERROR("Unexpected CCA reset!");
2171 break;
2173 break;
2174 case UNKNOWN:
2175 default:
2176 NS_FATAL_ERROR("Unknown drop reason!");
2177 break;
2178 }
2179}
2180
2181/**
2182 * PHY RX end trace
2183 *
2184 * @param context The context.
2185 * @param p The packet.
2186 */
2187void
2188PhyRxDoneTrace(std::string context, Ptr<const Packet> p)
2189{
2190 NS_LOG_INFO("PHY-RX-END time=" << Simulator::Now() << " node=" << ContextToNodeId(context)
2191 << " size=" << p->GetSize());
2192}
2193
2194/**
2195 * PHY successful RX trace
2196 *
2197 * @param context The context.
2198 * @param p The packet.
2199 * @param snr The SNR.
2200 * @param mode The WiFi mode.
2201 * @param preamble The preamble.
2202 */
2203void
2204PhyRxOkTrace(std::string context,
2206 double snr,
2207 WifiMode mode,
2208 WifiPreamble preamble)
2209{
2210 uint8_t nMpdus = (p->GetSize() / pktSize);
2211 NS_LOG_INFO("PHY-RX-OK time=" << Simulator::Now().As(Time::S) << " node="
2212 << ContextToNodeId(context) << " size=" << p->GetSize()
2213 << " nMPDUs=" << +nMpdus << " snr=" << snr << " mode=" << mode
2214 << " preamble=" << preamble);
2215 if ((maxMpdus != 0) && (nMpdus != 0) && (nMpdus != maxMpdus))
2216 {
2217 if (nMpdus > maxMpdus)
2218 {
2219 NS_FATAL_ERROR("A-MPDU settings not properly applied: maximum configured MPDUs is "
2220 << +maxMpdus << " but received an A-MPDU containing " << +nMpdus
2221 << " MPDUs");
2222 }
2223 NS_LOG_WARN("Warning: less MPDUs aggregated in a received A-MPDU ("
2224 << +nMpdus << ") than configured (" << +maxMpdus << ")");
2225 }
2226 if (p->GetSize() >= pktSize) // ignore non-data frames
2227 {
2228 Mac48Address addr = ContextToMac(context);
2230 }
2231}
2232
2233/**
2234 * PHY RX error trace
2235 *
2236 * @param context The context.
2237 * @param p The packet.
2238 * @param snr The SNR.
2239 */
2240void
2241PhyRxErrorTrace(std::string context, Ptr<const Packet> p, double snr)
2242{
2243 NS_LOG_INFO("PHY-RX-ERROR time=" << Simulator::Now() << " node=" << ContextToNodeId(context)
2244 << " size=" << p->GetSize() << " snr=" << snr);
2245 if (p->GetSize() >= pktSize) // ignore non-data frames
2246 {
2247 Mac48Address addr = ContextToMac(context);
2249 }
2250}
2251
2252/**
2253 * PHY TX trace
2254 *
2255 * @param context The context.
2256 * @param p The packet.
2257 * @param txPowerW The TX power.
2258 */
2259void
2260PhyTxTrace(std::string context, Ptr<const Packet> p, double txPowerW)
2261{
2262 NS_LOG_INFO("PHY-TX-START time=" << Simulator::Now() << " node=" << ContextToNodeId(context)
2263 << " size=" << p->GetSize() << " " << txPowerW);
2264 if (tracing)
2265 {
2267 << " size=" << p->GetSize() << " " << txPowerW << std::endl;
2268 }
2269 if (p->GetSize() >= pktSize) // ignore non-data frames
2270 {
2271 Mac48Address addr = ContextToMac(context);
2273 }
2274}
2275
2276/**
2277 * PHY TX end trace.
2278 *
2279 * @param context The context.
2280 * @param p The packet.
2281 */
2282void
2283PhyTxDoneTrace(std::string context, Ptr<const Packet> p)
2284{
2285 NS_LOG_INFO("PHY-TX-END time=" << Simulator::Now() << " node=" << ContextToNodeId(context)
2286 << " " << p->GetSize());
2287}
2288
2289/**
2290 * MAC TX trace.
2291 *
2292 * @param context The context.
2293 * @param p The packet.
2294 */
2295void
2296MacTxTrace(std::string context, Ptr<const Packet> p)
2297{
2298 if (tracing)
2299 {
2300 macTxTraceFile << Simulator::Now().GetSeconds() << " " << ContextToNodeId(context) << " "
2301 << p->GetSize() << std::endl;
2302 }
2303}
2304
2305/**
2306 * MAC RX trace.
2307 *
2308 * @param context The context.
2309 * @param p The packet.
2310 */
2311void
2312MacRxTrace(std::string context, Ptr<const Packet> p)
2313{
2314 if (tracing)
2315 {
2316 macRxTraceFile << Simulator::Now().GetSeconds() << " " << ContextToNodeId(context) << " "
2317 << p->GetSize() << std::endl;
2318 }
2319}
2320
2321/**
2322 * Socket send trace.
2323 *
2324 * @param context The context.
2325 * @param p The packet.
2326 * @param addr destination address.
2327 */
2328void
2329SocketSendTrace(std::string context, Ptr<const Packet> p, const Address& addr)
2330{
2331 if (tracing)
2332 {
2334 << " " << p->GetSize() << " " << addr << std::endl;
2335 }
2336}
2337
2338/**
2339 * Association log trace.
2340 *
2341 * @param context The context.
2342 * @param address The MAC address.
2343 */
2344void
2345AssociationLog(std::string context, Mac48Address address)
2346{
2347 uint32_t nodeId = ContextToNodeId(context);
2348 auto it = associated.find(nodeId);
2349 if (it == associated.end())
2350 {
2351 NS_LOG_DEBUG("Association: time=" << Simulator::Now() << " node=" << nodeId);
2352 associated.insert(it, nodeId);
2353 }
2354 else
2355 {
2356 NS_FATAL_ERROR(nodeId << " is already associated!");
2357 }
2358}
2359
2360/**
2361 * Deassociation log trace.
2362 *
2363 * @param context The context.
2364 * @param address The MAC address.
2365 */
2366void
2367DisassociationLog(std::string context, Mac48Address address)
2368{
2369 uint32_t nodeId = ContextToNodeId(context);
2370 NS_LOG_DEBUG("Disassociation: time=" << Simulator::Now() << " node=" << nodeId);
2371 NS_FATAL_ERROR("Device should not disassociate!");
2372}
2373
2374/**
2375 * Reset the stats.
2376 */
2377void
2379{
2380 bytesReceived.clear();
2381 packetsReceived.clear();
2382 packetsTransmitted.clear();
2383 psduFailed.clear();
2384 psduSucceeded.clear();
2385 phyHeaderFailed.clear();
2386 timeFirstReceived.clear();
2387 timeLastReceived.clear();
2389 rxEventWhileRxing.clear();
2390 rxEventWhileTxing.clear();
2391 rxEventAbortedByTx.clear();
2392}
2393
2394/**
2395 * Class to configure and run an experiment.
2396 */
2398{
2399 public:
2400 Experiment();
2401
2402 /**
2403 * Configure and run the experiment.
2404 *
2405 * @param wifi the pre-configured WifiHelper
2406 * @param wifiPhy the pre-configured YansWifiPhyHelper
2407 * @param wifiMac the pre-configured WifiMacHelper
2408 * @param wifiChannel the pre-configured YansWifiChannelHelper
2409 * @param trialNumber the trial index
2410 * @param networkSize the number of stations
2411 * @param duration the duration of each simulation run
2412 * @param pcap flag to enable/disable PCAP files generation
2413 * @param infra flag to enable infrastructure model, ring adhoc network if not set
2414 * @param guardIntervalNs the guard interval in ns
2415 * @param distance the distance
2416 * @param apTxPower the AP transmit power
2417 * @param staTxPower the STA transmit power
2418 * @param pktInterval the packet interval
2419 * @return 0 if all went well
2420 *
2421 * Call graph was not generated because of its size.
2422 * @hidecallgraph
2423 */
2424 int Run(const WifiHelper& wifi,
2425 const YansWifiPhyHelper& wifiPhy,
2426 const WifiMacHelper& wifiMac,
2427 const YansWifiChannelHelper& wifiChannel,
2428 uint32_t trialNumber,
2429 uint32_t networkSize,
2430 Time duration,
2431 bool pcap,
2432 bool infra,
2433 uint16_t guardIntervalNs,
2434 meter_u distance,
2435 dBm_u apTxPower,
2436 dBm_u staTxPower,
2437 Time pktInterval);
2438};
2439
2443
2444int
2446 const YansWifiPhyHelper& wifiPhy,
2447 const WifiMacHelper& wifiMac,
2448 const YansWifiChannelHelper& wifiChannel,
2449 uint32_t trialNumber,
2450 uint32_t networkSize,
2451 Time duration,
2452 bool pcap,
2453 bool infra,
2454 uint16_t guardIntervalNs,
2455 meter_u distance,
2456 dBm_u apTxPower,
2457 dBm_u staTxPower,
2458 Time pktInterval)
2459{
2460 NodeContainer wifiNodes;
2461 if (infra)
2462 {
2463 wifiNodes.Create(networkSize + 1);
2464 }
2465 else
2466 {
2467 wifiNodes.Create(networkSize);
2468 }
2469
2470 YansWifiPhyHelper phy = wifiPhy;
2471 phy.SetErrorRateModel("ns3::NistErrorRateModel");
2472 phy.SetChannel(wifiChannel.Create());
2473 phy.SetPcapDataLinkType(WifiPhyHelper::DLT_IEEE802_11_RADIO);
2474
2475 WifiMacHelper mac = wifiMac;
2476 const auto& wifi = helper;
2477 NetDeviceContainer devices;
2478 uint32_t nNodes = wifiNodes.GetN();
2479 if (infra)
2480 {
2481 Ssid ssid = Ssid("wifi-bianchi");
2482 uint64_t beaconInterval = std::min<uint64_t>(
2483 (ceil((duration.GetSeconds() * 1000000) / 1024) * 1024),
2484 (65535 * 1024)); // beacon interval needs to be a multiple of time units (1024 us)
2485 mac.SetType("ns3::ApWifiMac",
2486 "BeaconInterval",
2487 TimeValue(MicroSeconds(beaconInterval)),
2488 "Ssid",
2489 SsidValue(ssid));
2490 phy.Set("TxPowerStart", DoubleValue(apTxPower));
2491 phy.Set("TxPowerEnd", DoubleValue(apTxPower));
2492 devices = wifi.Install(phy, mac, wifiNodes.Get(0));
2493
2494 mac.SetType("ns3::StaWifiMac",
2495 "MaxMissedBeacons",
2496 UintegerValue(std::numeric_limits<uint32_t>::max()),
2497 "Ssid",
2498 SsidValue(ssid));
2499 phy.Set("TxPowerStart", DoubleValue(staTxPower));
2500 phy.Set("TxPowerEnd", DoubleValue(staTxPower));
2501 for (uint32_t i = 1; i < nNodes; ++i)
2502 {
2503 devices.Add(wifi.Install(phy, mac, wifiNodes.Get(i)));
2504 }
2505 }
2506 else
2507 {
2508 mac.SetType("ns3::AdhocWifiMac");
2509 phy.Set("TxPowerStart", DoubleValue(staTxPower));
2510 phy.Set("TxPowerEnd", DoubleValue(staTxPower));
2511 devices = wifi.Install(phy, mac, wifiNodes);
2512 }
2513
2514 WifiHelper::AssignStreams(devices, trialNumber);
2515
2517 "/NodeList/*/DeviceList/*/$ns3::WifiNetDevice/HtConfiguration/ShortGuardIntervalSupported",
2518 BooleanValue(guardIntervalNs == 400));
2519 Config::Set("/NodeList/*/DeviceList/*/$ns3::WifiNetDevice/HeConfiguration/GuardInterval",
2520 TimeValue(NanoSeconds(guardIntervalNs)));
2521
2522 // Configure aggregation
2523 for (uint32_t i = 0; i < nNodes; ++i)
2524 {
2525 Ptr<NetDevice> dev = wifiNodes.Get(i)->GetDevice(0);
2527 wifi_dev->GetMac()->SetAttribute("BE_MaxAmpduSize",
2528 UintegerValue(maxMpdus * (pktSize + 50)));
2529 wifi_dev->GetMac()->SetAttribute("BK_MaxAmpduSize",
2530 UintegerValue(maxMpdus * (pktSize + 50)));
2531 wifi_dev->GetMac()->SetAttribute("VO_MaxAmpduSize",
2532 UintegerValue(maxMpdus * (pktSize + 50)));
2533 wifi_dev->GetMac()->SetAttribute("VI_MaxAmpduSize",
2534 UintegerValue(maxMpdus * (pktSize + 50)));
2535 }
2536
2537 MobilityHelper mobility;
2539 mobility.SetMobilityModel("ns3::ConstantPositionMobilityModel");
2540 // Set position for AP
2541 positionAlloc->Add(Vector(1.0, 1.0, 0.0));
2542
2543 // Set position for STAs
2544 const auto angle = (static_cast<degree_u>(360) / (nNodes - 1));
2545 for (uint32_t i = 0; i < (nNodes - 1); ++i)
2546 {
2547 positionAlloc->Add(Vector(1.0 + (distance * cos((i * angle * std::numbers::pi) / 180)),
2548 1.0 + (distance * sin((i * angle * std::numbers::pi) / 180)),
2549 0.0));
2550 }
2551
2552 mobility.SetPositionAllocator(positionAlloc);
2553 mobility.Install(wifiNodes);
2554
2555 PacketSocketHelper packetSocket;
2556 packetSocket.Install(wifiNodes);
2557
2560 startTime->SetAttribute("Stream", IntegerValue(trialNumber));
2561 startTime->SetAttribute("Max", DoubleValue(5.0));
2562
2563 uint32_t i = infra ? 1 : 0;
2564 for (; i < nNodes; ++i)
2565 {
2566 uint32_t j = infra ? 0 : (i + 1) % nNodes;
2567 PacketSocketAddress socketAddr;
2568 socketAddr.SetSingleDevice(devices.Get(i)->GetIfIndex());
2569 socketAddr.SetPhysicalAddress(devices.Get(j)->GetAddress());
2570 socketAddr.SetProtocol(1);
2571
2573 client->SetRemote(socketAddr);
2574 wifiNodes.Get(i)->AddApplication(client);
2575 client->SetAttribute("PacketSize", UintegerValue(pktSize));
2576 client->SetAttribute("MaxPackets", UintegerValue(0));
2577 client->SetAttribute("Interval", TimeValue(pktInterval));
2578 double start = startTime->GetValue();
2579 NS_LOG_DEBUG("Client " << i << " starting at " << start);
2580 client->SetStartTime(Seconds(start));
2581
2583 server->SetLocal(socketAddr);
2584 wifiNodes.Get(j)->AddApplication(server);
2585 }
2586
2587 // Log packet receptions
2589 "/NodeList/*/DeviceList/*/$ns3::WifiNetDevice/Phy/$ns3::WifiPhy/MonitorSnifferRx",
2591
2592 // Log association and disassociation
2593 if (infra)
2594 {
2595 Config::Connect("/NodeList/*/DeviceList/*/$ns3::WifiNetDevice/Mac/$ns3::StaWifiMac/Assoc",
2597 Config::Connect("/NodeList/*/DeviceList/*/$ns3::WifiNetDevice/Mac/$ns3::StaWifiMac/DeAssoc",
2599 }
2600
2601 std::string txop =
2602 StaticCast<WifiNetDevice>(wifiNodes.Get(0)->GetDevice(0))->GetMac()->GetQosSupported()
2603 ? "BE_Txop"
2604 : "Txop";
2605 // Trace CW evolution
2606 Config::Connect("/NodeList/*/DeviceList/*/$ns3::WifiNetDevice/Mac/$ns3::WifiMac/" + txop +
2607 "/CwTrace",
2609 // Trace backoff evolution
2610 Config::Connect("/NodeList/*/DeviceList/*/$ns3::WifiNetDevice/Mac/$ns3::WifiMac/" + txop +
2611 "/BackoffTrace",
2613 // Trace PHY Tx start events
2614 Config::Connect("/NodeList/*/DeviceList/*/$ns3::WifiNetDevice/Phy/$ns3::WifiPhy/PhyTxBegin",
2616 // Trace PHY Tx end events
2617 Config::Connect("/NodeList/*/DeviceList/*/$ns3::WifiNetDevice/Phy/$ns3::WifiPhy/PhyTxEnd",
2619 // Trace PHY Rx start events
2620 Config::Connect("/NodeList/*/DeviceList/*/$ns3::WifiNetDevice/Phy/$ns3::WifiPhy/PhyRxBegin",
2622 // Trace PHY Rx payload start events
2624 "/NodeList/*/DeviceList/*/$ns3::WifiNetDevice/Phy/$ns3::WifiPhy/PhyRxPayloadBegin",
2626 // Trace PHY Rx drop events
2627 Config::Connect("/NodeList/*/DeviceList/*/$ns3::WifiNetDevice/Phy/$ns3::WifiPhy/PhyRxDrop",
2629 // Trace PHY Rx end events
2630 Config::Connect("/NodeList/*/DeviceList/*/$ns3::WifiNetDevice/Phy/$ns3::WifiPhy/PhyRxEnd",
2632 // Trace PHY Rx error events
2633 Config::Connect("/NodeList/*/DeviceList/*/$ns3::WifiNetDevice/Phy/$ns3::WifiPhy/State/RxError",
2635 // Trace PHY Rx success events
2636 Config::Connect("/NodeList/*/DeviceList/*/$ns3::WifiNetDevice/Phy/$ns3::WifiPhy/State/RxOk",
2638 // Trace packet transmission by the device
2639 Config::Connect("/NodeList/*/DeviceList/*/$ns3::WifiNetDevice/Mac/MacTx",
2641 // Trace packet receptions to the device
2642 Config::Connect("/NodeList/*/DeviceList/*/$ns3::WifiNetDevice/Mac/MacRx",
2644 // Trace packets transmitted by the application
2645 Config::Connect("/NodeList/*/$ns3::Node/ApplicationList/*/$ns3::PacketSocketClient/Tx",
2647
2648 WifiTxStatsHelper wifiTxStats;
2649 if (useTxHelper)
2650 {
2651 // Setup Wi-Fi Transmission Statistics Helper (WifiTxStatsHelper) for all devices
2652 wifiTxStats.Enable(devices);
2653 wifiTxStats.Start(Seconds(10));
2654 wifiTxStats.Stop(Seconds(10) + duration);
2655 }
2656
2657 WifiPhyRxTraceHelper rxTraceHelper;
2658 if (useRxHelper)
2659 {
2660 // Setup Wi-Fi PHY Reception Trace Helper (WifiPhyRxTraceHelper) for all devices
2661 rxTraceHelper.Enable(devices);
2662 rxTraceHelper.Start(Seconds(10));
2663 rxTraceHelper.Stop(Seconds(10) + duration);
2664 }
2665
2667 Simulator::Stop(Seconds(10) + duration);
2668
2669 if (pcap)
2670 {
2671 phy.EnablePcap("wifi_bianchi_pcap", devices);
2672 }
2673
2676
2677 if (useTxHelper)
2678 {
2679 // Get results from WifiTxStatsHelper
2680 const auto numSuccessPerNodeDevice = wifiTxStats.GetSuccessesByNodeDevice();
2681 const auto numFailurePerNodeDevice = wifiTxStats.GetFailuresByNodeDevice();
2682 const auto numFailureDueToFailedEnqueuePerNodeDevice =
2684 const auto numFailureDueToExpiredLifetimePerNodeDevice =
2686 const auto numFailureDueToRetryLimitReachedPerNodeDevice =
2688 const auto numFailureDueToQosOldPacketPerNodeDevice =
2690 const auto numRetransPerNodeDevice = wifiTxStats.GetRetransmissionsByNodeDevice();
2691 std::cout << "WifiTxStatsHelper: node to number of MPDUs acked during (10, "
2692 << 10 + duration.ToInteger(Time::S) << "] s:" << std::endl;
2693 if (numSuccessPerNodeDevice.empty())
2694 {
2695 std::cout << "none\n";
2696 }
2697 else
2698 {
2699 std::cout << std::setw(5) << "node" << std::setw(10) << "nSuccess" << std::endl;
2700 for (const auto& [nodeDevTuple, nSuccess] : numSuccessPerNodeDevice)
2701 {
2702 std::cout << std::setw(5) << std::get<0>(nodeDevTuple) << std::setw(10) << nSuccess
2703 << std::endl;
2704 }
2705 }
2706 std::cout
2707 << "WifiTxStatsHelper: node to number of MPDUs failed (due to any reason) during (10, "
2708 << 10 + duration.ToInteger(Time::S) << "] s:" << std::endl;
2709 if (numFailurePerNodeDevice.empty())
2710 {
2711 std::cout << "none\n";
2712 }
2713 else
2714 {
2715 std::cout << std::setw(5) << "node" << std::setw(10) << "nFailed" << std::endl;
2716 for (const auto& [nodeDevTuple, nFailure] : numFailurePerNodeDevice)
2717 {
2718 std::cout << std::setw(5) << std::get<0>(nodeDevTuple) << std::setw(10) << nFailure
2719 << std::endl;
2720 }
2721 std::cout << "WifiTxStatsHelper: node to number of MPDUs failed (due to "
2722 "WIFI_MAC_DROP_FAILED_ENQUEUE) during (10, "
2723 << 10 + duration.ToInteger(Time::S) << "] s:" << std::endl;
2724 if (numFailureDueToFailedEnqueuePerNodeDevice.empty())
2725 {
2726 std::cout << "none\n";
2727 }
2728 else
2729 {
2730 std::cout << std::setw(5) << "node" << std::setw(10) << "nFailed" << std::endl;
2731 for (const auto& [nodeDevTuple, nFailure] :
2732 numFailureDueToFailedEnqueuePerNodeDevice)
2733 {
2734 std::cout << std::setw(5) << std::get<0>(nodeDevTuple) << std::setw(10)
2735 << nFailure << std::endl;
2736 }
2737 }
2738 std::cout << "WifiTxStatsHelper: node to number of MPDUs failed (due to "
2739 "WIFI_MAC_DROP_EXPIRED_LIFETIME) during (10, "
2740 << 10 + duration.ToInteger(Time::S) << "] s:" << std::endl;
2741 if (numFailureDueToExpiredLifetimePerNodeDevice.empty())
2742 {
2743 std::cout << "none\n";
2744 }
2745 else
2746 {
2747 std::cout << std::setw(5) << "node" << std::setw(10) << "nFailed" << std::endl;
2748 for (const auto& [nodeDevTuple, nFailure] :
2749 numFailureDueToExpiredLifetimePerNodeDevice)
2750 {
2751 std::cout << std::setw(5) << std::get<0>(nodeDevTuple) << std::setw(10)
2752 << nFailure << std::endl;
2753 }
2754 }
2755 std::cout << "WifiTxStatsHelper: node to number of MPDUs failed (due to "
2756 "WIFI_MAC_DROP_REACHED_RETRY_LIMIT) during (10, "
2757 << 10 + duration.ToInteger(Time::S) << "] s:" << std::endl;
2758 if (numFailureDueToRetryLimitReachedPerNodeDevice.empty())
2759 {
2760 std::cout << "none\n";
2761 }
2762 else
2763 {
2764 std::cout << std::setw(5) << "node" << std::setw(10) << "nFailed" << std::endl;
2765 for (const auto& [nodeDevTuple, nFailure] :
2766 numFailureDueToRetryLimitReachedPerNodeDevice)
2767 {
2768 std::cout << std::setw(5) << std::get<0>(nodeDevTuple) << std::setw(10)
2769 << nFailure << std::endl;
2770 }
2771 }
2772 std::cout << "WifiTxStatsHelper: node to number of MPDUs failed (due to "
2773 "WIFI_MAC_DROP_QOS_OLD_PACKET) during (10, "
2774 << 10 + duration.ToInteger(Time::S) << "] s:" << std::endl;
2775 if (numFailureDueToQosOldPacketPerNodeDevice.empty())
2776 {
2777 std::cout << "none\n";
2778 }
2779 else
2780 {
2781 std::cout << std::setw(5) << "node" << std::setw(10) << "nFailed" << std::endl;
2782 for (const auto& [nodeDevTuple, nFailure] :
2783 numFailureDueToQosOldPacketPerNodeDevice)
2784 {
2785 std::cout << std::setw(5) << std::get<0>(nodeDevTuple) << std::setw(10)
2786 << nFailure << std::endl;
2787 }
2788 }
2789 }
2790 std::cout << "WifiTxStatsHelper: node to number of retransmissions of MPDUs "
2791 "Acked during (10, "
2792 << 10 + duration.ToInteger(Time::S) << "] s:" << std::endl;
2793 if (numRetransPerNodeDevice.empty())
2794 {
2795 std::cout << "none\n";
2796 }
2797 else
2798 {
2799 std::cout << std::setw(5) << "node" << std::setw(10) << "nRetrans" << std::endl;
2800 for (const auto& [nodeDevTuple, nRetrans] : numRetransPerNodeDevice)
2801 {
2802 std::cout << std::setw(5) << std::get<0>(nodeDevTuple) << std::setw(10) << nRetrans
2803 << std::endl;
2804 }
2805 }
2806 }
2807
2808 if (useRxHelper)
2809 {
2810 // Get results from WifiPhyRxTraceHelper
2811 std::cout << "\nWifiPhyRxTraceHelper: overall statistics" << std::endl;
2812 rxTraceHelper.PrintStatistics();
2813 for (uint32_t nodeIndex = 0; nodeIndex < nNodes; ++nodeIndex)
2814 {
2815 std::cout << "\nWifiPhyRxTraceHelper: per-node statistics for node " << nodeIndex
2816 << std::endl;
2817 rxTraceHelper.PrintStatistics(nodeIndex);
2818 }
2819 std::cout << std::endl;
2820 }
2821
2822 if (tracing)
2823 {
2824 cwTraceFile.flush();
2825 backoffTraceFile.flush();
2826 phyTxTraceFile.flush();
2827 macTxTraceFile.flush();
2828 macRxTraceFile.flush();
2829 socketSendTraceFile.flush();
2830 }
2831
2832 return 0;
2833}
2834
2835/**
2836 * Get the Counter associated with a MAC address.
2837 *
2838 * @param counter The map of counters to inspect.
2839 * @param addr The MAC address.
2840 * @return the value of the counter,
2841 */
2842uint64_t
2843GetCount(const std::map<Mac48Address, uint64_t>& counter, Mac48Address addr)
2844{
2845 uint64_t count = 0;
2846 auto it = counter.find(addr);
2847 if (it != counter.end())
2848 {
2849 count = it->second;
2850 }
2851 return count;
2852}
2853
2854} // unnamed namespace
2855
2856int
2857main(int argc, char* argv[])
2858{
2859 uint32_t nMinStas = 5; ///< Minimum number of STAs to start with
2860 uint32_t nMaxStas = 50; ///< Maximum number of STAs to end with
2861 uint32_t nStepSize = 5; ///< Number of stations to add at each step
2862 uint32_t verbose = 0; ///< verbosity level that increases the number of debugging traces
2863 double duration = 100; ///< duration (in seconds) of each simulation run (i.e. per trial and per
2864 ///< number of stations)
2865 uint32_t trials = 1; ///< Number of runs per point in the plot
2866 bool pcap = false; ///< Flag to enable/disable PCAP files generation
2867 bool infra = false; ///< Flag to enable infrastructure model, ring adhoc network if not set
2868 std::string workDir = "./"; ///< the working directory to store generated files
2869 std::string phyMode =
2870 "OfdmRate54Mbps"; ///< the constant PHY mode string used to transmit frames
2871 std::string standard("11a"); ///< the 802.11 standard
2872 bool validate = false; ///< Flag used for regression in order to verify ns-3 results are in the
2873 ///< expected boundaries
2874 uint16_t plotBianchiModel =
2875 0x01; ///< First bit corresponds to the DIFS model, second bit to the EIFS model
2876 double maxRelativeError =
2877 0.015; ///< Maximum relative error tolerated between ns-3 results and the Bianchi model
2878 ///< (used for regression, i.e. when the validate flag is set)
2879 double frequency = 5; ///< The operating frequency band in GHz: 2.4, 5 or 6
2880 uint16_t channelWidth = 20; ///< The constant channel width in MHz (only for 11n/ac/ax)
2881 uint16_t guardIntervalNs = 800; ///< The guard interval in nanoseconds (800 or 400 for 11n/ac,
2882 ///< 800 or 1600 or 3200 for 11 ax)
2883 uint16_t pktInterval =
2884 1000; ///< The socket packet interval in microseconds (a higher value is needed to reach
2885 ///< saturation conditions as the channel bandwidth or the MCS increases)
2886 meter_u distance = 0.001; ///< The distance in meters between the AP and the STAs
2887 dBm_u apTxPower{16}; ///< The transmit power of the AP (if infrastructure only)
2888 dBm_u staTxPower{16}; ///< The transmit power of each STA (or all STAs if adhoc)
2889
2890 // Disable fragmentation and RTS/CTS
2891 Config::SetDefault("ns3::WifiRemoteStationManager::FragmentationThreshold",
2892 StringValue("22000"));
2893 Config::SetDefault("ns3::WifiRemoteStationManager::RtsCtsThreshold", StringValue("22000"));
2894 // Make CW stay equal to CWmax until a packet is acknowledged
2895 Config::SetDefault("ns3::WifiMac::FrameRetryLimit", UintegerValue(65535));
2896 // Set maximum queue size to the largest value and set maximum queue delay to be larger than the
2897 // simulation time
2899 "ns3::WifiMacQueue::MaxSize",
2900 QueueSizeValue(QueueSize(QueueSizeUnit::PACKETS, std::numeric_limits<uint32_t>::max())));
2901 Config::SetDefault("ns3::WifiMacQueue::MaxDelay", TimeValue(Seconds(2 * duration)));
2902
2903 CommandLine cmd(__FILE__);
2904 cmd.AddValue("verbose",
2905 "Logging level (0: no log - 1: simulation script logs - 2: all logs)",
2906 verbose);
2907 cmd.AddValue("tracing", "Generate trace files", tracing);
2908 cmd.AddValue("useTxHelper", "Enable WifiTxStatsHelper on all devices", useTxHelper);
2909 cmd.AddValue("useRxHelper", "Enable WifiPhyRxTraceHelper on all devices", useRxHelper);
2910 cmd.AddValue("pktSize", "The packet size in bytes", pktSize);
2911 cmd.AddValue("trials", "The maximal number of runs per network size", trials);
2912 cmd.AddValue("duration", "Time duration for each trial in seconds", duration);
2913 cmd.AddValue("pcap", "Enable/disable PCAP tracing", pcap);
2914 cmd.AddValue("infra", "True to use infrastructure mode, false to use ring adhoc mode", infra);
2915 cmd.AddValue("workDir", "The working directory used to store generated files", workDir);
2916 cmd.AddValue("phyMode", "Set the constant PHY mode string used to transmit frames", phyMode);
2917 cmd.AddValue("standard", "Set the standard (11a, 11b, 11g, 11n, 11ac, 11ax)", standard);
2918 cmd.AddValue("nMinStas", "Minimum number of stations to start with", nMinStas);
2919 cmd.AddValue("nMaxStas", "Maximum number of stations to start with", nMaxStas);
2920 cmd.AddValue("nStepSize", "Number of stations to add at each step", nStepSize);
2921 cmd.AddValue("plotBianchiModel",
2922 "First bit corresponds to the DIFS model, second bit to the EIFS model",
2923 plotBianchiModel);
2924 cmd.AddValue("validate",
2925 "Enable/disable validation of the ns-3 simulations against the Bianchi model",
2926 validate);
2927 cmd.AddValue("maxRelativeError",
2928 "The maximum relative error tolerated between ns-3 results and the Bianchi model "
2929 "(used for regression, i.e. when the validate flag is set)",
2930 maxRelativeError);
2931 cmd.AddValue("frequency", "Set the operating frequency band in GHz: 2.4, 5 or 6", frequency);
2932 cmd.AddValue("channelWidth",
2933 "Set the constant channel width in MHz (only for 11n/ac/ax)",
2934 channelWidth);
2935 cmd.AddValue("guardIntervalNs",
2936 "Set the guard interval in nanoseconds (800 or 400 for 11n/ac, 800 or 1600 or "
2937 "3200 for 11 ax)",
2938 guardIntervalNs);
2939 cmd.AddValue("maxMpdus",
2940 "Set the maximum number of MPDUs in A-MPDUs (0 to disable MPDU aggregation)",
2941 maxMpdus);
2942 cmd.AddValue("distance", "Set the distance in meters between the AP and the STAs", distance);
2943 cmd.AddValue("apTxPower",
2944 "Set the transmit power of the AP in dBm (if infrastructure only)",
2945 apTxPower);
2946 cmd.AddValue("staTxPower",
2947 "Set the transmit power of each STA in dBm (or all STAs if adhoc)",
2948 staTxPower);
2949 cmd.AddValue("pktInterval", "Set the socket packet interval in microseconds", pktInterval);
2950 cmd.Parse(argc, argv);
2951
2952 if (tracing)
2953 {
2954 cwTraceFile.open("wifi-bianchi-cw-trace.out");
2955 if (!cwTraceFile.is_open())
2956 {
2957 NS_FATAL_ERROR("Failed to open file wifi-bianchi-cw-trace.out");
2958 }
2959 backoffTraceFile.open("wifi-bianchi-backoff-trace.out");
2960 if (!backoffTraceFile.is_open())
2961 {
2962 NS_FATAL_ERROR("Failed to open file wifi-bianchi-backoff-trace.out");
2963 }
2964 phyTxTraceFile.open("wifi-bianchi-phy-tx-trace.out");
2965 if (!phyTxTraceFile.is_open())
2966 {
2967 NS_FATAL_ERROR("Failed to open file wifi-bianchi-phy-tx-trace.out");
2968 }
2969 macTxTraceFile.open("wifi-bianchi-mac-tx-trace.out");
2970 if (!macTxTraceFile.is_open())
2971 {
2972 NS_FATAL_ERROR("Failed to open file wifi-bianchi-mac-tx-trace.out");
2973 }
2974 macRxTraceFile.open("wifi-bianchi-mac-rx-trace.out");
2975 if (!macRxTraceFile.is_open())
2976 {
2977 NS_FATAL_ERROR("Failed to open file wifi-bianchi-mac-rx-trace.out");
2978 }
2979 socketSendTraceFile.open("wifi-bianchi-socket-send-trace.out");
2980 if (!socketSendTraceFile.is_open())
2981 {
2982 NS_FATAL_ERROR("Failed to open file wifi-bianchi-socket-send-trace.out");
2983 }
2984 }
2985
2986 if (verbose >= 1)
2987 {
2988 LogComponentEnable("WifiBianchi", LOG_LEVEL_ALL);
2989 }
2990 else
2991 {
2992 LogComponentEnable("WifiBianchi", LOG_LEVEL_WARN);
2993 }
2994 if (verbose >= 2)
2995 {
2997 }
2998
2999 std::stringstream phyModeStr;
3000 phyModeStr << phyMode;
3001 if (phyMode.find("Mcs") != std::string::npos)
3002 {
3003 phyModeStr << "_" << channelWidth << "MHz";
3004 }
3005
3006 std::stringstream ss;
3007 ss << "wifi-" << standard << "-p-" << pktSize << (infra ? "-infrastructure" : "-adhoc") << "-r-"
3008 << phyModeStr.str() << "-min-" << nMinStas << "-max-" << nMaxStas << "-step-" << nStepSize
3009 << "-throughput.plt";
3010 std::ofstream throughputPlot(ss.str());
3011 ss.str("");
3012 ss << "wifi-" << standard << "-p-" << pktSize << (infra ? "-infrastructure" : "-adhoc") << "-r-"
3013 << phyModeStr.str() << "-min-" << nMinStas << "-max-" << nMaxStas << "-step-" << nStepSize
3014 << "-throughput.eps";
3015 Gnuplot gnuplot = Gnuplot(ss.str());
3016
3017 WifiStandard wifiStandard;
3018 if (standard == "11a")
3019 {
3020 wifiStandard = WIFI_STANDARD_80211a;
3021 frequency = 5;
3022 channelWidth = 20;
3023 }
3024 else if (standard == "11b")
3025 {
3026 wifiStandard = WIFI_STANDARD_80211b;
3027 frequency = 2.4;
3028 channelWidth = 22;
3029 }
3030 else if (standard == "11g")
3031 {
3032 wifiStandard = WIFI_STANDARD_80211g;
3033 frequency = 2.4;
3034 channelWidth = 20;
3035 }
3036 else if (standard == "11n")
3037 {
3038 if (frequency == 2.4 || frequency == 5)
3039 {
3040 wifiStandard = WIFI_STANDARD_80211n;
3041 }
3042 else
3043 {
3044 NS_FATAL_ERROR("Unsupported frequency band " << frequency << " GHz for standard "
3045 << standard);
3046 }
3047 }
3048 else if (standard == "11ac")
3049 {
3050 wifiStandard = WIFI_STANDARD_80211ac;
3051 frequency = 5;
3052 }
3053 else if (standard == "11ax")
3054 {
3055 if (frequency == 2.4 || frequency == 5 || frequency == 6)
3056 {
3057 wifiStandard = WIFI_STANDARD_80211ax;
3058 }
3059 else
3060 {
3061 NS_FATAL_ERROR("Unsupported frequency band " << frequency << " GHz for standard "
3062 << standard);
3063 }
3064 }
3065 else
3066 {
3067 NS_FATAL_ERROR("Unsupported standard: " << standard);
3068 }
3069
3070 std::string channelStr = "{0, " + std::to_string(channelWidth) + ", BAND_" +
3071 (frequency == 2.4 ? "2_4" : (frequency == 5 ? "5" : "6")) + "GHZ, 0}";
3072 Config::SetDefault("ns3::WifiPhy::ChannelSettings", StringValue(channelStr));
3073
3074 YansWifiPhyHelper wifiPhy;
3076
3077 YansWifiChannelHelper wifiChannel;
3078 wifiChannel.SetPropagationDelay("ns3::ConstantSpeedPropagationDelayModel");
3079 if (frequency == 6)
3080 {
3081 // Reference Loss for Friss at 1 m with 6.0 GHz
3082 wifiChannel.AddPropagationLoss("ns3::LogDistancePropagationLossModel",
3083 "Exponent",
3084 DoubleValue(2.0),
3085 "ReferenceDistance",
3086 DoubleValue(1.0),
3087 "ReferenceLoss",
3088 DoubleValue(49.013));
3089 }
3090 else if (frequency == 5)
3091 {
3092 // Reference Loss for Friss at 1 m with 5.15 GHz
3093 wifiChannel.AddPropagationLoss("ns3::LogDistancePropagationLossModel",
3094 "Exponent",
3095 DoubleValue(2.0),
3096 "ReferenceDistance",
3097 DoubleValue(1.0),
3098 "ReferenceLoss",
3099 DoubleValue(46.6777));
3100 }
3101 else
3102 {
3103 // Reference Loss for Friss at 1 m with 2.4 GHz
3104 wifiChannel.AddPropagationLoss("ns3::LogDistancePropagationLossModel",
3105 "Exponent",
3106 DoubleValue(2.0),
3107 "ReferenceDistance",
3108 DoubleValue(1.0),
3109 "ReferenceLoss",
3110 DoubleValue(40.046));
3111 }
3112
3114 wifi.SetStandard(wifiStandard);
3115 wifi.SetRemoteStationManager("ns3::ConstantRateWifiManager",
3116 "DataMode",
3117 StringValue(phyMode),
3118 "ControlMode",
3119 StringValue(phyMode));
3120
3121 Gnuplot2dDataset dataset;
3122 Gnuplot2dDataset datasetBianchiEifs;
3123 Gnuplot2dDataset datasetBianchiDifs;
3126 datasetBianchiEifs.SetStyle(Gnuplot2dDataset::LINES_POINTS);
3127 datasetBianchiDifs.SetStyle(Gnuplot2dDataset::LINES_POINTS);
3128
3130 WifiMacHelper wifiMac;
3131 double averageThroughput;
3132 std::vector<double> throughputArray(trials);
3133 for (uint32_t n = nMinStas; n <= nMaxStas; n += nStepSize)
3134 {
3135 averageThroughput = 0;
3136 double throughput;
3137 for (uint32_t runIndex = 0; runIndex < trials; runIndex++)
3138 {
3139 packetsReceived.clear();
3140 bytesReceived.clear();
3141 packetsTransmitted.clear();
3142 psduFailed.clear();
3143 psduSucceeded.clear();
3144 phyHeaderFailed.clear();
3145 timeFirstReceived.clear();
3146 timeLastReceived.clear();
3148 rxEventWhileRxing.clear();
3149 rxEventWhileTxing.clear();
3150 rxEventAbortedByTx.clear();
3151 associated.clear();
3152 throughput = 0;
3153 std::cout << "Trial " << runIndex + 1 << " of " << trials << "; " << phyModeStr.str()
3154 << " for " << n << " nodes " << std::endl;
3155 if (tracing)
3156 {
3157 cwTraceFile << "# Trial " << runIndex + 1 << " of " << trials << "; "
3158 << phyModeStr.str() << " for " << n << " nodes" << std::endl;
3159 backoffTraceFile << "# Trial " << runIndex + 1 << " of " << trials << "; "
3160 << phyModeStr.str() << " for " << n << " nodes" << std::endl;
3161 phyTxTraceFile << "# Trial " << runIndex + 1 << " of " << trials << "; "
3162 << phyModeStr.str() << " for " << n << " nodes" << std::endl;
3163 macTxTraceFile << "# Trial " << runIndex + 1 << " of " << trials << "; "
3164 << phyModeStr.str() << " for " << n << " nodes" << std::endl;
3165 macRxTraceFile << "# Trial " << runIndex + 1 << " of " << trials << "; "
3166 << phyModeStr.str() << " for " << n << " nodes" << std::endl;
3167 socketSendTraceFile << "# Trial " << runIndex + 1 << " of " << trials << "; "
3168 << phyModeStr.str() << " for " << n << " nodes" << std::endl;
3169 }
3170 experiment.Run(wifi,
3171 wifiPhy,
3172 wifiMac,
3173 wifiChannel,
3174 runIndex,
3175 n,
3176 Seconds(duration),
3177 pcap,
3178 infra,
3179 guardIntervalNs,
3180 distance,
3181 apTxPower,
3182 staTxPower,
3183 MicroSeconds(pktInterval));
3184 if (bytesReceived.size() != n)
3185 {
3186 NS_FATAL_ERROR("Not all stations got traffic!");
3187 }
3188 for (auto it = bytesReceived.begin(); it != bytesReceived.end(); ++it)
3189 {
3190 Time first = timeFirstReceived.find(it->first)->second;
3191 Time last = timeLastReceived.find(it->first)->second;
3192 Time dataTransferDuration = last - first;
3193 double nodeThroughput =
3194 (it->second * 8 / static_cast<double>(dataTransferDuration.GetMicroSeconds()));
3195 throughput += nodeThroughput;
3196 uint64_t nodeTxPackets = GetCount(packetsTransmitted, it->first);
3197 uint64_t nodeRxPackets = GetCount(packetsReceived, it->first);
3198 uint64_t nodePhyHeaderFailures = GetCount(phyHeaderFailed, it->first);
3199 uint64_t nodePsduFailures = GetCount(psduFailed, it->first);
3200 uint64_t nodePsduSuccess = GetCount(psduSucceeded, it->first);
3201 uint64_t nodeRxEventWhileDecodingPreamble =
3203 uint64_t nodeRxEventWhileRxing = GetCount(rxEventWhileRxing, it->first);
3204 uint64_t nodeRxEventWhileTxing = GetCount(rxEventWhileTxing, it->first);
3205 uint64_t nodeRxEventAbortedByTx = GetCount(rxEventAbortedByTx, it->first);
3206 uint64_t nodeRxEvents = nodePhyHeaderFailures + nodePsduFailures + nodePsduSuccess +
3207 nodeRxEventWhileDecodingPreamble + nodeRxEventWhileRxing +
3208 nodeRxEventWhileTxing + nodeRxEventAbortedByTx;
3209 std::cout << "Node " << it->first << ": TX packets " << nodeTxPackets
3210 << "; RX packets " << nodeRxPackets << "; PHY header failures "
3211 << nodePhyHeaderFailures << "; PSDU failures " << nodePsduFailures
3212 << "; PSDU success " << nodePsduSuccess
3213 << "; RX events while decoding preamble "
3214 << nodeRxEventWhileDecodingPreamble << "; RX events while RXing "
3215 << nodeRxEventWhileRxing << "; RX events while TXing "
3216 << nodeRxEventWhileTxing << "; RX events aborted by TX "
3217 << nodeRxEventAbortedByTx << "; total RX events " << nodeRxEvents
3218 << "; total events " << nodeTxPackets + nodeRxEvents << "; time first RX "
3219 << first << "; time last RX " << last << "; dataTransferDuration "
3220 << dataTransferDuration << "; throughput " << nodeThroughput << " Mbps"
3221 << std::endl;
3222 }
3223 std::cout << "Total throughput: " << throughput << " Mbps" << std::endl;
3224 averageThroughput += throughput;
3225 throughputArray[runIndex] = throughput;
3226 }
3227 averageThroughput = averageThroughput / trials;
3228
3229 bool rateFound = false;
3230 double relativeErrorDifs = 0;
3231 double relativeErrorEifs = 0;
3232 auto itDifs = bianchiResultsDifs.find(phyModeStr.str());
3233 if (itDifs != bianchiResultsDifs.end())
3234 {
3235 rateFound = true;
3236 auto it = itDifs->second.find(n);
3237 if (it != itDifs->second.end())
3238 {
3239 relativeErrorDifs = (std::abs(averageThroughput - it->second) / it->second);
3240 std::cout << "Relative error (DIFS): " << 100 * relativeErrorDifs << "%"
3241 << std::endl;
3242 }
3243 else if (validate)
3244 {
3245 NS_FATAL_ERROR("No Bianchi results (DIFS) calculated for that number of stations!");
3246 }
3247 }
3248 auto itEifs = bianchiResultsEifs.find(phyModeStr.str());
3249 if (itEifs != bianchiResultsEifs.end())
3250 {
3251 rateFound = true;
3252 auto it = itEifs->second.find(n);
3253 if (it != itEifs->second.end())
3254 {
3255 relativeErrorEifs = (std::abs(averageThroughput - it->second) / it->second);
3256 std::cout << "Relative error (EIFS): " << 100 * relativeErrorEifs << "%"
3257 << std::endl;
3258 }
3259 else if (validate)
3260 {
3261 NS_FATAL_ERROR("No Bianchi results (EIFS) calculated for that number of stations!");
3262 }
3263 }
3264 if (!rateFound && validate)
3265 {
3266 NS_FATAL_ERROR("No Bianchi results calculated for that rate!");
3267 }
3268 double relativeError = std::min(relativeErrorDifs, relativeErrorEifs);
3269 if (validate && (relativeError > maxRelativeError))
3270 {
3271 NS_FATAL_ERROR("Relative error is too high!");
3272 }
3273
3274 double stDev = 0;
3275 for (uint32_t i = 0; i < trials; ++i)
3276 {
3277 stDev += pow(throughputArray[i] - averageThroughput, 2);
3278 }
3279 stDev = sqrt(stDev / (trials - 1));
3280 dataset.Add(n, averageThroughput, stDev);
3281 }
3282 dataset.SetTitle("ns-3");
3283
3284 auto itDifs = bianchiResultsDifs.find(phyModeStr.str());
3285 if (itDifs != bianchiResultsDifs.end())
3286 {
3287 for (uint32_t i = nMinStas; i <= nMaxStas; i += nStepSize)
3288 {
3289 double value = 0.0;
3290 auto it = itDifs->second.find(i);
3291 if (it != itDifs->second.end())
3292 {
3293 value = it->second;
3294 }
3295 datasetBianchiDifs.Add(i, value);
3296 }
3297 }
3298 else
3299 {
3300 for (uint32_t i = nMinStas; i <= nMaxStas; i += nStepSize)
3301 {
3302 datasetBianchiDifs.Add(i, 0.0);
3303 }
3304 }
3305
3306 auto itEifs = bianchiResultsEifs.find(phyModeStr.str());
3307 if (itEifs != bianchiResultsEifs.end())
3308 {
3309 for (uint32_t i = nMinStas; i <= nMaxStas; i += nStepSize)
3310 {
3311 double value = 0.0;
3312 auto it = itEifs->second.find(i);
3313 if (it != itEifs->second.end())
3314 {
3315 value = it->second;
3316 }
3317 datasetBianchiEifs.Add(i, value);
3318 }
3319 }
3320 else
3321 {
3322 for (uint32_t i = nMinStas; i <= nMaxStas; i += nStepSize)
3323 {
3324 datasetBianchiEifs.Add(i, 0.0);
3325 }
3326 }
3327
3328 datasetBianchiEifs.SetTitle("Bianchi (EIFS - lower bound)");
3329 datasetBianchiDifs.SetTitle("Bianchi (DIFS - upper bound)");
3330 gnuplot.AddDataset(dataset);
3331 gnuplot.SetTerminal("postscript eps color enh \"Times-BoldItalic\"");
3332 gnuplot.SetLegend("Number of competing stations", "Throughput (Mbps)");
3333 ss.str("");
3334 ss << "Frame size " << pktSize << " bytes";
3335 gnuplot.SetTitle(ss.str());
3336 ss.str("");
3337 ss << "set xrange [" << nMinStas << ":" << nMaxStas << "]\n"
3338 << "set xtics " << nStepSize << "\n"
3339 << "set grid xtics ytics\n"
3340 << "set mytics\n"
3341 << "set style line 1 linewidth 5\n"
3342 << "set style line 2 linewidth 5\n"
3343 << "set style line 3 linewidth 5\n"
3344 << "set style line 4 linewidth 5\n"
3345 << "set style line 5 linewidth 5\n"
3346 << "set style line 6 linewidth 5\n"
3347 << "set style line 7 linewidth 5\n"
3348 << "set style line 8 linewidth 5\n"
3349 << "set style increment user";
3350 gnuplot.SetExtra(ss.str());
3351 if (plotBianchiModel & 0x0001)
3352 {
3353 datasetBianchiDifs.SetTitle("Bianchi");
3354 gnuplot.AddDataset(datasetBianchiDifs);
3355 }
3356 if (plotBianchiModel & 0x0002)
3357 {
3358 datasetBianchiEifs.SetTitle("Bianchi");
3359 gnuplot.AddDataset(datasetBianchiEifs);
3360 }
3361 if (plotBianchiModel == 0x0003)
3362 {
3363 datasetBianchiEifs.SetTitle("Bianchi (EIFS - lower bound)");
3364 datasetBianchiDifs.SetTitle("Bianchi (DIFS - upper bound)");
3365 }
3366 gnuplot.GenerateOutput(throughputPlot);
3367 throughputPlot.close();
3368
3369 if (tracing)
3370 {
3371 cwTraceFile.close();
3372 backoffTraceFile.close();
3373 phyTxTraceFile.close();
3374 macTxTraceFile.close();
3375 macRxTraceFile.close();
3376 socketSendTraceFile.close();
3377 }
3378
3379 return 0;
3380}
Gnuplot2dDataset Run(const WifiHelper &wifi, const YansWifiPhyHelper &wifiPhy, const WifiMacHelper &wifiMac, const YansWifiChannelHelper &wifiChannel)
Run an experiment.
int Run(const WifiHelper &wifi, const YansWifiPhyHelper &wifiPhy, const WifiMacHelper &wifiMac, const YansWifiChannelHelper &wifiChannel, uint32_t trialNumber, uint32_t networkSize, Time duration, bool pcap, bool infra, uint16_t guardIntervalNs, meter_u distance, dBm_u apTxPower, dBm_u staTxPower, Time pktInterval)
Configure and run the experiment.
a polymophic address class
Definition address.h:114
Headers for A-MPDU subframes.
uint16_t GetLength() const
Return the length field.
holds a vector of ns3::Application pointers.
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
Class to represent a 2D points plot.
Definition gnuplot.h:105
void SetErrorBars(ErrorBars errorBars)
Definition gnuplot.cc:360
void SetStyle(Style style)
Definition gnuplot.cc:348
void Add(double x, double y)
Definition gnuplot.cc:366
void SetTitle(const std::string &title)
Change line title.
Definition gnuplot.cc:137
a simple class to generate gnuplot-ready plotting commands from a set of datasets.
Definition gnuplot.h:359
void AddDataset(const GnuplotDataset &dataset)
Definition gnuplot.cc:785
void SetLegend(const std::string &xLegend, const std::string &yLegend)
Definition gnuplot.cc:765
void SetTerminal(const std::string &terminal)
Definition gnuplot.cc:753
void GenerateOutput(std::ostream &os)
Writes gnuplot commands and data values to a single output stream.
Definition gnuplot.cc:791
void SetExtra(const std::string &extra)
Definition gnuplot.cc:772
void SetTitle(const std::string &title)
Definition gnuplot.cc:759
Hold a signed integer type.
Definition integer.h:34
an EUI-48 address
static Mac48Address ConvertFrom(const Address &address)
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.
uint32_t GetN() const
Get the number of Ptr<Node> stored in this container.
void Create(uint32_t n)
Create n nodes and append pointers to them to the end of this NodeContainer.
Ptr< Node > Get(uint32_t i) const
Get the Ptr<Node> stored in this container at a given index.
uint32_t AddApplication(Ptr< Application > application)
Associate an Application to this Node.
Definition node.cc:153
Ptr< NetDevice > GetDevice(uint32_t index) const
Retrieve the index-th NetDevice associated to this node.
Definition node.cc:138
static Ptr< Node > GetNode(uint32_t n)
Definition node-list.cc:240
an address for a packet socket
void SetProtocol(uint16_t protocol)
Set the protocol.
void SetPhysicalAddress(const Address address)
Set the destination address.
void SetSingleDevice(uint32_t device)
Set the address to match only a specified NetDevice.
Give ns3::PacketSocket powers to ns3::Node.
void Install(Ptr< Node > node) const
Aggregate an instance of a ns3::PacketSocketFactory onto the provided node.
Smart pointer class similar to boost::intrusive_ptr.
Definition ptr.h:70
Class for representing queue sizes.
Definition queue-size.h:85
Received power (W) per spectrum band.
static EventId Schedule(const Time &delay, FUNC f, Ts &&... args)
Schedule an event to expire after delay.
Definition simulator.h:580
static void Destroy()
Execute the events scheduled with ScheduleDestroy().
Definition simulator.cc:125
static Time Now()
Return the current simulation virtual time.
Definition simulator.cc:191
static void Run()
Run the simulation.
Definition simulator.cc:161
static void Stop()
Tell the Simulator the calling event should be the last one executed.
Definition simulator.cc:169
The IEEE 802.11 SSID Information Element.
Definition ssid.h:27
AttributeValue implementation for Ssid.
Definition ssid.h:98
Hold variables of type string.
Definition string.h:45
Simulation virtual time values and global simulation resolution.
Definition nstime.h:95
@ S
second
Definition nstime.h:106
double GetSeconds() const
Get an approximation of the time stored in this instance in the indicated unit.
Definition nstime.h:398
int64_t ToInteger(Unit unit) const
Get the Time value expressed in a particular unit.
Definition nstime.h:568
int64_t GetMicroSeconds() const
Get an approximation of the time stored in this instance in the indicated unit.
Definition nstime.h:408
Hold an unsigned integer type.
Definition uinteger.h:34
helps to create WifiNetDevice objects
static void EnableLogComponents(LogLevel logLevel=LOG_LEVEL_ALL)
Helper to enable all WifiNetDevice log components with one statement.
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 ...
Implements the IEEE 802.11 MAC header.
Mac48Address GetAddr1() const
Return the address in the Address 1 field.
Mac48Address GetAddr2() const
Return the address in the Address 2 field.
create MAC layers for a ns3::WifiNetDevice.
represent a single transmission mode
Definition wifi-mode.h:39
Hold together all Wifi-related objects.
void DisablePreambleDetectionModel()
Disable the preamble detection model on all links.
@ DLT_IEEE802_11_RADIO
Include Radiotap link layer information.
Assists in tracing and analyzing Wi-Fi Physical Layer (PHY) receptions.
void PrintStatistics() const
Print statistics for all nodes, devices, and links during the collection period.
void Stop(Time stopTime)
Stops the collection of statistics at a specified time.
void Enable(NodeContainer nodes)
Enables trace collection for all nodes and WifiNetDevices in the specified NodeContainer.
void Start(Time startTime)
Starts the collection of statistics from a specified start time.
Statistics helper for tracking outcomes of data MPDU transmissions.
void Stop(Time stopTime)
Set the stop time for statistics collection.
CountPerNodeDevice_t GetFailuresByNodeDevice() const
Return the counts of failed MPDU transmissions in a hash map.
CountPerNodeDevice_t GetSuccessesByNodeDevice() const
Return the counts of successful MPDU transmissions in a hash map.
void Enable(const NodeContainer &nodes)
Enables trace collection for all nodes and WifiNetDevices in the specified NodeContainer.
CountPerNodeDevice_t GetRetransmissionsByNodeDevice() const
Return the counts of MPDU retransmissions in a hash map.
void Start(Time startTime)
Set the start time for statistics collection.
This class mimics the TXVECTOR which is to be passed to the PHY in order to define the parameters whi...
bool IsAggregation() const
Checks whether the PSDU contains A-MPDU.
manage and create wifi channel objects for the YANS model.
void SetPropagationDelay(std::string name, Ts &&... args)
void AddPropagationLoss(std::string name, Ts &&... args)
Ptr< YansWifiChannel > Create() const
Make it easy to create and manage PHY objects for the YANS model.
void experiment(std::string queue_disc_type)
auto packetsReceived
Record received pkts by Data Rate (DR) [index 0 -> DR5, index 5 -> DR0].
Callback< R, Args... > MakeCallback(R(T::*memPtr)(Args...), OBJ objPtr)
Build Callbacks for class method members which take varying numbers of arguments and potentially retu...
Definition callback.h:690
void SetDefault(std::string name, const AttributeValue &value)
Definition config.cc:886
void Connect(std::string path, const CallbackBase &cb)
Definition config.cc:966
void Set(std::string path, const AttributeValue &value)
Definition config.cc:872
#define NS_FATAL_ERROR(msg)
Report a fatal error with a message and terminate.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition log.h:201
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
Definition log.h:267
#define NS_LOG_WARN(msg)
Use NS_LOG to output a message of level LOG_WARN.
Definition log.h:260
#define NS_LOG_INFO(msg)
Use NS_LOG to output a message of level LOG_INFO.
Definition log.h:274
Ptr< T > CreateObject(Args &&... args)
Create an object by type, with varying number of constructor parameters.
Definition object.h:627
@ PACKETS
Use number of packets for queue size.
Definition queue-size.h:34
Time MicroSeconds(uint64_t value)
Construct a Time in the indicated unit.
Definition nstime.h:1347
Time NanoSeconds(uint64_t value)
Construct a Time in the indicated unit.
Definition nstime.h:1364
Time Seconds(double value)
Construct a Time in the indicated unit.
Definition nstime.h:1313
WifiStandard
Identifies the IEEE 802.11 specifications that a Wifi device can be configured to use.
WifiPhyRxfailureReason
Enumeration of the possible reception failure reasons.
WifiPreamble
The type of preamble to be used by an IEEE 802.11 transmission.
@ WIFI_STANDARD_80211a
@ WIFI_STANDARD_80211n
@ WIFI_STANDARD_80211g
@ WIFI_STANDARD_80211ax
@ WIFI_STANDARD_80211ac
@ WIFI_STANDARD_80211b
@ OBSS_PD_CCA_RESET
@ PREAMBLE_DETECT_FAILURE
@ FRAME_CAPTURE_PACKET_SWITCH
@ UNSUPPORTED_SETTINGS
@ L_SIG_FAILURE
@ SIGNAL_DETECTION_ABORTED_BY_TX
@ RECEPTION_ABORTED_BY_TX
@ SIG_A_FAILURE
@ CHANNEL_SWITCHING
@ BUSY_DECODING_PREAMBLE
@ SIG_B_FAILURE
@ HT_SIG_FAILURE
@ PREAMBLE_DETECTION_PACKET_SWITCH
@ WIFI_MAC_DROP_QOS_OLD_PACKET
Definition wifi-mac.h:76
@ WIFI_MAC_DROP_FAILED_ENQUEUE
Definition wifi-mac.h:73
@ WIFI_MAC_DROP_EXPIRED_LIFETIME
Definition wifi-mac.h:74
@ WIFI_MAC_DROP_REACHED_RETRY_LIMIT
Definition wifi-mac.h:75
std::ofstream socketSendTraceFile
File that traces packets transmitted by the application over time.
bool tracing
Flag to enable/disable generation of tracing files.
uint8_t maxMpdus
The maximum number of MPDUs in A-MPDUs (0 to disable MPDU aggregation).
Mac48Address ContextToMac(std::string context)
Parse context strings of the form "/NodeList/x/DeviceList/x/..." and fetch the Mac address.
std::map< Mac48Address, uint64_t > rxEventWhileDecodingPreamble
Map that stores the number of reception events per STA that occurred while PHY was already decoding a...
std::ofstream macTxTraceFile
File that traces MAC transmissions over time.
std::map< Mac48Address, uint64_t > rxEventWhileTxing
Map that stores the number of reception events per STA that occurred while PHY was already transmitti...
std::ofstream cwTraceFile
File that traces CW over time.
std::set< uint32_t > associated
Contains the IDs of the STAs that successfully associated to the access point (in infrastructure mode...
std::map< Mac48Address, uint64_t > packetsTransmitted
Map that stores the total packets transmitted per STA.
void PhyTxDoneTrace(std::string context, Ptr< const Packet > p)
PHY TX end trace.
uint32_t pktSize
packet size used for the simulation (in bytes)
bool useRxHelper
Flag to get PPDU statistics with WifiPhyRxTraceHelper.
std::map< Mac48Address, uint64_t > bytesReceived
Map that stores the total bytes received per STA (and addressed to that STA).
std::map< Mac48Address, uint64_t > packetsReceived
Map that stores the total packets received per STA (and addressed to that STA).
void TracePacketReception(std::string context, Ptr< const Packet > p, uint16_t channelFreqMhz, WifiTxVector txVector, MpduInfo aMpdu, SignalNoiseDbm signalNoise, uint16_t staId)
Trace a packet reception.
uint32_t ContextToNodeId(std::string context)
Parse context strings of the form "/NodeList/x/DeviceList/x/..." to extract the NodeId integer.
void AssociationLog(std::string context, Mac48Address address)
Association log trace.
void PhyRxTrace(std::string context, Ptr< const Packet > p, RxPowerWattPerChannelBand power)
PHY Rx trace.
void PhyRxErrorTrace(std::string context, Ptr< const Packet > p, double snr)
PHY RX error trace.
void PhyRxOkTrace(std::string context, Ptr< const Packet > p, double snr, WifiMode mode, WifiPreamble preamble)
PHY successful RX trace.
std::map< Mac48Address, uint64_t > phyHeaderFailed
Map that stores the total number of unsuccessfully received PHY headers per STA.
std::map< Mac48Address, Time > timeFirstReceived
Map that stores the time at which the first packet was received per STA (and the packet is addressed ...
std::ofstream backoffTraceFile
File that traces backoff over time.
void DisassociationLog(std::string context, Mac48Address address)
Deassociation log trace.
std::map< Mac48Address, uint64_t > rxEventWhileRxing
Map that stores the number of reception events per STA that occurred while PHY was already receiving ...
void PhyRxDoneTrace(std::string context, Ptr< const Packet > p)
PHY RX end trace.
void PhyTxTrace(std::string context, Ptr< const Packet > p, double txPowerW)
PHY TX trace.
std::map< Mac48Address, uint64_t > psduFailed
Map that stores the total number of unsuccessfully received PSDUS (for which the PHY header was succe...
std::map< Mac48Address, uint64_t > rxEventAbortedByTx
Map that stores the number of reception events aborted per STA because the PHY has started to transmi...
void CwTrace(std::string context, uint32_t cw, uint8_t)
Contention window trace.
std::map< std::string, std::map< unsigned int, double > > bianchiResultsEifs
Table of the expected values for EIFS.
uint64_t GetCount(const std::map< Mac48Address, uint64_t > &counter, Mac48Address addr)
Get the Counter associated with a MAC address.
void IncrementCounter(std::map< Mac48Address, uint64_t > &counter, Mac48Address addr, uint64_t increment=1)
Increment the counter for a given address.
bool useTxHelper
Flag to get MPDU statistics with WifiTxStatsHelper.
std::ofstream phyTxTraceFile
File that traces PHY transmissions over time.
std::map< Mac48Address, Time > timeLastReceived
Map that stores the time at which the last packet was received per STA (and the packet is addressed t...
std::map< std::string, std::map< unsigned int, double > > bianchiResultsDifs
Table of the expected values for DIFS.
void MacTxTrace(std::string context, Ptr< const Packet > p)
MAC TX trace.
void SocketSendTrace(std::string context, Ptr< const Packet > p, const Address &addr)
Socket send trace.
std::ofstream macRxTraceFile
File that traces MAC receptions over time.
std::map< Mac48Address, uint64_t > psduSucceeded
Map that stores the total number of successfully received PSDUs per STA (including PSDUs not addresse...
void MacRxTrace(std::string context, Ptr< const Packet > p)
MAC RX trace.
void PhyRxPayloadTrace(std::string context, WifiTxVector txVector, Time psduDuration)
PHY Rx trace.
std::map< Mac48Address, Time > timeLastTransmitted
Map that stores the time at which the last packet was transmitted per STA.
std::map< Mac48Address, Time > timeFirstTransmitted
Map that stores the time at which the first packet was transmitted per STA.
void PhyRxDropTrace(std::string context, Ptr< const Packet > p, WifiPhyRxfailureReason reason)
PHY Drop trace.
void BackoffTrace(std::string context, uint32_t newVal, uint8_t)
Backoff trace.
Definition first.py:1
Every class exported by the ns3 library is enclosed in the ns3 namespace.
void LogComponentEnable(const std::string &name, LogLevel level)
Enable the logging output associated with that log component.
Definition log.cc:491
Ptr< T1 > DynamicCast(const Ptr< T2 > &p)
Cast a Ptr.
Definition ptr.h:643
double dBm_u
dBm weak type
Definition wifi-units.h:27
@ LOG_LEVEL_ALL
Print everything.
Definition log.h:115
@ LOG_LEVEL_WARN
LOG_WARN and above.
Definition log.h:100
Ptr< T1 > StaticCast(const Ptr< T2 > &p)
Cast a Ptr.
Definition ptr.h:650
double degree_u
degree weak type (angle)
Definition wifi-units.h:35
double meter_u
meter weak type
Definition wifi-units.h:32
value
Definition second.py:37
wifi
Definition third.py:84
uint32_t bytesReceived
Counter of the received bytes.
bool verbose
MpduInfo structure.
Definition wifi-types.h:78
SignalNoiseDbm structure.
Definition wifi-types.h:71
std::ofstream throughput