BEGIN {
seqno = -1;
droppedPackets = 0;
count_cbr = 0;
count_exp = 0;
drop_cbr = 0;
drop_exp = 0;
n_to_n_delay_cbr = 0;
n_to_n_delay_exp = 0;
avg_n_to_n_delay_cbr = 0;
avg_n_to_n_delay_exp = 0;
}
#end-to-end delay
{
#packet delivery ratio
if(($4 == "AGT") && ($1 == "s") && (seqno < $6)) {
seqno = $6;
}
if(($1 == "s") && ($4 == "AGT") && ($7 == "cbr" )) {
start_time_cbr[$6] = $2;
traffic_type[$6] = "cbr";
} else if(($3 == "1") && ($1 == "r") && ($4 == "0") && ($5 == "cbr")){
end_time_cbr[$12] = $2;
} else if(($1 == "D") && ($4 == "IFQ") && ($7 == "cbr")) {
end_time_cbr[$6] = -1;
}
else if(($1 == "s") && ($4 == "AGT") && ($7 == "exp" )) {
start_time_exp[$6] = $2;
traffic_type[$6] = "exp";
}
else if(($3 == "1") && ($1 == "r") && ($4 == "0") && ($5 == "exp")){
end_time_exp[$12] = $2;
} else if(($1 == "D") && ($4 == "IFQ") && ($7 == "exp")) {
end_time_exp[$6] = -1;
}
}
END {
for(i=0; i<=seqno; i++)
{
if(traffic_type[i] == "cbr")
{
if(end_time_cbr[i] > 0) {
delay_cbr[i] = end_time_cbr[i] - start_time_cbr[i];
count_cbr++;
n_to_n_delay_cbr = n_to_n_delay_cbr + delay_cbr[i];
}
else
{
drop_cbr++;
}
}
else if (traffic_type[i] == "exp" )
{
if(end_time_exp[i] > 0) {
delay_exp[i] = end_time_exp[i] - start_time_exp[i];
count_exp++;
n_to_n_delay_exp = n_to_n_delay_exp + delay_exp[i];
}
else
{
drop_exp++;
}
}
}
print "total number of packet generated = " seqno+1;
print "count video packets = " count_cbr;
print "count Voice packets = " count_exp;
avg_n_to_n_delay_cbr = n_to_n_delay_cbr/count_cbr;
avg_n_to_n_delay_exp = n_to_n_delay_exp/count_exp;
print "avg delay of Video = " avg_n_to_n_delay_cbr " ""seconds";
print "avg delay of Voice = " avg_n_to_n_delay_exp " ""seconds";
print "Number of Dropped Voice Packets = " drop_exp ;
print "Number of Dropped Video Packets = " drop_cbr ;
}
Do the following before run the awk file
Step 1: grep "^s" x.tr > xs.tr
Step 2: grep "^r" x.tr > xr.tr
Step 2: grep "^D" x.tr > xd.tr
Step 3: Merge xs.tr, xr.tr and xd.tr into single file and then run the above awk code.
No comments:
Post a Comment