Fix of bug 706: Backoff counting when starting NS
authorKirill Andreev <andreev@iitp.ru>
Mon, 11 Jan 2010 12:23:09 +0300
changeset 5903 395e17028faf
parent 5902 8788d85a6c3e
child 5904 025c764ba6b6
child 5906 509b5089a081
Fix of bug 706: Backoff counting when starting NS
src/devices/mesh/mesh-wifi-interface-mac.cc
src/devices/mesh/mesh-wifi-interface-mac.h
src/devices/wifi/adhoc-wifi-mac.cc
src/devices/wifi/adhoc-wifi-mac.h
src/devices/wifi/dca-txop.cc
src/devices/wifi/dca-txop.h
src/devices/wifi/edca-txop-n.cc
src/devices/wifi/edca-txop-n.h
src/devices/wifi/nqap-wifi-mac.cc
src/devices/wifi/nqsta-wifi-mac.cc
src/devices/wifi/nqsta-wifi-mac.h
src/devices/wifi/qadhoc-wifi-mac.cc
src/devices/wifi/qadhoc-wifi-mac.h
src/devices/wifi/qap-wifi-mac.cc
src/devices/wifi/qsta-wifi-mac.cc
src/devices/wifi/qsta-wifi-mac.h
--- a/src/devices/mesh/mesh-wifi-interface-mac.cc	Fri Jan 08 18:04:01 2010 +0100
+++ b/src/devices/mesh/mesh-wifi-interface-mac.cc	Mon Jan 11 12:23:09 2010 +0300
@@ -720,6 +720,16 @@
 {
   m_txErrCallback (hdr);
 }
+void
+MeshWifiInterfaceMac::DoStart ()
+{
+  m_beaconDca->Start ();
+  for (Queues::iterator i = m_queues.begin (); i != m_queues.end (); i ++)
+  {
+    i->second->Start ();
+  }
+  WifiMac::DoStart ();
+}
 
 void 
 MeshWifiInterfaceMac::FinishConfigureStandard (enum WifiPhyStandard standard)
--- a/src/devices/mesh/mesh-wifi-interface-mac.h	Fri Jan 08 18:04:01 2010 +0100
+++ b/src/devices/mesh/mesh-wifi-interface-mac.h	Mon Jan 11 12:23:09 2010 +0300
@@ -179,6 +179,8 @@
   bool GetBeaconGeneration () const;
   /// Real d-tor
   virtual void DoDispose ();
+  ///Initiator at t=0
+  void DoStart ();
 
 private:
   typedef std::map<AccessClass, Ptr<DcaTxop> > Queues;
--- a/src/devices/wifi/adhoc-wifi-mac.cc	Fri Jan 08 18:04:01 2010 +0100
+++ b/src/devices/wifi/adhoc-wifi-mac.cc	Mon Jan 11 12:23:09 2010 +0300
@@ -298,4 +298,11 @@
 {
   m_txErrCallback (hdr);
 }
+void
+AdhocWifiMac::DoStart ()
+{
+  m_dca->Start ();
+  WifiMac::DoStart ();
+}
+
 } // namespace ns3
--- a/src/devices/wifi/adhoc-wifi-mac.h	Fri Jan 08 18:04:01 2010 +0100
+++ b/src/devices/wifi/adhoc-wifi-mac.h	Mon Jan 11 12:23:09 2010 +0300
@@ -82,6 +82,7 @@
 private:
   // inherited from Object base class.
   virtual void DoDispose (void);
+  void DoStart ();
   /* invoked by the MacLows. */
   void ForwardUp (Ptr<Packet> packet, const WifiMacHeader *hdr);
   AdhocWifiMac (const AdhocWifiMac & ctor_arg);
--- a/src/devices/wifi/dca-txop.cc	Fri Jan 08 18:04:01 2010 +0100
+++ b/src/devices/wifi/dca-txop.cc	Mon Jan 11 12:23:09 2010 +0300
@@ -268,6 +268,13 @@
   return m_low;
 }
 
+void
+DcaTxop::DoStart ()
+{
+  m_dcf->ResetCw ();
+  m_dcf->StartBackoffNow (m_rng->GetNext (0, m_dcf->GetCw ()));
+  ns3::Dcf::DoStart ();
+}
 bool
 DcaTxop::NeedRts (Ptr<const Packet> packet)
 {
--- a/src/devices/wifi/dca-txop.h	Fri Jan 08 18:04:01 2010 +0100
+++ b/src/devices/wifi/dca-txop.h	Mon Jan 11 12:23:09 2010 +0300
@@ -121,7 +121,7 @@
 
   // Inherited from ns3::Object
   Ptr<MacLow> Low (void);
-
+  void DoStart ();
   /* dcf notifications forwarded here */
   bool NeedsAccess (void) const;
   void NotifyAccessGranted (void);
--- a/src/devices/wifi/edca-txop-n.cc	Fri Jan 08 18:04:01 2010 +0100
+++ b/src/devices/wifi/edca-txop-n.cc	Mon Jan 11 12:23:09 2010 +0300
@@ -686,5 +686,11 @@
 {
   m_aggregator = aggr;
 }
-
+void
+EdcaTxopN::DoStart ()
+{
+  m_dcf->ResetCw ();
+  m_dcf->StartBackoffNow (m_rng->GetNext (0, m_dcf->GetCw ()));
+  ns3::Dcf::DoStart ();
+}
 } //namespace ns3
--- a/src/devices/wifi/edca-txop-n.h	Fri Jan 08 18:04:01 2010 +0100
+++ b/src/devices/wifi/edca-txop-n.h	Mon Jan 11 12:23:09 2010 +0300
@@ -132,6 +132,7 @@
   void SetMsduAggregator (Ptr<MsduAggregator> aggr);
 
 private:
