src/wifi/test/wifi-test.cc
changeset 10195 423dfabf60c1
parent 10157 02e3d2d7d7e1
child 10206 ecd136bcb899
--- a/src/wifi/test/wifi-test.cc	Fri Sep 06 18:46:39 2013 -0700
+++ b/src/wifi/test/wifi-test.cc	Sun Sep 08 09:57:13 2013 -0700
@@ -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<WifiMac> mac, int64_t stream)
+{
+  int64_t currentStream = stream;
+  Ptr<RegularWifiMac> rmac = DynamicCast<RegularWifiMac> (mac);
+  if (rmac)
+    {
+      PointerValue ptr;
+      rmac->GetAttribute ("DcaTxop", ptr);
+      Ptr<DcaTxop> dcaTxop = ptr.Get<DcaTxop> ();
+      currentStream += dcaTxop->AssignStreams (currentStream);
+
+      rmac->GetAttribute ("VO_EdcaTxopN", ptr);
+      Ptr<EdcaTxopN> vo_edcaTxopN = ptr.Get<EdcaTxopN> ();
+      currentStream += vo_edcaTxopN->AssignStreams (currentStream);
+
+      rmac->GetAttribute ("VI_EdcaTxopN", ptr);
+      Ptr<EdcaTxopN> vi_edcaTxopN = ptr.Get<EdcaTxopN> ();
+      currentStream += vi_edcaTxopN->AssignStreams (currentStream);
+
+      rmac->GetAttribute ("BE_EdcaTxopN", ptr);
+      Ptr<EdcaTxopN> be_edcaTxopN = ptr.Get<EdcaTxopN> ();
+      currentStream += be_edcaTxopN->AssignStreams (currentStream);
+
+      rmac->GetAttribute ("BK_EdcaTxopN", ptr);
+      Ptr<EdcaTxopN> bk_edcaTxopN = ptr.Get<EdcaTxopN> ();
+      currentStream += bk_edcaTxopN->AssignStreams (currentStream);
+    }
+}
+
 class WifiTest : public TestCase
 {
 public:
@@ -378,7 +411,8 @@
   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 @@
   Ptr<WifiNetDevice> txDev = CreateObject<WifiNetDevice> ();
   Ptr<WifiMac> txMac = m_mac.Create<WifiMac> ();
   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<ConstantPositionMobilityModel> txMobility = CreateObject<ConstantPositionMobilityModel> ();
   Ptr<YansWifiPhy> txPhy = CreateObject<YansWifiPhy> ();