MacBook – ntpd: consistently incorrect time on mid-2013 MacBook Air

data synchronizationmacbook prontp

I'm using ICMP time stamping on my mid-2013 MacBook Air, and I need my clock to have an accuracy of no worse than 1ms.

I see that ntpd is running, with the default settings, and /etc/ntp.conf contains just one line, server time.apple.com, without even any comments.

However, if I run ntpdate -d time.apple.com (or ntpdate -d ntp1.yycix.ca, which produces the same offset reading for any given time as time.apple.com farm does), always as a non-root user, I'm often getting the reading that my clock is offset by as much as 6ms, or, most often around 4ms (sometimes 0ms, but very rarely).

Why is this happening? I'm not even rebooting my MacBook, it runs 24/7, plugged in, why is its ntpd not keeping the time correctly?

Syslog has the following:

% syslog | fgrep ntp | fgrep -v sudo | tail
Nov 19 12:59:30 mba.cnst ntpd[86861] <Notice>: proto: precision = 1.000 usec

Last I checked, 1.000 usec is no worse than 1 us, which is 0.001ms, or 0.000001s; why does it claim that precision is 0.001ms, when in reality the clock is offset by as much as 6ms?

Best Answer

The server keyword of ntp.conf(5) would appear to configure only a single server, even if the provided hostname resolves to more than one IP address.

It would appear that the specific server that was being selected is a PoS.

mba: {4899} ntpdc -s ; ntpdc -sn
     remote           local      st poll reach  delay   offset    disp
=======================================================================
*time.apple.com  129.xx.xxx.xxx   2 4096  377 0.07106  0.000248 0.24763
     remote           local      st poll reach  delay   offset    disp
=======================================================================
*17.151.16.22    129.xx.xxx.xxx   2 4096  377 0.07106  0.000248 0.24763
mba: {4900} ntpdate -d 17.151.16.22 |& tail -1 ; \
?           ntpdate -d time.apple.com |& tail -1 ; \
?           ntpdate -d ntp1.yycix.ca |& tail -1
26 Nov 01:49:13 ntpdate[97738]: adjust time server 17.151.16.22 offset -0.000318 sec
26 Nov 01:49:16 ntpdate[97740]: adjust time server 17.171.4.15 offset -0.006493 sec
26 Nov 01:49:16 ntpdate[97742]: adjust time server 192.75.191.6 offset -0.006443 sec
mba: {4901}

Going to Date & Time Preferences, and providing a comma-separated list of valid NTP servers seems to fix the issue.

Providing a comma-separated list in GUI results in several server entries in /etc/ntp.conf, although you have to make sure that the hostnames themselves are different (otherwise, the repeated hostnames don't result in any extra actual servers being selected, as per ntpq -p).

mba: {5104} cat /etc/ntp.conf
server ntp1.yycix.ca
server time.nist.gov
server tick.usask.ca
server tock.usask.ca
server clock.nyc.he.net
mba: {5105} ntpq -p
     remote           refid      st t when poll reach   delay   offset  jitter
==============================================================================
+ntp1.yycix.ca   .GPS.            1 u  138  512  377   56.517   -0.662   0.319
-2610:20:6f15:15 .ACTS.           1 u  117  512  377   27.975   -1.774   0.989
+tick.usask.ca   .GPS.            1 u  456  512  377   31.388   -0.636   0.135
*tock.usask.ca   .GPS.            1 u  124  512  377   31.486   -0.864   0.413
-clock.nyc.he.ne .CDMA.           1 u  139  512  377   26.860   -2.161   0.194
mba: {5106}

A list of servers is available at http://support.ntp.org/servers; you have to try to select the servers that are close to you, especially not just geographically, but network-wise.