diff options
Diffstat (limited to 'networking/ntpd.c')
-rw-r--r-- | networking/ntpd.c | 37 |
1 files changed, 20 insertions, 17 deletions
diff --git a/networking/ntpd.c b/networking/ntpd.c index 7b800369e..991c518f6 100644 --- a/networking/ntpd.c +++ b/networking/ntpd.c | |||
@@ -149,8 +149,8 @@ | |||
149 | */ | 149 | */ |
150 | 150 | ||
151 | #define INITIAL_SAMPLES 4 /* how many samples do we want for init */ | 151 | #define INITIAL_SAMPLES 4 /* how many samples do we want for init */ |
152 | #define MIN_FREQHOLD 10 /* adjust offset, but not freq in this many first adjustments */ | 152 | #define MIN_FREQHOLD 12 /* adjust offset, but not freq in this many first adjustments */ |
153 | #define BAD_DELAY_GROWTH 4 /* drop packet if its delay grew by more than this */ | 153 | #define BAD_DELAY_GROWTH 4 /* drop packet if its delay grew by more than this factor */ |
154 | 154 | ||
155 | #define RETRY_INTERVAL 32 /* on send/recv error, retry in N secs (need to be power of 2) */ | 155 | #define RETRY_INTERVAL 32 /* on send/recv error, retry in N secs (need to be power of 2) */ |
156 | #define NOREPLY_INTERVAL 512 /* sent, but got no reply: cap next query by this many seconds */ | 156 | #define NOREPLY_INTERVAL 512 /* sent, but got no reply: cap next query by this many seconds */ |
@@ -1777,9 +1777,9 @@ update_local_clock(peer_t *p) | |||
1777 | //15:31:53.473 update from:<IP> offset:+0.000007 delay:0.158142 jitter:0.010922 clock drift:+9.343ppm tc:6 | 1777 | //15:31:53.473 update from:<IP> offset:+0.000007 delay:0.158142 jitter:0.010922 clock drift:+9.343ppm tc:6 |
1778 | //15:32:58.902 update from:<IP> offset:-0.000728 delay:0.158222 jitter:0.009454 clock drift:+9.298ppm tc:6 | 1778 | //15:32:58.902 update from:<IP> offset:-0.000728 delay:0.158222 jitter:0.009454 clock drift:+9.298ppm tc:6 |
1779 | /* | 1779 | /* |
1780 | * This expression would choose MIN_FREQHOLD + 7 in the above example. | 1780 | * This expression would choose MIN_FREQHOLD + 8 in the above example. |
1781 | */ | 1781 | */ |
1782 | G.FREQHOLD_cnt = MIN_FREQHOLD + ((unsigned)(abs(tmx.offset)) >> 16); | 1782 | G.FREQHOLD_cnt = 1 + MIN_FREQHOLD + ((unsigned)(abs(tmx.offset)) >> 16); |
1783 | } | 1783 | } |
1784 | G.FREQHOLD_cnt--; | 1784 | G.FREQHOLD_cnt--; |
1785 | tmx.status |= STA_FREQHOLD; | 1785 | tmx.status |= STA_FREQHOLD; |
@@ -1819,7 +1819,7 @@ update_local_clock(peer_t *p) | |||
1819 | VERB2 bb_error_msg("update from:%s offset:%+f delay:%f jitter:%f clock drift:%+.3fppm tc:%d", | 1819 | VERB2 bb_error_msg("update from:%s offset:%+f delay:%f jitter:%f clock drift:%+.3fppm tc:%d", |
1820 | p->p_dotted, | 1820 | p->p_dotted, |
1821 | offset, | 1821 | offset, |
1822 | p->lastpkt_delay, | 1822 | p->p_raw_delay, |
1823 | G.discipline_jitter, | 1823 | G.discipline_jitter, |
1824 | (double)tmx.freq / 65536, | 1824 | (double)tmx.freq / 65536, |
1825 | (int)tmx.constant | 1825 | (int)tmx.constant |
@@ -1976,27 +1976,30 @@ recv_and_process_peer_pkt(peer_t *p) | |||
1976 | T2 = lfp_to_d(msg.m_rectime); | 1976 | T2 = lfp_to_d(msg.m_rectime); |
1977 | T3 = lfp_to_d(msg.m_xmttime); | 1977 | T3 = lfp_to_d(msg.m_xmttime); |
1978 | T4 = G.cur_time; | 1978 | T4 = G.cur_time; |
1979 | |||
1980 | /* The delay calculation is a special case. In cases where the | ||
1981 | * server and client clocks are running at different rates and | ||
1982 | * with very fast networks, the delay can appear negative. In | ||
1983 | * order to avoid violating the Principle of Least Astonishment, | ||
1984 | * the delay is clamped not less than the system precision. | ||
1985 | */ | ||
1986 | delay = (T4 - T1) - (T3 - T2); | 1979 | delay = (T4 - T1) - (T3 - T2); |
1987 | if (delay < G_precision_sec) | 1980 | |
1988 | delay = G_precision_sec; | ||
1989 | /* | 1981 | /* |
1990 | * If this packet's delay is much bigger than the last one, | 1982 | * If this packet's delay is much bigger than the last one, |
1991 | * it's better to just ignore it than use its much less precise value. | 1983 | * it's better to just ignore it than use its much less precise value. |
1992 | */ | 1984 | */ |
1993 | prev_delay = p->p_raw_delay; | 1985 | prev_delay = p->p_raw_delay; |
1994 | p->p_raw_delay = delay; | 1986 | p->p_raw_delay = (delay < 0 ? 0.0 : delay); |
1995 | if (p->reachable_bits && delay > prev_delay * BAD_DELAY_GROWTH) { | 1987 | if (p->reachable_bits |
1988 | && delay > prev_delay * BAD_DELAY_GROWTH | ||
1989 | && delay > 1.0 / (8 * 1024) /* larger than ~0.000122 */ | ||
1990 | ) { | ||
1996 | bb_error_msg("reply from %s: delay %f is too high, ignoring", p->p_dotted, delay); | 1991 | bb_error_msg("reply from %s: delay %f is too high, ignoring", p->p_dotted, delay); |
1997 | goto pick_normal_interval; | 1992 | goto pick_normal_interval; |
1998 | } | 1993 | } |
1999 | 1994 | ||
1995 | /* The delay calculation is a special case. In cases where the | ||
1996 | * server and client clocks are running at different rates and | ||
1997 | * with very fast networks, the delay can appear negative. In | ||
1998 | * order to avoid violating the Principle of Least Astonishment, | ||
1999 | * the delay is clamped not less than the system precision. | ||
2000 | */ | ||
2001 | if (delay < G_precision_sec) | ||
2002 | delay = G_precision_sec; | ||
2000 | p->lastpkt_delay = delay; | 2003 | p->lastpkt_delay = delay; |
2001 | p->lastpkt_recv_time = T4; | 2004 | p->lastpkt_recv_time = T4; |
2002 | VERB6 bb_error_msg("%s->lastpkt_recv_time=%f", p->p_dotted, p->lastpkt_recv_time); | 2005 | VERB6 bb_error_msg("%s->lastpkt_recv_time=%f", p->p_dotted, p->lastpkt_recv_time); |
@@ -2024,7 +2027,7 @@ recv_and_process_peer_pkt(peer_t *p) | |||
2024 | bb_error_msg("reply from %s: offset:%+f delay:%f status:0x%02x strat:%d refid:0x%08x rootdelay:%f reach:0x%02x", | 2027 | bb_error_msg("reply from %s: offset:%+f delay:%f status:0x%02x strat:%d refid:0x%08x rootdelay:%f reach:0x%02x", |
2025 | p->p_dotted, | 2028 | p->p_dotted, |
2026 | offset, | 2029 | offset, |
2027 | p->lastpkt_delay, | 2030 | p->p_raw_delay, |
2028 | p->lastpkt_status, | 2031 | p->lastpkt_status, |
2029 | p->lastpkt_stratum, | 2032 | p->lastpkt_stratum, |
2030 | p->lastpkt_refid, | 2033 | p->lastpkt_refid, |