diff --git a/src/devices/wifi/dcf-manager.cc b/src/devices/wifi/dcf-manager.cc index ab85889db..e09c7f2f1 100644 --- a/src/devices/wifi/dcf-manager.cc +++ b/src/devices/wifi/dcf-manager.cc @@ -243,7 +243,7 @@ DcfManager::DcfManager () 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 @@ DcfManager::SetupLowListener (Ptr low) void DcfManager::SetSlot (Time slotTime) { - m_slotTime = slotTime; + m_slotTimeUs = slotTime.GetMicroSeconds (); } void DcfManager::SetSifs (Time sifs) @@ -493,7 +493,7 @@ Time DcfManager::GetBackoffStartFor (DcfState *state) { Time mostRecentEvent = MostRecent (state->GetBackoffStart (), - GetAccessGrantStart () + Scalar (state->GetAifsn ()) * m_slotTime); + GetAccessGrantStart () + MicroSeconds (state->GetAifsn () * m_slotTimeUs)); return mostRecentEvent; } @@ -501,7 +501,7 @@ DcfManager::GetBackoffStartFor (DcfState *state) Time DcfManager::GetBackoffEndFor (DcfState *state) { - return GetBackoffStartFor (state) + Scalar (state->GetBackoffSlots ()) * m_slotTime; + return GetBackoffStartFor (state) + MicroSeconds (state->GetBackoffSlots () * m_slotTimeUs); } void @@ -515,11 +515,11 @@ DcfManager::UpdateBackoff (void) 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 --git a/src/devices/wifi/dcf-manager.h b/src/devices/wifi/dcf-manager.h index dcd2393f9..f6b07cb8d 100644 --- a/src/devices/wifi/dcf-manager.h +++ b/src/devices/wifi/dcf-manager.h @@ -323,7 +323,7 @@ private: 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;