Debian Codegraph @

tcl/ex/red-pd/pktsVsBytes/pktsVsBytesA.pl

raw
1 #!/usr/bin/perl -w
2
3 use strict 'refs';
4 use strict 'subs';
5
6 if ($#ARGV != 3) {
7 &usage;
8 exit;
9 }
10
11 sub usage {
12 print STDERR " usage: $0 <pattern> <time> <noTries> <bit>\n";
13 exit;
14 }
15
16 my $time = $ARGV[1] - 10;
17 my $tries = $ARGV[2];
18 my $bit = $ARGV[3];
19
20
21 for ($tryNo=1; $tryNo <= $tries; $tryNo++) {
22 my @a = <$ARGV[0]-$tryNo-*>;
23
24 foreach $file (@a) {
25
26 my ($pre1, $try, $suffix) = split(/-/,$file);
27 my $i = $suffix;
28 print STDERR "Doing $file tmp-$tryNo-$suffix\n";
29
30 my $command2 = "awk \'BEGIN {k=$i} {if (\$4!=0 && \$2==$time) if (\$4<=k/2) {if (\$4%2!=0) shortBig+=\$6; else shortSmall+=\$6} else if (\$4%2!=0) longBig+=\$6; else longSmall+=\$6} END {div = shortBig+shortSmall+longBig+longSmall; print $i, shortBig/shortSmall, longBig/longSmall, shortBig/div, shortSmall/div, longBig/div, longSmall/div}\' $file >> data$bit-$tryNo";
31
32 # output: i, shortBig/shortSmall, longBig/longSmall,
33 # shortBig, shortSmall, longBig, longSmall.
34
35 # print "$command2", "\n";
36 system($command2);
37
38 }
39 system("sort -n +0 -1 data$bit-$tryNo -o data$bit-$tryNo");
40
41 }
42