From 2e22c3da6b18fa8c46debb4a45ab3865ee38f0e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Deronne?= Date: Mon, 9 Sep 2019 17:33:30 +0200 Subject: [PATCH] wifi: Add PCAP support for HE MU and HE TB PPDUs --- .../wireless/wifi-spectrum-per-example.cc | 3 +- .../wifi-spectrum-per-interference.cc | 3 +- src/network/utils/radiotap-header.cc | 22 +++-- src/network/utils/radiotap-header.h | 26 +++--- src/wifi/examples/wifi-bianchi.cc | 2 +- src/wifi/helper/wifi-helper.cc | 90 ++++++++++++++----- src/wifi/helper/wifi-helper.h | 14 ++- src/wifi/model/wifi-phy.cc | 19 ++-- src/wifi/model/wifi-phy.h | 20 +++-- src/wifi/test/wifi-test.cc | 5 +- 10 files changed, 136 insertions(+), 68 deletions(-) diff --git a/examples/wireless/wifi-spectrum-per-example.cc b/examples/wireless/wifi-spectrum-per-example.cc index 590664964..eef389c6c 100644 --- a/examples/wireless/wifi-spectrum-per-example.cc +++ b/examples/wireless/wifi-spectrum-per-example.cc @@ -101,7 +101,8 @@ void MonitorSniffRx (Ptr packet, uint16_t channelFreqMhz, WifiTxVector txVector, MpduInfo aMpdu, - SignalNoiseDbm signalNoise) + SignalNoiseDbm signalNoise, + uint16_t staId) { g_samples++; diff --git a/examples/wireless/wifi-spectrum-per-interference.cc b/examples/wireless/wifi-spectrum-per-interference.cc index 28260f5f3..cdc996d63 100644 --- a/examples/wireless/wifi-spectrum-per-interference.cc +++ b/examples/wireless/wifi-spectrum-per-interference.cc @@ -107,7 +107,8 @@ void MonitorSniffRx (Ptr packet, uint16_t channelFreqMhz, WifiTxVector txVector, MpduInfo aMpdu, - SignalNoiseDbm signalNoise) + SignalNoiseDbm signalNoise, + uint16_t staId) { g_samples++; diff --git a/src/network/utils/radiotap-header.cc b/src/network/utils/radiotap-header.cc index 93ce73449..b7e35a175 100644 --- a/src/network/utils/radiotap-header.cc +++ b/src/network/utils/radiotap-header.cc @@ -54,7 +54,9 @@ RadiotapHeader::RadiotapHeader () m_heData1 (0), m_heData2 (0), m_heData3 (0), - m_heData5 (0) + m_heData4 (0), + m_heData5 (0), + m_heData6 (0) { NS_LOG_FUNCTION (this); } @@ -272,9 +274,9 @@ RadiotapHeader::Serialize (Buffer::Iterator start) const start.WriteU16 (m_heData1); start.WriteU16 (m_heData2); start.WriteU16 (m_heData3); - start.WriteU16 (0); //HE data4 field + start.WriteU16 (m_heData4); start.WriteU16 (m_heData5); - start.WriteU16 (0); //HE data6 field + start.WriteU16 (m_heData6); } } @@ -501,9 +503,9 @@ RadiotapHeader::Deserialize (Buffer::Iterator start) m_heData1 = start.ReadU16 (); m_heData2 = start.ReadU16 (); m_heData3 = start.ReadU16 (); - start.ReadU16 (); //HE data4 field + m_heData4 = start.ReadU16 (); m_heData5 = start.ReadU16 (); - start.ReadU16 (); //HE data6 field + m_heData6 = start.ReadU16 (); bytesRead += (12 + m_hePad); } @@ -539,7 +541,9 @@ RadiotapHeader::Print (std::ostream &os) const << " heData1=" << m_heData1 << " heData2=" << m_heData2 << " heData3=" << m_heData3 - << " heData5=" << m_heData5; + << " heData4=" << m_heData4 + << " heData5=" << m_heData5 + << " heData6=" << m_heData6; } void @@ -714,13 +718,15 @@ RadiotapHeader::SetVhtFields (uint16_t known, uint8_t flags, uint8_t bandwidth, } void -RadiotapHeader::SetHeFields (uint16_t data1, uint16_t data2, uint16_t data3, uint16_t data5) +RadiotapHeader::SetHeFields (uint16_t data1, uint16_t data2, uint16_t data3, uint16_t data4, uint16_t data5, uint16_t data6) { - NS_LOG_FUNCTION (this << data1 << data2 << data3 << data5); + NS_LOG_FUNCTION (this << data1 << data2 << data3 << data4 << data5 << data6); m_heData1 = data1; m_heData2 = data2; m_heData3 = data3; + m_heData4 = data4; m_heData5 = data5; + m_heData6 = data6; if (!(m_present & RADIOTAP_HE)) { m_hePad = ((2 - m_length % 2) % 2); diff --git a/src/network/utils/radiotap-header.h b/src/network/utils/radiotap-header.h index de45165e7..fc671a55b 100644 --- a/src/network/utils/radiotap-header.h +++ b/src/network/utils/radiotap-header.h @@ -324,21 +324,6 @@ public: HE_DATA2_PRISEC_80_SEC = 0x8000, /**< pri/sec 80 MHz */ }; - /** - * @brief HE data3. - */ - enum HeData3 - { - HE_DATA3_BSS_COLOR = 0x003f, /**< BSS Color */ - HE_DATA3_BEAM_CHANGE = 0x0040, /**< Beam Change */ - HE_DATA3_UL_DL = 0x0080, /**< UL/DL */ - HE_DATA3_DATA_MCS = 0x0f00, /**< data MCS */ - HE_DATA3_DATA_DCM = 0x1000, /**< data DCM */ - HE_DATA3_CODING = 0x2000, /**< Coding */ - HE_DATA3_LDPC_XSYMSEG = 0x4000, /**< LDPC extra symbol segment */ - HE_DATA3_STBC = 0x8000, /**< STBC */ - }; - /** * @brief HE data5. */ @@ -369,9 +354,16 @@ public: * @param data1 The data1 field. * @param data2 The data2 field. * @param data3 The data3 field. + * @param data4 The data4 field. * @param data5 The data5 field. + * @param data6 The data6 field. */ - void SetHeFields (uint16_t data1, uint16_t data2, uint16_t data3, uint16_t data5); + void SetHeFields (uint16_t data1, + uint16_t data2, + uint16_t data3, + uint16_t data4, + uint16_t data5, + uint16_t data6); private: /** @@ -435,7 +427,9 @@ private: uint16_t m_heData1; //!< HE data1 field. uint16_t m_heData2; //!< HE data2 field. uint16_t m_heData3; //!< HE data3 field. + uint16_t m_heData4; //!< HE data4 field. uint16_t m_heData5; //!< HE data5 field. + uint16_t m_heData6; //!< HE data6 field. }; } // namespace ns3 diff --git a/src/wifi/examples/wifi-bianchi.cc b/src/wifi/examples/wifi-bianchi.cc index 42f395a94..dcc30f8b9 100644 --- a/src/wifi/examples/wifi-bianchi.cc +++ b/src/wifi/examples/wifi-bianchi.cc @@ -428,7 +428,7 @@ IncrementCounter (std::map & counter, Mac48Address addr, } void -TracePacketReception (std::string context, Ptr packet, uint16_t channelFreqMhz, WifiTxVector txVector, MpduInfo aMpdu, SignalNoiseDbm signalNoise) +TracePacketReception (std::string context, Ptr packet, uint16_t channelFreqMhz, WifiTxVector txVector, MpduInfo aMpdu, SignalNoiseDbm signalNoise, uint16_t staId) { WifiMacHeader hdr; packet->PeekHeader (hdr); diff --git a/src/wifi/helper/wifi-helper.cc b/src/wifi/helper/wifi-helper.cc index 1f06a3fd5..388f7bae3 100644 --- a/src/wifi/helper/wifi-helper.cc +++ b/src/wifi/helper/wifi-helper.cc @@ -226,7 +226,8 @@ WifiPhyHelper::PcapSniffTxEvent ( Ptr packet, uint16_t channelFreqMhz, WifiTxVector txVector, - MpduInfo aMpdu) + MpduInfo aMpdu, + uint16_t staId) { uint32_t dlt = file->GetDataLinkType (); switch (dlt) @@ -243,7 +244,7 @@ WifiPhyHelper::PcapSniffTxEvent ( { Ptr p = packet->Copy (); RadiotapHeader header; - GetRadiotapHeader (header, p, channelFreqMhz, txVector, aMpdu); + GetRadiotapHeader (header, p, channelFreqMhz, txVector, aMpdu, staId); p->AddHeader (header); file->Write (Simulator::Now (), p); return; @@ -260,7 +261,8 @@ WifiPhyHelper::PcapSniffRxEvent ( uint16_t channelFreqMhz, WifiTxVector txVector, MpduInfo aMpdu, - SignalNoiseDbm signalNoise) + SignalNoiseDbm signalNoise, + uint16_t staId) { uint32_t dlt = file->GetDataLinkType (); switch (dlt) @@ -277,7 +279,7 @@ WifiPhyHelper::PcapSniffRxEvent ( { Ptr p = packet->Copy (); RadiotapHeader header; - GetRadiotapHeader (header, p, channelFreqMhz, txVector, aMpdu, signalNoise); + GetRadiotapHeader (header, p, channelFreqMhz, txVector, aMpdu, staId, signalNoise); p->AddHeader (header); file->Write (Simulator::Now (), p); return; @@ -294,11 +296,12 @@ WifiPhyHelper::GetRadiotapHeader ( uint16_t channelFreqMhz, WifiTxVector txVector, MpduInfo aMpdu, + uint16_t staId, SignalNoiseDbm signalNoise) { header.SetAntennaSignalPower (signalNoise.signal); header.SetAntennaNoisePower (signalNoise.noise); - GetRadiotapHeader (header, packet, channelFreqMhz, txVector, aMpdu); + GetRadiotapHeader (header, packet, channelFreqMhz, txVector, aMpdu, staId); } void @@ -307,7 +310,8 @@ WifiPhyHelper::GetRadiotapHeader ( Ptr packet, uint16_t channelFreqMhz, WifiTxVector txVector, - MpduInfo aMpdu) + MpduInfo aMpdu, + uint16_t staId) { WifiPreamble preamble = txVector.GetPreambleType (); @@ -330,11 +334,11 @@ WifiPhyHelper::GetRadiotapHeader ( header.SetFrameFlags (frameFlags); uint64_t rate = 0; - if (txVector.GetMode ().GetModulationClass () != WIFI_MOD_CLASS_HT - && txVector.GetMode ().GetModulationClass () != WIFI_MOD_CLASS_VHT - && txVector.GetMode ().GetModulationClass () != WIFI_MOD_CLASS_HE) + if (txVector.GetMode (staId).GetModulationClass () != WIFI_MOD_CLASS_HT + && txVector.GetMode (staId).GetModulationClass () != WIFI_MOD_CLASS_VHT + && txVector.GetMode (staId).GetModulationClass () != WIFI_MOD_CLASS_HE) { - rate = txVector.GetMode ().GetDataRate (txVector.GetChannelWidth (), txVector.GetGuardInterval (), 1) * txVector.GetNss () / 500000; + rate = txVector.GetMode (staId).GetDataRate (txVector.GetChannelWidth (), txVector.GetGuardInterval (), 1) * txVector.GetNss (staId) / 500000; header.SetRate (static_cast (rate)); } @@ -363,7 +367,7 @@ WifiPhyHelper::GetRadiotapHeader ( header.SetChannelFrequencyAndFlags (channelFreqMhz, channelFlags); - if (txVector.GetMode ().GetModulationClass () == WIFI_MOD_CLASS_HT) + if (txVector.GetMode (staId).GetModulationClass () == WIFI_MOD_CLASS_HT) { uint8_t mcsKnown = RadiotapHeader::MCS_KNOWN_NONE; uint8_t mcsFlags = RadiotapHeader::MCS_FLAGS_NONE; @@ -406,7 +410,7 @@ WifiPhyHelper::GetRadiotapHeader ( mcsFlags |= RadiotapHeader::MCS_FLAGS_STBC_STREAMS; } - header.SetMcsFields (mcsKnown, mcsFlags, txVector.GetMode ().GetMcsValue ()); + header.SetMcsFields (mcsKnown, mcsFlags, txVector.GetMode (staId).GetMcsValue ()); } if (txVector.IsAggregation ()) @@ -426,7 +430,7 @@ WifiPhyHelper::GetRadiotapHeader ( header.SetAmpduStatus (aMpdu.mpduRefNumber, ampduStatusFlags, 1 /*CRC*/); } - if (txVector.GetMode ().GetModulationClass () == WIFI_MOD_CLASS_VHT) + if (txVector.GetMode (staId).GetModulationClass () == WIFI_MOD_CLASS_VHT) { uint16_t vhtKnown = RadiotapHeader::VHT_KNOWN_NONE; uint8_t vhtFlags = RadiotapHeader::VHT_FLAGS_NONE; @@ -466,15 +470,15 @@ WifiPhyHelper::GetRadiotapHeader ( } //only SU PPDUs are currently supported - vhtMcsNss[0] |= (txVector.GetNss () & 0x0f); - vhtMcsNss[0] |= ((txVector.GetMode ().GetMcsValue () << 4) & 0xf0); + vhtMcsNss[0] |= (txVector.GetNss (staId) & 0x0f); + vhtMcsNss[0] |= ((txVector.GetMode (staId).GetMcsValue () << 4) & 0xf0); header.SetVhtFields (vhtKnown, vhtFlags, vhtBandwidth, vhtMcsNss, vhtCoding, vhtGroupId, vhtPartialAid); } - if (txVector.GetMode ().GetModulationClass () == WIFI_MOD_CLASS_HE) + if (txVector.GetMode (staId).GetModulationClass () == WIFI_MOD_CLASS_HE) { - uint16_t data1 = RadiotapHeader::HE_DATA1_STBC_KNOWN | RadiotapHeader::HE_DATA1_DATA_MCS_KNOWN; + uint16_t data1 = RadiotapHeader::HE_DATA1_BSS_COLOR_KNOWN | RadiotapHeader::HE_DATA1_DATA_MCS_KNOWN | RadiotapHeader::HE_DATA1_BW_RU_ALLOC_KNOWN; if (preamble == WIFI_PREAMBLE_HE_ER_SU) { data1 |= RadiotapHeader::HE_DATA1_FORMAT_EXT_SU; @@ -482,22 +486,64 @@ WifiPhyHelper::GetRadiotapHeader ( else if (preamble == WIFI_PREAMBLE_HE_MU) { data1 |= RadiotapHeader::HE_DATA1_FORMAT_MU; + data1 |= RadiotapHeader::HE_DATA1_SPTL_REUSE2_KNOWN; } else if (preamble == WIFI_PREAMBLE_HE_TB) { data1 |= RadiotapHeader::HE_DATA1_FORMAT_TRIG; } - uint16_t data2 = RadiotapHeader::HE_DATA2_NUM_LTF_SYMS_KNOWN | RadiotapHeader::HE_DATA2_GI_KNOWN; + uint16_t data2 = RadiotapHeader::HE_DATA2_GI_KNOWN; + if (preamble == WIFI_PREAMBLE_HE_MU || preamble == WIFI_PREAMBLE_HE_TB) + { + data2 |= RadiotapHeader::HE_DATA2_RU_OFFSET_KNOWN; + //HeRu indices start at 1 whereas RadioTap starts at 0 + data2 |= (((txVector.GetHeMuUserInfo (staId).ru.index - 1) << 8) & 0x3f00); + data2 |= (((!txVector.GetHeMuUserInfo (staId).ru.primary80MHz) << 15) & 0x8000); + } uint16_t data3 = 0; - if (txVector.IsStbc ()) + data3 |= (txVector.GetBssColor () & 0x003f); + data3 |= ((txVector.GetMode (staId).GetMcsValue () << 8) & 0x0f00); + + uint16_t data4 = 0; + if (preamble == WIFI_PREAMBLE_HE_MU) { - data3 |= RadiotapHeader::HE_DATA3_STBC; + data4 |= ((staId << 4) & 0x7ff0); } uint16_t data5 = 0; - if (txVector.GetChannelWidth () == 40) + if (preamble == WIFI_PREAMBLE_HE_MU || preamble == WIFI_PREAMBLE_HE_TB) + { + HeRu::RuType ruType = txVector.GetHeMuUserInfo (staId).ru.ruType; + switch (ruType) + { + case HeRu::RU_26_TONE: + data5 |= RadiotapHeader::HE_DATA5_DATA_BW_RU_ALLOC_26T; + break; + case HeRu::RU_52_TONE: + data5 |= RadiotapHeader::HE_DATA5_DATA_BW_RU_ALLOC_52T; + break; + case HeRu::RU_106_TONE: + data5 |= RadiotapHeader::HE_DATA5_DATA_BW_RU_ALLOC_106T; + break; + case HeRu::RU_242_TONE: + data5 |= RadiotapHeader::HE_DATA5_DATA_BW_RU_ALLOC_242T; + break; + case HeRu::RU_484_TONE: + data5 |= RadiotapHeader::HE_DATA5_DATA_BW_RU_ALLOC_484T; + break; + case HeRu::RU_996_TONE: + data5 |= RadiotapHeader::HE_DATA5_DATA_BW_RU_ALLOC_996T; + break; + case HeRu::RU_2x996_TONE: + data5 |= RadiotapHeader::HE_DATA5_DATA_BW_RU_ALLOC_2x996T; + break; + default: + NS_ABORT_MSG ("Unexpected RU type"); + } + } + else if (txVector.GetChannelWidth () == 40) { data5 |= RadiotapHeader::HE_DATA5_DATA_BW_RU_ALLOC_40MHZ; } @@ -518,7 +564,7 @@ WifiPhyHelper::GetRadiotapHeader ( data5 |= RadiotapHeader::HE_DATA5_GI_3_2; } - header.SetHeFields (data1, data2, data3, data5); + header.SetHeFields (data1, data2, data3, data4, data5, 0); } } diff --git a/src/wifi/helper/wifi-helper.h b/src/wifi/helper/wifi-helper.h index a5d6568bc..b15888e2f 100644 --- a/src/wifi/helper/wifi-helper.h +++ b/src/wifi/helper/wifi-helper.h @@ -208,6 +208,7 @@ protected: * \param channelFreqMhz the channel frequency * \param txVector the TXVECTOR * \param aMpdu the A-MPDU information + * \param staId the STA-ID (only used for MU) * * Handle TX pcap. */ @@ -215,7 +216,8 @@ protected: Ptr packet, uint16_t channelFreqMhz, WifiTxVector txVector, - MpduInfo aMpdu); + MpduInfo aMpdu, + uint16_t staId = SU_STA_ID); /** * \param file the pcap file wrapper * \param packet the packet @@ -223,6 +225,7 @@ protected: * \param txVector the TXVECTOR * \param aMpdu the A-MPDU information * \param signalNoise the RX signal and noise information + * \param staId the STA-ID (only used for MU) * * Handle RX pcap. */ @@ -231,7 +234,8 @@ protected: uint16_t channelFreqMhz, WifiTxVector txVector, MpduInfo aMpdu, - SignalNoiseDbm signalNoise); + SignalNoiseDbm signalNoise, + uint16_t staId = SU_STA_ID); ObjectFactory m_phy; ///< PHY object ObjectFactory m_errorRateModel; ///< error rate model @@ -248,12 +252,14 @@ private: * \param channelFreqMhz the channel frequency * \param txVector the TXVECTOR * \param aMpdu the A-MPDU information + * \param staId the STA-ID */ static void GetRadiotapHeader (RadiotapHeader &header, Ptr packet, uint16_t channelFreqMhz, WifiTxVector txVector, - MpduInfo aMpdu); + MpduInfo aMpdu, + uint16_t staId); /** * Get the Radiotap header for a received packet. @@ -263,6 +269,7 @@ private: * \param channelFreqMhz the channel frequency * \param txVector the TXVECTOR * \param aMpdu the A-MPDU information + * \param staId the STA-ID * \param signalNoise the rx signal and noise information */ static void GetRadiotapHeader (RadiotapHeader &header, @@ -270,6 +277,7 @@ private: uint16_t channelFreqMhz, WifiTxVector txVector, MpduInfo aMpdu, + uint16_t staId, SignalNoiseDbm signalNoise); /** diff --git a/src/wifi/model/wifi-phy.cc b/src/wifi/model/wifi-phy.cc index 119a311cf..eb22fc2cc 100644 --- a/src/wifi/model/wifi-phy.cc +++ b/src/wifi/model/wifi-phy.cc @@ -2643,7 +2643,7 @@ WifiPhy::NotifyRxDrop (Ptr psdu, WifiPhyRxfailureReason reason) void WifiPhy::NotifyMonitorSniffRx (Ptr psdu, uint16_t channelFreqMhz, WifiTxVector txVector, - SignalNoiseDbm signalNoise, std::vector statusPerMpdu) + SignalNoiseDbm signalNoise, std::vector statusPerMpdu, uint16_t staId) { MpduInfo aMpdu; if (psdu->IsAggregate ()) @@ -2658,7 +2658,7 @@ WifiPhy::NotifyMonitorSniffRx (Ptr psdu, uint16_t channelFreqMhz { if (statusPerMpdu.at (i)) //packet received without error, hand over to sniffer { - m_phyMonitorSniffRxTrace (psdu->GetAmpduSubframe (i), channelFreqMhz, txVector, aMpdu, signalNoise); + m_phyMonitorSniffRxTrace (psdu->GetAmpduSubframe (i), channelFreqMhz, txVector, aMpdu, signalNoise, staId); } ++i; aMpdu.type = (i == (nMpdus - 1)) ? LAST_MPDU_IN_AGGREGATE : MIDDLE_MPDU_IN_AGGREGATE; @@ -2668,12 +2668,12 @@ WifiPhy::NotifyMonitorSniffRx (Ptr psdu, uint16_t channelFreqMhz { aMpdu.type = NORMAL_MPDU; NS_ASSERT_MSG (statusPerMpdu.size () == 1, "Should have one reception status for normal MPDU"); - m_phyMonitorSniffRxTrace (psdu->GetPacket (), channelFreqMhz, txVector, aMpdu, signalNoise); + m_phyMonitorSniffRxTrace (psdu->GetPacket (), channelFreqMhz, txVector, aMpdu, signalNoise, staId); } } void -WifiPhy::NotifyMonitorSniffTx (Ptr psdu, uint16_t channelFreqMhz, WifiTxVector txVector) +WifiPhy::NotifyMonitorSniffTx (Ptr psdu, uint16_t channelFreqMhz, WifiTxVector txVector, uint16_t staId) { MpduInfo aMpdu; if (psdu->IsAggregate ()) @@ -2685,7 +2685,7 @@ WifiPhy::NotifyMonitorSniffTx (Ptr psdu, uint16_t channelFreqMhz aMpdu.type = (psdu->IsSingle ()) ? SINGLE_MPDU: FIRST_MPDU_IN_AGGREGATE; for (size_t i = 0; i < nMpdus;) { - m_phyMonitorSniffTxTrace (psdu->GetAmpduSubframe (i), channelFreqMhz, txVector, aMpdu); + m_phyMonitorSniffTxTrace (psdu->GetAmpduSubframe (i), channelFreqMhz, txVector, aMpdu, staId); ++i; aMpdu.type = (i == (nMpdus - 1)) ? LAST_MPDU_IN_AGGREGATE : MIDDLE_MPDU_IN_AGGREGATE; } @@ -2693,7 +2693,7 @@ WifiPhy::NotifyMonitorSniffTx (Ptr psdu, uint16_t channelFreqMhz else { aMpdu.type = NORMAL_MPDU; - m_phyMonitorSniffTxTrace (psdu->GetPacket (), channelFreqMhz, txVector, aMpdu); + m_phyMonitorSniffTxTrace (psdu->GetPacket (), channelFreqMhz, txVector, aMpdu, staId); } } @@ -2771,7 +2771,10 @@ WifiPhy::Send (WifiConstPsduMap psdus, WifiTxVector txVector) double txPowerW = DbmToW (GetTxPowerForTransmission (txVector) + GetTxGain ()); NotifyTxBegin (psdus, txPowerW); m_phyTxPsduBeginTrace (psdus, txVector, txPowerW); - NotifyMonitorSniffTx (psdus.begin()->second, GetFrequency (), txVector); //TODO: fix for MU + for (auto const& psdu : psdus) + { + NotifyMonitorSniffTx (psdu.second, GetFrequency (), txVector, psdu.first); + } m_state->SwitchToTx (txDuration, psdus, GetPowerDbm (txVector.GetTxPowerLevel ()), txVector); Ptr ppdu = Create (psdus, txVector, txDuration, GetPhyBand ()); @@ -3254,7 +3257,7 @@ WifiPhy::EndReceive (Ptr event) { //At least one MPDU has been successfully received WifiTxVector txVector = event->GetTxVector (); - NotifyMonitorSniffRx (psdu, GetFrequency (), txVector, m_signalNoise, m_statusPerMpdu); + NotifyMonitorSniffRx (psdu, GetFrequency (), txVector, m_signalNoise, m_statusPerMpdu, staId); m_state->SwitchFromRxEndOk (Copy (psdu), snr, txVector, staId, m_statusPerMpdu); } else diff --git a/src/wifi/model/wifi-phy.h b/src/wifi/model/wifi-phy.h index 7450c0d8a..cac787303 100644 --- a/src/wifi/model/wifi-phy.h +++ b/src/wifi/model/wifi-phy.h @@ -1358,12 +1358,14 @@ public: * \param txVector the TXVECTOR that holds RX parameters * \param signalNoise signal power and noise power in dBm (noise power includes the noise figure) * \param statusPerMpdu reception status per MPDU + * \param staId the STA-ID */ void NotifyMonitorSniffRx (Ptr psdu, uint16_t channelFreqMhz, WifiTxVector txVector, SignalNoiseDbm signalNoise, - std::vector statusPerMpdu); + std::vector statusPerMpdu, + uint16_t staId = SU_STA_ID); /** * TracedCallback signature for monitor mode receive events. @@ -1381,6 +1383,7 @@ public: * \param aMpdu the type of the packet (0 is not A-MPDU, 1 is a MPDU that is part of an A-MPDU and 2 is the last MPDU in an A-MPDU) * and the A-MPDU reference number (must be a different value for each A-MPDU but the same for each subframe within one A-MPDU) * \param signalNoise signal power and noise power in dBm + * \param staId the STA-ID * \todo WifiTxVector should be passed by const reference because * of its size. */ @@ -1388,7 +1391,8 @@ public: uint16_t channelFreqMhz, WifiTxVector txVector, MpduInfo aMpdu, - SignalNoiseDbm signalNoise); + SignalNoiseDbm signalNoise, + uint16_t staId); /** * Public method used to fire a MonitorSniffer trace for a wifi PSDU being transmitted. @@ -1401,10 +1405,12 @@ public: * \param channelFreqMhz the frequency in MHz at which the packet is * transmitted. * \param txVector the TXVECTOR that holds TX parameters + * \param staId the STA-ID */ void NotifyMonitorSniffTx (Ptr psdu, uint16_t channelFreqMhz, - WifiTxVector txVector); + WifiTxVector txVector, + uint16_t staId = SU_STA_ID); /** * TracedCallback signature for monitor mode transmit events. @@ -1415,13 +1421,15 @@ public: * \param txVector the TXVECTOR that holds TX parameters * \param aMpdu the type of the packet (0 is not A-MPDU, 1 is a MPDU that is part of an A-MPDU and 2 is the last MPDU in an A-MPDU) * and the A-MPDU reference number (must be a different value for each A-MPDU but the same for each subframe within one A-MPDU) + * \param staId the STA-ID * \todo WifiTxVector should be passed by const reference because * of its size. */ typedef void (* MonitorSnifferTxCallback)(const Ptr packet, uint16_t channelFreqMhz, WifiTxVector txVector, - MpduInfo aMpdu); + MpduInfo aMpdu, + uint16_t staId); /** * TracedCallback signature for PSDU transmit events. @@ -2052,7 +2060,7 @@ private: * \todo WifiTxVector and signalNoiseDbm should be be passed as * const references because of their sizes. */ - TracedCallback, uint16_t, WifiTxVector, MpduInfo, SignalNoiseDbm> m_phyMonitorSniffRxTrace; + TracedCallback, uint16_t /* frequency (MHz) */, WifiTxVector, MpduInfo, SignalNoiseDbm, uint16_t /* STA-ID*/> m_phyMonitorSniffRxTrace; /** * A trace source that emulates a Wi-Fi device in monitor mode @@ -2066,7 +2074,7 @@ private: * \todo WifiTxVector should be passed by const reference because * of its size. */ - TracedCallback, uint16_t, WifiTxVector, MpduInfo> m_phyMonitorSniffTxTrace; + TracedCallback, uint16_t /* frequency (MHz) */, WifiTxVector, MpduInfo, uint16_t /* STA-ID*/> m_phyMonitorSniffTxTrace; /** * A trace source that indicates the end of both HE SIG fields as well as training fields for received 802.11ax packets diff --git a/src/wifi/test/wifi-test.cc b/src/wifi/test/wifi-test.cc index 84b0af04d..2f3a469bc 100644 --- a/src/wifi/test/wifi-test.cc +++ b/src/wifi/test/wifi-test.cc @@ -1957,8 +1957,9 @@ private: * \param txVector the TX vector * \param aMpdu the A-MPDU info * \param signalNoise the signal noise in dBm + * \param staId the STA-ID */ - void RxCallback (std::string context, Ptr p, uint16_t channelFreqMhz, WifiTxVector txVector, MpduInfo aMpdu, SignalNoiseDbm signalNoise); + void RxCallback (std::string context, Ptr p, uint16_t channelFreqMhz, WifiTxVector txVector, MpduInfo aMpdu, SignalNoiseDbm signalNoise, uint16_t staId); /** * Callback when packet is dropped * \param context node context @@ -2031,7 +2032,7 @@ Bug2470TestCase::AddbaStateChangedCallback (std::string context, Time t, Mac48Ad } void -Bug2470TestCase::RxCallback (std::string context, Ptr p, uint16_t channelFreqMhz, WifiTxVector txVector, MpduInfo aMpdu, SignalNoiseDbm signalNoise) +Bug2470TestCase::RxCallback (std::string context, Ptr p, uint16_t channelFreqMhz, WifiTxVector txVector, MpduInfo aMpdu, SignalNoiseDbm signalNoise, uint16_t staId) { Ptr packet = p->Copy (); if (aMpdu.type != MpduType::NORMAL_MPDU)