From 39800ef31d524affc19c0fda2224b6a89ad11d78 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Deronne?= Date: Tue, 24 Mar 2020 09:31:28 +0100 Subject: [PATCH] wifi: Reset PHY internals at the end of the detected packet if PHY header reception failed --- src/wifi/model/wifi-phy.cc | 17 +++++++++++++---- src/wifi/model/wifi-phy.h | 7 +++++++ 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/src/wifi/model/wifi-phy.cc b/src/wifi/model/wifi-phy.cc index 22ac4bea3..576a68674 100644 --- a/src/wifi/model/wifi-phy.cc +++ b/src/wifi/model/wifi-phy.cc @@ -2852,6 +2852,7 @@ WifiPhy::StartReceivePayload (Ptr event) //If we are here, this means non-HT PHY header was already successfully received canReceivePayload = true; } + Time payloadDuration = event->GetEndTime () - event->GetStartTime () - CalculatePhyPreambleAndHeaderDuration (txVector); if (canReceivePayload) //PHY reception succeeded { if (txVector.GetNss () > GetMaxSupportedRxSpatialStreams ()) @@ -2871,7 +2872,6 @@ WifiPhy::StartReceivePayload (Ptr event) } else { - Time payloadDuration = event->GetEndTime () - event->GetStartTime () - CalculatePhyPreambleAndHeaderDuration (txVector); m_state->SwitchToRx (payloadDuration); m_endRxEvent = Simulator::Schedule (payloadDuration, &WifiPhy::EndReceive, this, event); NS_LOG_DEBUG ("Receiving payload"); @@ -2890,9 +2890,7 @@ WifiPhy::StartReceivePayload (Ptr event) NS_LOG_DEBUG ("Drop packet because HT PHY header reception failed"); NotifyRxDrop (event->GetPsdu (), SIG_A_FAILURE); } - m_interference.NotifyRxEnd (); - m_currentEvent = 0; - MaybeCcaBusyDuration (); + m_endRxEvent = Simulator::Schedule (payloadDuration, &WifiPhy::ResetReceive, this, event); } void @@ -3010,6 +3008,17 @@ WifiPhy::EndReceiveInterBss (void) } } +void +WifiPhy::ResetReceive (Ptr event) +{ + NS_LOG_FUNCTION (this << *event); + NS_ASSERT (event->GetEndTime () == Simulator::Now ()); + NS_ASSERT (!IsStateRx ()); + m_interference.NotifyRxEnd (); + m_currentEvent = 0; + MaybeCcaBusyDuration (); +} + void WifiPhy::NotifyChannelAccessRequested (void) { diff --git a/src/wifi/model/wifi-phy.h b/src/wifi/model/wifi-phy.h index 9dd19f581..79e9c7ccc 100644 --- a/src/wifi/model/wifi-phy.h +++ b/src/wifi/model/wifi-phy.h @@ -177,6 +177,13 @@ public: */ void EndReceive (Ptr event); + /** + * Reset PHY at the end of the packet under reception after it has failed the PHY header. + * + * \param event the corresponding event of the first time the packet arrives (also storing packet and TxVector information) + */ + void ResetReceive (Ptr event); + /** * For HE receptions only, check and possibly modify the transmit power restriction state at * the end of PPDU reception.