Commit f6a1d906 authored by Junxing Zhang's avatar Junxing Zhang
Browse files

Use a min-median filter to replace the min filter per Dave's suggestion.

The samples with long RTT values are removed for possible lack of symmetric
one-way delays. The remaining samples with offset outliers are also removed
by the median filter.
parent c1e91eed
......@@ -15,15 +15,18 @@ if ($opt_n) {
if ($opt_n !~ /^\d+$/) {
print "Error: -n option must be a positive integer!\n";
exit -1;
}
if ($opt_n < 20) {
print "Error: -n option must be larger than 20 to enable the min-outlier-filter to work!\n";
exit -1;
}
$sampnum = $opt_n;
}
$mindelay = 100000;
for ($i=0; $i<$sampnum; $i++) {
open(PH, $cmd . "|") || die "failed to start command $cmd: $!";
$lineno = 1;
while (<PH>) {
print if ($opt_d);
#print if ($opt_d);
if ($lineno == 3) {
$delay = $1 if (/\sdelay\s(-?\d+\.?\d*),/);
$offset = $1 if (/\soffset\s(-?\d+\.?\d*)$/);
......@@ -38,12 +41,25 @@ for ($i=0; $i<$sampnum; $i++) {
}
if ($opt_d) {
printf("delay: %f, offset: %f \n", $delay, $offset);
printf("======================================================================\n");
#printf("======================================================================\n");
}
if ($delay < $mindelay){
$mindelay = $delay;
$minoffset = $offset;
}
push @delays, $delay;
push @offsets, $offset;
}
@sorted_delays = sort({$a <=> $b} @delays);
print "sorted_delays: ", @sorted_delays, "\n" if ($opt_d);
#choose the offsets corresponding to the shortest 11 delays
for ($i=0; $i<$sampnum; $i++) {
$delay = shift(@delays);
$offset = shift(@offsets);
if ($delay <= $sorted_delays[10]) {
push @chosen_offsets, $offset;
}
last if ($#chosen_offsets == 10);
}
printf("The min delay is %f, and the corresponding offset is %f\n", $mindelay, $minoffset);
@sorted_chosen_offsets = sort({$a <=> $b} @chosen_offsets);
print "sorted_chosen_offsets: ", @sorted_chosen_offsets, "\n" if ($opt_d);
printf("The median offset of the shortest 11 delays is %f second\n", $sorted_chosen_offsets[5]);
Supports Markdown
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