Commit 93151fda authored by Olav Kvittem's avatar Olav Kvittem
Browse files

added tcpdump for network interface

parent 18c3763b
......@@ -8,7 +8,7 @@ apt-get update
apt-get -y upgrade
package="mp-rude"
version="1.3.8"
version="1.3.9"
#version=$(git describe|perl -p -e 'chomp;s/v([^-]+)(-(\d+)-g.+)?$/\1+\3/;s/\+$//')
......
......@@ -19,7 +19,7 @@ use constant JAN_1970 => 0x83aa7e80;
# use LWP::Protocol::https;
# date --date 'jan 1 2000' +%s
$version="0.9.8";
$version="0.9.9";
$min_tx=946681200;
$max_tx=1893452400; # 2030-01-01
$maxseqreorder=1000; #
......@@ -28,6 +28,7 @@ $max_small_graphs=20;
$max_big_graphs=20;
$late_delay=3000; # ms to doom a packet late
my %src_adr=(), %dst_adr=();
my %least_delay; # least delay observed
# parms for jitter report
my %n_normal=(); # count of normal packets for modulo
......@@ -272,7 +273,8 @@ sub emit_summary_json{
"late_sec" => sprintf ( "%.3f", $latems/1000 ) * 1.0,
"duplicates" => $dupl{$id} * 1 || 0,
"reordered" => $reorder{$id} * 1 || 0,
"dTTL" => $dttl_count{$id} * 1 || 0,
"dTTL" => $dttl_count{$id} * 1 || 0,
"least_delay" => $least_delay{$id},
"down_ppm" => sprintf ( "%.3f", 10**6 * ($small_time{$id} + $big_time{$id}) / $duration{$id} ) * 1.0 # ppm
};
......@@ -282,7 +284,12 @@ sub emit_summary_json{
sub emit_json{
my ($json, $id, $tunix)=@_;
my $to=`hostname`; chomp($to);
my $to;
if ( $hostname{$dst_adr{$id}}){
$to=$hostname{$dst_adr{$id}}
} else {
$to=`hostname`; chomp($to);
}
my @gt=gmtime $tunix;
my $datems= sprintf "%s.%03d", strftime("%Y-%m-%dT%T", @gt), int( $tunix * 1000 ) % 1000 ;
......@@ -442,7 +449,8 @@ sub analyze_packet {
my $dseq=$seq - $pseq{$id};
$dt=$rx-$tx;
$ids{$id}++;
$least_delay{$id} = $dt if !$least_delay{$id} || $dt < $least_delay{$id};
if ( $tx < $t0{$id}) { # packets from the past
$late_n{$id}++;
$late_sum{$id}+=$dt;
......@@ -587,7 +595,7 @@ sub analyze_packet {
if ($nbreak{$id} > 0 && ($ntail{$id}[0] >= $maxtail)){
my $head=shift(@{$head1{$id}});
push(@{$tail{$id}}, report_delay( $id, 'tail', @slep{$id}), 0, 0);
push(@{$tail{$id}}, report_delay( $id, 'tail', \@slep{$id}), 0, 0);
$print_line.= sprintf "%s overlap %8d %2d ", $head, $head_seq{$id}, $#{$ntail{$id}}+1;
shift(@{$ntail{$id}});
&emit_stats($id);
......@@ -608,7 +616,7 @@ sub check_jitter{
if ( $start >= 0 && ( ($tstart) = $slep{$id}[$start] =~ /Tx=([\d\.]+)/ ) ) { # enough packets
my $l=report_delay( $id, 'stats', @slep{$id}, NULL, 0);
my $l=report_delay( $id, 'stats', \@slep{$id}, NULL, 0);
$l=~s/^\s*//;
my ( $n, $jit, $ddelay, $delay, $min_d, $slope_10, $slope_20, $slope_30, $slope_40, $slope_50)
= split(/\s+/, $l );
......@@ -676,7 +684,7 @@ sub emit_break_head {
$dseq-1, $dt*1000, $head_seq{$id}-$seq0{$id} );
push(@{$ntail{$id}}, 0); # remember this break
push(@{$head{$id}}, report_delay($id, 'head', @slep{$id}, $tx1, $dt));
push(@{$head{$id}}, report_delay($id, 'head', \@slep{$id}, $tx1, $dt));
# @slep{$id}=();
# $nslep{$id}=0;
}
......@@ -752,57 +760,51 @@ sub report_delay{ # jitter for one delay
my $txgap=shift;
my $dt=shift;
# my @l=@$refl;
# my @l=@$$refl;
my $ptx=0, $prx=0, $sumjit=0, $njit=0, $ndelay=0, $sumdd=0, $sumdelay=0;
my $start=$#$refl-$maxhead;
my $start=$#{$$refl}-$maxhead;
my $mindelay, $taildelay;
my @rdelay=(), @rtx=(), $tx0=0;
my @rrx=(), $rx0=0;
my $rudeid, $seq, $src, $dst, $tx, $rx, $size, $pseq;
foreach $i( 0 .. ($#$refl - 0) ){ # skip the last one which might be after the gap
my $rline=\@$refl[$i];
foreach $i( 0 .. ($#$$refl - 0) ){ # skip the last one which might be after the gap
my $rline=\@$$refl[$i];
if ( ( ($rudeid, $seq, $src, $dst, $tx, $rx, $size)=
$$rline =~ /ID=(\d+)\s+SEQ=(\d+)\s+SRC=([\d.:]+)\s+DST=([\d.:]+)\s+Tx=([\d.,]+)\s+Rx=([\d.,]+).+SIZE=(\d+)/)
|| ( ($seq, $src, $tx, $rx) = $$rline =~ /$bv_fmt/ )
){
$delay=$rx-$tx;
if ( $i < $start ) {
if ( !$mindelay || $delay < $mindelay){
$mindelay = $delay;
}
} else {
if ( !$taildelay || $delay < $taildelay){
$taildelay = $delay;
}
if ( $tx0 == 0 ) {
$tx0=$tx;
$rx0=$rx;
if ( $type eq "head" ){ # use start of head for tail also
push(@{$txgap{$id}}, $txgap); # stack head if nested gaps
} elsif ( $type eq "tail"){ # pull from stacked head
$txgap=shift( @{$txgap{$id}} );
}
}
$sumdelay+=$delay;
$ndelay++;
if ($ptx && ($seq - $pseq) == 1){ # jitter for normal packets
$dtx=$tx-$ptx;
$drx=$rx-$prx;
$jit=$drx-$dtx;
$sumjit += abs $jit;
$njit++;
$sumdd+=$delay;
push(@rtx, ($tx-$tx0)*1000); #ms
push(@rrx, ($rx-$rx0)*1000); #ms
push(@rdelay, $delay);
$mindelay = $delay if !$mindelay || $delay < $mindelay;
if ( !$taildelay || $delay < $taildelay){
$taildelay = $delay;
}
if ( $tx0 == 0 ) {
$tx0=$tx;
$rx0=$rx;
if ( $type eq "head" ){ # use start of head for tail also
push(@{$txgap{$id}}, $txgap); # stack head if nested gaps
} elsif ( $type eq "tail"){ # pull from stacked head
$txgap=shift( @{$txgap{$id}} );
}
$ptx=$tx;
$prx=$rx;
$pdelay=$delay;
$pseq=$seq;
}
$sumdelay+=$delay;
$ndelay++;
if ($ptx && ($seq - $pseq) == 1){ # jitter for normal packets
$dtx=$tx-$ptx;
$drx=$rx-$prx;
$jit=$drx-$dtx;
$sumjit += abs $jit;
$njit++;
$sumdd+=$delay;
push(@rtx, ($tx-$tx0)*1000); #ms
push(@rrx, ($rx-$rx0)*1000); #ms
push(@rdelay, $delay);
}
$ptx=$tx;
$prx=$rx;
$pdelay=$delay;
$pseq=$seq;
}
}
......@@ -821,6 +823,7 @@ sub report_delay{ # jitter for one delay
my $ctx_lr;
if ( $opt_graph && $emit_graph{$id}){
$cc = Chart::Clicker->new( width=>800, height=>600);
if ( $dt > 0) {
$cc->title->text(sprintf "$title $type $id %.3fs", $dt);
......@@ -896,7 +899,7 @@ sub report_delay{ # jitter for one delay
$slopes=join(' ', @slope);
return sprintf "%3d %9.3f %9.3f %9.3f %9.3f %s", $njit, $sumjit/$njit*1000, $sumdd/$njit*1000,
$sumdelay/$ndelay*1000, $taildelay*1000, $slopes;
$sumdelay/$ndelay*1000, $mindelay*1000, $slopes;
} else {
return sprintf "%3d %5.3f %5.3f", 0, 0, 0;
}
......
......@@ -20,4 +20,8 @@ done
# start tcpdump
/usr/sbin/tcpdump -G 86399 -W 1 -w ${logpath}/icmp-%F.pcap icmp
IF=`ip route get 158.38.62.1 | perl -ne 'print $1 if / dev (\w+) /'`
if test .$IF -ne .; then
/usr/sbin/tcpdump -i $IF -G 86399 -W 1 -w ${logpath}/icmp-%F.pcap icmp 2> ${logpath}/icmp.log
fi
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment