-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathl4s-wifi.cc
1574 lines (1431 loc) · 65.6 KB
/
l4s-wifi.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
* Copyright (c) 2023 CableLabs (change to L4s over Wi-Fi scenario)
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation;
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
// Nodes 0 Node 1 Node 2
//
// client ---------------------> AP -------------------------- > STA (server)
// 10 Gbps
// configurable delay channel widths 20/80/160 MHz
// Configurable MCS
// Configurable num. spatial streams
//
// ---- ---- ---- ---- > TCP data transfer direction
// < - - - - - - - ACK direction
//
// 0..N flows from client to server can be configured, for both Prague
// and Cubic. A special case is if zero Prague and Cubic flows are
// configured, for which UDP saturating traffic will be sent-- this can be
// used to test for maximum possible throughput of a configuration.
// Data transfer is from client to server (iperf naming convention).
//
// In addition (not depicted in the diagram), a configurable number of additional
// STAs are added to the same Wi-Fi channel, communicating with another AP
// (also on the same channel, but configured with a different SSID). These STAs,
// if configured, will send saturating UDP traffic on the channel, to create
// contention on the channel. The other STAs are configured on a different
// BSS and are served by a different AP.
//
// Configuration inputs:
// - number of Cubic flows under test
// - number of Prague flows under test
// - number of bytes for TCP flows, or zero bytes for unlimited
// - duration of TCP application flows
// - number of UDP senders
// - whether to disable flow control
// - Wi-Fi aggregation queue limit when flow control is enabled (scale factor)
//
// Behavior:
// - at around simulation time 1 second, each flow starts
// - simulation ends 1 second after last foreground flow terminates, unless
// a specific duration was configured
//
// Outputs (some of these are for future definition):
// 1) PCAP files at TCP endpoints
// 2) queue depth of the overlying and Wi-Fi AC_BE queue
// 3) queue depth of the WifiMacQueue AC_BE queue
// 4) dequeue events of the WifiMacQueue
// 5) Socket statistics for the first foreground Prague and Cubic flows defined
// (i.e., if multiple Prague or Cubic are configured, only the first such
// flow is traced in detail)
#include "ns3/applications-module.h"
#include "ns3/core-module.h"
#include "ns3/internet-module.h"
#include "ns3/mobility-module.h"
#include "ns3/network-module.h"
#include "ns3/point-to-point-module.h"
#include "ns3/stats.h"
#include "ns3/traffic-control-module.h"
#include "ns3/wifi-module.h"
#include <iomanip>
#include <sstream>
using namespace ns3;
#define MTU_SIZE 1500 //bytes
#define MAC_HEADER_SIZE 44 //bytes
#define GUARD_INTERVAL 800 //nanoseconds
const Time PREAMBLE_AND_HEADER_DURATION = MicroSeconds(52); //microseconds
const Time PROTECTION_TIME = MicroSeconds(88); //microseconds
const Time ACK_TIME = MicroSeconds(56); //microseconds
NS_LOG_COMPONENT_DEFINE("L4sWifi");
// Declare trace functions that are defined later in this file
std::ofstream g_fileBytesInAcBeQueue;
void TraceBytesInAcBeQueue(uint32_t oldVal, uint32_t newVal);
std::ofstream g_fileBytesInDualPi2Queue;
void TraceBytesInDualPi2Queue(uint32_t oldVal, uint32_t newVal);
uint32_t g_wifiThroughputData = 0;
uint32_t g_wifiFgThroughputData = 0;
uint32_t g_wifiBgThroughputData = 0;
Time g_lastQosDataTime;
std::ofstream g_fileWifiPhyTxPsduBegin;
void TraceWifiPhyTxPsduBegin(std::string context,
WifiConstPsduMap psduMap,
WifiTxVector txVector,
double txPower);
std::ofstream g_fileWifiThroughput;
std::ofstream g_fileWifiFgThroughput;
std::ofstream g_fileWifiBgThroughput;
void TraceWifiThroughput();
Time g_wifiThroughputInterval = MilliSeconds(100);
std::ofstream g_fileLSojourn;
void TraceLSojourn(Time sojourn);
std::ofstream g_fileCSojourn;
void TraceCSojourn(Time sojourn);
std::ofstream g_fileTraceProbChanges;
void TraceProbcL(double oldVal, double pCL);
void TraceProbL(double oldVal, double pL);
void TraceProbC(double oldVal, double pC);
uint32_t g_pragueData = 0;
std::map<uint16_t, uint32_t> g_pragueDataforEachPort;
Time g_lastSeenPrague = Seconds(0);
std::ofstream g_filePragueThroughput;
std::ofstream g_filePragueThroughputPerStream;
std::ofstream g_filePragueCwnd;
std::ofstream g_filePragueSsthresh;
std::ofstream g_filePragueSendInterval;
std::ofstream g_filePraguePacingRate;
std::ofstream g_filePragueCongState;
std::ofstream g_filePragueEcnState;
std::ofstream g_filePragueRtt;
Time g_pragueThroughputInterval = MilliSeconds(100);
void TracePragueThroughput();
void CalculatePragueThroughput();
void TracePragueTx(Ptr<const Packet> packet,
const TcpHeader& header,
Ptr<const TcpSocketBase> socket);
void TracePragueRx(Ptr<const Packet> packet,
const TcpHeader& header,
Ptr<const TcpSocketBase> socket);
void TracePragueCwnd(uint32_t oldVal, uint32_t newVal);
void TracePragueSsthresh(uint32_t oldVal, uint32_t newVal);
void TracePraguePacingRate(DataRate oldVal, DataRate newVal);
void TracePragueCongState(TcpSocketState::TcpCongState_t oldVal,
TcpSocketState::TcpCongState_t newVal);
void TracePragueEcnState(TcpSocketState::EcnState_t oldVal, TcpSocketState::EcnState_t newVal);
void TracePragueRtt(Time oldVal, Time newVal);
void TracePragueClientSocket(Ptr<Application>, uint32_t, bool, bool);
void TracePragueServerSocket(Ptr<Socket>);
uint32_t g_cubicData = 0;
std::map<uint16_t, uint32_t> g_cubicDataforEachPort; // Dst Port Number , Rx packet size
Time g_lastSeenCubic = Seconds(0);
std::ofstream g_fileCubicThroughput;
std::ofstream g_fileCubicThroughputPerStream;
std::ofstream g_fileCubicCwnd;
std::ofstream g_fileCubicSsthresh;
std::ofstream g_fileCubicSendInterval;
std::ofstream g_fileCubicPacingRate;
std::ofstream g_fileCubicCongState;
std::ofstream g_fileCubicRtt;
Time g_cubicThroughputInterval = MilliSeconds(100);
void TraceCubicThroughput();
void CalculateCubicThroughput();
void TraceCubicTx(Ptr<const Packet> packet,
const TcpHeader& header,
Ptr<const TcpSocketBase> socket);
void TraceCubicRx(Ptr<const Packet> packet,
const TcpHeader& header,
Ptr<const TcpSocketBase> socket);
void TraceCubicCwnd(uint32_t oldVal, uint32_t newVal);
void TraceCubicSsthresh(uint32_t oldVal, uint32_t newVal);
void TraceCubicPacingRate(DataRate oldVal, DataRate newVal);
void TraceCubicCongState(TcpSocketState::TcpCongState_t oldVal,
TcpSocketState::TcpCongState_t newVal);
void TraceCubicRtt(Time oldVal, Time newVal);
void TraceCubicClientSocket(Ptr<Application>, uint32_t, bool, bool);
void TraceCubicServerSocket(Ptr<Socket>);
// Count the number of flows to wait for completion before stopping the simulation
uint32_t g_flowsToClose = 0;
// Hook these methods to the PacketSink objects
void HandlePeerClose(std::string context, Ptr<const Socket> socket);
void HandlePeerError(std::string context, Ptr<const Socket> socket);
// For use in dynamically changing MCS and aggregation buffer limit
Ptr<ConstantRateWifiManager> apWifiMgr;
Ptr<WifiNetDevice> apWifiNetDevice;
Ptr<WifiNetDevice> staWifiNetDevice;
QueueDiscContainer apQueueDiscContainer;
QueueDiscContainer staQueueDiscContainer;
uint32_t CalculateLimit(uint32_t mcs,
uint32_t channelWidth,
uint32_t spatialStreams,
Time txopLimit);
void ChangeMcs(uint16_t mcs,
uint32_t limit,
uint16_t nextMcs,
uint32_t nextLimit,
double scale,
Time mcsChangeInterval);
// Helper function for EDCA overrides
void SetAcBeEdcaParameters(const NetDeviceContainer& ndc,
uint32_t cwMin,
uint32_t cwMax,
uint8_t aifsn,
Time txopLimit);
// These methods work around the lack of ability to configure different TCP socket types
// on the same node on a per-socket (per-application) basis. Instead, these methods can
// be scheduled (right before a socket creation) to change the default value
void ConfigurePragueSockets(Ptr<TcpL4Protocol> tcp1, Ptr<TcpL4Protocol> tcp2);
void ConfigureCubicSockets(Ptr<TcpL4Protocol> tcp1, Ptr<TcpL4Protocol> tcp2);
// Declare some statistics counters here so that they are updated in traces
MinMaxAvgTotalCalculator<uint32_t> pragueThroughputCalculator; // units of Mbps
MinMaxAvgTotalCalculator<uint32_t> cubicThroughputCalculator; // units of Mbps
// Utility function to connect DualPi2QueueDisc to WifiMacQueue callback
void ConnectPendingDequeueCallback(const NetDeviceContainer& devices,
const QueueDiscContainer& queueDiscs);
// Utility function to inform DualPi2 queues about a change to the limit
void UpdateDualPi2AggBufferLimit(const QueueDiscContainer& queueDiscs,
double scale,
uint32_t limit);
// Utility function to inform dynamic queue limits about a change to the limit
void UpdateDynamicQueueLimits(Ptr<WifiNetDevice> device, double scale, uint32_t limit);
// Utility function to populate ARP cache after simulation start
// Because of an interaction with LinkUp events (ns-3 issue #851)
void AddManualArpEntries(Ptr<Channel> channel);
int
main(int argc, char* argv[])
{
// Variable declaration, and constants
std::string wifiControlMode = "OfdmRate24Mbps";
double staDistance = 1; // meters; distance of 10 m or more will cause packet loss at MCS 11
const double pi = 3.1415927;
DataRate obssUdpRate{"2400Mbps"}; // MCS 6 maximum PHY rate with 160 MHz channel and 4 SS
DataRate perStaUdpRate; // Will be updated below
Time obssUdpStartTime{Seconds(1)};
// Variables that can be changed by command-line argument
uint32_t numCubic = 1;
uint32_t numPrague = 1;
uint32_t numBytes = 50e6; // default 50 MB
Time duration = Seconds(0); // By default, close one second after last TCP flow closes
Time wanLinkDelay = MilliSeconds(10); // base RTT is 20ms
bool useReno = false;
uint32_t numBackgroundUdp = 0;
uint16_t mcs = 2;
uint16_t secondMcs = 2;
Time mcsChangeInterval; // By default, zero means disabled
uint32_t channelWidth = 80;
uint32_t spatialStreams = 1;
// Default WifiMacQueue depth is roughly 40 ms at 2.4 Gbps ~= 8000 packets
// 2.4 Gbps is the maximum PHY rate for 160 MHz channels, 2 SS, MCS 11
std::string wifiQueueSize = "5000p";
bool flowControl = true;
uint32_t limit = 65535; // default flow control limit (max A-MPDU size in bytes)
double scale = 1.0; // default flow control scale factor
uint32_t rtsCtsThreshold = 0; // RTS/CTS disabled by default
Time processingDelay = MicroSeconds(10);
Time flowStartOffset = MicroSeconds(1); // Time between starting each TCP flow
bool showProgress = false;
uint32_t maxAmsduSize = 0; // zero means A-MSDU is disabled
Time progressInterval = Seconds(5);
Time arpCacheInstallTime = Seconds(0.5); // manually populate ARP cache at this time
bool enablePcapAll = false;
bool enablePcap = true;
bool enableTracesAll = false;
bool enableTraces = true;
// Default AC_BE EDCA configuration
uint32_t cwMin = 15;
uint32_t cwMax = 1023;
uint8_t aifsn = 3;
Time txopLimit = MicroSeconds(2528);
bool enableLogs = false;
uint16_t rngRun = 1;
// Increase some defaults (command-line can override below)
// ns-3 TCP does not automatically adjust MSS from the device MTU
Config::SetDefault("ns3::TcpSocket::SegmentSize", UintegerValue(1448));
// ns-3 TCP socket buffer sizes do not dynamically grow, so set to ~3 * BWD product
Config::SetDefault("ns3::TcpSocket::SndBufSize", UintegerValue(30000000));
Config::SetDefault("ns3::TcpSocket::RcvBufSize", UintegerValue(40000000));
// Enable pacing for Cubic
Config::SetDefault("ns3::TcpSocketState::EnablePacing", BooleanValue(true));
// Config::SetDefault("ns3::TcpSocketState::PaceInitialWindow", BooleanValue(true));
// Enable a timestamp (for latency sampling) in the bulk send application
Config::SetDefault("ns3::BulkSendApplication::EnableSeqTsSizeHeader", BooleanValue(true));
Config::SetDefault("ns3::PacketSink::EnableSeqTsSizeHeader", BooleanValue(true));
// The bulk send application should do 1448-byte writes (one timestamp per TCP packet)
Config::SetDefault("ns3::BulkSendApplication::SendSize", UintegerValue(1448));
// Bypass Laqm when using Wi-Fi
Config::SetDefault("ns3::DualPi2QueueDisc::DisableLaqm", BooleanValue(true));
// Set Classic AQM target to 30ms
Config::SetDefault("ns3::DualPi2QueueDisc::Target", TimeValue(MilliSeconds(30)));
// Set AC_BE max AMPDU to maximum 802.11ax value
Config::SetDefault("ns3::WifiMac::BE_MaxAmpduSize", UintegerValue(6500631));
CommandLine cmd;
cmd.Usage("The l4s-wifi program experiments with TCP flows over L4S Wi-Fi configuration");
cmd.AddValue("numCubic", "Number of foreground Cubic flows", numCubic);
cmd.AddValue("numPrague", "Number of foreground Prague flows", numPrague);
cmd.AddValue("numBytes", "Number of bytes for each TCP transfer", numBytes);
cmd.AddValue("duration", "(optional) scheduled end of simulation", duration);
cmd.AddValue("wanLinkDelay", "one-way base delay from server to AP", wanLinkDelay);
cmd.AddValue("useReno", "Use Linux Reno instead of Cubic", useReno);
cmd.AddValue("numBackgroundUdp", "Number of background UDP flows", numBackgroundUdp);
cmd.AddValue("mcs", "Index (0-11) of 11ax HE MCS", mcs);
cmd.AddValue("secondMcs", "Index (0-11) of 11ax HE MCS", secondMcs);
cmd.AddValue("mcsChangeInterval",
"if set, will toggle between mcs and secondMcs at this interval",
mcsChangeInterval);
cmd.AddValue("channelWidth", "Width (MHz) of channel", channelWidth);
cmd.AddValue("spatialStreams", "Number of spatial streams", spatialStreams);
cmd.AddValue("wifiQueueSize", "WifiMacQueue size", wifiQueueSize);
cmd.AddValue("flowControl", "Whether to enable flow control (set also the limit)", flowControl);
cmd.AddValue("limit", "Queue limit (bytes)", limit);
cmd.AddValue("scale", "Scaling factor for queue limit", scale);
cmd.AddValue("rtsCtsThreshold", "RTS/CTS threshold (bytes)", rtsCtsThreshold);
cmd.AddValue("processingDelay", "Notional packet processing delay", processingDelay);
cmd.AddValue("flowStartOffset",
"Time between successive TCP flow start times",
flowStartOffset);
cmd.AddValue("maxAmsduSize", "BE Max A-MSDU size in bytes", maxAmsduSize);
cmd.AddValue("cwMin", "BE CWmin in slots", cwMin);
cmd.AddValue("cwMax", "BE CWmax in slots", cwMax);
cmd.AddValue("aifsn", "BE AIFSN in slots", aifsn);
cmd.AddValue("txopLimit", "BE TXOP Limit", txopLimit);
cmd.AddValue("showProgress", "Show simulation progress every 5s", showProgress);
cmd.AddValue("enablePcapAll",
"Whether to enable PCAP trace output at all interfaces",
enablePcapAll);
cmd.AddValue("enablePcap", "Whether to enable PCAP trace output only at endpoints", enablePcap);
cmd.AddValue("enableTracesAll",
"Whether to enable full time-series trace output",
enableTracesAll);
cmd.AddValue("enableTraces",
"Whether to enable time-series traces necessary for plot-l4s-wifi.py",
enableTraces);
cmd.AddValue("enableLogs", "Whether to enable logs of DualPi2QueueDisc class", enableLogs);
cmd.AddValue("rngRun", "Random Number Generator run number", rngRun);
cmd.Parse(argc, argv);
if (limit < 65535)
{
std::cout << "Warning: 'limit' command-line argument is ignored; limit is now autoset"
<< std::endl;
}
if (enableLogs)
{
//LogComponentEnableAll(LOG_PREFIX_ALL);
//LogComponentEnable("DualPi2QueueDisc", LOG_LEVEL_INFO);
LogComponentEnable("L4sWifi", LOG_LEVEL_DEBUG);
}
NS_ABORT_MSG_UNLESS(mcs < 12, "Only MCS 0-11 supported");
NS_ABORT_MSG_UNLESS(secondMcs < 12, "Only MCS 0-11 supported");
limit = CalculateLimit(mcs, channelWidth, spatialStreams, txopLimit);
if (processingDelay > Seconds(0))
{
Config::SetDefault("ns3::WifiMacQueue::ProcessingDelay", TimeValue(processingDelay));
}
if (rtsCtsThreshold > 0)
{
Config::SetDefault("ns3::WifiRemoteStationManager::RtsCtsThreshold",
UintegerValue(rtsCtsThreshold));
}
std::ostringstream ossDataMode;
ossDataMode << "HeMcs" << mcs;
NS_ABORT_MSG_UNLESS(channelWidth == 20 || channelWidth == 40 || channelWidth == 80 ||
channelWidth == 160,
"Only widths 20, 40, 80, 160 supported");
// ns-3 format for Wi-Fi channel configuration:
// {channelNumber, channelWidth(MHz), band, and primary 20 MHz index}
// channel number of zero will cause the first such channel in the band to be used
std::string channelString("{0, " + std::to_string(channelWidth) + ", BAND_5GHZ, 0}");
// When using DCE with ns-3, or reading pcaps with Wireshark,
// enable checksum computations in ns-3 models
GlobalValue::Bind("ChecksumEnabled", BooleanValue(true));
Config::SetDefault("ns3::WifiMacQueue::MaxSize", StringValue(wifiQueueSize));
// Set AC_BE max AMSDU to four packets
Config::SetDefault("ns3::WifiMac::BE_MaxAmsduSize", UintegerValue(maxAmsduSize));
// Set DualPi2 buffer size (both L & C)
Config::SetDefault("ns3::DualPi2QueueDisc::QueueLimit",
UintegerValue(static_cast<uint32_t>(scale * limit * 100)));
if (useReno)
{
std::cout << "Using ns-3 LinuxReno model instead of Cubic" << std::endl;
Config::SetDefault("ns3::TcpL4Protocol::SocketType",
TypeIdValue(TcpLinuxReno::GetTypeId()));
}
RngSeedManager::SetRun(rngRun);
// Workaround until PRR response is debugged
Config::SetDefault("ns3::TcpL4Protocol::RecoveryType",
TypeIdValue(TcpClassicRecovery::GetTypeId()));
// Create the nodes and use containers for further configuration below
NodeContainer clientNode;
clientNode.Create(1);
NodeContainer apNode;
apNode.Create(1);
Names::Add("AP", apNode.Get(0));
NodeContainer staNode;
staNode.Create(1);
Names::Add("STA", staNode.Get(0));
// NodeContainers for nodes outside of the BSS under test (OBSS)
NodeContainer obssClientNode;
obssClientNode.Create(1);
NodeContainer obssApNode;
obssApNode.Create(1);
Names::Add("OBSS-AP", obssApNode.Get(0));
NodeContainer obssStaNodes;
obssStaNodes.Create(numBackgroundUdp);
for (uint32_t i = 0; i < numBackgroundUdp; i++)
{
Names::Add("OBSS-STA" + std::to_string(i), obssStaNodes.Get(i));
}
// Create point-to-point links between server and AP
PointToPointHelper pointToPoint;
pointToPoint.SetDeviceAttribute("DataRate", StringValue("10Gbps"));
pointToPoint.SetChannelAttribute("Delay", TimeValue(wanLinkDelay));
NetDeviceContainer wanDevices = pointToPoint.Install(clientNode.Get(0), apNode.Get(0));
NetDeviceContainer obssWanDevices =
pointToPoint.Install(obssClientNode.Get(0), obssApNode.Get(0));
// Wifi configuration; use the simpler Yans physical layer model
YansWifiPhyHelper wifiPhy;
YansWifiChannelHelper wifiChannel;
wifiChannel.SetPropagationDelay("ns3::ConstantSpeedPropagationDelayModel");
wifiChannel.AddPropagationLoss("ns3::LogDistancePropagationLossModel",
"Exponent",
DoubleValue(2.0),
"ReferenceDistance",
DoubleValue(1.0),
"ReferenceLoss",
DoubleValue(46.6777));
auto wifiChannelPtr = wifiChannel.Create();
wifiPhy.SetChannel(wifiChannelPtr);
wifiPhy.SetPcapDataLinkType(WifiPhyHelper::DLT_IEEE802_11_RADIO);
wifiPhy.Set("Antennas", UintegerValue(spatialStreams));
wifiPhy.Set("MaxSupportedTxSpatialStreams", UintegerValue(spatialStreams));
wifiPhy.Set("MaxSupportedRxSpatialStreams", UintegerValue(spatialStreams));
wifiPhy.Set("ChannelSettings", StringValue(channelString));
WifiHelper wifi;
wifi.SetStandard(WIFI_STANDARD_80211ax);
wifi.SetRemoteStationManager("ns3::ConstantRateWifiManager",
"DataMode",
StringValue(ossDataMode.str()),
"ControlMode",
StringValue(wifiControlMode));
// Set guard interval and MPDU buffer size
wifi.ConfigHeOptions("GuardInterval",
TimeValue(NanoSeconds(800)),
"MpduBufferSize",
UintegerValue(256));
WifiMacHelper wifiMac;
wifiMac.SetType("ns3::ApWifiMac", "Ssid", SsidValue(Ssid("l4s")));
NetDeviceContainer apDevice = wifi.Install(wifiPhy, wifiMac, apNode);
SetAcBeEdcaParameters(apDevice, cwMin, cwMax, aifsn, txopLimit);
apWifiMgr = apDevice.Get(0)
->GetObject<WifiNetDevice>()
->GetRemoteStationManager()
->GetObject<ConstantRateWifiManager>();
NS_ABORT_MSG_UNLESS(apWifiMgr, "Downcast failed");
apWifiNetDevice = apDevice.Get(0)->GetObject<WifiNetDevice>();
wifiMac.SetType("ns3::StaWifiMac", "Ssid", SsidValue(Ssid("l4s")));
NetDeviceContainer staDevices = wifi.Install(wifiPhy, wifiMac, staNode);
SetAcBeEdcaParameters(staDevices, cwMin, cwMax, aifsn, txopLimit);
staWifiNetDevice = staDevices.Get(0)->GetObject<WifiNetDevice>();
// OBSS configuration
wifiMac.SetType("ns3::ApWifiMac", "Ssid", SsidValue(Ssid("obss")));
NetDeviceContainer obssApDevice = wifi.Install(wifiPhy, wifiMac, obssApNode);
SetAcBeEdcaParameters(obssApDevice, cwMin, cwMax, aifsn, txopLimit);
wifiMac.SetType("ns3::StaWifiMac", "Ssid", SsidValue(Ssid("obss")));
NetDeviceContainer obssStaDevices = wifi.Install(wifiPhy, wifiMac, obssStaNodes);
SetAcBeEdcaParameters(obssStaDevices, cwMin, cwMax, aifsn, txopLimit);
// Set positions
MobilityHelper mobility;
Ptr<ListPositionAllocator> positionAlloc = CreateObject<ListPositionAllocator>();
mobility.SetMobilityModel("ns3::ConstantPositionMobilityModel");
// Set position for AP
positionAlloc->Add(Vector(0.0, 0.0, 0.0)); // X,Y,Z cartesian
// Set position for STAs; simple routine to distribute around a ring of distance 'staDistance'
uint32_t numSta = staNode.GetN() + obssStaNodes.GetN();
double angle = (static_cast<double>(360) / numSta);
for (uint32_t i = 0; i < numSta; ++i)
{
positionAlloc->Add(Vector(staDistance * cos((i * angle * pi) / 180),
staDistance * sin((i * angle * pi) / 180),
0.0));
}
// Create some additional container objects to simplify the below configuration
NodeContainer wifiNodes;
wifiNodes.Add(apNode);
wifiNodes.Add(staNode);
// Add Mobility (position objects) to the Wi-Fi nodes, for propagation
mobility.SetPositionAllocator(positionAlloc);
mobility.Install(wifiNodes);
mobility.Install(obssApNode);
mobility.Install(obssStaNodes);
// Internet stack installation
InternetStackHelper internetStack;
internetStack.Install(clientNode);
internetStack.Install(obssClientNode);
internetStack.Install(wifiNodes);
internetStack.Install(obssApNode);
internetStack.Install(obssStaNodes);
// Schedule an event to manually set ARP cache entries so that
// no neighbor discovery is needed
Simulator::Schedule(arpCacheInstallTime,
MakeBoundCallback(&AddManualArpEntries, wifiChannelPtr));
// By default, Ipv4AddressHelper below will configure a MqQueueDisc
// with FqCoDelQueueDisc as child queue discs (one per AC)
// The following statements change this configuration on the AP to
// an MqQueueDisc with a DualPi2QueueDisc as child queue disc
TrafficControlHelper tch;
uint16_t handle = tch.SetRootQueueDisc("ns3::MqQueueDisc");
TrafficControlHelper::ClassIdList cls =
tch.AddQueueDiscClasses(handle, 4, "ns3::QueueDiscClass");
tch.AddChildQueueDiscs(handle, cls, "ns3::DualPi2QueueDisc");
// The next statements configure flow control between Wi-Fi and DualPi2
if (flowControl)
{
tch.SetQueueLimits("ns3::DynamicQueueLimits",
"HoldTime",
StringValue("500ms"),
"MinLimit",
UintegerValue(static_cast<uint32_t>(scale * limit)),
"MaxLimit",
UintegerValue(static_cast<uint32_t>(scale * limit)));
}
else
{
// Leave a very small queue at the AQM layer
Config::SetDefault("ns3::DualPi2QueueDisc::QueueLimit", UintegerValue(1500));
}
// Install the traffic control configuration on the AP Wi-Fi device
// and on STA devices
apQueueDiscContainer = tch.Install(apDevice);
staQueueDiscContainer = tch.Install(staDevices);
// Hook DualPi2 queue to WifiMacQueue::PendingDequeue trace source
ConnectPendingDequeueCallback(apDevice, apQueueDiscContainer);
ConnectPendingDequeueCallback(staDevices, staQueueDiscContainer);
// Inform dualPi2 of aggregation buffer (scaled) limit
// Call this function any time that 'scale' or 'limit' changes, on
// all of the DualPi2QueueDisc in the simulation
// Note: if there are runtime changes to these values, the
// DynamicQueueLimits objects need to also be updated (not handled here)
UpdateDualPi2AggBufferLimit(apQueueDiscContainer, scale, limit);
UpdateDualPi2AggBufferLimit(staQueueDiscContainer, scale, limit);
// Configure IP addresses for all links
Ipv4AddressHelper address;
address.SetBase("10.1.1.0", "255.255.255.0");
Ipv4InterfaceContainer interfaces1 = address.Assign(wanDevices);
NetDeviceContainer wifiDevices;
wifiDevices.Add(apDevice);
wifiDevices.Add(staDevices);
address.SetBase("192.168.1.0", "255.255.255.0");
Ipv4InterfaceContainer wifiInterfaces = address.Assign(wifiDevices);
// OBSS network
address.SetBase("172.16.1.0", "255.255.255.0");
NetDeviceContainer obssWifiDevices;
obssWifiDevices.Add(obssApDevice);
obssWifiDevices.Add(obssStaDevices);
Ipv4InterfaceContainer obssWifiInterfaces = address.Assign(obssWifiDevices);
address.SetBase("20.1.1.0", "255.255.255.0");
Ipv4InterfaceContainer interfaces2 = address.Assign(obssWanDevices);
// The staNode and clientNode both need a static IPv4 route added; the AP node does not
// The obssStaNodes and obssClientNode both need static IPv4 routes added
Ptr<Ipv4StaticRouting> staticRouting;
staticRouting = Ipv4RoutingHelper::GetRouting<Ipv4StaticRouting>(
clientNode.Get(0)->GetObject<Ipv4>()->GetRoutingProtocol());
staticRouting->SetDefaultRoute("10.1.1.2", 1); // next hop, outgoing interface index
staticRouting = Ipv4RoutingHelper::GetRouting<Ipv4StaticRouting>(
staNode.Get(0)->GetObject<Ipv4>()->GetRoutingProtocol());
staticRouting->SetDefaultRoute("192.168.1.1", 1); // next hop, outgoing interface index
staticRouting = Ipv4RoutingHelper::GetRouting<Ipv4StaticRouting>(
obssClientNode.Get(0)->GetObject<Ipv4>()->GetRoutingProtocol());
staticRouting->SetDefaultRoute("20.1.1.2", 1); // next hop, outgoing interface index
for (uint32_t i = 0; i < numBackgroundUdp; i++)
{
staticRouting = Ipv4RoutingHelper::GetRouting<Ipv4StaticRouting>(
obssStaNodes.Get(i)->GetObject<Ipv4>()->GetRoutingProtocol());
staticRouting->SetDefaultRoute("172.16.1.1", 1); // next hop, outgoing interface index
}
// Application traffic configuration
// Get pointers to the TcpL4Protocol instances of the primary nodes
Ptr<TcpL4Protocol> tcpL4ProtocolClient = clientNode.Get(0)->GetObject<TcpL4Protocol>();
Ptr<TcpL4Protocol> tcpL4ProtocolSta = staNode.Get(0)->GetObject<TcpL4Protocol>();
// Application configuration for Prague flows under test
uint16_t port = 100;
ApplicationContainer pragueClientApps;
ApplicationContainer pragueServerApps;
for (auto i = 0U; i < numPrague; i++)
{
BulkSendHelper bulk("ns3::TcpSocketFactory",
InetSocketAddress(wifiInterfaces.GetAddress(1), port + i));
bulk.SetAttribute("MaxBytes", UintegerValue(numBytes));
bulk.SetAttribute("StartTime", TimeValue(Seconds(1) + i * flowStartOffset));
pragueClientApps.Add(bulk.Install(clientNode.Get(0)));
NS_LOG_DEBUG("Creating Prague foreground flow " << i);
PacketSinkHelper sink =
PacketSinkHelper("ns3::TcpSocketFactory",
InetSocketAddress(Ipv4Address::GetAny(), port + i));
sink.SetAttribute("StartTime", TimeValue(Seconds(1) + i * flowStartOffset));
pragueServerApps.Add(sink.Install(staNode.Get(0)));
g_flowsToClose++;
Simulator::Schedule(
Seconds(1) - TimeStep(1),
MakeBoundCallback(&ConfigurePragueSockets, tcpL4ProtocolClient, tcpL4ProtocolSta));
}
// The TCP socket factory needs to be reconfigured to create Cubic
// sockets after Prague sockets were generated.
Time factoryReconfigurationTime = Seconds(1) + (numPrague * flowStartOffset) - TimeStep(1);
Simulator::Schedule(
factoryReconfigurationTime,
MakeBoundCallback(&ConfigureCubicSockets, tcpL4ProtocolClient, tcpL4ProtocolSta));
// Application configuration for Cubic flows under test
port = 200;
ApplicationContainer cubicClientApps;
ApplicationContainer cubicServerApps;
for (auto i = 0U; i < numCubic; i++)
{
BulkSendHelper bulkCubic("ns3::TcpSocketFactory",
InetSocketAddress(wifiInterfaces.GetAddress(1), port + i));
bulkCubic.SetAttribute("MaxBytes", UintegerValue(numBytes));
bulkCubic.SetAttribute("StartTime",
TimeValue(Seconds(1) + (i + numPrague) * flowStartOffset));
cubicClientApps.Add(bulkCubic.Install(clientNode.Get(0)));
NS_LOG_DEBUG("Creating Cubic foreground flow " << i);
PacketSinkHelper sinkCubic =
PacketSinkHelper("ns3::TcpSocketFactory",
InetSocketAddress(Ipv4Address::GetAny(), port + i));
sinkCubic.SetAttribute("StartTime",
TimeValue(Seconds(1) + (i + numPrague) * flowStartOffset));
cubicServerApps.Add(sinkCubic.Install(staNode.Get(0)));
g_flowsToClose++;
}
// Allow the primary network to send saturating UDP traffic if no TCP is configured
if (!numCubic && !numPrague)
{
uint16_t udpPort = 9;
UdpServerHelper server(udpPort);
ApplicationContainer serverApp = server.Install(staNode.Get(0));
serverApp.Start(Seconds(1.0));
UdpClientHelper client(InetSocketAddress(wifiInterfaces.GetAddress(1), udpPort));
client.SetAttribute("MaxPackets", UintegerValue(4294967295U));
client.SetAttribute("Interval", TimeValue(Time("0.00001"))); // packets/s
client.SetAttribute("PacketSize", UintegerValue(1440));
ApplicationContainer clientApp = client.Install(clientNode.Get(0));
clientApp.Start(Seconds(1.1));
}
// Control the random variable stream assignments for Wi-Fi models (the value 100 is arbitrary)
wifi.AssignStreams(wifiDevices, 100);
// schedule MCS changes, if configured above
if (mcsChangeInterval > Seconds(0))
{
uint32_t secondLimit = CalculateLimit(secondMcs, channelWidth, spatialStreams, txopLimit);
Simulator::Schedule(Seconds(1) + mcsChangeInterval,
&ChangeMcs,
mcs,
limit,
secondMcs,
secondLimit,
scale,
mcsChangeInterval);
}
// OBSS traffic configuration
if (numBackgroundUdp)
{
perStaUdpRate = obssUdpRate * (1.0 / numBackgroundUdp);
uint16_t udpPort = 999;
std::string socketType = "ns3::UdpSocketFactory";
PacketSinkHelper packetSinkHelper(socketType,
InetSocketAddress(Ipv4Address::GetAny(), udpPort));
packetSinkHelper.SetAttribute("StartTime", TimeValue(obssUdpStartTime));
packetSinkHelper.Install(obssClientNode.Get(0));
OnOffHelper onOffHelper(socketType, InetSocketAddress(interfaces2.GetAddress(0), udpPort));
onOffHelper.SetAttribute("OnTime", StringValue("ns3::ConstantRandomVariable[Constant=1]"));
onOffHelper.SetAttribute("OffTime", StringValue("ns3::ConstantRandomVariable[Constant=0]"));
onOffHelper.SetAttribute("PacketSize", UintegerValue(1472));
onOffHelper.SetAttribute("MaxBytes", UintegerValue(0)); // Zero means no sending limits
onOffHelper.SetAttribute("DataRate", DataRateValue(perStaUdpRate));
onOffHelper.SetAttribute("StartTime", TimeValue(obssUdpStartTime));
onOffHelper.Install(obssStaNodes);
}
// PCAP traces
if (enablePcapAll)
{
pointToPoint.EnablePcapAll("l4s-wifi");
wifiPhy.EnablePcap("l4s-wifi", wifiDevices);
internetStack.EnablePcapIpv4("l4s-wifi-2-0-ip.pcap",
staNode.Get(0)->GetObject<Ipv4>(),
1,
true);
}
else if (enablePcap)
{
pointToPoint.EnablePcap("l4s-wifi", wanDevices.Get(0));
internetStack.EnablePcapIpv4("l4s-wifi-2-0-ip.pcap",
staNode.Get(0)->GetObject<Ipv4>(),
1,
true);
}
// Set up traces
// Bytes and throughput in WifiMacQueue
Ptr<WifiMacQueue> apWifiMacQueue =
apDevice.Get(0)->GetObject<WifiNetDevice>()->GetMac()->GetTxopQueue(AC_BE);
Ptr<WifiPhy> apPhy = apDevice.Get(0)->GetObject<WifiNetDevice>()->GetPhy();
NS_ASSERT_MSG(apPhy, "Could not acquire pointer to AP's WifiPhy");
if (enableTracesAll || enableTraces)
{
g_fileBytesInAcBeQueue.open("wifi-queue-bytes.dat", std::ofstream::out);
NS_ASSERT_MSG(apWifiMacQueue, "Could not acquire pointer to AC_BE WifiMacQueue on the AP");
apWifiMacQueue->TraceConnectWithoutContext("BytesInQueue",
MakeCallback(&TraceBytesInAcBeQueue));
apPhy->TraceConnect("PhyTxPsduBegin", "foreground", MakeCallback(&TraceWifiPhyTxPsduBegin));
for (uint32_t i = 0; i < obssStaDevices.GetN(); i++)
{
Ptr<WifiPhy> staPhy = obssStaDevices.Get(i)->GetObject<WifiNetDevice>()->GetPhy();
staPhy->TraceConnect("PhyTxPsduBegin",
"background",
MakeCallback(&TraceWifiPhyTxPsduBegin));
}
g_fileWifiThroughput.open("wifi-throughput.dat", std::ofstream::out);
g_fileWifiFgThroughput.open("wifi-foreground-throughput.dat", std::ofstream::out);
g_fileWifiBgThroughput.open("wifi-background-throughput.dat", std::ofstream::out);
Simulator::Schedule(g_wifiThroughputInterval, &TraceWifiThroughput);
}
if (enableTracesAll)
{
g_fileWifiPhyTxPsduBegin.open("wifi-phy-tx-psdu-begin.dat", std::ofstream::out);
}
// Throughput and latency for foreground flows, and set up close callbacks
if (pragueClientApps.GetN())
{
if (enableTracesAll || enableTraces)
{
g_filePragueThroughput.open("prague-throughput.dat", std::ofstream::out);
g_filePragueThroughputPerStream.open("prague-throughput-per-stream.dat",
std::ofstream::out);
g_filePragueCwnd.open("prague-cwnd.dat", std::ofstream::out);
g_filePragueRtt.open("prague-rtt.dat", std::ofstream::out);
}
if (enableTracesAll)
{
g_filePragueSsthresh.open("prague-ssthresh.dat", std::ofstream::out);
g_filePragueSendInterval.open("prague-send-interval.dat", std::ofstream::out);
g_filePraguePacingRate.open("prague-pacing-rate.dat", std::ofstream::out);
g_filePragueCongState.open("prague-cong-state.dat", std::ofstream::out);
g_filePragueEcnState.open("prague-ecn-state.dat", std::ofstream::out);
}
}
for (auto i = 0U; i < pragueClientApps.GetN(); i++)
{
// The TCP sockets that we want to connect
Simulator::Schedule(Seconds(1) + i * flowStartOffset + TimeStep(1),
MakeBoundCallback(&TracePragueClientSocket,
pragueClientApps.Get(i),
i,
enableTracesAll,
enableTraces));
pragueServerApps.Get(i)->GetObject<PacketSink>()->TraceConnectWithoutContext(
"Accept",
MakeCallback(&TracePragueServerSocket));
std::ostringstream oss;
oss << "Prague:" << i;
NS_LOG_DEBUG("Setting up callbacks on Prague sockets " << pragueServerApps.Get(i));
pragueServerApps.Get(i)->GetObject<PacketSink>()->TraceConnect(
"PeerClose",
oss.str(),
MakeCallback(&HandlePeerClose));
pragueServerApps.Get(i)->GetObject<PacketSink>()->TraceConnect(
"PeerError",
oss.str(),
MakeCallback(&HandlePeerError));
}
if (cubicClientApps.GetN())
{
if (enableTracesAll || enableTraces)
{
g_fileCubicThroughput.open("cubic-throughput.dat", std::ofstream::out);
g_fileCubicThroughputPerStream.open("cubic-throughput-per-stream.dat",
std::ofstream::out);
g_fileCubicCwnd.open("cubic-cwnd.dat", std::ofstream::out);
g_fileCubicRtt.open("cubic-rtt.dat", std::ofstream::out);
}
if (enableTracesAll)
{
g_fileCubicSsthresh.open("cubic-ssthresh.dat", std::ofstream::out);
g_fileCubicSendInterval.open("cubic-send-interval.dat", std::ofstream::out);
g_fileCubicPacingRate.open("cubic-pacing-rate.dat", std::ofstream::out);
g_fileCubicCongState.open("cubic-cong-state.dat", std::ofstream::out);
g_fileCubicRtt.open("cubic-rtt.dat", std::ofstream::out);
}
}
for (auto i = 0U; i < cubicClientApps.GetN(); i++)
{
// The TCP sockets that we want to connect
Simulator::Schedule(Seconds(1) + (i + numPrague) * flowStartOffset + TimeStep(1),
MakeBoundCallback(&TraceCubicClientSocket,
cubicClientApps.Get(i),
i,
enableTracesAll,
enableTraces));
cubicServerApps.Get(i)->GetObject<PacketSink>()->TraceConnectWithoutContext(
"Accept",
MakeCallback(&TraceCubicServerSocket));
std::ostringstream oss;
oss << "Cubic:" << i;
NS_LOG_DEBUG("Setting up callbacks on Cubic sockets " << i << " "
<< cubicServerApps.Get(i));
cubicServerApps.Get(i)->GetObject<PacketSink>()->TraceConnect(
"PeerClose",
oss.str(),
MakeCallback(&HandlePeerClose));
cubicServerApps.Get(i)->GetObject<PacketSink>()->TraceConnect(
"PeerError",
oss.str(),
MakeCallback(&HandlePeerError));
}
// Trace bytes in DualPi2 queue
Ptr<DualPi2QueueDisc> dualPi2 = apQueueDiscContainer.Get(0)
->GetQueueDiscClass(0)
->GetQueueDisc()
->GetObject<DualPi2QueueDisc>();
NS_ASSERT_MSG(dualPi2, "Could not acquire pointer to DualPi2 queue");
if (enableTracesAll || enableTraces)
{
g_fileBytesInDualPi2Queue.open("wifi-dualpi2-bytes.dat", std::ofstream::out);
dualPi2->TraceConnectWithoutContext("BytesInQueue",
MakeCallback(&TraceBytesInDualPi2Queue));
}
if (enableTracesAll)
{
g_fileLSojourn.open("wifi-dualpi2-l-sojourn.dat", std::ofstream::out);
dualPi2->TraceConnectWithoutContext("L4sSojournTime", MakeCallback(&TraceLSojourn));
g_fileCSojourn.open("wifi-dualpi2-c-sojourn.dat", std::ofstream::out);
dualPi2->TraceConnectWithoutContext("ClassicSojournTime", MakeCallback(&TraceCSojourn));
// Trace Probabilities
g_fileTraceProbChanges.open("wifi-dualpi2-TracedProbabilites.dat", std::ofstream::out);
dualPi2->TraceConnectWithoutContext("ProbCL", MakeCallback(&TraceProbcL));
dualPi2->TraceConnectWithoutContext("ProbL", MakeCallback(&TraceProbL));
dualPi2->TraceConnectWithoutContext("ProbC", MakeCallback(&TraceProbC));
}
WifiCoTraceHelper coHelper;
coHelper.Enable(NodeContainer(apNode, staNode, obssApNode, obssStaNodes));
if (duration > Seconds(0))
{
Simulator::Stop(duration);
}
else
{
// Keep the simulator from running forever in case Stop() is not triggered.
// However, the simulation should stop on the basis of the close callbacks.
Simulator::Stop(Seconds(1000));
}
std::cout << "Foreground flows: Cubic: " << numCubic << " Prague: " << numPrague << std::endl;
if (numBackgroundUdp)
{
std::cout << "Background UDP flows: " << numBackgroundUdp << " at per-STA rate of "
<< perStaUdpRate.GetBitRate() / 1e6 << " Mbps" << std::endl;
}
if (showProgress)
{
std::cout << std::endl;
// Keep progress object in scope of the Run() method
ShowProgress progress(progressInterval);
Simulator::Run();
}
else
{
Simulator::Run();
}
std::string stopReason = "automatic";
if (duration == Seconds(0) && Simulator::Now() >= Seconds(1000))
{
stopReason = "fail-safe";
}
else if (duration > Seconds(0))
{
stopReason = "scheduled";
}
std::cout << std::endl
<< "Reached simulation " << stopReason << " stop time after "
<< Simulator::Now().GetSeconds() << " seconds" << std::endl
<< std::endl;
if (stopReason == "fail-safe")
{
std::cout << "** Expected " << numCubic + numPrague << " flows to close, but "
<< g_flowsToClose << " are remaining" << std::endl
<< std::endl;
}
std::cout << std::fixed << std::setprecision(2);
if (numCubic)
{
std::cout << "Cubic throughput (Mbps) mean: " << cubicThroughputCalculator.getMean()
<< " max: " << cubicThroughputCalculator.getMax()
<< " min: " << cubicThroughputCalculator.getMin() << std::endl;
}
if (numPrague)
{
std::cout << "Prague throughput (Mbps) mean: " << pragueThroughputCalculator.getMean()
<< " max: " << pragueThroughputCalculator.getMax()
<< " min: " << pragueThroughputCalculator.getMin() << std::endl;
}
coHelper.PrintStatistics(std::cout);
g_fileBytesInAcBeQueue.close();
g_fileBytesInDualPi2Queue.close();
g_fileLSojourn.close();
g_fileCSojourn.close();
g_fileWifiPhyTxPsduBegin.close();
g_fileWifiThroughput.close();
g_fileWifiFgThroughput.close();
g_fileWifiBgThroughput.close();
g_filePragueThroughput.close();
g_filePragueThroughputPerStream.close();
g_filePragueCwnd.close();
g_filePragueSsthresh.close();
g_filePragueSendInterval.close();
g_filePraguePacingRate.close();
g_filePragueCongState.close();
g_filePragueEcnState.close();
g_filePragueRtt.close();
g_fileCubicThroughput.close();
g_fileCubicThroughputPerStream.close();
g_fileCubicCwnd.close();
g_fileCubicSsthresh.close();
g_fileCubicSendInterval.close();
g_fileCubicPacingRate.close();
g_fileCubicCongState.close();
g_fileCubicCongState.close();
g_fileCubicRtt.close();
Simulator::Destroy();