Tuesday 7 January 2014

Packet delivery ratio calculation in ns2 using awk

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);
}

5 comments:

  1. Hello Sir, i am working on VANETs. Sir i need your help analyzing the trace file.

    ReplyDelete
  2. I 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
  3. @MyNs2 ,

    its 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.

    ReplyDelete
  4. Hi there,
    I'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?

    ReplyDelete
  5. sir am yuvasri doing M.Tech (WC) ,
    am 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

    ReplyDelete