在 ns-2 的 EnergyModule() 方法中有参数l1
,l2
我想知道级别的含义,为什么我们称它为有级别。以及设置它的目的是什么?
EnergyModel::EnergyModel (
MobileNode * n,
double energy,
double l1,
double l2
)
L1 和 L1 是用于根据能量消耗改变节点颜色的值。双 l1 = 0.5; 双 l2 = 0.2;
if (srcnode) {
if (srcnode->energy_model()) {
energy = srcnode->energy_model()->energy();
initenergy = srcnode->energy_model()->initialenergy();
l1 = srcnode->energy_model()->level1();
l2 = srcnode->energy_model()->level2();
}
}
int energyLevel = 0 ;
double energyLeft = (double)(energy/initenergy) ;
if ((energyLeft <= 1 ) && (energyLeft >= l1 )) energyLevel = 3;
if ((energyLeft >= l2 ) && (energyLeft < l1 )) energyLevel = 2;
if ((energyLeft > 0 ) && (energyLeft < l2 )) energyLevel = 1;
if (energyLevel == 0)
strcpy(colors,"-c black -o red");
else if (energyLevel == 1)
strcpy(colors,"-c red -o yellow");
else if (energyLevel == 2)
strcpy(colors,"-c yellow -o green");
else if (energyLevel == 3)
strcpy(colors,"-c green -o black");