From dc8e78e8f734c068ca9b3ead60f6d5e3fbb3cdda Mon Sep 17 00:00:00 2001 From: Tom Henderson Date: Tue, 27 Sep 2016 10:57:11 -0700 Subject: [PATCH] wifi: (partial fix for #2477) Avoid assert when transmit cancels a reception It is possible for the DCF to be out of sync with the state of the PHY and to try to transmit a Block Ack when the PHY is receiving. This may occur in certain A-MPDU situations. The assert can be safely removed; it is for further study whether the scheduled block ack event should be cancelled to avoid the situation from arising. --- src/wifi/model/dcf-manager.cc | 28 +++++++++++++++++++++------- 1 file changed, 21 insertions(+), 7 deletions(-) diff --git a/src/wifi/model/dcf-manager.cc b/src/wifi/model/dcf-manager.cc index f1ace9335..2b08323dc 100644 --- a/src/wifi/model/dcf-manager.cc +++ b/src/wifi/model/dcf-manager.cc @@ -808,13 +808,27 @@ DcfManager::NotifyTxStartNow (Time duration) NS_LOG_FUNCTION (this << duration); if (m_rxing) { - //this may be caused only if PHY has started to receive a packet - //inside SIFS, so, we check that lastRxStart was maximum a SIFS ago - NS_ASSERT (Simulator::Now () - m_lastRxStart <= m_sifs); - m_lastRxEnd = Simulator::Now (); - m_lastRxDuration = m_lastRxEnd - m_lastRxStart; - m_lastRxReceivedOk = true; - m_rxing = false; + if (Simulator::Now () - m_lastRxStart <= m_sifs) + { + //this may be caused if PHY has started to receive a packet + //inside SIFS, so, we check that lastRxStart was within a SIFS ago + m_lastRxEnd = Simulator::Now (); + m_lastRxDuration = m_lastRxEnd - m_lastRxStart; + m_lastRxReceivedOk = true; + m_rxing = false; + } + else + { + // Bug 2477: It is possible for the DCF to fall out of + // sync with the PHY state if there are problems + // receiving A-MPDUs. PHY will cancel the reception + // and start to transmit + NS_LOG_DEBUG ("Phy is transmitting despite DCF being in receive state"); + m_lastRxEnd = Simulator::Now (); + m_lastRxDuration = m_lastRxEnd - m_lastRxStart; + m_lastRxReceivedOk = false; + m_rxing = false; + } } MY_DEBUG ("tx start for " << duration); UpdateBackoff ();