diff -r 2c4e9171497e src/devices/wifi/dcf-manager.cc --- a/src/devices/wifi/dcf-manager.cc Sat Feb 27 12:26:36 2010 +0300 +++ b/src/devices/wifi/dcf-manager.cc Sat Feb 27 17:14:13 2010 +0300 @@ -228,20 +228,20 @@ ****************************************************************/ DcfManager::DcfManager () - : m_lastAckTimeoutEnd (MicroSeconds (0)), - m_lastCtsTimeoutEnd (MicroSeconds (0)), - m_lastNavStart (MicroSeconds (0)), - m_lastNavDuration (MicroSeconds (0)), - m_lastRxStart (MicroSeconds (0)), - m_lastRxDuration (MicroSeconds (0)), + : m_lastAckTimeoutEnd (0), + m_lastCtsTimeoutEnd (0), + m_lastNavStart (0), + m_lastNavDuration (0), + m_lastRxStart (0), + m_lastRxDuration (0), m_lastRxReceivedOk (true), - m_lastRxEnd (MicroSeconds (0)), - m_lastTxStart (MicroSeconds (0)), - m_lastTxDuration (MicroSeconds (0)), - m_lastBusyStart (MicroSeconds (0)), - m_lastBusyDuration (MicroSeconds (0)), - m_lastSwitchingStart (MicroSeconds (0)), - m_lastSwitchingDuration (MicroSeconds (0)), + m_lastRxEnd (0), + m_lastTxStart (0), + m_lastTxDuration (0), + m_lastBusyStart (0), + m_lastBusyDuration (0), + m_lastSwitchingStart (0), + m_lastSwitchingDuration (0), m_rxing (false), m_slotTimeUs (0), m_sifs (Seconds (0.0)), @@ -340,23 +340,34 @@ Time retval = Max (k, l); return retval; } +uint64_t +DcfManager::Maximum (uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f, uint64_t g) const +{ + uint64_t h = a > b ? a : b; + uint64_t i = c > d ? c: d; + uint64_t j = e > f ? e : f; + uint64_t k = h > i ? h : i; + uint64_t l = j > g ? j : g; + return (k > l ? k : l); +} bool DcfManager::IsBusy (void) const { // PHY busy + uint64_t now = Simulator::Now ().GetNanoSeconds (); if (m_rxing) { return true; } - Time lastTxEnd = m_lastTxStart + m_lastTxDuration; - if (lastTxEnd > Simulator::Now ()) + uint64_t lastTxEnd = m_lastTxStart + m_lastTxDuration; + if (lastTxEnd > now) { return true; } // NAV busy - Time lastNavEnd = m_lastNavStart + m_lastNavDuration; - if (lastNavEnd > Simulator::Now ()) + uint64_t lastNavEnd = m_lastNavStart + m_lastNavDuration; + if (lastNavEnd > now) { return true; } @@ -454,39 +465,40 @@ Time DcfManager::GetAccessGrantStart (void) const { - Time rxAccessStart; + uint64_t rxAccessStart; + uint64_t sifsNanoSeconds = m_sifs.GetNanoSeconds (); if (!m_rxing) { - rxAccessStart = m_lastRxEnd + m_sifs; + rxAccessStart = m_lastRxEnd + sifsNanoSeconds; if (!m_lastRxReceivedOk) { - rxAccessStart += m_eifsNoDifs; + rxAccessStart += m_eifsNoDifs.GetNanoSeconds (); } } else { - rxAccessStart = m_lastRxStart + m_lastRxDuration + m_sifs; + rxAccessStart = m_lastRxStart + m_lastRxDuration + m_sifs.GetNanoSeconds (); } - Time busyAccessStart = m_lastBusyStart + m_lastBusyDuration + m_sifs; - Time txAccessStart = m_lastTxStart + m_lastTxDuration + m_sifs; - Time navAccessStart = m_lastNavStart + m_lastNavDuration + m_sifs; - Time ackTimeoutAccessStart = m_lastAckTimeoutEnd + m_sifs; - Time ctsTimeoutAccessStart = m_lastCtsTimeoutEnd + m_sifs; - Time switchingAccessStart = m_lastSwitchingStart + m_lastSwitchingDuration + m_sifs; - Time accessGrantedStart = MostRecent (rxAccessStart, - busyAccessStart, - txAccessStart, - navAccessStart, - ackTimeoutAccessStart, - ctsTimeoutAccessStart, - switchingAccessStart - ); + uint64_t busyAccessStart = m_lastBusyStart + m_lastBusyDuration + sifsNanoSeconds; + uint64_t txAccessStart = m_lastTxStart + m_lastTxDuration + sifsNanoSeconds; + uint64_t navAccessStart = m_lastNavStart + m_lastNavDuration + sifsNanoSeconds; + uint64_t ackTimeoutAccessStart = m_lastAckTimeoutEnd + sifsNanoSeconds; + uint64_t ctsTimeoutAccessStart = m_lastCtsTimeoutEnd + sifsNanoSeconds; + uint64_t switchingAccessStart = m_lastSwitchingStart + m_lastSwitchingDuration + sifsNanoSeconds; + uint64_t accessGrantedStart = Maximum (rxAccessStart, + busyAccessStart, + txAccessStart, + navAccessStart, + ackTimeoutAccessStart, + ctsTimeoutAccessStart, + switchingAccessStart + ); NS_LOG_INFO ("access grant start=" << accessGrantedStart << ", rx access start=" << rxAccessStart << ", busy access start=" << busyAccessStart << ", tx access start=" << txAccessStart << ", nav access start=" << navAccessStart); - return accessGrantedStart; + return NanoSeconds (accessGrantedStart); } Time @@ -569,15 +581,15 @@ { MY_DEBUG ("rx start for="<GetBackoffSlots (); if (remainingSlots > 0) { - state->UpdateBackoffSlotsNow (remainingSlots, now); + state->UpdateBackoffSlotsNow (remainingSlots, NanoSeconds(now)); NS_ASSERT(state->GetBackoffSlots()==0); } state->ResetCw(); @@ -672,8 +684,8 @@ } MY_DEBUG ("switching start for "<