LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   packet delivery ratio in awk (https://www.linuxquestions.org/questions/linux-newbie-8/packet-delivery-ratio-in-awk-4175526386/)

nadine01 11-24-2014 03:37 PM

packet delivery ratio in awk
 
hi all,

what is the correct code to calculate packet delivery ratio
Code:

if($4 == "AGT" && $1 == "s" && seqno < $6) {

  seqno = $6;

  } else if(($4 == "AGT") && ($1 == "r")) {

  receivedPackets++;

  } else if ($1 == "D" && $7 == "cbr" && $8 >= 512){

  droppedPackets++;

  }

end{

 print "Packet Delivery Ratio = " receivedPackets/(seqno+1)*100 "%";}

or

Code:

# number of s packets
if (level == "AGT" && event == "s" )  {

          sendLine ++ ;

  }
# number of r packets

if (level == "AGT" && event == "r" ){

          recvLine ++ ;

  }

end {

printf "cbr s:%d r:%d, r/s Ratio:%.4f, f:%d \n", sendLine, recvLine, (recvLine/sendLine);}


smallpond 11-25-2014 11:53 AM

When you make a post, re-read it from the point of view of someone who doesn't know you or what you are working on.


All times are GMT -5. The time now is 07:43 PM.