ntp: improve maxdelayratio test

Similarly to the maxdelaydevratio test, include in the maximum delay
dispersion which accumulated in the interval since the last sample.
Also, enable the test for symmetric associations.
This commit is contained in:
Miroslav Lichvar 2017-08-25 14:57:25 +02:00
parent 51fe80ad95
commit c68ca40ce4
3 changed files with 27 additions and 6 deletions

View file

@ -115,8 +115,7 @@ round-trip delay of 0.3 seconds or more should be ignored. The default value is
This option is similar to the maxdelay option above. *chronyd* keeps a record This option is similar to the maxdelay option above. *chronyd* keeps a record
of the minimum round-trip delay amongst the previous measurements that it has of the minimum round-trip delay amongst the previous measurements that it has
buffered. If a measurement has a round trip delay that is greater than the buffered. If a measurement has a round trip delay that is greater than the
maxdelayratio times the minimum delay, it will be rejected. This option does maxdelayratio times the minimum delay, it will be rejected.
not work in the *peer* directive.
*maxdelaydevratio* _ratio_::: *maxdelaydevratio* _ratio_:::
If a measurement has a ratio of the increase in the round-trip delay from the If a measurement has a ratio of the increase in the round-trip delay from the
minimum delay amongst the previous measurements to the standard deviation of minimum delay amongst the previous measurements to the standard deviation of

View file

@ -1325,6 +1325,30 @@ check_packet_auth(NTP_Packet *pkt, int length,
/* ================================================== */ /* ================================================== */
static int
check_delay_ratio(NCR_Instance inst, SST_Stats stats,
struct timespec *sample_time, double delay)
{
double last_sample_ago, predicted_offset, min_delay, skew, std_dev;
double max_delay;
if (inst->max_delay_ratio < 1.0 ||
!SST_GetDelayTestData(stats, sample_time, &last_sample_ago,
&predicted_offset, &min_delay, &skew, &std_dev))
return 1;
max_delay = min_delay * inst->max_delay_ratio +
last_sample_ago * (skew + LCL_GetMaxClockError());
if (delay <= max_delay)
return 1;
DEBUG_LOG("maxdelayratio: delay=%e max_delay=%e", delay, max_delay);
return 0;
}
/* ================================================== */
static int static int
check_delay_dev_ratio(NCR_Instance inst, SST_Stats stats, check_delay_dev_ratio(NCR_Instance inst, SST_Stats stats,
struct timespec *sample_time, double offset, double delay) struct timespec *sample_time, double offset, double delay)
@ -1582,9 +1606,7 @@ receive_packet(NCR_Instance inst, NTP_Local_Address *local_addr,
/* Test B requires in client mode that the ratio of the round trip delay /* Test B requires in client mode that the ratio of the round trip delay
to the minimum one currently in the stats data register is less than an to the minimum one currently in the stats data register is less than an
administrator-defined value */ administrator-defined value */
testB = inst->max_delay_ratio <= 1.0 || testB = check_delay_ratio(inst, stats, &sample_time, delay);
!(inst->mode == MODE_CLIENT &&
(delay - dispersion) / SST_MinRoundTripDelay(stats) > inst->max_delay_ratio);
/* Test C requires that the ratio of the increase in delay from the minimum /* Test C requires that the ratio of the increase in delay from the minimum
one in the stats data register to the standard deviation of the offsets one in the stats data register to the standard deviation of the offsets

View file

@ -18,7 +18,7 @@ check_source_selection || test_fail
check_packet_interval || test_fail check_packet_interval || test_fail
check_sync || test_fail check_sync || test_fail
for client_server_options in "maxpoll 6 maxdelay 2e-5" "maxpoll 6 maxdelayratio 1.001"; do for client_server_options in "maxpoll 6 maxdelay 2e-5"; do
run_test || test_fail run_test || test_fail
check_chronyd_exit || test_fail check_chronyd_exit || test_fail
check_packet_interval || test_fail check_packet_interval || test_fail