Bug 2154 [wifi] - Incorrect power calculation in wifi power adaptation examples

This commit is contained in:
Matias Richart
2015-07-22 23:16:53 +02:00
parent cb8b2a5ad1
commit c971b0de7d
2 changed files with 14 additions and 10 deletions

View File

@@ -197,9 +197,11 @@ NodeStatistics::PhyCallback (std::string path, Ptr<const Packet> packet)
packet->PeekHeader (head);
Mac48Address dest = head.GetAddr1 ();
totalEnergy += actualPower[dest] * GetCalcTxTime (actualMode[dest]).GetSeconds ();
totalTime += GetCalcTxTime (actualMode[dest]).GetSeconds ();
if (head.GetType() == WIFI_MAC_DATA)
{
totalEnergy += pow (10, actualPower[dest] / 10) * GetCalcTxTime (actualMode[dest]).GetSeconds ();
totalTime += GetCalcTxTime (actualMode[dest]).GetSeconds ();
}
}
void
@@ -259,10 +261,10 @@ NodeStatistics::AdvancePosition (Ptr<Node> node, int stepsSize, int stepsTime)
Vector pos = GetPosition (node);
double mbs = ((m_bytesTotal * 8.0) / (1000000 * stepsTime));
m_bytesTotal = 0;
double atm = pow (10, ((totalEnergy / stepsTime) / 10));
double atp = totalEnergy / stepsTime;
totalEnergy = 0;
totalTime = 0;
m_output_power.Add (pos.x, atm);
m_output_power.Add (pos.x, atp);
m_output.Add (pos.x, mbs);
pos.x += stepsSize;
SetPosition (node, pos);

View File

@@ -193,9 +193,11 @@ NodeStatistics::PhyCallback (std::string path, Ptr<const Packet> packet)
packet->PeekHeader (head);
Mac48Address dest = head.GetAddr1 ();
totalEnergy += actualPower[dest] * GetCalcTxTime (actualMode[dest]).GetSeconds ();
totalTime += GetCalcTxTime (actualMode[dest]).GetSeconds ();
if (head.GetType() == WIFI_MAC_DATA)
{
totalEnergy += pow(10, actualPower[dest] / 10) * GetCalcTxTime (actualMode[dest]).GetSeconds ();
totalTime += GetCalcTxTime (actualMode[dest]).GetSeconds ();
}
}
void
@@ -259,10 +261,10 @@ NodeStatistics::CheckStatistics (double time)
{
double mbs = ((m_bytesTotal * 8.0) / (1000000 * time));
m_bytesTotal = 0;
double atm = pow (10, ((totalEnergy / time) / 10));
double atp = totalEnergy / time;
totalEnergy = 0;
totalTime = 0;
m_output_power.Add ((Simulator::Now ()).GetSeconds (), atm);
m_output_power.Add ((Simulator::Now ()).GetSeconds (), atp);
m_output.Add ((Simulator::Now ()).GetSeconds (), mbs);
m_output_idle.Add ((Simulator::Now ()).GetSeconds (), idleTime * 100);