diff --git a/examples/wireless/wifi-power-adaptation-distance.cc b/examples/wireless/wifi-power-adaptation-distance.cc index df8194b62..a3082b06f 100644 --- a/examples/wireless/wifi-power-adaptation-distance.cc +++ b/examples/wireless/wifi-power-adaptation-distance.cc @@ -272,9 +272,9 @@ NodeStatistics::PhyCallback(std::string path, Ptr packet, double p if (head.GetType() == WIFI_MAC_DATA) { - m_totalEnergy += pow(10.0, m_currentPower[dest] / 10.0) * - GetCalcTxTime(m_currentRate[dest]).GetSeconds(); - m_totalTime += GetCalcTxTime(m_currentRate[dest]).GetSeconds(); + const auto txTimeSeconds = GetCalcTxTime(m_currentRate[dest]).GetSeconds(); + m_totalEnergy += DbmToW(m_currentPower[dest]) * txTimeSeconds; + m_totalTime += txTimeSeconds; } } diff --git a/examples/wireless/wifi-power-adaptation-interference.cc b/examples/wireless/wifi-power-adaptation-interference.cc index 7d032d579..60cc17cbf 100644 --- a/examples/wireless/wifi-power-adaptation-interference.cc +++ b/examples/wireless/wifi-power-adaptation-interference.cc @@ -293,9 +293,9 @@ NodeStatistics::PhyCallback(std::string path, Ptr packet, double p if (head.GetType() == WIFI_MAC_DATA) { - m_totalEnergy += pow(10.0, m_currentPower[dest] / 10.0) * - GetCalcTxTime(m_currentRate[dest]).GetSeconds(); - m_totalTime += GetCalcTxTime(m_currentRate[dest]).GetSeconds(); + const auto txTimeSeconds = GetCalcTxTime(m_currentRate[dest]).GetSeconds(); + m_totalEnergy += DbmToW(m_currentPower[dest]) * txTimeSeconds; + m_totalTime += txTimeSeconds; } }