Skip to content

Commit

Permalink
wifi: Reduce amount of Watt/dBm conversion
Browse files Browse the repository at this point in the history
  • Loading branch information
sderonne authored and Sébastien Deronne committed Sep 2, 2024
1 parent 7a8da34 commit c288ebb
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 20 deletions.
12 changes: 6 additions & 6 deletions src/wifi/model/he/constant-obss-pd-algorithm.cc
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ ConstantObssPdAlgorithm::ConnectWifiNetDevice(const Ptr<WifiNetDevice> device)
void
ConstantObssPdAlgorithm::ReceiveHeSigA(HeSigAParameters params)
{
NS_LOG_FUNCTION(this << +params.bssColor << WToDbm(params.rssiW));
NS_LOG_FUNCTION(this << +params.bssColor << params.rssiDbm);

Ptr<StaWifiMac> mac = m_device->GetMac()->GetObject<StaWifiMac>();
if (mac && !mac->IsAssociated())
Expand Down Expand Up @@ -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
Expand Down
7 changes: 4 additions & 3 deletions src/wifi/model/he/he-phy.cc
Original file line number Diff line number Diff line change
Expand Up @@ -612,9 +612,10 @@ HePhy::ProcessSigA(Ptr<Event> 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

Expand Down
2 changes: 1 addition & 1 deletion src/wifi/model/he/he-phy.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ class ObssPdAlgorithm;
*/
struct HeSigAParameters
{
double rssiW; ///< RSSI in W
double rssiDbm; ///< RSSI in dBm
uint8_t bssColor; ///< BSS color
};

Expand Down
2 changes: 1 addition & 1 deletion src/wifi/model/he/obss-pd-algorithm.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
8 changes: 4 additions & 4 deletions src/wifi/model/wifi-phy.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 5 additions & 5 deletions src/wifi/model/wifi-phy.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit c288ebb

Please sign in to comment.