public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* ntp: Adjustment of time_maxerror with 500ppm instead of 15ppm
@ 2025-05-07 11:28 Keno Goertz
  2025-05-08 19:45 ` John Stultz
  0 siblings, 1 reply; 7+ messages in thread
From: Keno Goertz @ 2025-05-07 11:28 UTC (permalink / raw)
  To: tglx, zippel, mingo, john.stulz; +Cc: linux-kernel

Hello,

I've been looking into the kernel's NTP code and found what I understand 
to be a deviation from NTP as standardized by RFC 5905.  The 
documentation of this part of the kernel is pretty sparse, so there may 
be some motivation behind this that I don't know of.  Perhaps someone 
with more knowledge can explain this.

The doc string of `struct ntp_data` states that `time_maxerror` holds 
the "NTP sync distance (NTP dispersion + delay / 2)".

ntpd indeed sets this value to what RFC 5905 calls the "root 
synchronization distance" LAMBDA.

In RFC 5905, this LAMBDA increases over time because the root dispersion 
increases at a rate of PHI, which is set to 15ppm.  Running

$ ntpq -c "rv 0 rootdisp"

a couple of times confirms that the root dispersion reported by ntpd 
increases with this rate.  Consequently, so does the root 
synchronization distance LAMBDA.

However, the function `ntp.c:second_overflow()` instead increases the 
value of `time_maxerror` with the rate MAXFREQ, which is set to 500ppm.

This leads to standard library functions like ntp_gettime() reporting 
much bigger values of `maxerror` than ntpd is working with.  This can be 
confirmed by running

$ adjtimex -p

a couple of times.

MAXFREQ *can* be found in the reference implementation of RFC 5905 and 
is also set to 500ppm there, but it is used in a different context: 
MAXFREQ is an upper bound for the local clock's frequency offset, while 
PHI is an upper bound for the frequency drift of a clock synchronized 
with NTP.

At least this is my understanding.  Can someone explain this?

Best regards
Keno

^ permalink raw reply	[flat|nested] 7+ messages in thread
* ntp: Adjustment of time_maxerror with 500ppm instead of 15ppm
@ 2025-05-07  9:15 Keno Goertz
  0 siblings, 0 replies; 7+ messages in thread
From: Keno Goertz @ 2025-05-07  9:15 UTC (permalink / raw)
  To: linux-kernel

Hello,

I've been looking into the kernel's NTP code and found what I understand 
to be a deviation from NTP as standardized by RFC 5905.  The 
documentation of this part of the kernel is pretty sparse, so there may 
be some motivation behind this that I don't know of.  Perhaps someone 
with more knowledge can explain this.

The doc string of `struct ntp_data` states that `time_maxerror` holds 
the "NTP sync distance (NTP dispersion + delay / 2)".

ntpd indeed sets this value to what RFC 5905 calls the "root 
synchronization distance" LAMBDA.

In RFC 5905, this LAMBDA increases over time because the root dispersion 
increases at a rate of PHI, which is set to 15ppm.  Running

$ ntpq -c "rv 0 rootdisp"

a couple of times confirms that the root dispersion reported by ntpd 
increases with this rate.  Consequently, so does the root 
synchronization distance LAMBDA.

However, the function `ntp.c:second_overflow()` instead increases the 
value of `time_maxerror` with the rate MAXFREQ, which is set to 500ppm.

This leads to standard library functions like ntp_gettime() reporting 
much bigger values of `maxerror` than ntpd is working with.  This can be 
confirmed by running

$ adjtimex -p

a couple of times.

MAXFREQ *can* be found in the reference implementation of RFC 5905 and 
is also set to 500ppm there, but it is used in a different context: 
MAXFREQ is an upper bound for the local clock's frequency offset, while 
PHI is an upper bound for the frequency drift of a clock synchronized 
with NTP.

At least this is my understanding.  Can someone explain this?

Best regards
Keno

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2025-05-14 10:02 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-05-07 11:28 ntp: Adjustment of time_maxerror with 500ppm instead of 15ppm Keno Goertz
2025-05-08 19:45 ` John Stultz
2025-05-09 19:40   ` Keno Goertz
2025-05-09 19:49     ` John Stultz
2025-05-12  8:57   ` Miroslav Lichvar
2025-05-14 10:01     ` Keno Goertz
  -- strict thread matches above, loose matches on Subject: below --
2025-05-07  9:15 Keno Goertz

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox