NS3能量模块遇到的坑

22 views

背景

近期,本人在学习NS3的时,需要对能耗进行记录分析。此外,由于只需要统计传输方面的能耗,因此一开始本人将休眠时的电流、闲置时的电流置为0,但结果是最后传输方面的输出为0。接着,下面将对此进行实验分析。

代码

本次的实验所使用的,为多设备,传输模块。具体的网络拓扑图如下:


m1 m2 m3 m4 ….
丨 丨 丨 丨 10.1.1.0\24

r1 r2 r3 r4 ….
丨 丨 丨 丨 10.1.2.0\24

d1 d2 d3 d4 …

transmission way: wireless (Wi-Fi)


关于能量模型的代码如下:

// Energy model
BasicEnergySourceHelper basicSourceHelper;

// configure energy source
basicSourceHelper.Set ("BasicEnergySourceInitialEnergyJ", DoubleValue (100));

// install energy consumption model
double txPowerW = pow (10, txpower/10-3);
EnergySourceContainer mobileEnergy = basicSourceHelper.Install (mobileNode);
EnergySourceContainer relayEnergy = basicSourceHelper.Install (relayNode);
EnergySourceContainer destinationEnergy = basicSourceHelper.Install (destinationNode);
WifiRadioEnergyModelHelper radioEnergyHelper;
radioEnergyHelper.Set ("TxCurrentA", DoubleValue (txPowerW/0.3));
radioEnergyHelper.Set ("SleepCurrentA", DoubleValue (0));
radioEnergyHelper.Set ("IdleCurrentA", DoubleValue (0));

DeviceEnergyModelContainer mobileEnergyDevice = radioEnergyHelper.Install (mobileDevices, mobileEnergy);
DeviceEnergyModelContainer relayEnergyDevice = radioEnergyHelper.Install (relayDevices, relayEnergy);
DeviceEnergyModelContainer _relayEnergyDevice = radioEnergyHelper.Install (_relayDevices, relayEnergy);
DeviceEnergyModelContainer destinationEnergyDevice = radioEnergyHelper.Install (destinationDevice, destinationEnergy);

其中导致传输方面的消耗为0主要是下面的代码导致:

radioEnergyHelper.Set ("IdleCurrentA", DoubleValue (0));

上述结论由本人做实验得出结果。

下面,本人将对此进行实验,验证上述结果的准确性。

实验

能耗方面变量

作为缺省值,我们设定SleepCurrentA=0.000001,设定IdleCurrentA=0.000001。

  • 实验1:设置设备休眠下的能耗为0,即SleepCurrentA=0

实验结果:

End of Simulation (11s) Total energy consumption by device 0 is 1.1471 J
End of Simulation (11s) Total energy consumption by device 1 is 1.07598 J
End of Simulation (11s) Total energy consumption by device 2 is 1.2189 J
End of Simulation (11s) Total energy consumption by device 3 is 1.28972 J
End of Simulation (11s) Total energy consumption by device 4 is 1.34537 J

  • 实验2:设置闲置状态下设备的能耗为0,即IdleCurrentA=0

实验结果:

End of Simulation (11s) Total energy consumption by device 0 is 0 J
End of Simulation (11s) Total energy consumption by device 1 is 0 J
End of Simulation (11s) Total energy consumption by device 2 is 0 J
End of Simulation (11s) Total energy consumption by device 3 is 0 J
End of Simulation (11s) Total energy consumption by device 4 is 0 J

可以看出,闲置状态下,设备的能耗为0,导致传输方面的能耗为0,具体原因不详。接着进行实验,判断闲置状态的电流大小对实验是否有影响。

  • 实验3:为方便测量,下面将IdleCurrentA设为0.001,并将另一个参数设置为0

实验结果:

End of Simulation (11s) Total energy consumption by device 0 is 1.17692 J
End of Simulation (11s) Total energy consumption by device 1 is 1.10574 J
End of Simulation (11s) Total energy consumption by device 2 is 1.24849 J
End of Simulation (11s) Total energy consumption by device 3 is 1.3192 J
End of Simulation (11s) Total energy consumption by device 4 is 1.37489 J

  • 实验4:同时,进行对照组实验,将实验2中SleepCurrentA设置为0.001,并将另一个参数设置为0

实验结果:

End of Simulation (11s) Total energy consumption by device 0 is 0 J
End of Simulation (11s) Total energy consumption by device 1 is 0 J
End of Simulation (11s) Total energy consumption by device 2 is 0 J
End of Simulation (11s) Total energy consumption by device 3 is 0 J
End of Simulation (11s) Total energy consumption by device 4 is 0 J

为直观分析,本文将上述实验整理形成表格如下:

SleepCurrentA\IdleCurrentA00.0000010.001
004.787356.21796
0.00000106.076926.22524
0.00106.076926.22524

结论1:因此,到此可以得出本文的第一个结论,将SleepCurrentA设置为0不会导致结果的异常,而将IdleCurrentA设置为0会导致结果的异常(传输方面的能耗为0)。

为判断闲置时的能耗产生是否对结果产生影响,因此,本文通过实验2与实验4进行对照。从结果可以看出,将IdleCurrentA扩大10k倍的情况下,能耗方面的消耗不是呈现10k倍左右的增长。与实验2相比,当闲置能耗提高10k倍时,总能耗只提升30%。因此,我们可以有以下结论:

结论2:影响能耗方面不止有闲置状态下的能耗,还有其他因素的产生。

传输方面

作为缺省值,我们假设每个设备传输的数据量大小为:$1024\times 1000\times 5 Bytes= 5000kb=4.88mb$。此外,由于睡眠时的能耗置为0由上述结果发现没有影响,因此我们将其置为0,即SleepCurrentA=0,减少其他方面的干扰。此外,IdleCurrentA=0.01。

  • 实验5:对照实验,我们在不改变现有条件下进行实验。

实验结果:

End of Simulation (11s) Total energy consumption by device 0 is 1.17692 J
End of Simulation (11s) Total energy consumption by device 1 is 1.10574 J
End of Simulation (11s) Total energy consumption by device 2 is 1.24849 J
End of Simulation (11s) Total energy consumption by device 3 is 1.3192 J
End of Simulation (11s) Total energy consumption by device 4 is 1.37489 J

  • 实验6:将数据量大小设置为实验5的2倍,即$10000kb=9.76mb$$。

实验结果:

End of Simulation (11s) Total energy consumption by device 0 is 2.00079 J
End of Simulation (11s) Total energy consumption by device 1 is 1.9074 J
End of Simulation (11s) Total energy consumption by device 2 is 2.06705 J
End of Simulation (11s) Total energy consumption by device 3 is 2.14267 J
End of Simulation (11s) Total energy consumption by device 4 is 2.20612 J

  • 实验7:将数据量大小设置为实验5的3倍,即$15000kb=14.64mb$。

End of Simulation (11s) Total energy consumption by device 0 is 2.82119 J
End of Simulation (11s) Total energy consumption by device 1 is 2.72762 J
End of Simulation (11s) Total energy consumption by device 2 is 2.9038 J
End of Simulation (11s) Total energy consumption by device 3 is 2.96692 J
End of Simulation (11s) Total energy consumption by device 4 is 3.04899 J

从结果可以看出,当数据量大小变为现有大小的2倍时,所产生的能耗比原先(实验5)提升65.83%;而当数据量大小变为现有大小的3倍时,所产生的能耗比元素(实验5)提升132.42%。因此,我们可以看出。在实验5-实验7中,数据量的大小是影响传输方面的主要因素。

因此我们有以下的结论:

结论3:闲置状态下的能耗只影响实验的一部分能耗,而任务传输的总能耗则是影响更大的一个。此外,当数据量越大时,闲置状态下的能耗占比越小。

从结论3,我们可以得出下面的推论1。

推论1:随着数据量大小的提升,闲置状态下的能耗影响占比逐渐下降。

接着,我们将IdleCurrentA变为0.0000001。进行实验,结合实验5-实验7,本文得到以下的表格。

data size \ idleCurrentA0.00000010.01
$4.88mb$5.976926.22525
$9.76mb$10.1773410.32403
$14.64mb$14.3234514.46852

增设实验

通过前面的实验分析,我们在确定data size和闲置状态的能耗对实验结果有比较大的影响下。重新进行一些额外实验,对睡眠时的电流分析进行考虑。可得出以下结果。

data size \ SleepCurrentA00.0110
$4.88mb$5.976926.076926.07692
$9.76mb$10.1773410.1773410.17734
$14.64mb$14.3234514.3234514.32345

结论

为实验结果的准确性,我们通常是希望将闲置的电流置为0,以及睡眠时的电流置为0。然而,由实验结果可知,当闲置状态下的电流为0时,整个传输能耗出现错误(结果为0)。

因此,为解决上述问题,本文通过实验得出以下可解决方案:

1、将ideaCurrentA设置为足够小,从而减小ideaCurrentA对整个实验结果的影响。

2、在可允许的范围内将传输的数据量增大,增大数据量大小在实验的比重。

3、将sleepCurrentA设置为0,当SleepCurrentA开始增长时,消耗的能量开始增长,随后迅速趋于水平。即之后随着SleepCurrentA的增长,消耗的能量不再增长。

Rating: 5.0/5. From 1 vote.
Please wait...