From 96cc80ffc87701dc0eaeccf2cf5e387436b13d5b Mon Sep 17 00:00:00 2001 From: Miroslav Lichvar Date: Wed, 4 Jan 2017 15:40:52 +0100 Subject: [PATCH] ntp: improve dispersion calculation Instead of adding precision (sum of the local and remote precision) to the TX and RX timestamp error, include only the maximum. --- ntp_core.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ntp_core.c b/ntp_core.c index fd22cc0..ed8c85f 100644 --- a/ntp_core.c +++ b/ntp_core.c @@ -1435,7 +1435,8 @@ receive_packet(NCR_Instance inst, NTP_Local_Address *local_addr, skew = (source_freq_hi - source_freq_lo) / 2.0; /* and then calculate peer dispersion */ - dispersion = precision + inst->local_tx.err + rx_ts_err + skew * fabs(local_interval); + dispersion = MAX(precision, MAX(inst->local_tx.err, rx_ts_err)) + + skew * fabs(local_interval); /* Additional tests required to pass before accumulating the sample */