NS2.35中对leach.alive文件分析遇见问题

NS2中对leach.alive文件分析:

在ns2中移植了mit文件,在运行./test 之后leach.err没有报错,之后对leach.alive文件进行分析,


问题描述

leach_test文件中的参数配置如下 簇头数量为5,基站坐标为(0,0),节点数101:

num_clusters=5
# energy values.  How much energy does each node have initially
eq_energy=1
init_energy=2
# stop is the time to stop the simulation if it is still running
stop=500
# x,y is the size of the field
x=100
y=100
# bs_x, bs_y is the location of the base station in the field.
bs_x=0
bs_y=0
# Number of nodes.  WARNING!  This should be 1 higher then the number
#  of nodes generated in the scenario.
nn=101

contions.txt文件内容如下:


Simulation will stop after 500 seconds.
Base station at (0, 0)
Each node starting with 2 Joules of energy.

Energy Model:
		RXThresh = 6e-9
		CSThresh = 1e-9
		Rb = 1e6
		Excvr = 50e-9
		Efriss_amp = 9.6741659015025702e-12
		Etwo_ray_amp = 1.3037037037037037e-15
		Ebf = 5e-9
		Pidle = 0
		Psleep = 0

Thresholds chosen using original probs.
Desired number of clusters = 5
Spreading factor = 8
Changing clusters every 20 seconds

leach.alive文件部分如下:

10 0 1
10 1 1
10 2 1
10 3 1
10 4 1
10 5 1
10 6 1
10 7 1
10 8 1
10 9 1
10 10 1
10 11 1
10 12 1
10 13 1
10 14 1
10 15 1
10 16 1
10 17 1
10 18 1
10 19 1
10 20 1
10 21 1
10 22 1
10 23 1
10 24 1
10 25 1
10 26 1
10 27 1
10 28 1
10 29 1
10 30 1
10 31 1
10 32 1
10 33 1
10 34 1
10 35 1
10 36 1
10 37 1
10 38 1
10 39 1
10 40 1
10 41 1
10 42 1
10 43 1
10 44 1
10 45 1
10 46 1
10 47 1
10 48 1
10 49 1
10 50 1
10 51 1
10 52 1
10 53 1
10 54 1
10 55 1
10 56 1
10 57 1
10 58 1
10 59 1
10 60 1
10 61 1
10 62 1
10 63 1
10 64 1
10 65 1
10 66 1
10 67 1
10 68 1
10 69 1
10 70 1
10 71 1
10 72 1
10 73 1
10 74 1
10 75 1
10 76 1
10 77 1
10 78 1
10 79 1
10 80 1
10 81 1
10 82 1
10 83 1
10 84 1
10 85 1
10 86 1
10 87 1
10 88 1
10 89 1
10 90 1
10 91 1
10 92 1
10 93 1
10 94 1
10 95 1
10 96 1
10 97 1
10 98 1
10 99 1
20 0 1
20 1 1
20 2 1
20 3 1
20 4 1
20 5 1
20 6 1
20 7 1
20 8 1
20 9 1
20 10 1
20 11 1
20 12 1
20 13 1
20 14 1
20 15 1
20 16 1
20 17 1
20 18 1
20 19 1
20 20 1
20 21 1
20 22 1
20 23 1
20 24 1
20 25 1
20 26 1
20 27 1
20 28 1
20 29 1
20 30 1
20 31 1
20 32 1
20 33 1
20 34 1
20 35 1
20 36 1
20 37 1
20 38 1
20 39 1
20 40 1
20 41 1
20 42 1
20 43 1
20 44 1
20 45 1
20 46 1
20 47 1
20 48 1
20 49 1
20 50 1
20 51 1
20 52 1
20 53 1
20 54 1
20 55 1
20 56 1
20 57 1
20 58 1
20 59 1
20 60 1
20 61 1
20 62 1
20 63 1
20 64 1
20 65 1
20 66 1
20 67 1
20 68 1
20 69 1
20 70 1
20 71 1
20 72 1
20 73 1
20 74 1
20 75 1
20 76 1
20 77 1
20 78 1
20 79 1
20 80 1
20 81 1
20 82 1
20 83 1
20 84 1
20 85 1
20 86 1
20 87 1
20 88 1
20 89 1
20 90 1
20 91 1
20 92 1
20 93 1
20 94 1
20 95 1
20 96 1
20 97 1
20 98 1
20 99 1
30 0 1
30 1 1
30 2 1
30 3 1
30 4 1
30 5 1
30 6 1
30 7 1
30 8 1
30 9 1
30 10 1
30 11 1
30 12 1
30 13 1
30 14 1
30 15 1
30 16 1
30 17 1
30 18 1
30 19 1
30 20 1
30 21 1
30 22 1
30 23 1
30 24 1
30 25 1
30 26 1
30 27 1
30 28 1
30 29 1
30 30 1
30 31 1
30 32 1
30 33 1
30 34 1
30 35 1
30 36 1
30 37 1
30 38 1
30 39 1
30 40 1
30 41 1
30 42 1
30 43 1
30 44 1
30 45 1
30 46 1
30 47 1
30 48 1
30 49 1
30 50 1
30 51 1
30 52 1
30 53 1
30 54 1
30 55 1
30 56 1
30 57 1
30 58 1
30 59 1
30 60 1
30 61 1
30 62 1
30 63 1
30 64 1
30 65 1
30 66 1
30 67 1
30 68 1
30 69 1
30 70 1
30 71 1
30 72 1
30 73 1
30 74 1
30 75 1
30 76 1
30 77 1
30 78 1
30 79 1
30 80 1
30 81 1
30 82 1
30 83 1
30 84 1
30 85 1
30 86 1
30 87 1
30 88 1
30 89 1
30 90 1
30 91 1
30 92 1
30 93 1
30 94 1
30 95 1
30 96 1
30 97 1
30 98 1
30 99 1

