Denys Vlasenko | aee7cd8 | 2016-03-04 07:36:04 +0100 | [diff] [blame] | 1 | This patch scales down small offsets quadratically. Reduces sensitivity to jitter |
| 2 | |
| 3 | diff --git a/networking/ntpd.c b/networking/ntpd.c |
| 4 | index 4695c33..ac05815 100644 |
| 5 | --- a/networking/ntpd.c |
| 6 | +++ b/networking/ntpd.c |
| 7 | @@ -1654,6 +1654,17 @@ update_local_clock(peer_t *p) |
| 8 | */ |
| 9 | if (G.offset_to_jitter_ratio >= TIMECONST_HACK_GATE) |
| 10 | tmx.constant--; |
| 11 | + |
| 12 | +{ |
| 13 | + double d = p->lastpkt_delay; |
| 14 | + if (d > SLEW_THRESHOLD) |
| 15 | + d = SLEW_THRESHOLD; |
| 16 | + d /= 2; |
| 17 | + if ((abs_offset / d) < 1) { |
| 18 | + offset *= (abs_offset / d); |
| 19 | + } |
| 20 | +} |
| 21 | + |
| 22 | tmx.offset = (long)(offset * 1000000); /* usec */ |
| 23 | if (SLEW_THRESHOLD < STEP_THRESHOLD) { |
| 24 | if (tmx.offset > (long)(SLEW_THRESHOLD * 1000000)) { |