1、DTN MED平均等待时间计算公式
下面这段代码是在dtnsim2中的packageprotocolStack.globalKnowledge;下的contactschedule中,有一个计算MED时间的函数
/** Computes the MED metric assuming that time begins at startTime. */
public double getMEDWeight(double simTime)
{
if (nextUpTime != null)
{
throw new RuntimeException("ContactSchedule is not closed");
}
double downSquaredSum = 0;
double lastTime = 0;
for (UpTime up : times)
{
if (up.getTimeUp() != 0)
{
assert up.getTimeUp() > lastTime;
double downTime = up.getTimeUp() - lastTime;
assert downTime > 0;
downSquaredSum += downTime * downTime;
}
lastTime = up.getTimeDown();//仅仅统计down的时间长度
}
// Add the very last down time
double downTime = simTime - lastTime;
if (downTime > 0)
{
downSquaredSum += downTime * downTime;
}
double ret = (double) (downSquaredSum / (2 * simTime)) + contact.getLatency();
return ret;
}
在example-simple-readme中有下面情景
This scenario has four nodes: A, B, C, D. Band C are permanently connected to
D. A <-> B has a down interval of 40,and an up interval of 20 (MED = 13.3).
A <-> C has adown interval of 20, and an up interval of 5 (MED = 8).
对于AB之间的链路调度如下:
0 40 60 100 120
start up down up down
通过手动计算可以知道0-40期间平均等待时间为40/2=20,而40-60期间平均等待时间是0,所以整个60s的周期中平均等待时间为:20*(40/60)+0*(20/60)=13.3
上面函数中downSquaredSum统计了链路中断持续时间的平方,最后又除以2倍的simTime,让人有点摸不着头脑,其实是这样的:(downtime/2) * (downtime/simtime)即在中断时间的平均等待时间乘以中断时间占整个时间的百分比。在MEED的硕士论文中提到了如何计算。
2、如何运行dtnsim2
在console界面下进入到E:\Network\ONE\Eclipseprj\dtnsim2的examples/simple目录下,运行如下命令行:
java -ea -cp ../../bin/lib simulator.Main-verbose 1 simple_MED
verbose冗长的、啰嗦的,Setthe amount of logging output that should be generated
其中