diff --git a/examples/wireless/wifi-spatial-reuse.cc b/examples/wireless/wifi-spatial-reuse.cc index 9a1cbd17b..4d06f3c30 100644 --- a/examples/wireless/wifi-spatial-reuse.cc +++ b/examples/wireless/wifi-spatial-reuse.cc @@ -44,22 +44,46 @@ // The following command will display all of the available run-time help options: // ./ns3 run "wifi-spatial-reuse --help" // -// By default, the script shows the benefit of the OBSS_PD spatial reuse script: -// ./ns3 run wifi-spatial-reuse -// Throughput for BSS 1: 6.6468 Mbit/s -// Throughput for BSS 2: 6.6672 Mbit/s +// According to the Wi-Fi models of ns-3.36 release, throughput with +// OBSS PD enabled (--enableObssPd=True) was roughly 6.5 Mbps, and with +// it disabled (--enableObssPd=False) was roughly 3.5 Mbps. // -// If one disables the OBSS_PD feature, a lower throughput is obtained per BSS: -// ./ns3 run "wifi-spatial-reuse --enableObssPd=0" -// Throughput for BSS 1: 5.8692 Mbit/s -// Throughput for BSS 2: 5.9364 Mbit/ +// This difference between those results is because OBSS_PD spatial +// reuse enables to ignore transmissions from another BSS when the +// received power is below the configured threshold, and therefore +// either defer during ongoing transmission or transmit at the same +// time. // -// This difference between those results is because OBSS_PD spatial -// enables to ignore transmissions from another BSS when the received power -// is below the configured threshold, and therefore either defer during ongoing -// transmission or transmit at the same time. +// Note that, by default, this script configures a network using a +// channel bandwidth of 20 MHz. Changing this value alone (through +// the --channelWidth argument) without properly adjusting other +// parameters will void the effect of spatial reuse: since energy is +// measured over the 20 MHz primary channel regardless of the channel +// width, doubling the transmission bandwidth creates a 3 dB drop in +// the measured energy level (i.e., a halving of the measured +// energy). Because of this, when using the channelWidth argument +// users should also adjust the CCA-ED Thresholds (via --ccaEdTrSta1, +// --ccaEdTrSta2, --ccaEdTrAp1, and --ccaEdTrAp2), the Minimum RSSI +// for preamble detection (via --minimumRssi), and the OBSS PD +// Threshold (via --obssPdThreshold) appropriately. For instance, +// this can be accomplished for a channel width of 40 MHz by lowering +// all these values by 3 dB compared to their defaults. +// +// In addition, consider that adapting the adjustments shown above +// for an 80 MHz bandwidth (using a 6 dB threshold adjustment instead +// of 3 dB) will not produce any changes when enableObssPd is enabled +// or disabled. The cause for this is the insufficient amount of +// traffic that is generated by default in the example: increasing +// the bandwidth shortens the frame durations, and lowers the +// collision probability. Collisions between BSSs are a necessary +// condition to see the improvements brought by spatial reuse, and +// thus increasing the amount of generated traffic by setting the +// interval argument to a lower value is necessary to see the +// benefits of spatial reuse in this scenario. This can, for +// instance, be accomplished by setting --interval=0.0001. // +#include "ns3/abort.h" #include "ns3/command-line.h" #include "ns3/config.h" #include "ns3/string.h" @@ -110,6 +134,8 @@ main (int argc, char *argv[]) double ccaEdTrSta2 = -62; // dBm double ccaEdTrAp1 = -62; // dBm double ccaEdTrAp2 = -62; // dBm + double minimumRssi = -82; // dBm + int channelBandwidth = 20; // MHz uint32_t payloadSize = 1500; // bytes uint32_t mcs = 0; // MCS value double interval = 0.001; // seconds @@ -131,6 +157,9 @@ main (int argc, char *argv[]) cmd.AddValue ("ccaEdTrSta2", "CCA-ED Threshold of STA2 (dBm)", ccaEdTrSta2); cmd.AddValue ("ccaEdTrAp1", "CCA-ED Threshold of AP1 (dBm)", ccaEdTrAp1); cmd.AddValue ("ccaEdTrAp2", "CCA-ED Threshold of AP2 (dBm)", ccaEdTrAp2); + cmd.AddValue ("minimumRssi", "Minimum RSSI for the ThresholdPreambleDetectionModel", minimumRssi); + cmd.AddValue ("channelBandwidth", "Bandwidth of the channel in MHz [20, 40, or 80]", channelBandwidth); + cmd.AddValue ("obssPdThreshold", "Threshold for the OBSS PD Algorithm", obssPdThreshold); cmd.AddValue ("mcs", "The constant MCS value to transmit HE PPDUs", mcs); cmd.Parse (argc, argv); @@ -149,9 +178,23 @@ main (int argc, char *argv[]) spectrumPhy.SetChannel (spectrumChannel); spectrumPhy.SetErrorRateModel ("ns3::YansErrorRateModel"); - spectrumPhy.Set ("Frequency", UintegerValue (5180)); // channel 36 at 20 MHz - spectrumPhy.SetPreambleDetectionModel ("ns3::ThresholdPreambleDetectionModel"); - //TODO: add parameter to configure CCA-PD + switch (channelBandwidth) + { + case 20: + spectrumPhy.Set ("ChannelSettings", StringValue ("{36, 20, BAND_5GHZ, 0}")); + break; + case 40: + spectrumPhy.Set ("ChannelSettings", StringValue ("{62, 40, BAND_5GHZ, 0}")); + break; + case 80: + spectrumPhy.Set ("ChannelSettings", StringValue ("{171, 80, BAND_5GHZ, 0}")); + break; + default: + NS_ABORT_MSG ("Unrecognized channel bandwidth: " << channelBandwidth); + break; + } + spectrumPhy.SetPreambleDetectionModel ("ns3::ThresholdPreambleDetectionModel", + "MinimumRssi", DoubleValue (minimumRssi)); WifiHelper wifi; wifi.SetStandard (WIFI_STANDARD_80211ax);