diff -r bb1eea10412f src/devices/wifi/dcf-manager.cc --- a/src/devices/wifi/dcf-manager.cc Tue Nov 24 10:45:08 2009 +0100 +++ b/src/devices/wifi/dcf-manager.cc Tue Nov 24 12:26:02 2009 +0100 @@ -243,7 +243,7 @@ m_lastSwitchingStart (MicroSeconds (0)), m_lastSwitchingDuration (MicroSeconds (0)), m_rxing (false), - m_slotTime (Seconds (0.0)), + m_slotTimeUs (0), m_sifs (Seconds (0.0)), m_phyListener (0), m_lowListener (0) @@ -273,7 +273,7 @@ void DcfManager::SetSlot (Time slotTime) { - m_slotTime = slotTime; + m_slotTimeUs = slotTime.GetMicroSeconds (); } void DcfManager::SetSifs (Time sifs) @@ -497,7 +497,7 @@ DcfManager::GetBackoffStartFor (DcfState *state) { Time mostRecentEvent = MostRecent (state->GetBackoffStart (), - GetAccessGrantStart () + Scalar (state->GetAifsn ()) * m_slotTime); + GetAccessGrantStart () + MicroSeconds (state->GetAifsn () * m_slotTimeUs)); return mostRecentEvent; } @@ -505,7 +505,7 @@ Time DcfManager::GetBackoffEndFor (DcfState *state) { - return GetBackoffStartFor (state) + Scalar (state->GetBackoffSlots ()) * m_slotTime; + return GetBackoffStartFor (state) + MicroSeconds (state->GetBackoffSlots () * m_slotTimeUs); } void @@ -519,11 +519,11 @@ Time backoffStart = GetBackoffStartFor (state); if (backoffStart <= Simulator::Now ()) { - Scalar nSlots = (Simulator::Now () - backoffStart) / m_slotTime; - uint32_t nIntSlots = lrint (nSlots.GetDouble ()); + uint32_t nus = (Simulator::Now () - backoffStart).GetMicroSeconds (); + uint32_t nIntSlots = nus / m_slotTimeUs; uint32_t n = std::min (nIntSlots, state->GetBackoffSlots ()); MY_DEBUG ("dcf " << k << " dec backoff slots=" << n); - Time backoffUpdateBound = backoffStart + Scalar (n) * m_slotTime; + Time backoffUpdateBound = backoffStart + MicroSeconds (n * m_slotTimeUs); state->UpdateBackoffSlotsNow (n, backoffUpdateBound); } } diff -r bb1eea10412f src/devices/wifi/dcf-manager.h --- a/src/devices/wifi/dcf-manager.h Tue Nov 24 10:45:08 2009 +0100 +++ b/src/devices/wifi/dcf-manager.h Tue Nov 24 12:26:02 2009 +0100 @@ -323,7 +323,7 @@ bool m_sleeping; Time m_eifsNoDifs; EventId m_accessTimeout; - Time m_slotTime; + uint32_t m_slotTimeUs; Time m_sifs; class PhyListener *m_phyListener; class LowDcfListener *m_lowListener;