wifi: Fix reception logic due to A-MPDU parameters that are not correctly reset
authorSébastien Deronne <sebastien.deronne@gmail.com>
Thu, 06 Dec 2018 22:35:26 +0100
changeset 13890 b6be8762cc18
parent 13889 207a8e737d20
child 13891 cce751c7e678
wifi: Fix reception logic due to A-MPDU parameters that are not correctly reset
src/wifi/model/wifi-phy.cc
--- a/src/wifi/model/wifi-phy.cc	Wed Dec 05 21:47:12 2018 +0100
+++ b/src/wifi/model/wifi-phy.cc	Thu Dec 06 22:35:26 2018 +0100
@@ -2496,6 +2496,7 @@
   else
   {
     NS_LOG_DEBUG ("Packet reception could not be started because PHY preamble detection failed");
+    m_mpdusNum = 0;
     m_plcpSuccess = false;
     m_interference.NotifyRxEnd ();
   }
@@ -2527,8 +2528,6 @@
       return;
     }
 
-  NS_LOG_FUNCTION (this << packet << WToDbm (rxPowerW) << rxDuration);
-
   if (tag.GetFrameComplete () == 0)
     {
       NS_LOG_DEBUG ("Packet reception stopped because transmitter has been switched off");
@@ -2735,9 +2734,10 @@
       m_state->SwitchFromRxEndError (packet, snrPer.snr);
     }
 
-  if (preamble == WIFI_PREAMBLE_NONE && mpdutype == LAST_MPDU_IN_AGGREGATE)
+  if ((mpdutype == NORMAL_MPDU) || (preamble == WIFI_PREAMBLE_NONE && mpdutype == LAST_MPDU_IN_AGGREGATE))
     {
       m_plcpSuccess = false;
+      m_mpdusNum = 0;
     }
 
 }
@@ -3793,8 +3793,8 @@
     }
   else if (preamble != WIFI_PREAMBLE_NONE && packet->PeekPacketTag (ampduTag) && m_mpdusNum == 0)
     {
-      //received the first MPDU in an MPDU
       m_mpdusNum = ampduTag.GetRemainingNbOfMpdus ();
+      NS_LOG_DEBUG ("Received the first MPDU in an A-MPDU, remaining number of MPDUs to be received: " << m_mpdusNum);
       m_rxMpduReferenceNumber++;
     }
   else if (preamble == WIFI_PREAMBLE_NONE && packet->PeekPacketTag (ampduTag) && m_mpdusNum > 0)
@@ -3826,9 +3826,10 @@
   m_interference.NotifyRxStart (); //We need to notify it now so that it starts recording events
   if (preamble == WIFI_PREAMBLE_NONE)
     {
+      NS_ASSERT (m_endPreambleDetectionEvent.IsExpired ());
+
       m_state->SwitchToRx (rxDuration);
       NotifyRxBegin (packet);
-      m_interference.NotifyRxStart ();
 
       NS_ASSERT (m_endRxEvent.IsExpired ());
       m_endRxEvent = Simulator::Schedule (rxDuration, &WifiPhy::EndReceive, this,