+  void DoStart ();
   /**
    * This functions are used only to correctly set addresses in a-msdu subframe.
    * If aggregating sta is a STA (in an infrastructured network):
--- a/src/devices/wifi/nqap-wifi-mac.cc	Fri Jan 08 18:04:01 2010 +0100
+++ b/src/devices/wifi/nqap-wifi-mac.cc	Mon Jan 11 12:23:09 2010 +0300
@@ -606,6 +606,8 @@
     {
       m_beaconEvent = Simulator::ScheduleNow (&NqapWifiMac::SendOneBeacon, this);
     }
+  m_dca->Start ();
+  m_beaconDca->Start ();
   WifiMac::DoStart ();
 }
 
--- a/src/devices/wifi/nqsta-wifi-mac.cc	Fri Jan 08 18:04:01 2010 +0100
+++ b/src/devices/wifi/nqsta-wifi-mac.cc	Mon Jan 11 12:23:09 2010 +0300
@@ -686,5 +686,10 @@
       break;
     }
 }
-
+void
+NqstaWifiMac::DoStart ()
+{
+  m_dca->Start ();
+  WifiMac::DoStart ();
+}
 } // namespace ns3
--- a/src/devices/wifi/nqsta-wifi-mac.h	Fri Jan 08 18:04:01 2010 +0100
+++ b/src/devices/wifi/nqsta-wifi-mac.h	Mon Jan 11 12:23:09 2010 +0300
@@ -119,6 +119,7 @@
     BEACON_MISSED,
     REFUSED
   };
+  void DoStart ();
   void SetBssid (Mac48Address bssid);
   void SetActiveProbing (bool enable);
   bool GetActiveProbing (void) const;
--- a/src/devices/wifi/qadhoc-wifi-mac.cc	Fri Jan 08 18:04:01 2010 +0100
+++ b/src/devices/wifi/qadhoc-wifi-mac.cc	Mon Jan 11 12:23:09 2010 +0300
@@ -108,10 +108,6 @@
   m_dcfManager = 0;
   m_low = 0;
   m_phy = 0;
-  m_voEdca = 0;
-  m_viEdca = 0;
-  m_beEdca = 0;
-  m_bkEdca = 0;
   m_stationManager = 0;
   for (Queues::iterator i = m_queues.begin (); i != m_queues.end (); ++i)
     {
@@ -445,5 +441,14 @@
       break;
     }
 }
+void
+QadhocWifiMac::DoStart ()
+{
+  for (Queues::iterator i = m_queues.begin (); i != m_queues.end (); ++i)
+    {
+      i->second->Start ();
+    }
+  WifiMac::DoStart ();
+}
 
 } //namespace ns3
--- a/src/devices/wifi/qadhoc-wifi-mac.h	Fri Jan 08 18:04:01 2010 +0100
+++ b/src/devices/wifi/qadhoc-wifi-mac.h	Mon Jan 11 12:23:09 2010 +0300
@@ -78,6 +78,7 @@
 private:
   Callback<void, Ptr<Packet>, Mac48Address, Mac48Address> m_forwardUp;
   virtual void DoDispose (void);
+  void DoStart ();
   void Receive (Ptr<Packet> packet, const WifiMacHeader *hdr);
   void ForwardUp (Ptr<Packet> packet, Mac48Address from, Mac48Address to);
   QadhocWifiMac &operator = (const QadhocWifiMac &);
@@ -101,10 +102,6 @@
   Ptr<EdcaTxopN> GetBKQueue (void) const;
 
   Queues m_queues;
-  Ptr<EdcaTxopN> m_voEdca;
-  Ptr<EdcaTxopN> m_viEdca;
-  Ptr<EdcaTxopN> m_beEdca;
-  Ptr<EdcaTxopN> m_bkEdca;
   Ptr<MacLow> m_low;
   Ptr<WifiPhy> m_phy;
   Ptr<WifiRemoteStationManager> m_stationManager;
--- a/src/devices/wifi/qap-wifi-mac.cc	Fri Jan 08 18:04:01 2010 +0100
+++ b/src/devices/wifi/qap-wifi-mac.cc	Mon Jan 11 12:23:09 2010 +0300
@@ -791,6 +791,11 @@
 void
 QapWifiMac::DoStart (void)
 {
+  m_beaconDca->Start ();
+  for (Queues::iterator i = m_queues.begin (); i != m_queues.end (); ++i)
+    {
+      i->second->Start ();
+    }
   m_beaconEvent.Cancel ();
   if (m_enableBeaconGeneration)
     {
--- a/src/devices/wifi/qsta-wifi-mac.cc	Fri Jan 08 18:04:01 2010 +0100
+++ b/src/devices/wifi/qsta-wifi-mac.cc	Mon Jan 11 12:23:09 2010 +0300
@@ -775,5 +775,13 @@
     }
 }
 
-
+void
+QstaWifiMac::DoStart ()
+{
+  for (Queues::iterator i = m_queues.begin (); i != m_queues.end (); ++i)
+    {
+      i->second->Start ();
+    }
+  WifiMac::DoStart ();
+}
 }  //namespace ns3
--- a/src/devices/wifi/qsta-wifi-mac.h	Fri Jan 08 18:04:01 2010 +0100
+++ b/src/devices/wifi/qsta-wifi-mac.h	Mon Jan 11 12:23:09 2010 +0300
@@ -87,6 +87,7 @@
   void StartActiveAssociation (void);
 
 private:
+  void DoStart ();
   void SetBssid (Mac48Address bssid);
   Mac48Address GetBroadcastBssid (void);
   void Receive (Ptr<Packet> p, const WifiMacHeader *hdr);