[RndTbl] More about network time...

Gilbert E. Detillieux gedetil at cs.umanitoba.ca
Wed Sep 13 14:18:41 CDT 2017


Wyatt's presentation on NTPD last night prompted some discussion about 
other NTP implementations.  (Chrony was mentioned in the presentation, 
and systemd-timesyncd was mentioned in discussion.)

The latest Raspbian boot image for the Raspberry Pi (based on Debian 
stretch) no longer installs ntpd by default, but relies on 
systemd-timesyncd instead.  (Presumably Debian stretch does something 
similar, though that may not be the case...)  Of course, ntpd, chrony, 
and openntpd are all available as alternatives.

The good news is that systemd-timesyncd seems to work for the very 
simple case of a client-only setup, where you just want to get the time 
reasonably close to some official time source (it only implements an NTP 
client, not a server), requires no special configuration, and seems to 
get out of the way if you install any of the more-capable NTP server 
packages.

The bad news is that it doesn't do as good a job of keeping time in 
sync.  It only contacts one of the available NTP servers, and sticks to 
that one until it's not reachable, in which case it tries the next 
available one, etc.  It will use as time sources one of the available 
pool servers for the distribution, or (if provided) one of those 
indicated by the DHCP server.  So, for the typical client, it may be fine.

Also, it doesn't give you much by way of stats.  You can use the 
"timedatectl" command, to find out if NTP synchronization is enabled or 
not, but that's about it.  You can also use the "systemctl -l status 
systemd-tymesyncd" command, and look at the log entries showing which 
time server was used...

Sep 09 07:02:29 raspberrypi systemd-timesyncd[215]: Synchronized to time 
server 206.108.0.134:123 (2.debian.pool.ntp.org).
Sep 09 23:33:45 raspberrypi systemd-timesyncd[215]: Timed out waiting 
for reply from 206.108.0.134:123 (2.debian.pool.ntp.org).
Sep 09 23:33:45 raspberrypi systemd-timesyncd[215]: Synchronized to time 
server 208.81.1.244:123 (2.debian.pool.ntp.org).
Sep 10 00:43:48 raspberrypi systemd-timesyncd[215]: Timed out waiting 
for reply from 208.81.1.244:123 (2.debian.pool.ntp.org).
Sep 10 00:43:48 raspberrypi systemd-timesyncd[215]: Synchronized to time 
server 174.94.155.224:123 (2.debian.pool.ntp.org).

No way to check for offset and other such stats, though.  (It may not 
even track that.)

Chrony seems to be a quite capable replacement for NTPD, with a 
configuration file format that looks quite similar (at least for the 
basic config).  There are a couple different commands to get stats...

[root at host ~]# chronyc sources
210 Number of sources = 7
MS Name/IP address         Stratum Poll Reach LastRx Last sample
===============================================================================
^* ntp1.mydomain.net             3  10   377   280   -274us[ -216us] +/- 
   71ms
^+ ntp2.mydomain.net             3  10   377   585   -348us[ -290us] +/- 
   66ms
^+ ntp3.mydomain.net             3  10   377   510   -696us[ -638us] +/- 
   68ms
^+ james.kirk.hungrycats.org     2  10   377   229  -3138us[-3138us] +/- 
   69ms
^+ ns541050.ip-144-217-252.n     3   9   377   390  -2763us[-2705us] +/- 
  102ms
^+ sanction.treborlogic.com      2  10   377   983   +573us[ +630us] +/- 
   75ms
^+ 209.115.181.107               3  10   377   455    +13ms[  +13ms] +/- 
  108ms
[root at host ~]# chronyc sourcestats
210 Number of sources = 7
Name/IP Address            NP  NR  Span  Frequency  Freq Skew  Offset 
Std Dev
==============================================================================
ntp1.mydomain.net          39  19  273m     -0.000      0.007   -814us 
  65us
ntp2.mydomain.net          16   9   90m     -0.002      0.066   -619us 
  68us
ntp3.mydomain.net          27  17  226m     -0.010      0.013   -784us 
  52us
james.kirk.hungrycats.org   6   4   86m     +0.160      1.290  -3291us 
739us
ns541050.ip-144-217-252.n   8   6   60m     -0.143      0.280  -3050us 
162us
sanction.treborlogic.com    6   3   86m     +0.287      0.623   +614us 
302us
209.115.181.107            12   9  189m     +0.129      0.121    +13ms 
262us
[root at hedge ~]#

The default config is set up to query servers in the pool for the distro 
(rhel in the above example, with the last 4 servers shown), but will 
also include any NTP servers indicated by DHCP (the first 3 servers 
shown, with bogus host names in this example).

I haven't tried OpenNTPD (The OpenBSD NTP daemon), so I don't know how 
that one looks compared to the classic NTPD.

Gilbert

-- 
Manitoba UNIX User Group	E-mail: <gedetil at muug.ca>
c/o Gilbert E. Detillieux	Web:	http://muug.ca/
University of Manitoba		Phone:  (204)474-8161
Winnipeg MB CANADA  R3T 2N2	Fax:    (204)474-7609


More information about the Roundtable mailing list