From 18e5bf9c075982b504ab40b647e90ea29c638524 Mon Sep 17 00:00:00 2001 From: Mathieu Lacage Date: Thu, 15 Nov 2007 14:21:48 +0100 Subject: [PATCH] keep track of the last time a backoff was updated. --- src/devices/wifi/dcf-manager.cc | 8 +++++--- src/devices/wifi/dcf-manager.h | 2 +- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/devices/wifi/dcf-manager.cc b/src/devices/wifi/dcf-manager.cc index 65b1c78be..17455f40a 100644 --- a/src/devices/wifi/dcf-manager.cc +++ b/src/devices/wifi/dcf-manager.cc @@ -55,10 +55,11 @@ DcfState::UpdateFailedCw (void) 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 @@ DcfManager::UpdateBackoff (void) 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 @@ DcfManager::UpdateBackoff (void) 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); } } } diff --git a/src/devices/wifi/dcf-manager.h b/src/devices/wifi/dcf-manager.h index 1c70519eb..39e9089ea 100644 --- a/src/devices/wifi/dcf-manager.h +++ b/src/devices/wifi/dcf-manager.h @@ -29,7 +29,7 @@ private: uint32_t GetBackoffSlots (void) const; Time GetBackoffStart (void) const; - void UpdateBackoffSlotsNow (uint32_t nSlots); + void UpdateBackoffSlotsNow (uint32_t nSlots, Time backoffUpdateBound); virtual bool NeedsAccess (void) const = 0; virtual void NotifyAccessGranted (void) = 0;