simple/tcpdump_tools/tcpdumptognuplot

31 lines
845 B
Plaintext
Raw Permalink Normal View History

#!/usr/bin/perl
$count = $ack = $prevtime = 0;
while (<STDIN>) {
if (/${ARGV[0]}/) {
print "# ", $_;
# 20:22:42.441592 calypso.wsr.ac.at.ftp-data > octopussy.wsr.ac.at.1365: . 1:1461(1460) ack 1 win 57344 (DF)
if (/^(\d\d):(\d\d):(\d\d).(\d\d\d\d\d\d) /) {
print "# time: $1 $2 $3 $4\n";
$time = $1 * 3600 + $2 * 60 + $3 + $4 * 0.000001;
if ($prevtime == 0) { $prevtime = $time };
$time -= $prevtime;
}
if (/(\d+):(\d+)\((\d+)\)/) {
print "# sequence: $1 $2 $3\n";
# filter out initial seq. number but allow some packet loss
if ($2 == $1 + $3 && $1 <= $count + 300000) {
$count = $2;
}
}
if (/ ack (\d+)/) {
print "# ack: $1\n";
# filter out initial seq. number but allow some packet loss
if ($1 <= $ack + 300000) {
$ack = $1;
}
}
print $time, "\t", $count, "\t", $ack, "\n";
}
}