-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgoodput_rx.pl
44 lines (37 loc) · 920 Bytes
/
goodput_rx.pl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# usage: perl goodput_rx.pl <tracefile> <granularity> <dest> <fid> > file
$infile=$ARGV[0];
$granularity=$ARGV[1];
$to=$ARGV[2];
$fid=$ARGV[3];
# we compute how many bytes were transmitted during time interval specified
# by granularity parameter in seconds
$sum=0;
$clock=0;
open (DATA,"<$infile") || die "Can't open $infile $!";
while (<DATA>) {
@x = split(' ');
if($x[7]==$fid && $x[3]==$to){
# checking if the event corresponds to a reception
# column 0 is event type
if ($x[0] eq 'r'){
if($x[4] eq 'ack'){
# do nothing
}else{
$sum=$sum+$x[5]*8;
}
}
# column 1 is time and column 3 is to
if ($x[1]-$clock > $granularity){
$throughput=$sum/$granularity;
print STDOUT "$x[1] $throughput\n";
$clock=$clock+$granularity;
$sum=0;
}
}
}
# $throughput=$sum/$granularity;
# print STDOUT "$x[1] $throughput\n";
# $clock=$clock+$granularity;
# $sum=0;
close DATA;
exit(0);