Ack timeout patch was merged. HWMP: DO=1 by default, if packet is unresolved -
authorKirill Andreev <andreev@iitp.ru>
Wed, 29 Apr 2009 19:37:19 +0400
changeset 4989 5f5b321b92d1
parent 4988 9293f61456d7
child 4990 404c7a03dd5c
child 4995 6a8113d46565
Ack timeout patch was merged. HWMP: DO=1 by default, if packet is unresolved - we queue it
src/devices/mesh/dot11s/hwmp-protocol.cc
src/devices/wifi/dcf-manager.cc
src/devices/wifi/dcf-manager.h
src/devices/wifi/mac-low.cc
src/devices/wifi/mac-low.h
--- a/src/devices/mesh/dot11s/hwmp-protocol.cc	Wed Apr 29 19:28:46 2009 +0400
+++ b/src/devices/mesh/dot11s/hwmp-protocol.cc	Wed Apr 29 19:37:19 2009 +0400
@@ -132,13 +132,13 @@
         )
     .AddAttribute ("doFlag",
         "Destination only HWMP flag",
-        BooleanValue (false),
+        BooleanValue (true),
         MakeUintegerAccessor (&HwmpProtocol::m_doFlag),
         MakeUintegerChecker<bool> ()
         )
     .AddAttribute ("rfFlag",
         "Reply and forward flag",
-        BooleanValue (false),
+        BooleanValue (true),
         MakeUintegerAccessor (&HwmpProtocol::m_rfFlag),
         MakeUintegerChecker<bool> ()
         );
@@ -286,8 +286,6 @@
     //    root
     if(result.retransmitter == Mac48Address::GetBroadcast ())
       result = m_rtable->LookupProactiveExpired ();
-    if(result.retransmitter == Mac48Address::GetBroadcast ())
-      return false;
     std::vector<IePerr::FailedDestination> destinations = m_rtable->GetUnreachableDestinations (result.retransmitter);
     MakePathError (destinations);
   }
--- a/src/devices/wifi/dcf-manager.cc	Wed Apr 29 19:28:46 2009 +0400
+++ b/src/devices/wifi/dcf-manager.cc	Wed Apr 29 19:37:19 2009 +0400
@@ -160,17 +160,29 @@
  *         Listener for Nav events. Forwards to DcfManager
  ***************************************************************/
 
-class LowNavListener : public ns3::MacLowNavListener {
+class LowDcfListener : public ns3::MacLowDcfListener {
 public:
-  LowNavListener (ns3::DcfManager *dcf)
+  LowDcfListener (ns3::DcfManager *dcf)
     : m_dcf (dcf) {}
-  virtual ~LowNavListener () {}
+  virtual ~LowDcfListener () {}
   virtual void NavStart (Time duration) {
     m_dcf->NotifyNavStartNow (duration);
   }
   virtual void NavReset (Time duration) {
     m_dcf->NotifyNavResetNow (duration);
   }
+  virtual void AckTimeoutStart (Time duration) {
+    m_dcf->NotifyAckTimeoutStartNow (duration);
+  }
+  virtual void AckTimeoutReset () {
+    m_dcf->NotifyAckTimeoutResetNow ();
+  }
+  virtual void CtsTimeoutStart (Time duration) {
+    m_dcf->NotifyCtsTimeoutStartNow (duration);
+  }
+  virtual void CtsTimeoutReset () {
+    m_dcf->NotifyCtsTimeoutResetNow ();
+  }
 private:
   ns3::DcfManager *m_dcf;
 };
@@ -208,7 +220,9 @@
  ****************************************************************/
 
 DcfManager::DcfManager ()
-  : m_lastNavStart (MicroSeconds (0)),
+  : m_lastAckTimeoutEnd (MicroSeconds (0)),
+    m_lastCtsTimeoutEnd (MicroSeconds (0)),
+    m_lastNavStart (MicroSeconds (0)),
     m_lastNavDuration (MicroSeconds (0)),
     m_lastRxStart (MicroSeconds (0)),
     m_lastRxDuration (MicroSeconds (0)),
@@ -242,8 +256,8 @@
 void 
 DcfManager::SetupLowListener (Ptr<MacLow> low)
 {
-  m_lowListener = new LowNavListener (this);
-  low->RegisterNavListener (m_lowListener);
+  m_lowListener = new LowDcfListener (this);
+  low->RegisterDcfListener (m_lowListener);
 }
 
 void 
@@ -289,6 +303,16 @@
   Time retval = Max (e, f);
   return retval;
 }
