ワイヤレストレーススクリプト(旧形式)-平均遅延
1947 ワード
BEGIN {
# , ID 。 awk , 。
highest_uid = 0;
total_packet=0;
total_delay_time=0;
}
# ( trace )
{
event = $1; #$1 , 。 。 。
time = $2; #
node_nb = $3; # ( “_”, “_” )
trace_type = $4; #trace ( mac )
flag = $5; #
uid = $6; # uid ( uid)
pkt_type = $7; # ( )
pkt_size = $8; # (byte)
# CBR packet ID, ( ), , CBR , 。
if ( event=="s"&& pkt_type=="cbr" && uid > highest_uid )
{#if , 1
highest_uid = uid;
}
#
if ( event=="s"&& pkt_type=="cbr" && uid==highest_uid&&trace_type=="AGT" )
start_time[uid] = time; # start_time[]
#
if ( event=="r"&& pkt_type=="cbr" && uid==highest_uid&&trace_type=="AGT" )
end_time[uid] = time;
if( event=="D")
end_time[uid] =-1;
}
#END ,
END {
# , 。
for ( packet_id = 0; packet_id <= highest_uid; packet_id++ )
{
start = start_time[packet_id];
end = end_time[packet_id];
#
if ( end!=-1&&start < end ){
packet_duration = end - start;
total_packet++;
total_delay_time+=packet_duration;
}
}
printf("%f
",total_delay_time/total_packet);
}