From c7ff001548f468d0d775b747771307c68bb4bfbf Mon Sep 17 00:00:00 2001 From: Rediet Date: Tue, 26 Jan 2021 16:35:57 +0100 Subject: [PATCH] wifi: Move EndOfHeSigA callback to HePhy WifiPhy::GetPhyEntity now returns a non-const pointer (needed to connect callback) --- src/wifi/model/constant-obss-pd-algorithm.cc | 5 ++- src/wifi/model/he-phy.cc | 17 +++++++- src/wifi/model/he-phy.h | 38 ++++++++++++++++- src/wifi/model/obss-pd-algorithm.cc | 1 + src/wifi/model/wifi-phy.cc | 21 +--------- src/wifi/model/wifi-phy.h | 44 +------------------- 6 files changed, 61 insertions(+), 65 deletions(-) diff --git a/src/wifi/model/constant-obss-pd-algorithm.cc b/src/wifi/model/constant-obss-pd-algorithm.cc index 2f59f08e2..8a7afd221 100644 --- a/src/wifi/model/constant-obss-pd-algorithm.cc +++ b/src/wifi/model/constant-obss-pd-algorithm.cc @@ -27,6 +27,7 @@ #include "sta-wifi-mac.h" #include "wifi-utils.h" #include "wifi-phy.h" +#include "he-phy.h" #include "wifi-net-device.h" #include "he-configuration.h" @@ -56,7 +57,9 @@ void ConstantObssPdAlgorithm::ConnectWifiNetDevice (const Ptr device) { Ptr phy = device->GetPhy (); - phy->TraceConnectWithoutContext ("EndOfHeSigA", MakeCallback (&ConstantObssPdAlgorithm::ReceiveHeSigA, this)); + auto hePhy = DynamicCast (phy->GetPhyEntity (WIFI_MOD_CLASS_HE)); + NS_ASSERT (hePhy); + hePhy->SetEndOfHeSigACallback (MakeCallback (&ConstantObssPdAlgorithm::ReceiveHeSigA, this)); ObssPdAlgorithm::ConnectWifiNetDevice (device); } diff --git a/src/wifi/model/he-phy.cc b/src/wifi/model/he-phy.cc index 7e675cbc3..134a5769d 100644 --- a/src/wifi/model/he-phy.cc +++ b/src/wifi/model/he-phy.cc @@ -515,7 +515,7 @@ HePhy::ProcessSigA (Ptr event, PhyFieldRxStatus status) HeSigAParameters params; params.rssiW = GetRxPowerWForPpdu (event); params.bssColor = event->GetTxVector ().GetBssColor (); - Simulator::ScheduleNow (&WifiPhy::NotifyEndOfHeSigA, GetPointer (m_wifiPhy), params); + Simulator::ScheduleNow (&HePhy::NotifyEndOfHeSigA, this, params); //finish field processing first if (status.isSuccess) { @@ -549,6 +549,21 @@ HePhy::ProcessSigA (Ptr event, PhyFieldRxStatus status) return status; } +void +HePhy::SetEndOfHeSigACallback (EndOfHeSigACallback callback) +{ + m_endOfHeSigACallback = callback; +} + +void +HePhy::NotifyEndOfHeSigA (HeSigAParameters params) +{ + if (!m_endOfHeSigACallback.IsNull ()) + { + m_endOfHeSigACallback (params); + } +} + PhyEntity::PhyFieldRxStatus HePhy::ProcessSigB (Ptr event, PhyFieldRxStatus status) { diff --git a/src/wifi/model/he-phy.h b/src/wifi/model/he-phy.h index 6709991ca..464c6220c 100644 --- a/src/wifi/model/he-phy.h +++ b/src/wifi/model/he-phy.h @@ -24,11 +24,13 @@ #include "vht-phy.h" #include "wifi-phy-band.h" +#include "ns3/callback.h" /** * \file * \ingroup wifi - * Declaration of ns3::HePhy class. + * Declaration of ns3::HePhy class + * and ns3::HeSigAParameters struct. */ namespace ns3 { @@ -38,6 +40,15 @@ namespace ns3 { */ #define HE_PHY 125 +/** + * Parameters for received HE-SIG-A for OBSS_PD based SR + */ +struct HeSigAParameters +{ + double rssiW; ///< RSSI in W + uint8_t bssColor; ///< BSS color +}; + /** * \brief PHY entity for HE (11ax) * \ingroup wifi @@ -49,6 +60,13 @@ namespace ns3 { class HePhy : public VhtPhy { public: + /** + * Callback upon end of HE-SIG-A + * + * arg1: Parameters of HE-SIG-A + */ + typedef Callback EndOfHeSigACallback; + /** * Constructor for HE PHY * @@ -144,6 +162,22 @@ public: */ uint16_t GetCenterFrequencyForNonOfdmaPart (WifiTxVector txVector, uint16_t staId) const; + /** + * Set a callback for a end of HE-SIG-A. + * + * \param callback the EndOfHeSigACallback to set + */ + void SetEndOfHeSigACallback (EndOfHeSigACallback callback); + + /** + * Fire a EndOfHeSigA callback (if connected) once HE-SIG-A field has been received. + * This method is scheduled immediatly after end of HE-SIG-A, once + * field processing is finished. + * + * \param params the HE-SIG-A parameters + */ + void NotifyEndOfHeSigA (HeSigAParameters params); + /** * Initialize all HE modes. */ @@ -257,6 +291,8 @@ protected: std::map m_beginOfdmaPayloadRxEvents; //!< the beginning of the OFDMA payload reception events (indexed by STA-ID) + EndOfHeSigACallback m_endOfHeSigACallback; //!< end of HE-SIG-A callback + private: // Inherited virtual void BuildModeList (void) override; diff --git a/src/wifi/model/obss-pd-algorithm.cc b/src/wifi/model/obss-pd-algorithm.cc index 1d3562043..64f2d535e 100644 --- a/src/wifi/model/obss-pd-algorithm.cc +++ b/src/wifi/model/obss-pd-algorithm.cc @@ -24,6 +24,7 @@ #include "obss-pd-algorithm.h" #include "wifi-net-device.h" #include "wifi-phy.h" +#include "he-phy.h" #include "wifi-utils.h" namespace ns3 { diff --git a/src/wifi/model/wifi-phy.cc b/src/wifi/model/wifi-phy.cc index 94c17c743..c6aefef10 100644 --- a/src/wifi/model/wifi-phy.cc +++ b/src/wifi/model/wifi-phy.cc @@ -508,10 +508,6 @@ WifiPhy::GetTypeId (void) "in monitor mode to sniff all frames being transmitted", MakeTraceSourceAccessor (&WifiPhy::m_phyMonitorSniffTxTrace), "ns3::WifiPhy::MonitorSnifferTxTracedCallback") - .AddTraceSource ("EndOfHeSigA", - "Trace source indicating the end of the HE-SIG-A field for HE PPDUs (or more recent)", - MakeTraceSourceAccessor (&WifiPhy::m_phyEndOfHeSigATrace), - "ns3::WifiPhy::EndOfHeSigATracedCallback") ; return tid; } @@ -966,7 +962,7 @@ WifiPhy::GetStaticPhyEntity (WifiModulationClass modulation) return it->second; } -const Ptr +Ptr WifiPhy::GetPhyEntity (WifiModulationClass modulation) const { const auto it = m_phyEntities.find (modulation); @@ -974,15 +970,6 @@ WifiPhy::GetPhyEntity (WifiModulationClass modulation) const return it->second; } -Ptr -WifiPhy::GetPhyEntity (WifiModulationClass modulation) -{ - //This method returns a non-const pointer to be used by child classes - const auto it = m_phyEntities.find (modulation); - NS_ABORT_MSG_IF (it == m_phyEntities.end (), "Unsupported Wi-Fi modulation class"); - return it->second; -} - void WifiPhy::AddStaticPhyEntity (WifiModulationClass modulation, Ptr phyEntity) { @@ -2006,12 +1993,6 @@ WifiPhy::NotifyMonitorSniffTx (Ptr psdu, uint16_t channelFreqMhz } } -void -WifiPhy::NotifyEndOfHeSigA (HeSigAParameters params) -{ - m_phyEndOfHeSigATrace (params); //TODO to move to HePhy -} - void WifiPhy::Send (Ptr psdu, WifiTxVector txVector) { diff --git a/src/wifi/model/wifi-phy.h b/src/wifi/model/wifi-phy.h index 8fac28000..1d933dda2 100644 --- a/src/wifi/model/wifi-phy.h +++ b/src/wifi/model/wifi-phy.h @@ -39,13 +39,6 @@ class PreambleDetectionModel; class WifiRadioEnergyModel; class UniformRandomVariable; -/// Parameters for received HE-SIG-A for OBSS_PD based SR -struct HeSigAParameters -{ - double rssiW; ///< RSSI in W - uint8_t bssColor; ///< BSS color -}; - /** * \brief 802.11 PHY layer model * \ingroup wifi @@ -676,21 +669,6 @@ public: */ typedef void (* PsduTxBeginCallback)(WifiConstPsduMap psduMap, WifiTxVector txVector, double txPowerW); - /** - * Public method used to fire a EndOfHeSigA trace once HE-SIG-A field has been received. - * - * \param params the HE-SIG-A parameters - */ - void NotifyEndOfHeSigA (HeSigAParameters params); - - /** - * TracedCallback signature for end of HE-SIG-A events. - * - * - * \param params the HE-SIG-A parameters - */ - typedef void (* EndOfHeSigACallback)(HeSigAParameters params); - /** * TracedCallback signature for start of PSDU reception events. * @@ -1011,9 +989,9 @@ public: * the WifiPhy instance. * * \param modulation the modulation class - * \return the const pointer to the supported PHY entity + * \return the pointer to the supported PHY entity */ - const Ptr GetPhyEntity (WifiModulationClass modulation) const; + Ptr GetPhyEntity (WifiModulationClass modulation) const; /** * \return the UID of the previously received PPDU (reset to UINT64_MAX upon transmission) @@ -1116,17 +1094,6 @@ protected: * \param phyEntity the PHY entity */ void AddPhyEntity (WifiModulationClass modulation, Ptr phyEntity); - /** - * Get the supported PHY entity corresponding to the modulation class, for - * the WifiPhy instance. - * - * This method enables child classes to retrieve the non-const pointer to - * the supported PHY entity. - * - * \param modulation the modulation class - * \return the non-const pointer to the supported PHY entity - */ - Ptr GetPhyEntity (WifiModulationClass modulation); InterferenceHelper m_interference; //!< the class handling interference computations Ptr m_random; //!< Provides uniform random variables. @@ -1379,13 +1346,6 @@ private: */ TracedCallback, uint16_t /* frequency (MHz) */, WifiTxVector, MpduInfo, uint16_t /* STA-ID*/> m_phyMonitorSniffTxTrace; - /** - * A trace source that indicates the end of HE SIG-A field for received 802.11ax PPDUs - * - * \see class CallBackTraceSource - */ - TracedCallback m_phyEndOfHeSigATrace; - /** * Map of __implemented__ PHY entities. This is used to compute the different * amendment-specific parameters in a static manner.