From c288ebbbe7a66a9145a8f17daa37f7860fd5c0df Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Deronne?= Date: Thu, 8 Aug 2024 09:47:57 +0200 Subject: [PATCH] wifi: Reduce amount of Watt/dBm conversion --- src/wifi/model/he/constant-obss-pd-algorithm.cc | 12 ++++++------ src/wifi/model/he/he-phy.cc | 7 ++++--- src/wifi/model/he/he-phy.h | 2 +- src/wifi/model/he/obss-pd-algorithm.cc | 2 +- src/wifi/model/wifi-phy.cc | 8 ++++---- src/wifi/model/wifi-phy.h | 10 +++++----- 6 files changed, 21 insertions(+), 20 deletions(-) diff --git a/src/wifi/model/he/constant-obss-pd-algorithm.cc b/src/wifi/model/he/constant-obss-pd-algorithm.cc index e3bd8f15077..d95adb4899f 100644 --- a/src/wifi/model/he/constant-obss-pd-algorithm.cc +++ b/src/wifi/model/he/constant-obss-pd-algorithm.cc @@ -72,7 +72,7 @@ ConstantObssPdAlgorithm::ConnectWifiNetDevice(const Ptr device) void ConstantObssPdAlgorithm::ReceiveHeSigA(HeSigAParameters params) { - NS_LOG_FUNCTION(this << +params.bssColor << WToDbm(params.rssiW)); + NS_LOG_FUNCTION(this << +params.bssColor << params.rssiDbm); Ptr mac = m_device->GetMac()->GetObject(); if (mac && !mac->IsAssociated()) @@ -100,12 +100,12 @@ ConstantObssPdAlgorithm::ReceiveHeSigA(HeSigAParameters params) bool isObss = (bssColor != params.bssColor); if (isObss) { - const double obssPdLevel = GetObssPdLevel(); - if (WToDbm(params.rssiW) < obssPdLevel) + const auto obssPdLevel = GetObssPdLevel(); + if (params.rssiDbm < obssPdLevel) { - NS_LOG_DEBUG("Frame is OBSS and RSSI " << WToDbm(params.rssiW) - << " is below OBSS-PD level of " << obssPdLevel - << "; reset PHY to IDLE"); + NS_LOG_DEBUG("Frame is OBSS and RSSI " + << params.rssiDbm << " dBm is below OBSS-PD level of " << obssPdLevel + << " dBm; reset PHY to IDLE"); ResetPhy(params); } else diff --git a/src/wifi/model/he/he-phy.cc b/src/wifi/model/he/he-phy.cc index 4b0189f6606..d366df57912 100644 --- a/src/wifi/model/he/he-phy.cc +++ b/src/wifi/model/he/he-phy.cc @@ -612,9 +612,10 @@ HePhy::ProcessSigA(Ptr event, PhyFieldRxStatus status) NS_LOG_FUNCTION(this << *event << status); // Notify end of SIG-A (in all cases) const auto& txVector = event->GetPpdu()->GetTxVector(); - HeSigAParameters params; - params.rssiW = GetRxPowerWForPpdu(event); - params.bssColor = txVector.GetBssColor(); + HeSigAParameters params{ + .rssiDbm = WToDbm(GetRxPowerWForPpdu(event)), + .bssColor = txVector.GetBssColor(), + }; NotifyEndOfHeSigA(params); // if OBSS_PD CCA_RESET, set power restriction first and wait till // field is processed before switching to IDLE diff --git a/src/wifi/model/he/he-phy.h b/src/wifi/model/he/he-phy.h index e1a233622f2..23b1915e305 100644 --- a/src/wifi/model/he/he-phy.h +++ b/src/wifi/model/he/he-phy.h @@ -53,7 +53,7 @@ class ObssPdAlgorithm; */ struct HeSigAParameters { - double rssiW; ///< RSSI in W + double rssiDbm; ///< RSSI in dBm uint8_t bssColor; ///< BSS color }; diff --git a/src/wifi/model/he/obss-pd-algorithm.cc b/src/wifi/model/he/obss-pd-algorithm.cc index 9b88a85dfb0..ada910f8f85 100644 --- a/src/wifi/model/he/obss-pd-algorithm.cc +++ b/src/wifi/model/he/obss-pd-algorithm.cc @@ -116,7 +116,7 @@ ObssPdAlgorithm::ResetPhy(HeSigAParameters params) txPowerMaxMimo = m_txPowerRefMimo - (m_obssPdLevel - m_obssPdLevelMin); powerRestricted = true; } - m_resetEvent(bssColor, WToDbm(params.rssiW), powerRestricted, txPowerMaxSiso, txPowerMaxMimo); + m_resetEvent(bssColor, params.rssiDbm, powerRestricted, txPowerMaxSiso, txPowerMaxMimo); phy->ResetCca(powerRestricted, txPowerMaxSiso, txPowerMaxMimo); } diff --git a/src/wifi/model/wifi-phy.cc b/src/wifi/model/wifi-phy.cc index 4cc2139a213..940234067d9 100644 --- a/src/wifi/model/wifi-phy.cc +++ b/src/wifi/model/wifi-phy.cc @@ -526,26 +526,26 @@ void WifiPhy::SetCcaEdThreshold(double threshold) { NS_LOG_FUNCTION(this << threshold); - m_ccaEdThresholdW = DbmToW(threshold); + m_ccaEdThresholdDbm = threshold; } double WifiPhy::GetCcaEdThreshold() const { - return WToDbm(m_ccaEdThresholdW); + return m_ccaEdThresholdDbm; } void WifiPhy::SetCcaSensitivityThreshold(double threshold) { NS_LOG_FUNCTION(this << threshold); - m_ccaSensitivityThresholdW = DbmToW(threshold); + m_ccaSensitivityThresholdDbm = threshold; } double WifiPhy::GetCcaSensitivityThreshold() const { - return WToDbm(m_ccaSensitivityThresholdW); + return m_ccaSensitivityThresholdDbm; } void diff --git a/src/wifi/model/wifi-phy.h b/src/wifi/model/wifi-phy.h index 3611ec3af84..42bed8e430e 100644 --- a/src/wifi/model/wifi-phy.h +++ b/src/wifi/model/wifi-phy.h @@ -1609,11 +1609,11 @@ class WifiPhy : public Object Time m_ackTxTime; //!< estimated Ack TX time Time m_blockAckTxTime; //!< estimated BlockAck TX time - double m_rxSensitivityDbm; //!< Receive sensitivity threshold in dBm - double m_ccaEdThresholdW; //!< Clear channel assessment (CCA) energy detection (ED) threshold in - //!< watts - double m_ccaSensitivityThresholdW; //!< Clear channel assessment (CCA) modulation and coding - //!< rate sensitivity threshold in watts + double m_rxSensitivityDbm; //!< Receive sensitivity threshold in dBm + double m_ccaEdThresholdDbm; //!< Clear channel assessment (CCA) energy detection (ED) threshold + //!< in dBm + double m_ccaSensitivityThresholdDbm; //!< Clear channel assessment (CCA) modulation and coding + //!< rate sensitivity threshold in dBm double m_txGainDb; //!< Transmission gain (dB) double m_rxGainDb; //!< Reception gain (dB)