diff --git a/examples/wireless/examples-to-run.py b/examples/wireless/examples-to-run.py index 92c489422..bf7d8f45c 100755 --- a/examples/wireless/examples-to-run.py +++ b/examples/wireless/examples-to-run.py @@ -41,9 +41,9 @@ cpp_examples = [ ("wifi-ht-network --simulationTime=0.2 --frequency=5 --useRts=0 --minExpectedThroughput=5 --maxExpectedThroughput=135", "True", "True"), ("wifi-ht-network --simulationTime=0.2 --frequency=5 --useRts=1 --minExpectedThroughput=5 --maxExpectedThroughput=131", "True", "True"), ("wifi-ht-network --simulationTime=0.2 --frequency=2.4 --useRts=0 --minExpectedThroughput=5 --maxExpectedThroughput=132", "True", "True"), - ("wifi-ht-network --simulationTime=0.2 --frequency=2.4 --useRts=1 --minExpectedThroughput=5 --maxExpectedThroughput=128", "True", "True"), + ("wifi-ht-network --simulationTime=0.2 --frequency=2.4 --useRts=1 --minExpectedThroughput=5 --maxExpectedThroughput=129", "True", "True"), ("wifi-vht-network --simulationTime=0.2 --useRts=0 --minExpectedThroughput=5 --maxExpectedThroughput=583", "True", "True"), - ("wifi-vht-network --simulationTime=0.2 --useRts=1 --minExpectedThroughput=5 --maxExpectedThroughput=543", "True", "True"), + ("wifi-vht-network --simulationTime=0.2 --useRts=1 --minExpectedThroughput=5 --maxExpectedThroughput=547", "True", "True"), ("wifi-he-network --simulationTime=0.25 --frequency=5 --useRts=0 --minExpectedThroughput=6 --maxExpectedThroughput=844", "True", "True"), ("wifi-he-network --simulationTime=0.3 --frequency=5 --useRts=0 --useExtendedBlockAck=1 --minExpectedThroughput=6 --maxExpectedThroughput=1033", "True", "True"), ("wifi-he-network --simulationTime=0.3 --frequency=5 --useRts=1 --minExpectedThroughput=6 --maxExpectedThroughput=745", "True", "True"), diff --git a/examples/wireless/wifi-80211e-txop.cc b/examples/wireless/wifi-80211e-txop.cc index 412249d21..2ef4b8f0e 100644 --- a/examples/wireless/wifi-80211e-txop.cc +++ b/examples/wireless/wifi-80211e-txop.cc @@ -396,7 +396,7 @@ int main (int argc, char *argv[]) throughput = totalPacketsThroughC * payloadSize * 8 / (simulationTime * 1000000.0); std::cout << "AC_VI with default TXOP limit (4.096ms): " << '\n' << " Throughput = " << throughput << " Mbit/s" << '\n'; - if (verifyResults && (throughput < 37.0 || throughput > 37.5)) + if (verifyResults && (throughput < 36.5 || throughput > 37.5)) { NS_LOG_ERROR ("Obtained throughput " << throughput << " is not in the expected boundaries!"); exit (1); diff --git a/examples/wireless/wifi-aggregation.cc b/examples/wireless/wifi-aggregation.cc index 1dc5376f2..75f50b865 100644 --- a/examples/wireless/wifi-aggregation.cc +++ b/examples/wireless/wifi-aggregation.cc @@ -330,7 +330,7 @@ int main (int argc, char *argv[]) double throughput = totalPacketsThroughA * payloadSize * 8 / (simulationTime * 1000000.0); std::cout << "Throughput with default configuration (A-MPDU aggregation enabled, 65kB): " << throughput << " Mbit/s" << '\n'; - if (verifyResults && (throughput < 58.5 || throughput > 59.5)) + if (verifyResults && (throughput < 59.0 || throughput > 60.0)) { NS_LOG_ERROR ("Obtained throughput " << throughput << " is not in the expected boundaries!"); exit (1); diff --git a/examples/wireless/wifi-he-network.cc b/examples/wireless/wifi-he-network.cc index 53ac57f38..9cd7f6bf5 100644 --- a/examples/wireless/wifi-he-network.cc +++ b/examples/wireless/wifi-he-network.cc @@ -261,7 +261,7 @@ int main (int argc, char *argv[]) RngSeedManager::SetSeed (1); RngSeedManager::SetRun (1); - int64_t streamNumber = 100; + int64_t streamNumber = 150; streamNumber += wifi.AssignStreams (apDevice, streamNumber); streamNumber += wifi.AssignStreams (staDevices, streamNumber); diff --git a/src/wifi/helper/wifi-helper.cc b/src/wifi/helper/wifi-helper.cc index c662cddaf..5f168670e 100644 --- a/src/wifi/helper/wifi-helper.cc +++ b/src/wifi/helper/wifi-helper.cc @@ -22,6 +22,7 @@ #include "ns3/wifi-net-device.h" #include "ns3/ap-wifi-mac.h" +#include "ns3/sta-wifi-mac.h" #include "ns3/ampdu-subframe-header.h" #include "ns3/mobility-model.h" #include "ns3/log.h" @@ -992,11 +993,15 @@ WifiHelper::AssignStreams (NetDeviceContainer c, int64_t stream) currentStream += bk_txop->AssignStreams (currentStream); } - //if an AP, handle any beacon jitter - Ptr apmac = DynamicCast (mac); - if (apmac) + // if an AP, handle any beacon jitter + if (auto apMac = DynamicCast (mac); apMac) { - currentStream += apmac->AssignStreams (currentStream); + currentStream += apMac->AssignStreams (currentStream); + } + // if a STA, handle any probe request jitter + if (auto staMac = DynamicCast (mac); staMac) + { + currentStream += staMac->AssignStreams (currentStream); } } } diff --git a/src/wifi/model/sta-wifi-mac.cc b/src/wifi/model/sta-wifi-mac.cc index d9990b6c7..d0dd06429 100644 --- a/src/wifi/model/sta-wifi-mac.cc +++ b/src/wifi/model/sta-wifi-mac.cc @@ -23,7 +23,10 @@ #include "ns3/log.h" #include "ns3/packet.h" +#include "ns3/pointer.h" +#include "ns3/random-variable-stream.h" #include "ns3/simulator.h" +#include "ns3/string.h" #include "qos-txop.h" #include "sta-wifi-mac.h" #include "wifi-phy.h" @@ -73,6 +76,12 @@ StaWifiMac::GetTypeId (void) BooleanValue (false), MakeBooleanAccessor (&StaWifiMac::SetActiveProbing, &StaWifiMac::GetActiveProbing), MakeBooleanChecker ()) + .AddAttribute ("ProbeDelay", + "Delay (in microseconds) to be used prior to transmitting a " + "Probe frame during active scanning.", + StringValue ("ns3::UniformRandomVariable[Min=50.0|Max=250.0]"), + MakePointerAccessor (&StaWifiMac::m_probeDelay), + MakePointerChecker ()) .AddTraceSource ("Assoc", "Associated with an access point.", MakeTraceSourceAccessor (&StaWifiMac::m_assocLogger), "ns3::Mac48Address::TracedCallback") @@ -114,6 +123,14 @@ StaWifiMac::~StaWifiMac () NS_LOG_FUNCTION (this); } +int64_t +StaWifiMac::AssignStreams (int64_t stream) +{ + NS_LOG_FUNCTION (this << stream); + m_probeDelay->SetStream (stream); + return 1; +} + uint16_t StaWifiMac::GetAssociationId (void) const { diff --git a/src/wifi/model/sta-wifi-mac.h b/src/wifi/model/sta-wifi-mac.h index 63f43a5ae..8e11aab16 100644 --- a/src/wifi/model/sta-wifi-mac.h +++ b/src/wifi/model/sta-wifi-mac.h @@ -35,6 +35,8 @@ namespace ns3 { class SupportedRates; class CapabilityInformation; +class RandomVariableStream; + /** * \ingroup wifi @@ -194,6 +196,17 @@ public: void NotifyChannelSwitching (void) override; + /** + * Assign a fixed random variable stream number to the random variables + * used by this model. Return the number of streams (possibly zero) that + * have been assigned. + * + * \param stream first stream index to use + * + * \return the number of stream indices assigned by this model + */ + int64_t AssignStreams (int64_t stream); + private: /** * The current MAC state of the STA. @@ -357,6 +370,8 @@ private: Time m_beaconWatchdogEnd; ///< beacon watchdog end uint32_t m_maxMissedBeacons; ///< maximum missed beacons bool m_activeProbing; ///< active probing + Ptr m_probeDelay; ///< RandomVariable used to randomize the time + ///< of the first Probe Response on each channel std::vector m_candidateAps; ///< list of candidate APs to associate to // Note: std::multiset might be a candidate container to implement // this sorted list, but we are using a std::vector because we want to sort