From 3034748f9ad806e49134d3459fa0bba836b84301 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Deronne?= Date: Wed, 26 Jul 2023 20:35:14 +0200 Subject: [PATCH] wifi: Store transmission width in WifiPpdu --- src/wifi/model/he/he-ppdu.cc | 8 ++++---- src/wifi/model/he/he-ppdu.h | 2 +- src/wifi/model/wifi-phy.cc | 2 +- src/wifi/model/wifi-ppdu.cc | 15 ++++++++------- src/wifi/model/wifi-ppdu.h | 10 ++++++++-- src/wifi/model/yans-wifi-channel.cc | 2 +- 6 files changed, 23 insertions(+), 16 deletions(-) diff --git a/src/wifi/model/he/he-ppdu.cc b/src/wifi/model/he/he-ppdu.cc index 7449c0ab0..569a26f97 100644 --- a/src/wifi/model/he/he-ppdu.cc +++ b/src/wifi/model/he/he-ppdu.cc @@ -413,10 +413,10 @@ HePpdu::GetStaId() const } uint16_t -HePpdu::GetTransmissionChannelWidth() const +HePpdu::GetTxChannelWidth() const { - const auto& txVector = GetTxVector(); - if (txVector.IsUlMu() && GetStaId() != SU_STA_ID) + if (const auto& txVector = GetTxVector(); + txVector.IsValid() && txVector.IsUlMu() && GetStaId() != SU_STA_ID) { TxPsdFlag flag = GetTxPsdFlag(); uint16_t ruWidth = HeRu::GetBandwidth(txVector.GetRu(GetStaId()).GetRuType()); @@ -427,7 +427,7 @@ HePpdu::GetTransmissionChannelWidth() const } else { - return OfdmPpdu::GetTransmissionChannelWidth(); + return OfdmPpdu::GetTxChannelWidth(); } } diff --git a/src/wifi/model/he/he-ppdu.h b/src/wifi/model/he/he-ppdu.h index 8713f9c39..76e49adbb 100644 --- a/src/wifi/model/he/he-ppdu.h +++ b/src/wifi/model/he/he-ppdu.h @@ -154,7 +154,7 @@ class HePpdu : public OfdmPpdu Ptr Copy() const override; WifiPpduType GetType() const override; uint16_t GetStaId() const override; - uint16_t GetTransmissionChannelWidth() const override; + uint16_t GetTxChannelWidth() const override; /** * Get the payload of the PPDU. diff --git a/src/wifi/model/wifi-phy.cc b/src/wifi/model/wifi-phy.cc index 51e340b36..7d7958121 100644 --- a/src/wifi/model/wifi-phy.cc +++ b/src/wifi/model/wifi-phy.cc @@ -2185,7 +2185,7 @@ WifiPhy::GetTxPowerForTransmission(Ptr ppdu) const } // Apply power density constraint on EIRP - uint16_t channelWidth = ppdu->GetTransmissionChannelWidth(); + uint16_t channelWidth = ppdu->GetTxChannelWidth(); double txPowerDbmPerMhz = (txPowerDbm + GetTxGain()) - RatioToDb(channelWidth); // account for antenna gain since EIRP NS_LOG_INFO("txPowerDbm=" << txPowerDbm << " with txPowerDbmPerMhz=" << txPowerDbmPerMhz diff --git a/src/wifi/model/wifi-ppdu.cc b/src/wifi/model/wifi-ppdu.cc index b04e61279..b68a6c37c 100644 --- a/src/wifi/model/wifi-ppdu.cc +++ b/src/wifi/model/wifi-ppdu.cc @@ -43,7 +43,8 @@ WifiPpdu::WifiPpdu(Ptr psdu, m_operatingChannel(channel), m_truncatedTx(false), m_txPowerLevel(txVector.GetTxPowerLevel()), - m_txAntennas(txVector.GetNTx()) + m_txAntennas(txVector.GetNTx()), + m_txChannelWidth(txVector.GetChannelWidth()) { NS_LOG_FUNCTION(this << *psdu << txVector << channel << uid); m_psdus.insert(std::make_pair(SU_STA_ID, psdu)); @@ -64,7 +65,8 @@ WifiPpdu::WifiPpdu(const WifiConstPsduMap& psdus, m_operatingChannel(channel), m_truncatedTx(false), m_txPowerLevel(txVector.GetTxPowerLevel()), - m_txAntennas(txVector.GetNTx()) + m_txAntennas(txVector.GetNTx()), + m_txChannelWidth(txVector.GetChannelWidth()) { NS_LOG_FUNCTION(this << psdus << txVector << channel << uid); m_psdus = psdus; @@ -140,9 +142,9 @@ WifiPpdu::GetModulation() const } uint16_t -WifiPpdu::GetTransmissionChannelWidth() const +WifiPpdu::GetTxChannelWidth() const { - return GetTxVector().GetChannelWidth(); + return m_txChannelWidth; } uint16_t @@ -155,9 +157,8 @@ bool WifiPpdu::DoesOverlapChannel(uint16_t minFreq, uint16_t maxFreq) const { NS_LOG_FUNCTION(this << m_txCenterFreq << minFreq << maxFreq); - uint16_t txChannelWidth = GetTxVector().GetChannelWidth(); - uint16_t minTxFreq = m_txCenterFreq - txChannelWidth / 2; - uint16_t maxTxFreq = m_txCenterFreq + txChannelWidth / 2; + uint16_t minTxFreq = m_txCenterFreq - m_txChannelWidth / 2; + uint16_t maxTxFreq = m_txCenterFreq + m_txChannelWidth / 2; /** * The PPDU does not overlap the channel in two cases. * diff --git a/src/wifi/model/wifi-ppdu.h b/src/wifi/model/wifi-ppdu.h index 7cbfc08de..a8364bc1e 100644 --- a/src/wifi/model/wifi-ppdu.h +++ b/src/wifi/model/wifi-ppdu.h @@ -134,7 +134,7 @@ class WifiPpdu : public SimpleRefCount * * \return the effective channel width (in MHz) used for the tranmsission */ - virtual uint16_t GetTransmissionChannelWidth() const; + virtual uint16_t GetTxChannelWidth() const; /** * \return the center frequency (MHz) used for the transmission of this PPDU @@ -222,7 +222,13 @@ class WifiPpdu : public SimpleRefCount uint8_t m_txPowerLevel; //!< the transmission power level (used only for TX and initializing the //!< returned WifiTxVector) uint8_t m_txAntennas; //!< the number of antennas used to transmit this PPDU -}; // class WifiPpdu + + uint16_t m_txChannelWidth; /**< The channel width (MHz) used for the transmission of this + PPDU. This has to be stored since channel width can not + always be obtained from the PHY headers, especially for + non-HT PPDU, since we do not sense the spectrum to + determine the occupied channel width for simplicity. */ +}; // class WifiPpdu /** * \brief Stream insertion operator. diff --git a/src/wifi/model/yans-wifi-channel.cc b/src/wifi/model/yans-wifi-channel.cc index 7e66c9c4f..419b48e13 100644 --- a/src/wifi/model/yans-wifi-channel.cc +++ b/src/wifi/model/yans-wifi-channel.cc @@ -137,7 +137,7 @@ YansWifiChannel::Receive(Ptr phy, Ptr ppdu, double // Do no further processing if signal is too weak // Current implementation assumes constant RX power over the PPDU duration // Compare received TX power per MHz to normalized RX sensitivity - uint16_t txWidth = ppdu->GetTransmissionChannelWidth(); + uint16_t txWidth = ppdu->GetTxChannelWidth(); if ((rxPowerDbm + phy->GetRxGain()) < phy->GetRxSensitivity() + RatioToDb(txWidth / 20.0)) { NS_LOG_INFO("Received signal too weak to process: " << rxPowerDbm << " dBm");