diff --git a/src/wifi/examples/wifi-phy-test.cc b/src/wifi/examples/wifi-phy-test.cc index 98456a9a5..d25721348 100644 --- a/src/wifi/examples/wifi-phy-test.cc +++ b/src/wifi/examples/wifi-phy-test.cc @@ -67,8 +67,9 @@ private: * \param p the packet * \param snr the SNR * \param txVector the wifi transmit vector + * \param statusPerMpdu reception status per MPDU */ - void Receive (Ptr p, double snr, WifiTxVector txVector); + void Receive (Ptr p, double snr, WifiTxVector txVector, std::vector statusPerMpdu); Ptr m_tx; ///< transmit struct Input m_input; ///< input struct Output m_output; ///< output @@ -87,7 +88,7 @@ PsrExperiment::Send (void) } void -PsrExperiment::Receive (Ptr p, double snr, WifiTxVector txVector) +PsrExperiment::Receive (Ptr p, double snr, WifiTxVector txVector, std::vector statusPerMpdu) { m_output.received++; } @@ -188,8 +189,9 @@ private: * \param p the packet * \param snr the SNR * \param txVector the wifi transmit vector + * \param statusPerMpdu reception status per MPDU */ - void Receive (Ptr p, double snr, WifiTxVector txVector); + void Receive (Ptr p, double snr, WifiTxVector txVector, std::vector statusPerMpdu); Ptr m_txA; ///< transmit A Ptr m_txB; ///< transmit B uint32_t m_flowIdA; ///< flow ID A @@ -223,7 +225,7 @@ CollisionExperiment::SendB (void) const } void -CollisionExperiment::Receive (Ptr p, double snr, WifiTxVector txVector) +CollisionExperiment::Receive (Ptr p, double snr, WifiTxVector txVector, std::vector statusPerMpdu) { FlowIdTag tag; if (p->FindFirstMatchingByteTag (tag)) diff --git a/src/wifi/model/mac-low.cc b/src/wifi/model/mac-low.cc index 91c8eaffd..56c9c099a 100644 --- a/src/wifi/model/mac-low.cc +++ b/src/wifi/model/mac-low.cc @@ -270,7 +270,7 @@ MacLow::GetPhy (void) const void MacLow::ResetPhy (void) { - m_phy->SetReceiveOkCallback (MakeNullCallback, double, WifiTxVector> ()); + m_phy->SetReceiveOkCallback (MakeNullCallback, double, WifiTxVector, std::vector> ()); m_phy->SetReceiveErrorCallback (MakeNullCallback> ()); RemovePhyMacLowListener (m_phy); m_phy = 0; @@ -2724,7 +2724,7 @@ MacLow::RegisterEdcaForAc (AcIndex ac, Ptr edca) } void -MacLow::DeaggregateAmpduAndReceive (Ptr aggregatedPacket, double rxSnr, WifiTxVector txVector) +MacLow::DeaggregateAmpduAndReceive (Ptr aggregatedPacket, double rxSnr, WifiTxVector txVector, std::vector statusPerMpdu) { NS_LOG_FUNCTION (this); AmpduTag ampdu; diff --git a/src/wifi/model/mac-low.h b/src/wifi/model/mac-low.h index 1d723fbdd..d5443c957 100644 --- a/src/wifi/model/mac-low.h +++ b/src/wifi/model/mac-low.h @@ -402,11 +402,13 @@ public: * \param aggregatedPacket which is the current A-MPDU * \param rxSnr snr of packet received * \param txVector TXVECTOR of packet received + * \param statusPerMpdu reception status per MPDU * * This function de-aggregates an A-MPDU and decide if each MPDU is received correctly or not * */ - void DeaggregateAmpduAndReceive (Ptr aggregatedPacket, double rxSnr, WifiTxVector txVector); + void DeaggregateAmpduAndReceive (Ptr aggregatedPacket, double rxSnr, WifiTxVector txVector, + std::vector statusPerMpdu); /** * * This function is called to flush the aggregate queue, which is used for A-MPDU diff --git a/src/wifi/model/wifi-phy-state-helper.cc b/src/wifi/model/wifi-phy-state-helper.cc index 1b2d14a06..c60a624e8 100644 --- a/src/wifi/model/wifi-phy-state-helper.cc +++ b/src/wifi/model/wifi-phy-state-helper.cc @@ -458,15 +458,17 @@ WifiPhyStateHelper::SwitchToChannelSwitching (Time switchingDuration) } void -WifiPhyStateHelper::SwitchFromRxEndOk (Ptr packet, double snr, WifiTxVector txVector) +WifiPhyStateHelper::SwitchFromRxEndOk (Ptr packet, double snr, WifiTxVector txVector, std::vector statusPerMpdu) { - NS_LOG_FUNCTION (this << packet << snr << txVector); + NS_LOG_FUNCTION (this << packet << snr << txVector << statusPerMpdu.size () << + std::all_of(statusPerMpdu.begin(), statusPerMpdu.end(), [](bool v) { return v; })); //returns true if all true + NS_ASSERT (statusPerMpdu.size () != 0); m_rxOkTrace (packet, snr, txVector.GetMode (), txVector.GetPreambleType ()); NotifyRxEndOk (); DoSwitchFromRx (); if (!m_rxOkCallback.IsNull ()) { - m_rxOkCallback (packet, snr, txVector); + m_rxOkCallback (packet, snr, txVector, statusPerMpdu); } } diff --git a/src/wifi/model/wifi-phy-state-helper.h b/src/wifi/model/wifi-phy-state-helper.h index 6818c4f28..e3cbafafe 100644 --- a/src/wifi/model/wifi-phy-state-helper.h +++ b/src/wifi/model/wifi-phy-state-helper.h @@ -36,14 +36,16 @@ class WifiMode; class Packet; /** - * Callback if packet successfully received + * Callback if packet successfully received (i.e. if aggregate, + * it means that at least one MPDU of the A-MPDU was received, + * considering that the per-MPDU reception status is also provided). * * arg1: packet received successfully - * arg2: snr of packet + * arg2: SNR of packet * arg3: TXVECTOR of packet - * arg4: type of preamble used for packet. + * arg4: vector of per-MPDU status of reception. */ -typedef Callback, double, WifiTxVector> RxOkCallback; +typedef Callback, double, WifiTxVector, std::vector> RxOkCallback; /** * Callback if packet unsuccessfully received * @@ -179,8 +181,9 @@ public: * \param packet the successfully received packet * \param snr the SNR of the received packet * \param txVector TXVECTOR of the packet + * \param statusPerMpdu reception status per MPDU */ - void SwitchFromRxEndOk (Ptr packet, double snr, WifiTxVector txVector); + void SwitchFromRxEndOk (Ptr packet, double snr, WifiTxVector txVector, std::vector statusPerMpdu); /** * Switch from RX after the reception failed. * diff --git a/src/wifi/model/wifi-phy.cc b/src/wifi/model/wifi-phy.cc index 9c0f66125..21b372e7c 100644 --- a/src/wifi/model/wifi-phy.cc +++ b/src/wifi/model/wifi-phy.cc @@ -2764,8 +2764,9 @@ WifiPhy::EndReceive (Ptr packet, WifiPreamble preamble, MpduType mpdutyp MpduInfo aMpdu; aMpdu.type = mpdutype; aMpdu.mpduRefNumber = m_rxMpduReferenceNumber; + std::vector statusPerMpdu {true}; //TODO update when A-MPDUs are handled as single packet NotifyMonitorSniffRx (packet, GetFrequency (), event->GetTxVector (), aMpdu, signalNoise); - m_state->SwitchFromRxEndOk (packet, snrPer.snr, event->GetTxVector ()); + m_state->SwitchFromRxEndOk (packet, snrPer.snr, event->GetTxVector (), statusPerMpdu); } else { diff --git a/src/wifi/test/spectrum-wifi-phy-test.cc b/src/wifi/test/spectrum-wifi-phy-test.cc index 688c88f71..bdcc8f514 100644 --- a/src/wifi/test/spectrum-wifi-phy-test.cc +++ b/src/wifi/test/spectrum-wifi-phy-test.cc @@ -75,8 +75,9 @@ protected: * \param p the packet * \param snr the SNR * \param txVector the transmit vector + * \param statusPerMpdu reception status per MPDU */ - void SpectrumWifiPhyRxSuccess (Ptr p, double snr, WifiTxVector txVector); + void SpectrumWifiPhyRxSuccess (Ptr p, double snr, WifiTxVector txVector, std::vector statusPerMpdu); /** * Spectrum wifi receive failure function * \param p the packet @@ -138,7 +139,7 @@ SpectrumWifiPhyBasicTest::SendSignal (double txPowerWatts) } void -SpectrumWifiPhyBasicTest::SpectrumWifiPhyRxSuccess (Ptr p, double snr, WifiTxVector txVector) +SpectrumWifiPhyBasicTest::SpectrumWifiPhyRxSuccess (Ptr p, double snr, WifiTxVector txVector, std::vector statusPerMpdu) { NS_LOG_FUNCTION (this << p << snr << txVector); m_count++; diff --git a/src/wifi/test/wifi-phy-reception-test.cc b/src/wifi/test/wifi-phy-reception-test.cc index cc861d2e8..c6be7adf3 100644 --- a/src/wifi/test/wifi-phy-reception-test.cc +++ b/src/wifi/test/wifi-phy-reception-test.cc @@ -70,8 +70,9 @@ protected: * \param p the packet * \param snr the SNR * \param txVector the transmit vector + * \param statusPerMpdu reception status per MPDU */ - void RxSuccess (Ptr p, double snr, WifiTxVector txVector); + void RxSuccess (Ptr p, double snr, WifiTxVector txVector, std::vector statusPerMpdu); /** * Spectrum wifi receive failure function * \param p the packet @@ -152,7 +153,7 @@ TestThresholdPreambleDetectionWithoutFrameCapture::CheckRxPacketCount (uint32_t } void -TestThresholdPreambleDetectionWithoutFrameCapture::RxSuccess (Ptr p, double snr, WifiTxVector txVector) +TestThresholdPreambleDetectionWithoutFrameCapture::RxSuccess (Ptr p, double snr, WifiTxVector txVector, std::vector statusPerMpdu) { NS_LOG_FUNCTION (this << p << snr << txVector); m_countRxSuccess++; @@ -269,8 +270,9 @@ protected: * \param p the packet * \param snr the SNR * \param txVector the transmit vector + * \param statusPerMpdu reception status per MPDU */ - void RxSuccess (Ptr p, double snr, WifiTxVector txVector); + void RxSuccess (Ptr p, double snr, WifiTxVector txVector, std::vector statusPerMpdu); /** * Spectrum wifi receive failure function * \param p the packet @@ -351,7 +353,7 @@ TestThresholdPreambleDetectionWithFrameCapture::CheckRxPacketCount (uint32_t exp } void -TestThresholdPreambleDetectionWithFrameCapture::RxSuccess (Ptr p, double snr, WifiTxVector txVector) +TestThresholdPreambleDetectionWithFrameCapture::RxSuccess (Ptr p, double snr, WifiTxVector txVector, std::vector statusPerMpdu) { NS_LOG_FUNCTION (this << p << txVector); m_countRxSuccess++; @@ -481,8 +483,9 @@ private: * \param p the packet * \param snr the SNR * \param txVector the transmit vector + * \param statusPerMpdu reception status per MPDU */ - void RxSuccess (Ptr p, double snr, WifiTxVector txVector); + void RxSuccess (Ptr p, double snr, WifiTxVector txVector, std::vector statusPerMpdu); /** * RX packet dropped function * \param p the packet @@ -542,7 +545,7 @@ TestSimpleFrameCaptureModel::SendPacket (double txPowerDbm, uint32_t packetSize) } void -TestSimpleFrameCaptureModel::RxSuccess (Ptr p, double snr, WifiTxVector txVector) +TestSimpleFrameCaptureModel::RxSuccess (Ptr p, double snr, WifiTxVector txVector, std::vector statusPerMpdu) { NS_LOG_FUNCTION (this << p << snr << txVector); if (p->GetSize () == 1030) @@ -692,8 +695,9 @@ private: * \param p the packet * \param snr the SNR * \param txVector the transmit vector + * \param statusPerMpdu reception status per MPDU */ - void RxSuccess (Ptr p, double snr, WifiTxVector txVector); + void RxSuccess (Ptr p, double snr, WifiTxVector txVector, std::vector statusPerMpdu); /** * RX failure function * \param p the packet @@ -806,7 +810,7 @@ TestAmpduReception::ResetBitmaps() } void -TestAmpduReception::RxSuccess (Ptr p, double snr, WifiTxVector txVector) +TestAmpduReception::RxSuccess (Ptr p, double snr, WifiTxVector txVector, std::vector statusPerMpdu) { NS_LOG_FUNCTION (this << p << snr << txVector); if (p->GetSize () == 1030) //A-MPDU 1 - MPDU #1 diff --git a/src/wifi/test/wifi-phy-thresholds-test.cc b/src/wifi/test/wifi-phy-thresholds-test.cc index db80c5faf..7f43f38ee 100644 --- a/src/wifi/test/wifi-phy-thresholds-test.cc +++ b/src/wifi/test/wifi-phy-thresholds-test.cc @@ -74,8 +74,9 @@ protected: * \param p the packet * \param snr the SNR * \param txVector the transmit vector + * \param statusPerMpdu reception status per MPDU */ - virtual void RxSuccess (Ptr p, double snr, WifiTxVector txVector); + virtual void RxSuccess (Ptr p, double snr, WifiTxVector txVector, std::vector statusPerMpdu); /** * PHY receive failure callback function * \param p the packet @@ -177,7 +178,7 @@ WifiPhyThresholdsTest::SendSignal (double txPowerWatts, bool wifiSignal) } void -WifiPhyThresholdsTest::RxSuccess (Ptr p, double snr, WifiTxVector txVector) +WifiPhyThresholdsTest::RxSuccess (Ptr p, double snr, WifiTxVector txVector, std::vector statusPerMpdu) { NS_LOG_FUNCTION (this << p << snr << txVector); m_rxSuccess++;