ntpd - BYO-NTP/recipes GitHub Wiki
To serve Stratum 1 level time data via NTP, there are currently1 4 software packages available: chrony, NTPsec, ntp, and OpenNTPD.
Choosing a ntpd can be as simple as:
- Are you using Windows? If yes, use ntpd.
- Is the OS OpenBSD? If yes, probably use OpenNTPD.
- Does chrony support your OS (Unix-like)? If yes, probably use chrony.
- Does chrony's dependency on gpsd trouble you? If yes, use NTPsec.
- Does NTPsec support your OS and your GNSS? If yes, use NTPsec.
- Use ntpd
- 👍 ntp has the most mature code base (since ~1980)
- 👍 ntp runs almost everywhere
- 👍 supports a myriad of reference clocks
- 👎 seems to have a bus-factor problem
- 👎 the dev community seems insular and change resistant
- NTPsec
- 👍 jettisoned much legacy code
- 👍 audited the code and improved security
- 👍 replaced the obscure refclock notations with humane tokens
-
127.127.22.0
->pps
-
mode 88
->mode 8 baud 115200
- etc...
-
- chrony
- 👍 comparatively-modern implementation (initial release in 1997)
- 👍 best accuracy
- 👍 fastest syncronization
- 👎 depends on gpsd for NMEA interaction
-
The suggested NTP configurations attempt to have consistently reported
refid
s. Often this means configuring PPS separately from NMEA, when they could be collapsed. Splitting them has the handy benefit of being able to see how each is performing. -
specific names are better, bonus points for consistentcy
- better names: NMEA, PPS, GPSD_JSON
- ambigious names:
- GPS: was it GPS, Beidou, or Galileo? Was it NMEA or PPS?
minjitter is the minimum allowed jitter (in seconds) for a reference clock. If a time source reports jitter lower than this, NTP will treat it as if it were equal to minjitter.
Use Case | minjitter |
---|---|
GNSS + PPS | 0.0005 to 0.001 sec |
GNSS | 0.001 to 0.01 sec |
USB GNSS | 0.01 to 0.05 sec |
USB GNSS dongle | 0.05 to 0.1 sec |
Testing | 0.1+ sec |
- tune based on empirical measurements, use loop.awk to calculate from loopstats log file.
#millisecondPrecision
For locally connected reference clocks (GNSS), especially units with PPS, set the minpoll and maxpoll down to 4 (16 seconds) to improve the accuracy. Following is an example of the difference:
Similarly for the poll setting on Chrony:
The lowest possible value for maxpoll on ntp is 4, which is attained by setting minpoll 3 maxpoll 4
. In my testing against the u-blox 7, 7M, M8Q, and M8T, this yields the best performance. When testing against the ublox 6, even with a clear view of the sky the unit loses its fix several times a day, which causes 10x accuracy losses. Setting maxpoll 5
greatly reduces the accuracy loss from a fix loss.
mindist, ntpsec
For NTP refclock sources without PPS (cheap USB GPS), relaxing mindist to 0.05 (50 ms) can allow a GPS source to not get rejected as a peer.
For NTP servers with a well-configured GNSS reference clock, the NMEA source is typically within 0.050 seconds and the PPS source is typically within .000005 seconds. In order for PPS to remain active, it must have a reliable peer to number the seconds. The following graph shows what losing the PPS peer looks like when the NMEA source wanders out of the zoo with no other peer available.
Ways to avoid losing our peer are:
- flag the PPS source with
prefer
(NTPsec only) - designate more than one reliable source with 'prefer'
- lower
mindist
from the default .001 ms to .05
- wikipedia: ntpd, Ntpd Implementations, chrony, OpenNTPD
- ntp:
- NTPsec, Miscellaneous Commands and Options
- chrony-project.org: A very technical Comparison of NTP implementations of the 4 is available on the chrony web site.
- Scott Laird, Linux Time Syncing 101