From 2daa6519231ce58c9c49dbe3a1b5f9db75553efc Mon Sep 17 00:00:00 2001 From: Kirill Andreev Date: Wed, 29 Apr 2009 19:37:19 +0400 Subject: [PATCH] Ack timeout patch was merged. HWMP: DO=1 by default, if packet is unresolved - we queue it --- src/devices/mesh/dot11s/hwmp-protocol.cc | 6 +-- src/devices/wifi/dcf-manager.cc | 69 ++++++++++++++++++++---- src/devices/wifi/dcf-manager.h | 11 +++- src/devices/wifi/mac-low.cc | 51 +++++++++++++++--- src/devices/wifi/mac-low.h | 22 +++++--- 5 files changed, 130 insertions(+), 29 deletions(-) diff --git a/src/devices/mesh/dot11s/hwmp-protocol.cc b/src/devices/mesh/dot11s/hwmp-protocol.cc index 9d189a9bc..b69c573ff 100644 --- a/src/devices/mesh/dot11s/hwmp-protocol.cc +++ b/src/devices/mesh/dot11s/hwmp-protocol.cc @@ -132,13 +132,13 @@ HwmpProtocol::GetTypeId () ) .AddAttribute ("doFlag", "Destination only HWMP flag", - BooleanValue (false), + BooleanValue (true), MakeUintegerAccessor (&HwmpProtocol::m_doFlag), MakeUintegerChecker () ) .AddAttribute ("rfFlag", "Reply and forward flag", - BooleanValue (false), + BooleanValue (true), MakeUintegerAccessor (&HwmpProtocol::m_rfFlag), MakeUintegerChecker () ); @@ -286,8 +286,6 @@ HwmpProtocol::ForwardUnicast(uint32_t sourceIface, const Mac48Address source, c // root if(result.retransmitter == Mac48Address::GetBroadcast ()) result = m_rtable->LookupProactiveExpired (); - if(result.retransmitter == Mac48Address::GetBroadcast ()) - return false; std::vector destinations = m_rtable->GetUnreachableDestinations (result.retransmitter); MakePathError (destinations); } diff --git a/src/devices/wifi/dcf-manager.cc b/src/devices/wifi/dcf-manager.cc index 6dd69b31f..a7c436491 100644 --- a/src/devices/wifi/dcf-manager.cc +++ b/src/devices/wifi/dcf-manager.cc @@ -160,17 +160,29 @@ DcfState::NotifyInternalCollision (void) * 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 @@ private: ****************************************************************/ 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 @@ DcfManager::SetupPhyListener (Ptr phy) 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 @@ DcfManager::MostRecent (Time a, Time b, Time c, Time d) const 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 @@ DcfManager::DoGrantAccess (void) { 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 @@ DcfManager::GetAccessGrantStart (void) const 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 @@ DcfManager::DoRestartAccessTimeoutIfNeeded (void) 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 @@ private: Time m_slotTime; Time m_sifs; class PhyListener *m_phyListener; - class LowNavListener *m_lowListener; + class LowDcfListener *m_lowListener; }; } // namespace ns3 diff --git a/src/devices/wifi/mac-low.cc b/src/devices/wifi/mac-low.cc index f98124adb..c25958794 100644 --- a/src/devices/wifi/mac-low.cc +++ b/src/devices/wifi/mac-low.cc @@ -110,9 +110,9 @@ MacLowTransmissionListener::MacLowTransmissionListener () {} MacLowTransmissionListener::~MacLowTransmissionListener () {} -MacLowNavListener::MacLowNavListener () +MacLowDcfListener::MacLowDcfListener () {} -MacLowNavListener::~MacLowNavListener () +MacLowDcfListener::~MacLowDcfListener () {} MacLowTransmissionParameters::MacLowTransmissionParameters () @@ -424,9 +424,9 @@ MacLow::SetRxCallback (Callback,const WifiMacHeader *> callback m_rxCallback = callback; } void -MacLow::RegisterNavListener (MacLowNavListener *listener) +MacLow::RegisterDcfListener (MacLowDcfListener *listener) { - m_navListeners.push_back (listener); + m_dcfListeners.push_back (listener); } @@ -544,6 +544,7 @@ MacLow::ReceiveOk (Ptr packet, double rxSnr, WifiMode txMode, WifiPreamb 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 +571,14 @@ MacLow::ReceiveOk (Ptr packet, double rxSnr, WifiMode txMode, WifiPreamb 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 +800,7 @@ MacLow::NavCounterResetCtsMissed (Time rtsEndRxTime) 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 +810,7 @@ MacLow::DoNavResetNow (Time duration) 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); } @@ -821,6 +824,38 @@ MacLow::DoNavStartNow (Time duration) } 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 MacLow::ForwardDown (Ptr packet, WifiMacHeader const* hdr, @@ -946,6 +981,7 @@ MacLow::SendRtsForPacket (void) Time timerDelay = txDuration + GetCtsTimeout (); NS_ASSERT (m_ctsTimeoutEvent.IsExpired ()); + NotifyCtsTimeoutStartNow (timerDelay); m_ctsTimeoutEvent = Simulator::Schedule (timerDelay, &MacLow::CtsTimeout, this); Ptr packet = Create (); @@ -965,18 +1001,21 @@ MacLow::StartDataTxTimers (void) { 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 --git a/src/devices/wifi/mac-low.h b/src/devices/wifi/mac-low.h index b3925f57f..7f1bca086 100644 --- a/src/devices/wifi/mac-low.h +++ b/src/devices/wifi/mac-low.h @@ -100,10 +100,10 @@ public: * 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 @@ public: * \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 @@ public: * \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 @@ private: 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 @@ private: 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;