1999-03-06 15:19:22 +01:00
|
|
|
#!/usr/bin/perl
|
|
|
|
|
|
|
|
# print summary of tcpdump output
|
|
|
|
|
|
|
|
sub dumpstats {
|
|
|
|
print "-" x 60, "\n";
|
1999-03-22 11:36:41 +01:00
|
|
|
print "$time_last\n";
|
1999-03-06 15:19:22 +01:00
|
|
|
for $i (sort { $sum{$a} <=> $sum{$b} } keys (%sum)) {
|
|
|
|
printf("\t%6d %s\n", $sum{$i}, $i);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
while (<>) {
|
2002-04-19 12:05:27 +02:00
|
|
|
if (m/^(\d\d:\d\d):\d\d\.\d{6} . ([-\w\.]+) \> ([-\w\.]+): (.*)/) {
|
1999-03-06 15:19:22 +01:00
|
|
|
$time = $1;
|
|
|
|
$from = $2;
|
|
|
|
$to = $3;
|
|
|
|
$rest = $4;
|
|
|
|
if ($time ne $time_last) {
|
|
|
|
dumpstats();
|
|
|
|
undef %sum;
|
|
|
|
$time_last = $time;
|
|
|
|
}
|
|
|
|
if ($rest =~ m/^. (\d+):(\d+)\((\d+)\)/) {
|
|
|
|
# tcp
|
|
|
|
$sum{$from . " > " . $to} += $3;
|
|
|
|
} elsif ($rest =~ m/^. ack (\d+) win (\d+) \(DF\)/) {
|
|
|
|
# tcp ack
|
|
|
|
$sum{$from . " > " . $to} += 0;
|
|
|
|
} else {
|
2002-04-19 12:05:27 +02:00
|
|
|
print stderr "unparseable2: $rest\n";
|
1999-03-06 15:19:22 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
print stderr "unparseable1: $_";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
dumpstats();
|