From 55a1578633de2e808b2e2138052eccffc75e2e4a Mon Sep 17 00:00:00 2001 From: Sebastien Deronne Date: Sun, 1 May 2022 09:41:43 +0200 Subject: [PATCH] wifi: Split processing of a received PSDU from RX end notifications --- src/wifi/model/phy-entity.cc | 8 +++-- src/wifi/model/wifi-phy-state-helper.cc | 41 ++++++++++++++++--------- src/wifi/model/wifi-phy-state-helper.h | 23 +++++++++----- 3 files changed, 47 insertions(+), 25 deletions(-) diff --git a/src/wifi/model/phy-entity.cc b/src/wifi/model/phy-entity.cc index cbb50d60f..d31e7eed1 100644 --- a/src/wifi/model/phy-entity.cc +++ b/src/wifi/model/phy-entity.cc @@ -626,7 +626,7 @@ PhyEntity::EndOfMpdu (Ptr event, Ptr psdu, size_t mpduInd if (rxInfo.first && GetAddressedPsduInPpdu (ppdu)->GetNMpdus () > 1) { //only done for correct MPDU that is part of an A-MPDU - m_state->ContinueRxNextMpdu (Copy (psdu), rxSignalInfo, txVector); + m_state->NotifyRxMpdu (Copy (psdu), rxSignalInfo, txVector); } } @@ -674,13 +674,15 @@ PhyEntity::RxPayloadSucceeded (Ptr psdu, RxSignalInfo rxSignalIn const WifiTxVector& txVector, uint16_t staId, const std::vector& statusPerMpdu) { - m_state->SwitchFromRxEndOk (Copy (psdu), rxSignalInfo, txVector, staId, statusPerMpdu); + m_state->NotifyRxPsduSucceeded (Copy (psdu), rxSignalInfo, txVector, staId, statusPerMpdu); + m_state->SwitchFromRxEndOk (); } void PhyEntity::RxPayloadFailed (Ptr psdu, double snr) { - m_state->SwitchFromRxEndError (Copy (psdu), snr); + m_state->NotifyRxPsduFailed (Copy (psdu), snr); + m_state->SwitchFromRxEndError (); } void diff --git a/src/wifi/model/wifi-phy-state-helper.cc b/src/wifi/model/wifi-phy-state-helper.cc index 372e57858..b6a4fe2a6 100644 --- a/src/wifi/model/wifi-phy-state-helper.cc +++ b/src/wifi/model/wifi-phy-state-helper.cc @@ -456,33 +456,28 @@ WifiPhyStateHelper::SwitchToChannelSwitching (Time switchingDuration) } void -WifiPhyStateHelper::ContinueRxNextMpdu (Ptr psdu, RxSignalInfo rxSignalInfo, const WifiTxVector& txVector) +WifiPhyStateHelper::NotifyRxMpdu (Ptr psdu, RxSignalInfo rxSignalInfo, const WifiTxVector& txVector) { NS_LOG_FUNCTION (this << *psdu << rxSignalInfo << txVector); - std::vector statusPerMpdu; if (!m_rxOkCallback.IsNull ()) { - m_rxOkCallback (psdu, rxSignalInfo, txVector, statusPerMpdu); + m_rxOkCallback (psdu, rxSignalInfo, txVector, {}); } } void -WifiPhyStateHelper::SwitchFromRxEndOk (Ptr psdu, RxSignalInfo rxSignalInfo, - const WifiTxVector& txVector, uint16_t staId, - const std::vector& statusPerMpdu) +WifiPhyStateHelper::NotifyRxPsduSucceeded (Ptr psdu, RxSignalInfo rxSignalInfo, + const WifiTxVector& txVector, uint16_t staId, + const std::vector& statusPerMpdu) { NS_LOG_FUNCTION (this << *psdu << rxSignalInfo << txVector << staId << statusPerMpdu.size () << std::all_of(statusPerMpdu.begin(), statusPerMpdu.end(), [](bool v) { return v; })); //returns true if all true NS_ASSERT (statusPerMpdu.size () != 0); - NS_ASSERT (Abs (m_endRx - Simulator::Now ()) < MicroSeconds (1)); //1us corresponds to the maximum propagation delay (delay spread) - //TODO: a better fix would be to call the function once all HE TB PPDUs are received if (!m_rxOkTrace.IsEmpty ()) { m_rxOkTrace (psdu->GetPacket (), rxSignalInfo.snr, txVector.GetMode (staId), txVector.GetPreambleType ()); } - NotifyRxEndOk (); - DoSwitchFromRx (); if (!m_rxOkCallback.IsNull ()) { m_rxOkCallback (psdu, rxSignalInfo, txVector, statusPerMpdu); @@ -490,23 +485,39 @@ WifiPhyStateHelper::SwitchFromRxEndOk (Ptr psdu, RxSignalInfo rxSignal } void -WifiPhyStateHelper::SwitchFromRxEndError (Ptr psdu, double snr) +WifiPhyStateHelper::NotifyRxPsduFailed (Ptr psdu, double snr) { NS_LOG_FUNCTION (this << *psdu << snr); - NS_ASSERT (Abs (m_endRx - Simulator::Now ()) < MicroSeconds (1)); //1us corresponds to the maximum propagation delay (delay spread) - //TODO: a better fix would be to call the function once all HE TB PPDUs are received if (!m_rxErrorTrace.IsEmpty ()) { m_rxErrorTrace (psdu->GetPacket (), snr); } - NotifyRxEndError (); - DoSwitchFromRx (); if (!m_rxErrorCallback.IsNull ()) { m_rxErrorCallback (psdu); } } +void +WifiPhyStateHelper::SwitchFromRxEndOk (void) +{ + NS_LOG_FUNCTION (this); + NS_ASSERT (Abs (m_endRx - Simulator::Now ()) < MicroSeconds (1)); //1us corresponds to the maximum propagation delay (delay spread) + //TODO: a better fix would be to call the function once all HE TB PPDUs are received + NotifyRxEndOk (); + DoSwitchFromRx (); +} + +void +WifiPhyStateHelper::SwitchFromRxEndError (void) +{ + NS_LOG_FUNCTION (this); + NS_ASSERT (Abs (m_endRx - Simulator::Now ()) < MicroSeconds (1)); //1us corresponds to the maximum propagation delay (delay spread) + //TODO: a better fix would be to call the function once all HE TB PPDUs are received + NotifyRxEndError (); + DoSwitchFromRx (); +} + void WifiPhyStateHelper::DoSwitchFromRx (void) { diff --git a/src/wifi/model/wifi-phy-state-helper.h b/src/wifi/model/wifi-phy-state-helper.h index aeaf06e26..354e7e63d 100644 --- a/src/wifi/model/wifi-phy-state-helper.h +++ b/src/wifi/model/wifi-phy-state-helper.h @@ -187,15 +187,15 @@ public: */ void SwitchToChannelSwitching (Time switchingDuration); /** - * Continue RX after the reception of an MPDU in an A-MPDU was successful. + * Notify the reception of an MPDU included in an A-MPDU. * * \param psdu the successfully received PSDU * \param rxSignalInfo the info on the received signal (\see RxSignalInfo) * \param txVector TXVECTOR of the PSDU */ - void ContinueRxNextMpdu (Ptr psdu, RxSignalInfo rxSignalInfo, const WifiTxVector& txVector); + void NotifyRxMpdu (Ptr psdu, RxSignalInfo rxSignalInfo, const WifiTxVector& txVector); /** - * Switch from RX after the reception was successful. + * Handle the successful reception of a PSDU. * * \param psdu the successfully received PSDU * \param rxSignalInfo the info on the received signal (\see RxSignalInfo) @@ -203,15 +203,24 @@ public: * \param staId the station ID of the PSDU (only used for MU) * \param statusPerMpdu reception status per MPDU */ - void SwitchFromRxEndOk (Ptr psdu, RxSignalInfo rxSignalInfo, const WifiTxVector& txVector, - uint16_t staId, const std::vector& statusPerMpdu); + void NotifyRxPsduSucceeded (Ptr psdu, RxSignalInfo rxSignalInfo, + const WifiTxVector& txVector, uint16_t staId, + const std::vector& statusPerMpdu); /** - * Switch from RX after the reception failed. + * Handle the unsuccessful reception of a PSDU. * * \param psdu the PSDU that we failed to received * \param snr the SNR of the received PSDU in linear scale */ - void SwitchFromRxEndError (Ptr psdu, double snr); + void NotifyRxPsduFailed (Ptr psdu, double snr); + /** + * Switch from RX after the reception was successful. + */ + void SwitchFromRxEndOk (void); + /** + * Switch from RX after the reception failed. + */ + void SwitchFromRxEndError (void); /** * Switch to CCA busy. *