From 0537d167b1b5ddb9b89c279e4e86c962ee05de06 Mon Sep 17 00:00:00 2001 From: Stefano Avallone Date: Tue, 3 Mar 2020 18:42:31 +0100 Subject: [PATCH] wifi: Adapt the PhyTxPsduBegin trace to handle HE MU PPDUs --- src/netanim/model/animation-interface.cc | 17 ++++++++++------- src/netanim/model/animation-interface.h | 4 ++-- src/wifi/model/wifi-phy.cc | 2 +- src/wifi/model/wifi-phy.h | 8 ++++---- src/wifi/test/wifi-aggregation-test.cc | 15 +++++++++------ src/wifi/test/wifi-test.cc | 24 ++++++++++++------------ 6 files changed, 38 insertions(+), 32 deletions(-) diff --git a/src/netanim/model/animation-interface.cc b/src/netanim/model/animation-interface.cc index 09dc26f6e..250ea6e55 100644 --- a/src/netanim/model/animation-interface.cc +++ b/src/netanim/model/animation-interface.cc @@ -868,7 +868,7 @@ AnimationInterface::UanPhyGenRxTrace (std::string context, Ptr p) } void -AnimationInterface::WifiPhyTxBeginTrace (std::string context, Ptr psdu, WifiTxVector txVector, double txPowerW) +AnimationInterface::WifiPhyTxBeginTrace (std::string context, WifiConstPsduMap psduMap, WifiTxVector txVector, double txPowerW) { NS_LOG_FUNCTION (this); NS_UNUSED (txVector); @@ -879,13 +879,16 @@ AnimationInterface::WifiPhyTxBeginTrace (std::string context, Ptrbegin (); mpdu != psdu->end (); ++mpdu) + for (auto& psdu : psduMap) { - ++gAnimUid; - NS_LOG_INFO ("WifiPhyTxTrace for MPDU:" << gAnimUid); - AddByteTag (gAnimUid, (*mpdu)->GetPacket ()); //the underlying MSDU/A-MSDU should be handed off - AddPendingPacket (WIFI, gAnimUid, pktInfo); - OutputWirelessPacketTxInfo ((*mpdu)->GetProtocolDataUnit (), pendingPackets->at (gAnimUid), gAnimUid); //PDU should be considered in order to have header + for (auto& mpdu : *PeekPointer (psdu.second)) + { + ++gAnimUid; + NS_LOG_INFO ("WifiPhyTxTrace for MPDU:" << gAnimUid); + AddByteTag (gAnimUid, mpdu->GetPacket ()); //the underlying MSDU/A-MSDU should be handed off + AddPendingPacket (WIFI, gAnimUid, pktInfo); + OutputWirelessPacketTxInfo (mpdu->GetProtocolDataUnit (), pendingPackets->at (gAnimUid), gAnimUid); //PDU should be considered in order to have header + } } Ptr netDevice = DynamicCast (ndev); diff --git a/src/netanim/model/animation-interface.h b/src/netanim/model/animation-interface.h index b9c6f9c5d..6f792688f 100644 --- a/src/netanim/model/animation-interface.h +++ b/src/netanim/model/animation-interface.h @@ -1047,11 +1047,11 @@ private: /** * wifi Phy transmit PSDU begin trace function * \param context the context - * \param psdu the PSDU + * \param psduMap the PSDU map * \param txVector the TXVECTOR * \param txPowerW the tx power in Watts */ - void WifiPhyTxBeginTrace (std::string context, Ptr psdu, WifiTxVector txVector, double txPowerW); + void WifiPhyTxBeginTrace (std::string context, WifiConstPsduMap psduMap, WifiTxVector txVector, double txPowerW); /** * wifi Phy receive begin trace function * diff --git a/src/wifi/model/wifi-phy.cc b/src/wifi/model/wifi-phy.cc index 90f15750f..9a737e1a4 100644 --- a/src/wifi/model/wifi-phy.cc +++ b/src/wifi/model/wifi-phy.cc @@ -2768,7 +2768,7 @@ WifiPhy::Send (WifiConstPsduMap psdus, WifiTxVector txVector) double txPowerW = DbmToW (GetTxPowerForTransmission (txVector) + GetTxGain ()); NotifyTxBegin (psdus, txPowerW); - m_phyTxPsduBeginTrace (psdus.begin()->second, txVector, txPowerW); // TODO: fix for MU + m_phyTxPsduBeginTrace (psdus, txVector, txPowerW); NotifyMonitorSniffTx (psdus.begin()->second, GetFrequency (), txVector); //TODO: fix for MU m_state->SwitchToTx (txDuration, psdus, GetPowerDbm (txVector.GetTxPowerLevel ()), txVector); diff --git a/src/wifi/model/wifi-phy.h b/src/wifi/model/wifi-phy.h index 359559e99..9dfb09ffe 100644 --- a/src/wifi/model/wifi-phy.h +++ b/src/wifi/model/wifi-phy.h @@ -1425,11 +1425,11 @@ public: /** * TracedCallback signature for PSDU transmit events. * - * \param psdu the PSDU being transmitted + * \param psduMap the PSDU map being transmitted * \param txVector the TXVECTOR holding the TX parameters * \param txPowerW the transmit power in Watts */ - typedef void (* PsduTxBeginCallback)(Ptr psdu, WifiTxVector txVector, double txPowerW); + typedef void (* PsduTxBeginCallback)(WifiConstPsduMap psduMap, WifiTxVector txVector, double txPowerW); /** * Public method used to fire a EndOfHePreamble trace once both HE SIG fields have been received, as well as training fields. @@ -1949,12 +1949,12 @@ private: */ TracedCallback, double > m_phyTxBeginTrace; /** - * The trace source fired when a PSDU begins the transmission process on + * The trace source fired when a PSDU map begins the transmission process on * the medium. * * \see class CallBackTraceSource */ - TracedCallback, WifiTxVector, double /* TX power (W) */> m_phyTxPsduBeginTrace; + TracedCallback m_phyTxPsduBeginTrace; /** * The trace source fired when a packet ends the transmission process on diff --git a/src/wifi/test/wifi-aggregation-test.cc b/src/wifi/test/wifi-aggregation-test.cc index 3d686890e..639803f6c 100644 --- a/src/wifi/test/wifi-aggregation-test.cc +++ b/src/wifi/test/wifi-aggregation-test.cc @@ -654,11 +654,11 @@ private: void NotifyMacTransmit (Ptr packet); /** * Callback invoked when the sender MAC passes a PSDU(s) to the PHY - * \param psdu the PSDU + * \param psduMap the PSDU map * \param txVector the TX vector * \param txPowerW the transmit power in Watts */ - void NotifyPsduForwardedDown (Ptr psdu, WifiTxVector txVector, double txPowerW); + void NotifyPsduForwardedDown (WifiConstPsduMap psduMap, WifiTxVector txVector, double txPowerW); /** * Callback invoked when the receiver MAC forwards a packet up to the upper layer * \param p the packet @@ -682,16 +682,19 @@ PreservePacketsInAmpdus::NotifyMacTransmit (Ptr packet) } void -PreservePacketsInAmpdus::NotifyPsduForwardedDown (Ptr psdu, WifiTxVector txVector, double txPowerW) +PreservePacketsInAmpdus::NotifyPsduForwardedDown (WifiConstPsduMap psduMap, WifiTxVector txVector, double txPowerW) { - if (!psdu->GetHeader (0).IsQosData ()) + NS_TEST_EXPECT_MSG_EQ ((psduMap.size () == 1 && psduMap.begin ()->first == SU_STA_ID), + true, "No DL MU PPDU expected"); + + if (!psduMap[SU_STA_ID]->GetHeader (0).IsQosData ()) { return; } - m_nMpdus.push_back (psdu->GetNMpdus ()); + m_nMpdus.push_back (psduMap[SU_STA_ID]->GetNMpdus ()); - for (auto& mpdu : *PeekPointer (psdu)) + for (auto& mpdu : *PeekPointer (psduMap[SU_STA_ID])) { std::size_t dist = std::distance (mpdu->begin (), mpdu->end ()); // the list of aggregated MSDUs is empty if the MPDU includes a non-aggregated MSDU diff --git a/src/wifi/test/wifi-test.cc b/src/wifi/test/wifi-test.cc index 064eb7565..38d7cbc25 100644 --- a/src/wifi/test/wifi-test.cc +++ b/src/wifi/test/wifi-test.cc @@ -2422,11 +2422,11 @@ private: /** * Callback that indicates a PSDU is being transmitted * \param context the context - * \param psdu the PSDU to transmit + * \param psduMap the PSDU map to transmit * \param txVector the TX vector * \param txPowerW the TX power (W) */ - void TxCallback (std::string context, Ptr psdu, WifiTxVector txVector, double txPowerW); + void TxCallback (std::string context, WifiConstPsduMap psdus, WifiTxVector txVector, double txPowerW); }; Issue169TestCase::Issue169TestCase () @@ -2452,9 +2452,9 @@ Issue169TestCase::SendPackets (uint8_t numPackets, Ptr sourceDevice, } void -Issue169TestCase::TxCallback (std::string context, Ptr psdu, WifiTxVector txVector, double txPowerW) +Issue169TestCase::TxCallback (std::string context, WifiConstPsduMap psdus, WifiTxVector txVector, double txPowerW) { - if (psdu->GetSize () >= 1000) + if (psdus.begin()->second->GetSize () >= 1000) { NS_TEST_ASSERT_MSG_EQ (txVector.GetMode ().GetModulationClass (), WifiModulationClass::WIFI_MOD_CLASS_VHT, "Ideal rate manager selected incorrect modulation class"); } @@ -2556,11 +2556,11 @@ private: /** * Callback that indicates a PSDU is being transmitted * \param context the context - * \param psdu the PSDU to transmit + * \param psduMap the PSDU map to transmit * \param txVector the TX vector * \param txPowerW the TX power (W) */ - void TxCallback (std::string context, Ptr psdu, WifiTxVector txVector, double txPowerW); + void TxCallback (std::string context, WifiConstPsduMap psduMap, WifiTxVector txVector, double txPowerW); /** * Check if the selected WifiMode is correct @@ -2594,9 +2594,9 @@ IdealRateManagerChannelWidthTest::SendPacket (Ptr sourceDevice, Addre } void -IdealRateManagerChannelWidthTest::TxCallback (std::string context, Ptr psdu, WifiTxVector txVector, double txPowerW) +IdealRateManagerChannelWidthTest::TxCallback (std::string context, WifiConstPsduMap psduMap, WifiTxVector txVector, double txPowerW) { - if (psdu->GetSize () >= 1000) + if (psduMap.begin ()->second->GetSize () >= 1000) { m_txMode = txVector.GetMode (); } @@ -2715,11 +2715,11 @@ private: /** * Callback that indicates a PSDU is being transmitted * \param context the context - * \param psdu the PSDU to transmit + * \param psduMap the PSDU map to transmit * \param txVector the TX vector * \param txPowerW the TX power (W) */ - void TxCallback (std::string context, Ptr psdu, WifiTxVector txVector, double txPowerW); + void TxCallback (std::string context, WifiConstPsduMap psdus, WifiTxVector txVector, double txPowerW); /** * Check if the selected WifiMode is correct @@ -2768,9 +2768,9 @@ IdealRateManagerMimoTest::SendPacket (Ptr sourceDevice, Address& dest } void -IdealRateManagerMimoTest::TxCallback (std::string context, Ptr psdu, WifiTxVector txVector, double txPowerW) +IdealRateManagerMimoTest::TxCallback (std::string context, WifiConstPsduMap psdus, WifiTxVector txVector, double txPowerW) { - if (psdu->GetSize () >= 1000) + if (psdus.begin ()->second->GetSize () >= 1000) { m_txVector = txVector; }