Packet delivery ratio calculation in ns2 using awk
Solution
BEGIN {
sendLine = 0;
recvLine = 0;
fowardLine = 0;
}
$0 ~/^s.* AGT/ {
sendLine ++ ;
}
$0 ~/^r.* AGT/ {
recvLine ++ ;
}
$0 ~/^f.* RTR/ {
fowardLine ++ ;
}
$0 ~/^D.* cbr/ {
dropLine ++ ;
}
END {
printf "PacketDelivery Ratio:%.4f \n",(recvLine/sendLine);
}
Solution
BEGIN {
sendLine = 0;
recvLine = 0;
fowardLine = 0;
}
$0 ~/^s.* AGT/ {
sendLine ++ ;
}
$0 ~/^r.* AGT/ {
recvLine ++ ;
}
$0 ~/^f.* RTR/ {
fowardLine ++ ;
}
$0 ~/^D.* cbr/ {
dropLine ++ ;
}
END {
printf "PacketDelivery Ratio:%.4f \n",(recvLine/sendLine);
}
Hello Sir, i am working on VANETs. Sir i need your help analyzing the trace file.
ReplyDeleteI mean running the awk -f file.awk file.tr gives error stating fatal division by zero when GPSR is used as routing protocol, but when aodv is used as routing protocol it works fine........... What can i do?
ReplyDelete@MyNs2 ,
ReplyDeleteits work fine with GPSR (hope you are using gpsr and hls patch) protocol, Check the agent trace mode in your tcl script,
-agentTrace ON
it should be ON.
Hi there,
ReplyDeleteI'm wondering whether this script applies to new trace format or old trace format?
I tried implementing it on a LEACH routing protocol tr file and I got the results, but the sent packets seem to be much less than the received packets.. is this output correct?
sir am yuvasri doing M.Tech (WC) ,
ReplyDeleteam doing target tracking in WSN under algorithm technique project using NS2 tool .
plz help me how to write taregt tracking coding using bayesian algorithm or anyone algorithm ? plz reply me sir
yuvasekar7@gmail.com