examples: Fix incorrect energy calculation in wifi power adaptation examples

This commit is contained in:
Sébastien Deronne
2024-10-29 16:04:17 +01:00
parent afeec2978c
commit ce2239202c
2 changed files with 6 additions and 6 deletions

View File

@@ -272,9 +272,9 @@ NodeStatistics::PhyCallback(std::string path, Ptr<const Packet> 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;
}
}

View File

@@ -293,9 +293,9 @@ NodeStatistics::PhyCallback(std::string path, Ptr<const Packet> 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;
}
}