+Time
+DcfManager::MostRecent (Time a, Time b, Time c, Time d, Time e, Time f) const
+{
+  Time g = Max (a, b);
+  Time h = Max (c, d);
+  Time i = Max (e, f);
+  Time k = Max (g, h);
+  Time retval = Max (k, i);
+  return retval;
+}
 
 bool 
 DcfManager::IsBusy (void) const
@@ -346,7 +370,7 @@
     {
       DcfState *state = *i;
       if (state->IsAccessRequested () && 
-          GetBackoffEndFor (state) <= Simulator::Now ())
+          GetBackoffEndFor (state).GetTimeStep() <= Simulator::Now ().GetTimeStep ())
         {
           /**
            * This is the first dcf we find with an expired backoff and which
@@ -426,7 +450,10 @@
   Time accessGrantedStart = MostRecent (rxAccessStart, 
                                         busyAccessStart,
                                         txAccessStart, 
-                                        navAccessStart);
+                                        navAccessStart,
+                                        m_lastAckTimeoutEnd,
+                                        m_lastCtsTimeoutEnd
+                                        );
   NS_LOG_INFO ("access grant start=" << accessGrantedStart <<
                ", rx access start=" << rxAccessStart <<
                ", busy access start=" << busyAccessStart <<
@@ -486,8 +513,9 @@
       if (state->IsAccessRequested ())
         {
           Time tmp = GetBackoffEndFor (state);
-          if (tmp > Simulator::Now ())
+          if (tmp.GetTimeStep () > Simulator::Now ().GetTimeStep ())
             {
+              //NS_LOG_UNCOND("Now:"<<Simulator::Now ().GetTimeStep ());
               accessTimeoutNeeded = true;
               expectedBackoffEnd = std::min (expectedBackoffEnd, tmp);
             }
@@ -581,5 +609,26 @@
       m_lastNavDuration = duration;
     }
 }
-
+void
+DcfManager::NotifyAckTimeoutStartNow (Time duration)
+{
+  m_lastAckTimeoutEnd = Simulator::Now () + duration;
+}
+void
+DcfManager::NotifyAckTimeoutResetNow ()
+{
+  m_lastAckTimeoutEnd = Simulator::Now ();
+  DoRestartAccessTimeoutIfNeeded ();
+}
+void
+DcfManager::NotifyCtsTimeoutStartNow (Time duration)
+{
+  m_lastCtsTimeoutEnd = Simulator::Now () + duration;
+}
+void
+DcfManager::NotifyCtsTimeoutResetNow ()
+{
+  m_lastCtsTimeoutEnd = Simulator::Now ();
+  DoRestartAccessTimeoutIfNeeded ();
+}
 } // namespace ns3
--- a/src/devices/wifi/dcf-manager.h	Wed Apr 29 19:28:46 2009 +0400
+++ b/src/devices/wifi/dcf-manager.h	Wed Apr 29 19:37:19 2009 +0400
@@ -233,12 +233,17 @@
    * Called at end of rx
    */
   void NotifyNavStartNow (Time duration);
-
+  void NotifyAckTimeoutStartNow (Time duration);
+  void NotifyAckTimeoutResetNow ();
+  void NotifyCtsTimeoutStartNow (Time duration);
+  void NotifyCtsTimeoutResetNow ();
+  void NotifyAckTimeoutEnd (Time duration);
 private:
   void UpdateBackoff (void);
   Time MostRecent (Time a, Time b) const;
   Time MostRecent (Time a, Time b, Time c) const;
   Time MostRecent (Time a, Time b, Time c, Time d) const;
+  Time MostRecent (Time a, Time b, Time c, Time d, Time e, Time f) const;
   /**
    * Access will never be granted to the medium _before_
    * the time returned by this method.
@@ -257,6 +262,8 @@
   typedef std::vector<DcfState *> States;
 
   States m_states;
+  Time m_lastAckTimeoutEnd;
+  Time m_lastCtsTimeoutEnd;
   Time m_lastNavStart;
   Time m_lastNavDuration;
   Time m_lastRxStart;
@@ -274,7 +281,7 @@
   Time m_slotTime;
   Time m_sifs;
   class PhyListener *m_phyListener;
-  class LowNavListener *m_lowListener;
+  class LowDcfListener *m_lowListener;
 };
 
 } // namespace ns3
--- a/src/devices/wifi/mac-low.cc	Wed Apr 29 19:28:46 2009 +0400
+++ b/src/devices/wifi/mac-low.cc	Wed Apr 29 19:37:19 2009 +0400
@@ -110,9 +110,9 @@
 {}
 MacLowTransmissionListener::~MacLowTransmissionListener ()
 {}
-MacLowNavListener::MacLowNavListener ()
+MacLowDcfListener::MacLowDcfListener ()
 {}
-MacLowNavListener::~MacLowNavListener ()
+MacLowDcfListener::~MacLowDcfListener ()
 {}
 
 MacLowTransmissionParameters::MacLowTransmissionParameters ()
@@ -424,9 +424,9 @@
   m_rxCallback = callback;
 }
 void 
-MacLow::RegisterNavListener (MacLowNavListener *listener)
+MacLow::RegisterDcfListener (MacLowDcfListener *listener)
 {
-  m_navListeners.push_back (listener);
+  m_dcfListeners.push_back (listener);
 }
 
 
@@ -544,6 +544,7 @@
       station->ReportRtsOk (rxSnr, txMode, tag.Get ());
       
       m_ctsTimeoutEvent.Cancel ();
+      NotifyCtsTimeoutResetNow ();
       m_listener->GotCts (rxSnr, txMode);
       NS_ASSERT (m_sendDataEvent.IsExpired ());
       m_sendDataEvent = Simulator::Schedule (GetSifs (), 
@@ -570,12 +571,14 @@
           m_normalAckTimeoutEvent.IsRunning ()) 
         {
           m_normalAckTimeoutEvent.Cancel ();
+          NotifyAckTimeoutResetNow ();
           gotAck = true;
         }
       if (m_txParams.MustWaitFastAck () &&
           m_fastAckTimeoutEvent.IsRunning ()) 
         {
           m_fastAckTimeoutEvent.Cancel ();
+          NotifyAckTimeoutResetNow ();
           gotAck = true;
         }
       if (gotAck) 
@@ -797,7 +800,7 @@
 void
 MacLow::DoNavResetNow (Time duration)
 {
-  for (NavListenersCI i = m_navListeners.begin (); i != m_navListeners.end (); i++) 
+  for (DcfListenersCI i = m_dcfListeners.begin (); i != m_dcfListeners.end (); i++) 
     {
       (*i)->NavReset (duration);
     }
@@ -807,7 +810,7 @@
 bool
 MacLow::DoNavStartNow (Time duration)
 {
-  for (NavListenersCI i = m_navListeners.begin (); i != m_navListeners.end (); i++) 
+  for (DcfListenersCI i = m_dcfListeners.begin (); i != m_dcfListeners.end (); i++) 
     {
       (*i)->NavStart (duration);
     }
@@ -821,6 +824,38 @@
     }
   return false;
 }
+void
+MacLow::NotifyAckTimeoutStartNow (Time duration)
+{
+  for (DcfListenersCI i = m_dcfListeners.begin (); i != m_dcfListeners.end (); i++) 
+    {
+      (*i)->AckTimeoutStart (duration);
+    }
+}
+void
+MacLow::NotifyAckTimeoutResetNow ()
+{
+  for (DcfListenersCI i = m_dcfListeners.begin (); i != m_dcfListeners.end (); i++) 
+    {
+      (*i)->AckTimeoutReset ();
+    }
+}
+void
+MacLow::NotifyCtsTimeoutStartNow (Time duration)
+{
+  for (DcfListenersCI i = m_dcfListeners.begin (); i != m_dcfListeners.end (); i++) 
+    {
+      (*i)->CtsTimeoutStart (duration);
+    }
+}
+void
+MacLow::NotifyCtsTimeoutResetNow ()
+{
+  for (DcfListenersCI i = m_dcfListeners.begin (); i != m_dcfListeners.end (); i++) 
+    {
+      (*i)->CtsTimeoutReset ();
+    }
+}
 
 void
 MacLow::ForwardDown (Ptr<const Packet> packet, WifiMacHeader const* hdr, 
@@ -946,6 +981,7 @@
   Time timerDelay = txDuration + GetCtsTimeout ();
 
   NS_ASSERT (m_ctsTimeoutEvent.IsExpired ());
+  NotifyCtsTimeoutStartNow (timerDelay);
   m_ctsTimeoutEvent = Simulator::Schedule (timerDelay, &MacLow::CtsTimeout, this);
 
   Ptr<Packet> packet = Create<Packet> ();
@@ -965,18 +1001,21 @@
     {
       Time timerDelay = txDuration + GetAckTimeout ();
       NS_ASSERT (m_normalAckTimeoutEvent.IsExpired ());
+      NotifyAckTimeoutStartNow (timerDelay);
       m_normalAckTimeoutEvent = Simulator::Schedule (timerDelay, &MacLow::NormalAckTimeout, this);
     } 
   else if (m_txParams.MustWaitFastAck ()) 
     {
       Time timerDelay = txDuration + GetPifs ();
       NS_ASSERT (m_fastAckTimeoutEvent.IsExpired ());
+      NotifyAckTimeoutStartNow (timerDelay);
       m_fastAckTimeoutEvent = Simulator::Schedule (timerDelay, &MacLow::FastAckTimeout, this);
     } 
   else if (m_txParams.MustWaitSuperFastAck ()) 
     {
       Time timerDelay = txDuration + GetPifs ();
       NS_ASSERT (m_superFastAckTimeoutEvent.IsExpired ());
+      NotifyAckTimeoutStartNow (timerDelay);
       m_superFastAckTimeoutEvent = Simulator::Schedule (timerDelay, 
                                                         &MacLow::SuperFastAckTimeout, this);
     } 
--- a/src/devices/wifi/mac-low.h	Wed Apr 29 19:28:46 2009 +0400
+++ b/src/devices/wifi/mac-low.h	Wed Apr 29 19:37:19 2009 +0400
@@ -100,10 +100,10 @@
  * and calls to its methods are forwards to the corresponding
  * ns3::Dcf methods.
  */
-class MacLowNavListener {
+class MacLowDcfListener {
 public:
-  MacLowNavListener ();
-  virtual ~MacLowNavListener ();
+  MacLowDcfListener ();
+  virtual ~MacLowDcfListener ();
   /**
    * \param duration duration of NAV timer
    */
@@ -112,6 +112,10 @@
    * \param duration duration of NAV timer
    */
   virtual void NavReset (Time duration) = 0;
+  virtual void AckTimeoutStart (Time duration) = 0;
+  virtual void AckTimeoutReset () = 0;
+  virtual void CtsTimeoutStart (Time duration) = 0;
+  virtual void CtsTimeoutReset () = 0;
 };
 
 /**
@@ -306,7 +310,7 @@
    * \param listener listen to NAV events for every incoming
    *        and outgoing packet.
    */
-  void RegisterNavListener (MacLowNavListener *listener);
+  void RegisterDcfListener (MacLowDcfListener *listener);
 
   /**
    * \param packet to send (does not include the 802.11 MAC header and checksum)
@@ -375,6 +379,10 @@
   void DoNavResetNow (Time duration);
   bool DoNavStartNow (Time duration);
   bool IsNavZero (void) const;
+  void NotifyAckTimeoutStartNow (Time duration);
+  void NotifyAckTimeoutResetNow ();
+  void NotifyCtsTimeoutStartNow (Time duration);
+  void NotifyCtsTimeoutResetNow ();
   void MaybeCancelPrevious (void);
   
   void NavCounterResetCtsMissed (Time rtsEndRxTime);
@@ -397,9 +405,9 @@
   Ptr<WifiPhy> m_phy;
   Ptr<WifiRemoteStationManager> m_stationManager;
   MacLowRxCallback m_rxCallback;
-  typedef std::vector<MacLowNavListener *>::const_iterator NavListenersCI;
-  typedef std::vector<MacLowNavListener *> NavListeners;
-  NavListeners m_navListeners;
+  typedef std::vector<MacLowDcfListener *>::const_iterator DcfListenersCI;
+  typedef std::vector<MacLowDcfListener *> DcfListeners;
+  DcfListeners m_dcfListeners;
 
   EventId m_normalAckTimeoutEvent;
   EventId m_fastAckTimeoutEvent;