diff -r 99428bcb9b98 src/devices/wifi/dcf-manager.cc --- ./src/devices/wifi/dcf-manager.cc Wed Apr 29 13:06:55 2009 +0400 +++ ./src/devices/wifi/dcf-manager.cc Wed Apr 29 14:02:02 2009 +0400 @@ -160,16 +160,28 @@ * Listener for Nav events. Forwards to DcfManager ***************************************************************/ -class LowNavListener : public ns3::MacLowNavListener { +class LowDcfListener : public ns3::MacLowDcfListener { public: - LowNavListener (ns3::DcfManager *dcf) + LowDcfListener (ns3::DcfManager *dcf) : m_dcf (dcf) {} - virtual ~LowNavListener () {} + virtual ~LowDcfListener () {} virtual void NavStart (Time duration) { m_dcf->NotifyNavStartNow (duration); } virtual void NavReset (Time duration) { m_dcf->NotifyNavResetNow (duration); + } + virtual void AckTimeoutStart (Time duration) { + m_dcf->NotifyAckTimeoutStartNow (duration); + } + virtual void AckTimeoutReset () { + m_dcf->NotifyAckTimeoutResetNow (); + } + virtual void CtsTimeoutStart (Time duration) { + m_dcf->NotifyCtsTimeoutStartNow (duration); + } + virtual void CtsTimeoutReset () { + m_dcf->NotifyCtsTimeoutResetNow (); } private: ns3::DcfManager *m_dcf; @@ -208,7 +220,9 @@ ****************************************************************/ DcfManager::DcfManager () - : m_lastNavStart (MicroSeconds (0)), + : m_lastAckTimeoutEnd (MicroSeconds (0)), + m_lastCtsTimeoutEnd (MicroSeconds (0)), + m_lastNavStart (MicroSeconds (0)), m_lastNavDuration (MicroSeconds (0)), m_lastRxStart (MicroSeconds (0)), m_lastRxDuration (MicroSeconds (0)), @@ -242,8 +256,8 @@ void DcfManager::SetupLowListener (Ptr low) { - m_lowListener = new LowNavListener (this); - low->RegisterNavListener (m_lowListener); + m_lowListener = new LowDcfListener (this); + low->RegisterDcfListener (m_lowListener); } void @@ -289,6 +303,16 @@ Time retval = Max (e, f); return retval; } +Time +DcfManager::MostRecent (Time a, Time b, Time c, Time d, Time e, Time f) const +{ + Time g = Max (a, b); + Time h = Max (c, d); + Time i = Max (e, f); + Time k = Max (g, h); + Time retval = Max (k, i); + return retval; +} bool DcfManager::IsBusy (void) const @@ -346,7 +370,7 @@ { DcfState *state = *i; if (state->IsAccessRequested () && - GetBackoffEndFor (state) <= Simulator::Now ()) + GetBackoffEndFor (state).GetTimeStep() <= Simulator::Now ().GetTimeStep ()) { /** * This is the first dcf we find with an expired backoff and which @@ -426,7 +450,10 @@ Time accessGrantedStart = MostRecent (rxAccessStart, busyAccessStart, txAccessStart, - navAccessStart); + navAccessStart, + m_lastAckTimeoutEnd, + m_lastCtsTimeoutEnd + ); NS_LOG_INFO ("access grant start=" << accessGrantedStart << ", rx access start=" << rxAccessStart << ", busy access start=" << busyAccessStart << @@ -486,8 +513,9 @@ if (state->IsAccessRequested ()) { Time tmp = GetBackoffEndFor (state); - if (tmp > Simulator::Now ()) + if (tmp.GetTimeStep () > Simulator::Now ().GetTimeStep ()) { + //NS_LOG_UNCOND("Now:"< States; States m_states; + Time m_lastAckTimeoutEnd; + Time m_lastCtsTimeoutEnd; Time m_lastNavStart; Time m_lastNavDuration; Time m_lastRxStart; @@ -274,7 +281,7 @@ Time m_slotTime; Time m_sifs; class PhyListener *m_phyListener; - class LowNavListener *m_lowListener; + class LowDcfListener *m_lowListener; }; } // namespace ns3 diff -r 99428bcb9b98 src/devices/wifi/mac-low.cc --- ./src/devices/wifi/mac-low.cc Wed Apr 29 13:06:55 2009 +0400 +++ ./src/devices/wifi/mac-low.cc Wed Apr 29 14:02:02 2009 +0400 @@ -110,9 +110,9 @@ {} MacLowTransmissionListener::~MacLowTransmissionListener () {} -MacLowNavListener::MacLowNavListener () +MacLowDcfListener::MacLowDcfListener () {} -MacLowNavListener::~MacLowNavListener () +MacLowDcfListener::~MacLowDcfListener () {} MacLowTransmissionParameters::MacLowTransmissionParameters () @@ -424,9 +423,9 @@ m_rxCallback = callback; } void -MacLow::RegisterNavListener (MacLowNavListener *listener) +MacLow::RegisterDcfListener (MacLowDcfListener *listener) { - m_navListeners.push_back (listener); + m_dcfListeners.push_back (listener); } @@ -544,6 +543,7 @@ station->ReportRtsOk (rxSnr, txMode, tag.Get ()); m_ctsTimeoutEvent.Cancel (); + NotifyCtsTimeoutResetNow (); m_listener->GotCts (rxSnr, txMode); NS_ASSERT (m_sendDataEvent.IsExpired ()); m_sendDataEvent = Simulator::Schedule (GetSifs (), @@ -570,12 +570,14 @@ m_normalAckTimeoutEvent.IsRunning ()) { m_normalAckTimeoutEvent.Cancel (); + NotifyAckTimeoutResetNow (); gotAck = true; } if (m_txParams.MustWaitFastAck () && m_fastAckTimeoutEvent.IsRunning ()) { m_fastAckTimeoutEvent.Cancel (); + NotifyAckTimeoutResetNow (); gotAck = true; } if (gotAck) @@ -797,7 +799,7 @@ void MacLow::DoNavResetNow (Time duration) { - for (NavListenersCI i = m_navListeners.begin (); i != m_navListeners.end (); i++) + for (DcfListenersCI i = m_dcfListeners.begin (); i != m_dcfListeners.end (); i++) { (*i)->NavReset (duration); } @@ -807,7 +809,7 @@ bool MacLow::DoNavStartNow (Time duration) { - for (NavListenersCI i = m_navListeners.begin (); i != m_navListeners.end (); i++) + for (DcfListenersCI i = m_dcfListeners.begin (); i != m_dcfListeners.end (); i++) { (*i)->NavStart (duration); } @@ -820,6 +822,38 @@ return true; } return false; +} +void +MacLow::NotifyAckTimeoutStartNow (Time duration) +{ + for (DcfListenersCI i = m_dcfListeners.begin (); i != m_dcfListeners.end (); i++) + { + (*i)->AckTimeoutStart (duration); + } +} +void +MacLow::NotifyAckTimeoutResetNow () +{ + for (DcfListenersCI i = m_dcfListeners.begin (); i != m_dcfListeners.end (); i++) + { + (*i)->AckTimeoutReset (); + } +} +void +MacLow::NotifyCtsTimeoutStartNow (Time duration) +{ + for (DcfListenersCI i = m_dcfListeners.begin (); i != m_dcfListeners.end (); i++) + { + (*i)->CtsTimeoutStart (duration); + } +} +void +MacLow::NotifyCtsTimeoutResetNow () +{ + for (DcfListenersCI i = m_dcfListeners.begin (); i != m_dcfListeners.end (); i++) + { + (*i)->CtsTimeoutReset (); + } } void @@ -946,6 +980,7 @@ Time timerDelay = txDuration + GetCtsTimeout (); NS_ASSERT (m_ctsTimeoutEvent.IsExpired ()); + NotifyCtsTimeoutStartNow (timerDelay); m_ctsTimeoutEvent = Simulator::Schedule (timerDelay, &MacLow::CtsTimeout, this); Ptr packet = Create (); @@ -965,18 +1000,21 @@ { Time timerDelay = txDuration + GetAckTimeout (); NS_ASSERT (m_normalAckTimeoutEvent.IsExpired ()); + NotifyAckTimeoutStartNow (timerDelay); m_normalAckTimeoutEvent = Simulator::Schedule (timerDelay, &MacLow::NormalAckTimeout, this); } else if (m_txParams.MustWaitFastAck ()) { Time timerDelay = txDuration + GetPifs (); NS_ASSERT (m_fastAckTimeoutEvent.IsExpired ()); + NotifyAckTimeoutStartNow (timerDelay); m_fastAckTimeoutEvent = Simulator::Schedule (timerDelay, &MacLow::FastAckTimeout, this); } else if (m_txParams.MustWaitSuperFastAck ()) { Time timerDelay = txDuration + GetPifs (); NS_ASSERT (m_superFastAckTimeoutEvent.IsExpired ()); + NotifyAckTimeoutStartNow (timerDelay); m_superFastAckTimeoutEvent = Simulator::Schedule (timerDelay, &MacLow::SuperFastAckTimeout, this); } diff -r 99428bcb9b98 src/devices/wifi/mac-low.h --- ./src/devices/wifi/mac-low.h Wed Apr 29 13:06:55 2009 +0400 +++ ./src/devices/wifi/mac-low.h Wed Apr 29 14:02:02 2009 +0400 @@ -100,10 +100,10 @@ * and calls to its methods are forwards to the corresponding * ns3::Dcf methods. */ -class MacLowNavListener { +class MacLowDcfListener { public: - MacLowNavListener (); - virtual ~MacLowNavListener (); + MacLowDcfListener (); + virtual ~MacLowDcfListener (); /** * \param duration duration of NAV timer */ @@ -112,6 +112,10 @@ * \param duration duration of NAV timer */ virtual void NavReset (Time duration) = 0; + virtual void AckTimeoutStart (Time duration) = 0; + virtual void AckTimeoutReset () = 0; + virtual void CtsTimeoutStart (Time duration) = 0; + virtual void CtsTimeoutReset () = 0; }; /** @@ -306,7 +310,7 @@ * \param listener listen to NAV events for every incoming * and outgoing packet. */ - void RegisterNavListener (MacLowNavListener *listener); + void RegisterDcfListener (MacLowDcfListener *listener); /** * \param packet to send (does not include the 802.11 MAC header and checksum) @@ -375,6 +379,10 @@ void DoNavResetNow (Time duration); bool DoNavStartNow (Time duration); bool IsNavZero (void) const; + void NotifyAckTimeoutStartNow (Time duration); + void NotifyAckTimeoutResetNow (); + void NotifyCtsTimeoutStartNow (Time duration); + void NotifyCtsTimeoutResetNow (); void MaybeCancelPrevious (void); void NavCounterResetCtsMissed (Time rtsEndRxTime); @@ -397,9 +405,9 @@ Ptr m_phy; Ptr m_stationManager; MacLowRxCallback m_rxCallback; - typedef std::vector::const_iterator NavListenersCI; - typedef std::vector NavListeners; - NavListeners m_navListeners; + typedef std::vector::const_iterator DcfListenersCI; + typedef std::vector DcfListeners; + DcfListeners m_dcfListeners; EventId m_normalAckTimeoutEvent; EventId m_fastAckTimeoutEvent;