src/devices/wifi/dcf-manager.cc
changeset 2122 ee136bc4f214
parent 2120 9714777a8080
child 2127 2707cb71f6dc
--- a/src/devices/wifi/dcf-manager.cc	Thu Nov 15 13:44:58 2007 +0100
+++ b/src/devices/wifi/dcf-manager.cc	Thu Nov 15 14:21:48 2007 +0100
@@ -55,10 +55,11 @@
   m_cw = cw;
 }
 void 
-DcfState::UpdateBackoffSlotsNow (uint32_t nSlots)
+DcfState::UpdateBackoffSlotsNow (uint32_t nSlots, Time backoffUpdateBound)
 {
   uint32_t n = std::min (nSlots, m_backoffSlots);
   m_backoffSlots -= n;
+  m_backoffStart = backoffUpdateBound;
 }
 
 void 
@@ -319,7 +320,7 @@
       if (backoffStart <= Simulator::Now ())
         {
           Scalar nSlots = (Simulator::Now () - backoffStart) / m_slotTime;
-          uint32_t nIntSlots = lrint (nSlots.GetDouble ());
+          uint32_t nIntSlots = lrint (nSlots.GetDouble ());          
           /**
            * For each DcfState, calculate how many backoff slots elapsed since
            * the last time its backoff counter was updated. If the number of 
@@ -329,7 +330,8 @@
           if (nIntSlots > state->GetAifsn ())
             {
               MY_DEBUG ("dcf " << k << " dec backoff slots=" << nIntSlots);
-              state->UpdateBackoffSlotsNow (nIntSlots);
+              Time backoffUpdateBound = backoffStart + Scalar (nIntSlots) * m_slotTime;
+              state->UpdateBackoffSlotsNow (nIntSlots, backoffUpdateBound);
             }
         }
     }