创建一个awk文件对leach.alive文件进行分析 名为 test.awk,

BEGIN {
  countcyl=0;       
  totalleft=0;  
      
  lasttime=0;       
  time[0]=0;        
  node=0;      
  total[0]=100; 
}      
{
simtime = $1;          
nodeid = $2;              
statenode = $3;        

if (simtime>lasttime ) {
countcyl++;
lasttime=simtime;
time[countcyl]=simtime;
totalleft=0;
}                 

if (statenode==1) 
    totalleft++;
    total[countcyl]=totalleft;

}
END {
for(i=0;i<=countcyl;i++)
printf ( "%f %d\n",time[i],total[i]);
} 

用脚本进行分析,这将生成一个名为leach_alive_stats.txt的文件

gawk -f test.awk leach.alive > leach.gnuplot

leach.gnuplot内容如下:

0.000000 100
10.000000 100
20.000000 100
30.000000 100
40.000000 100
50.000000 100
60.000000 100
70.000000 100
80.000000 100
90.000000 100
100.000000 100
110.000000 100
120.000000 100
130.000000 100
140.000000 100
150.000000 100
160.000000 100
170.000000 100
180.000000 100
190.000000 100
200.000000 99
210.000000 99
220.000000 98
230.000000 98
240.000000 96
250.000000 96
260.000000 96
270.000000 96
280.000000 93
290.000000 93
300.000000 92
310.000000 92
320.000000 91
330.000000 91
340.000000 90
350.000000 90
360.000000 86
370.000000 79
380.000000 78
390.000000 75
400.000000 75
410.000000 68
420.000000 67
430.000000 62
440.000000 62
450.000000 53
460.000000 52
470.000000 48
480.000000 46
490.000000 38
500.000000 36

运行以下代码生成图片

gnuplot 
plot 'leach.gnuplot' w lp

生成图片如下
在这里插入图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值