2 # Draw graphs of TCP traffic from netgrind histograms
3 # (c) 2003 Martin Mares <mj@ucw.cz>, GPL'ed
9 my $datafile = "gp.tmp";
10 open D, ">$datafile" or die;
13 my @ewma = ( 0, 0, 0, 0, 0 );
21 @colnames = split /\t/;
25 my %row = map { $colnames[$i++] => $_ } split /\t/;
26 my $time = POSIX::strftime("%d-%m-%Y %H:%M:%S", localtime $row{'time'});
30 $row{'TCPBadSum'} / $w,
31 $row{'TCPUnmatch'} / $w,
32 $row{'TCPBadState'} / $w
35 for (my $i=0; $i<=$#r; $i++) {
36 $ewma[$i] = $ew*$ewma[$i] + $eww*$r[$i];
37 print D "\t", $ewma[$i];
44 open GP, "|gnuplot" or die;
49 set title "TCP packet spectrum"
51 set ylabel "Packets/s [EWMA $ew]"
53 set timefmt "%d-%m-%Y %H:%M:%S"
54 set format x "%d/%m\\n%H:%M"
57 plot "$datafile" using 1:3 title "All TCP packets", \\
58 "$datafile" using 1:4 title "Bad TCP header", \\
59 "$datafile" using 1:5 title "Bad checksum", \\
60 "$datafile" using 1:6 title "For unknown connection", \\
61 "$datafile" using 1:7 title "In bad state"