--- /dev/null
+#!/usr/bin/perl
+# Simple averages and medians
+# (c) 2003 Martin Mares <mj@ucw.cz>, GPL'ed
+
+use strict;
+use warnings;
+
+`sort >avg.tmp`; $? && die;
+open I, "avg.tmp" or die;
+my $n = 0;
+my $sum = 0;
+my $max = 0;
+my $min;
+while (<I>) {
+ chomp;
+ $n++;
+ $sum += $_;
+ $max = $_;
+ $min = $_ if !defined $min;
+}
+$n || die "No data found";
+seek(I, 0, 0);
+my $median = 0;
+for (my $i=0; $i<$n/2; $i++) {
+ $median = <I>;
+ chomp $median;
+}
+my $avg = $sum/$n;
+my $qsum = 0;
+seek (I, 0, 0);
+while (<I>) {
+ chomp;
+ my $d = $_ - $avg;
+ $qsum += $d*$d;
+}
+my $var = $qsum/$n;
+my $stdd = sqrt($var);
+printf "Number of records: %d\n", $n;
+printf "Average: %.3f\n", $avg;
+printf "Variance: %.3f\n", $var;
+printf "Std. deviation: %.3f\n", $stdd;
+printf "Median: %.3f\n", $median;
+printf "Minimum: %.3f\n", $min;
+printf "Maximum: %.3f\n", $max;
+;
plot "$datafile" using 1:3 title "All IP packets", \\
"$datafile" using 1:4 title "Bad IP header", \\
"$datafile" using 1:5 title "Non-TCP", \\
- "$datafile" using 1:6 title "Fragmented TCP", \\
- "$datafile" using 1:7 title "Processed TCP"
+ "$datafile" using 1:6 title "Processed TCP", \\
+ "$datafile" using 1:7 title "Fragmented TCP"
EOF
;
close GP;