simple/tcpdump_tools/by_hosts

29 lines
836 B
Plaintext
Raw Normal View History

2002-04-19 12:05:27 +02:00
#!/usr/bin/perl -w
use strict;
2016-07-05 21:16:42 +02:00
# 01:06:43.508117 00:00:24:d0:61:81 > 00:0e:0c:a9:5d:a4, ethertype IPv4 (0x0800), length 58: 93.174.93.51.35728 > 143.130.45.7.16719: Flags [S], seq 72688474, win 65535, options [mss 1436], length 0
2002-04-19 12:05:27 +02:00
my %octets;
while (<>) {
2016-07-05 21:16:42 +02:00
if (/ethertype\ IPv4\ \(0x0800\), \s
length\ (?<octets>\d+): \s
(?<sip> \d+\.\d+\.\d+\.\d+) .*?
> \s
(?<dip> \d+\.\d+\.\d+\.\d+) .*?
/x) {
$octets{"$+{sip} - $+{dip}"} += $+{octets};
} elsif (/ethertype\ IPv6\ \(0x86dd\), \s
length\ (?<octets>\d+): \s
(?<sip> [0-9a-f:]+) .*?
> \s
(?<dip> [0-9a-f:]+) .*?
/x) {
$octets{"$+{sip} - $+{dip}"} += $+{octets};
2002-04-19 12:05:27 +02:00
}
}
for my $i (sort { $octets{$a} <=> $octets{$b} } keys %octets) {
printf "%10d %s\n", $octets{$i}, $i;
}
#vim:sw=4