Name

sntpclock — check a system's clock through SNTP

Synopsis

sntpclock {host}

Description

sntpclock connects to an NTP server on port 123 of host and acts as a "leaf node" using the SNTP (RFC 2030) subset of NTP (RFC 1305). host must be a dotted-decimal IPv4 address, or the value 0 which is translated to the IP address 127.0.0.1.

Note

Although sntpclock accepts further arguments, it ignores them, and does not connect to more than 1 server.

sntpclock prints to its standard output a 16-byte TAI64NA adjustment that, when added to the local UNIX clock, will produce the TAI clock on host. This is suitable for input to programs such as clockadd(1) and clockview(1).

sntpclock limits the adjustment to 2 days.

sntpclock does not bind to port 123; this means that it does not need to run as the superuser. It may, rather, use any non-reserved source port that the operating system selects.

Note

Strictly, this is not conformant with RFC 2030, although it matches exactly the way in which RFC 4330 was later to loosen the restrictions of RFC 2030 eight years after sntpclock was written, and conforms with the client/server (non-symmetric) mode specified in RFC 5905 twelve years afterwards.

Note

Some historical firewalls that strictly enforced RFC 2030 did not permit sntpclock requests; albeit that those firewalls were rendered incorrect by RFC 4330 and RFC 5905. (Of course, any firewall can also be explicitly configured by its operator, or come default configured from its manufacturer, to block NTP, client/server or even symmetric.)

Notes

An NTP timestamp is a count of non-leap seconds. sntpclock uses a local leap-second table to convert the NTP timestamp to TAI with an epoch of 1970-01-01 00:00:10 TAI. For a discussion of the difference between UTC and TAI see UTC and TAI.

Bugs

SNTP transactions that cross a leap second will not correctly synchronize a system where the system clock ticks in SI (a.k.a. TAI) seconds. This is a problem with the protocol itself, as the UTC timestamp does not uniquely identify 1 TAI second at the point of a positive leap second. Avoid using sntpclock across a leap second on such systems.

The 32-bit NTP time scale of RFC 1305 (and RFC 5905, which does not change the 32-bit on-the-wire seconds counts) will break down in 2036. There is a suggested convention in RFC 4330 to extend this to 2104, subject to a window where the protocol breaks down because of an all-zero field, which however was obsoleted by a complex system of assumed "eras" in RFC 5905. A better approach is to use a 64-bit on-the-wire protocol that includes leap seconds and ticks SI seconds, such as the TAICLOCK protocol.

History

sntpclock was originally part of Daniel J. Bernstein's clockspeed toolset in 1998.

See also

taiclock(1)

a similar program that uses the TAICLOCK protocol

clockspeed(1)

Author

Original code and documentation by Daniel J. Bernstein. Documentation modernizations by Jonathan de Boyne Pollard.