my TR files are as fellows:
r 0.000000000 _1_ RTR --- 0 cbr 70 [0 0 0 0] ------- [1:0 0:0 32 0] [0] 0 0
v 0 eval {set sim_annotation {(at 0.0) cbr traffic from node 1 to node 0}}
s 0.000000000 _1_ RTR --- 0 AODV 48 [0 0 0 0] ------- [1:255 -1:255 30 0] [0x2 1 1 [0 0] [1 4]] (REQUEST)
r 0.005202035 _2_ RTR --- 0 AODV 48 [0 ffffffff 1 800] ------- [1:255 -1:255 30 0] [0x2 1 1 [0 0] [1 4]] (REQUEST)
r 0.005202046 _0_ RTR --- 0 AODV 48 [0 ffffffff 1 800] ------- [1:255 -1:255 30 0] [0x2 1 1 [0 0] [1 4]] (REQUEST)
s 0.005202046 _0_ RTR --- 0 AODV 44 [0 0 0 0] ------- [0:255 1:255 30 1] [0x4 1 [0 4] 10.000000] (REPLY)
s 0.013366795 _2_ RTR --- 0 AODV 48 [0 ffffffff 1 800] ------- [2:255 -1:255 29 0] [0x2 2 1 [0 0] [1 4]] (REQUEST)
r 0.015898183 _1_ RTR --- 0 AODV 44 [0 1 0 800] ------- [0:255 1:255 30 1] [0x4 1 [0 4] 10.000000] (REPLY)
s 0.015898183 _1_ RTR --- 0 cbr 90 [0 0 0 0] ------- [1:0 0:0 30 0] [0] 0 0
r 0.018568830 _1_ RTR --- 0 AODV 48 [0 ffffffff 2 800] ------- [2:255 -1:255 29 0] [0x2 2 1 [0 0] [1 4]] (REQUEST)
r 0.200000000 _1_ RTR --- 1 cbr 70 [0 0 0 0] ------- [1:0 0:0 32 0] [1] 0 0
s 0.200000000 _1_ RTR --- 1 cbr 90 [0 0 0 0] ------- [1:0 0:0 30 0] [1] 0 0
r 0.300000000 _2_ RTR --- 2 cbr 70 [0 0 0 0] ------- [2:0 1:1 32 0] [0] 0 0
v 0.29999999999999999 eval {set sim_annotation {(at 0.3) cbr traffic from node 2 to node 1}}
s 0.300000000 _2_ RTR --- 2 cbr 90 [0 0 0 0] ------- [2:0 1:1 30 1] [0] 0 0
r 0.400000000 _1_ RTR --- 3 cbr 70 [0 0 0 0] ------- [1:0 0:0 32 0] [2] 0 0
s 0.400000000 _1_ RTR --- 3 cbr 90 [0 0 0 0] ------- [1:0 0:0 30 0] [2] 0 0
r 0.500000000 _2_ RTR --- 4 cbr 70 [0 0 0 0] ------- [2:0 1:1 32 0] [1] 0 0
s 0.500000000 _2_ RTR --- 4 cbr 90 [0 0 0 0] ------- [2:0 1:1 30 1] [1] 0 0
r 0.600000000 _1_ RTR --- 5 cbr 70 [0 0 0 0] ------- [1:0 0:0 32 0] [3] 0 0
s 0.600000000 _1_ RTR --- 5 cbr 90 [0 0 0 0] ------- [1:0 0:0 30 0] [3] 0 0
r 0.700000000 _0_ RTR --- 6 cbr 70 [0 0 0 0] ------- [0:1 2:1 32 0] [0] 0 0
and my awk script language are as fellows:
# 使用的是无线trace的旧格式
BEGIN {
highest_packet_id = 0;
delaysum=0;
i=0;
}
{
action = $1;
time = $2;
packet_id = $6;
type = $7;
# 不考虑路由包,可以保证序号为0的cbr被统计到
if ( type == "cbr" ) {
if ( packet_id > highest_packet_id )
highest_packet_id = packet_id;
#记录封包的传送时间
if ( start_time[packet_id] == 0 )
start_time[packet_id] = time;
#记录CBR 的接收时间
if ( action != "d" ) {
if ( action == "r" ) {
end_time[packet_id] = time;
}
} else {
#把不符合条件的数据包的时间设为-1
end_time[packet_id] = -1;
}
}
}
END {
#当资料列全部读取完后,开始计算有效封包的端点到端点延迟时间
for ( packet_id = 0; packet_id <= highest_packet_id; packet_id++ ) {
start = start_time[packet_id];
end = end_time[packet_id];
packet_duration = end - start;
#只把接收时间大于传送时间的记录列出来
if ( start < end ) {
delaysum+=packet_duration;
i++;
}
}
printf "delay:%f\n",(delaysum/i);
}
when I executed awk -f /usr/local/ns2/ns-allinone-2.34/ns-2.34/delay.awk>/usr/local/ns2/ns-allinone-2.34/ns-2.34/cbr_delay
there is nothing in cbr_delay.
But when i executed it on Cygwin on XP,There is an error:awk:delay.awk:49
filename=wpan_demo1.tr fnr=260) fault division by zero attemped
Please help me!Thank you very much.