Sat Aug 4 06:52:57 EDT 2012

ntpblogging

So I was farting about trying to figure out how to ask a NTP server what it thinks the time is without having to edit ntp.conf on the client machine, when I discovered that NTP is like SSH— any machine with it installed acts as a server.

So now both of my machines get their time from bbot.org:

magnesium:~ $ ntpq -np
     remote           refid      st t when poll reach   delay   offset  jitter
==============================================================================
+76.72.161.27    138.236.128.112  3 u   44   64  377   81.174   -2.459   1.158
+209.177.158.233 134.21.35.167    3 u   42   64  377   62.137   -3.428   1.459
-64.34.171.122   198.60.22.240    2 u   42   64  377   85.527   -7.019   2.248
*69.50.219.51    209.51.161.238   2 u   36   64  377   54.501    0.361  45.780
bbot@neon:~ $ ntpq -np
     remote           refid      st t when poll reach   delay   offset  jitter
==============================================================================
+76.72.161.27    138.236.128.112  3 u   60  128  377   80.328    0.690  10.561
*67.23.181.241   128.4.1.1        2 u   35  128  377   82.895    1.003   7.373
+69.167.160.102  204.9.54.119     2 u   70  128  377   75.712    4.162  12.724
+50.16.231.185   192.5.41.40      2 u   26  128  377   87.617   -0.344  64.595

(The legend for the inscrutable linux bullshit can be found in ntpq’s manual file)

(Of course, at the moment I took these screenshots, neither neon or magnesium were syncing to bbot.org…)

The magic incantation to ask a NTP server for the time is sntp,

$ sntp 0.pool.ntp.org
2012 Aug 04 01:30:15.000857 + 0.001475 +/- 0.083787 secs

Which will return, (if you’ve got a machine with accurate time) a tiny drift number (1.4ms) swamped by a giant lake of uncertainty. (83.7ms) This is because sntp can only request a single packet, which means it doesn’t have a good idea of the jitter between you and the remote machine. The NTP daemon manages to extract accurate time from the storm of random network noise by requesting lots of packets, then doing a lot of clever things. You can sanity-check sntp by going to time.is, which for any Linux machine will tell you that your clock is bang-on accurate. (NTP on Windows will only get the clock within 1000ms of the true time, by design. Microsoft assumes that their users aren’t pedantically obsessive nerds who absolutely positively must have the most accurate computer clocks possible. The same assumption can’t be made of Linux users.)


Posted by Samuel Bierwagen | Permanent link | File under: Linux