Commit d3e14e2e authored by Olav Kvittem's avatar Olav Kvittem
Browse files

cut gaps at 1000, drop computing slope for jitter to save cpu

parent c7497e09
......@@ -8,7 +8,7 @@ apt-get update
apt-get -y upgrade
package="mp-rude"
version="1.3.11"
version="1.3.12"
target="${package}_${version}_all"
......
......@@ -10,7 +10,7 @@ GetOptions(@opts) || die "usage: $0 [ -target <target host> ] config-file\n";
use Socket;
while(<>){
next if /s*#/; # comment
next if /^\s*#/; # comment
($src, @dst)=split;
foreach $dst(@dst){
$peers{$src, $dst}++;
......
......@@ -26,6 +26,8 @@ $maxseqreorder=1000; #
$max_small_gap=10; # the max size of a small graph
$max_small_graphs=20;
$max_big_graphs=20;
$gap_limit={'big'=>10000, 'small'=>1000, 'tiny'=>100}; # packets
$max_gaps={'big'=>10000, 'small'=>10000, 'tiny'=>1000}; # count
$late_delay=3000; # ms to doom a packet late
my %src_adr=(), %dst_adr=();
my %least_delay; # least delay observed
......@@ -259,7 +261,8 @@ sub emit_summary_json{
foreach $id ( sort keys %npackets){
my $latems=0;
$latems=$late_sum{$id}/$late_n{$id} if $late_n{$id} > 0;
my $json={
"event_type" => "gapsum",
"lasted" => sprintf ( "%02d:%02d:%02d", $duration{$id}/3600, $duration{$id}%3600/60, $duration{$id}%60 ),
......@@ -277,6 +280,9 @@ sub emit_summary_json{
"least_delay" => $least_delay{$id},
"down_ppm" => sprintf ( "%.3f", 10**6 * ($small_time{$id} + $big_time{$id}) / $duration{$id} ) * 1.0 # ppm
};
foreach $gap_type( keys %$gap_limit ){ # note dropped gaps
$json{"dropped_$gap_type"}=$dropped_gaps{$id}{$gap_type};
}
emit_json( $json, $id, $ptx{$id} );
}
......@@ -411,13 +417,19 @@ sub read_crude {
|| ( ($seq, $tx, $ssync, $serr, $rx, $rsync, $rerr, $ttl) = /$owamp_fmt/ )
|| ( ($seq, $src, $tx, $rx) = /$bv_fmt/ )
){
next if $size < 50; # just a sanity filter for the packets i harstad-mp that has SIZE=4
analyze_packet($seq, $src, $dst, $tx, $rx);
}
}
}
sub gap_type {
my $gap=shift;
foreach $type ( 'big', 'small', 'tiny'){
return $type if $gap >= $$gap_limit{$type};
}
}
sub analyze_packet {
my ($seq, $src, $dst, $tx, $rx ) = @_;
......@@ -460,42 +472,48 @@ sub analyze_packet {
if ( $ntail_seq{$id} > 0 ){ # is recovering
$ntail_seq{$id}++;
if ( $ntail_seq{$id} > $minrecover && $in_gap{$id} ){
my $gap_type=gap_type($missing);
if ( $n_gaps{$id}{$gap_type}++ <= $$max_gaps{$gap_type} ){
$emit_graph{$id}=1;
$emit_graph{$id}=1;
my $missing= $gap_end_seq{$id} - $head_seq{$id};
if ( $missing <= $max_small_gap ){
if ($n_small_graphs{$id} > $max_small_graphs){
$emit_graph{$id}=0;
} else {
my $missing= $gap_end_seq{$id} - $head_seq{$id};
if ( $missing <= $max_small_gap ){
$n_small_graphs{$id}++;
}
} else {
if ( $n_big_graphs{$id} > $max_big_graphs){
$emit_graph{$id}=0;
if ($n_small_graphs{$id} > $max_small_graphs){
$emit_graph{$id}=0;
}
} else {
$n_big_graphs{$id}++;
if ( $n_big_graphs{$id} > $max_big_graphs){
$emit_graph{$id}=0;
}
}
}
emit_break_head($id, $missing );
emit_break_head($id, $missing );
# add the ok part of the postgap tail
my $good=$#{$gap_slep{$id}} - $ntail_seq{$id};
$good = 0 if $bad < 0 ;
# add the ok part of the postgap tail
my $good=$#{$gap_slep{$id}} - $ntail_seq{$id};
$good = 0 if $bad < 0 ;
my $dttl= get_ttl($gap_slep{$id}[$good])-get_ttl($head_end{$id});
push(@{$dttl{$id}}, $tail_ttl - $head_ttl );
if ( $dttl != 0){
$dttl_count{$id}++;
}
for ($lno=0; $lno <= $#{$gap_slep{$id}}; $lno++){
push( @{$slep{$id}}, $gap_slep{$id}[$lno] );
$nslep{$id}++;
my $dttl= get_ttl($gap_slep{$id}[$good])-get_ttl($head_end{$id});
push(@{$dttl{$id}}, $tail_ttl - $head_ttl );
if ( $dttl != 0){
$dttl_count{$id}++;
}
for ($lno=0; $lno <= $#{$gap_slep{$id}}; $lno++){
push( @{$slep{$id}}, $gap_slep{$id}[$lno] );
$nslep{$id}++;
}
} else { # ignore when too many gaps
$dropped_gaps{$id}{$gap_type}++;
}
$gap_slep{$id}=[]; # copied - blank it.
$ntail_seq{$id}=0; #
}
} else { # normal packet
......@@ -640,12 +658,12 @@ sub check_jitter{
"h_jit" => $jit * 1.0,
"h_ddelay" => $ddelay * 1.0,
"h_delay" => $delay * 1.0,
"h_min_d" => $min_d * 1.0,
"h_slope_10" => $slope_10 * 1.0,
"h_slope_20" => $slope_20 * 1.0,
"h_slope_30" => $h_slope_30 * 1.0,
"h_slope_40" => $h_slope_40 * 1.0,
"h_slope_50" => $h_slope_50 * 1.0
"h_min_d" => $min_d * 1.0
# "h_slope_10" => $slope_10 * 1.0,
# "h_slope_20" => $slope_20 * 1.0,
# "h_slope_30" => $h_slope_30 * 1.0,
# "h_slope_40" => $h_slope_40 * 1.0,
# "h_slope_50" => $h_slope_50 * 1.0
};
emit_json($json, $id, $tstart);
$jitter_last{$id} = $tstart;
......@@ -861,9 +879,13 @@ sub report_delay{ # jitter for one delay
# virker ikke
# ($yfit, $coeffs) = fitpoly1d \@drtx, \@drdelay, 4; # Fit a cubi
$lineFit->setData ( \@drtx, \@drdelay );
if (! ( ($intercept, $slope) = $lineFit->coefficients() ) ){
warn "File $ARGV : $!";
if ($type eq 'stats' ){ # save on slope LR for jitter
$slope=$intercept=0;
} else {
$lineFit->setData ( \@drtx, \@drdelay );
if (! ( ($intercept, $slope) = $lineFit->coefficients() ) ){
warn "File $ARGV : $!";
}
}
push(@slope, sprintf("%9.3f ", $slope) );
# $slopes.=sprintf("%9.3f ", $slope);
......
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