Hi
  I am simulating the modified version of AODV protocol. In that I need to
calculate Packet delivery ratio, Packet overhead, Byte overhead and mean
latency time. I know how to calculate the first three and I wrote the
following perl script for that...

#!/usr/bin/perl -w
#
#usage: throughput1.pl <trace_file> <node> <granularity> <packet-type>
#
#Example: throughput1.pl out.tr1 0.1 udp
#
#HINT: if packet-type = any, it computes the overall throughput
#if packet-type == dropped, it counts the dropped packets

use strict;

my $infile = $ARGV[0];
my $overhead_bytes = 0;
my $overhead_packets = 0;
my $dropped = 0;
my $cbr_sent = 0;
my $cbr_recv =0;
my $packet_delivery_ratio = 0;

#we compute how many bytes were transmitted during time interval
#specified by granularity parameter in seconds
my($sum,$clock,$throughput)=(0,0,0);
my @x;
open(DATA,"<$infile") or die "Can't open $infile: $!\n";
while(<DATA>){
@x=split;

#map column ==>data;
#0 event-type (r,f,D,s)
#1 time
#2 from-node
#3 trace name (AGT, RTR)
#4 why
#5 ch->uid
#6 packet_type
#7 packet_size
#13 source address in form "node.port"
#14 destination address in form "node.port"
#15 ttl
#16 Nexthop
#17 Type

if(($x[0] eq 'r') and ($x[3] eq 'RTR') and (($x[6] eq 'EAODV') or ($x[6] eq
'AODV'))){
$overhead_packets += 1;
$overhead_bytes += $x[7];
}
if(($x[0] eq 'r') and ($x[3] eq 'AGT') and ($x[6] eq 'cbr')){
$cbr_recv += 1;
}
if(($x[0] eq 'D') and ($x[6] eq 'cbr')){
$dropped += 1;
}
if(($x[0] eq 's') and ($x[3] eq 'AGT') and ($x[6] eq 'cbr')){
$cbr_sent += 1;
}
}

$packet_delivery_ratio = ($cbr_sent / $cbr_recv) * 100 ;
print "\nNo.of Data packets Sent: $cbr_sent";
print "\nNo.of Data packets Received: $cbr_recv";
print "\nNo.of Data packets Dropped: $dropped";
print "\n\n Packet_delivery_ratio : $packet_delivery_ratio" ;
print "\n No.of Overhead packets sent: $overhead_packets";
print "\n No.of Overhead bytes sent: $overhead_bytes";

close DATA;
exit 0;


But, I don't know how to calculate the 'mean latency' . Can any one help me
in this aspect. Do anyone have ready code for calculating the mean latency
or can any one explain how to calculate....

Note: I am using AGT trace and RTR trace and my data traffic contains only
cbr packets.

Thanks in advance

Regards
Anupama A

Reply via email to