diff --git a/src/wifi/test/wifi-test.cc b/src/wifi/test/wifi-test.cc index 93bfeab9c..95e456dcb 100644 --- a/src/wifi/test/wifi-test.cc +++ b/src/wifi/test/wifi-test.cc @@ -38,9 +38,42 @@ #include "ns3/mac-rx-middle.h" #include "ns3/pointer.h" #include "ns3/rng-seed-manager.h" +#include "ns3/edca-txop-n.h" namespace ns3 { +// helper function to assign streams to random variables, to control +// randomness in the tests +static void +AssignWifiRandomStreams (Ptr mac, int64_t stream) +{ + int64_t currentStream = stream; + Ptr rmac = DynamicCast (mac); + if (rmac) + { + PointerValue ptr; + rmac->GetAttribute ("DcaTxop", ptr); + Ptr dcaTxop = ptr.Get (); + currentStream += dcaTxop->AssignStreams (currentStream); + + rmac->GetAttribute ("VO_EdcaTxopN", ptr); + Ptr vo_edcaTxopN = ptr.Get (); + currentStream += vo_edcaTxopN->AssignStreams (currentStream); + + rmac->GetAttribute ("VI_EdcaTxopN", ptr); + Ptr vi_edcaTxopN = ptr.Get (); + currentStream += vi_edcaTxopN->AssignStreams (currentStream); + + rmac->GetAttribute ("BE_EdcaTxopN", ptr); + Ptr be_edcaTxopN = ptr.Get (); + currentStream += be_edcaTxopN->AssignStreams (currentStream); + + rmac->GetAttribute ("BK_EdcaTxopN", ptr); + Ptr bk_edcaTxopN = ptr.Get (); + currentStream += bk_edcaTxopN->AssignStreams (currentStream); + } +} + class WifiTest : public TestCase { public: @@ -378,7 +411,8 @@ Bug555TestCase::DoRun (void) m_propDelay.SetTypeId ("ns3::ConstantSpeedPropagationDelayModel"); m_manager.SetTypeId ("ns3::ConstantRateWifiManager"); - //The simulation with the following seed and run numbers expe + // Assign a seed and run number, and later fix the assignment of streams to + // WiFi random variables, so that the first backoff used is zero slots RngSeedManager::SetSeed (1); RngSeedManager::SetRun (17); @@ -392,6 +426,11 @@ Bug555TestCase::DoRun (void) Ptr txDev = CreateObject (); Ptr txMac = m_mac.Create (); txMac->ConfigureStandard (WIFI_PHY_STANDARD_80211a); + // Fix the stream assignment to the Dcf Txop objects (backoffs) + // The below stream assignment will result in the DcaTxop object + // using a backoff value of zero for this test when the + // DcaTxop::EndTxNoAck() calls to StartBackoffNow() + AssignWifiRandomStreams (txMac, 23); Ptr txMobility = CreateObject (); Ptr txPhy = CreateObject ();