### Simple Network Time Protocol (SNTP) Client

from Alice's Adventures in Wonderland, Lewis Carroll

S is for snakeoil

Last update: 18:50 UTC Thursday, July 28, 2005

#### Synopsis

`sntp [{-h --help -?}][{ -v -V -W }][{-r -a}][-P prompt][-e minerr][-E maxerr][-c count][-d delay][address(es)]`

#### Description

This program is a Simple Network Time Protocol (SNTP) client that can be used to query a Network TIme Protocol (NTP) server and display the time offset of the system clock relative to the server clock. Run as root it can correct the system clock to this offset as well. It can be run as an interactive command or from a script by a `cron` job. The program implements the SNTP protocol defined in RFC-2030, which is a subset of the NTP protocol defined in RFC-1305, but does not provide the sanity checks, access controls, security functions and mitigation algorithms as in the full NTP implementation.

While this program can do other things, including operation as a primitive server, some of these things are truly dangerous in a ubiquitous public time server network. A full disclosure is in the man page in the `./sntp` directory, but be truly advised RFC-2030 specifically forbids a SNTP client to operate as a server for other NTP or SNTP clients. If such operation is contemplated, do not allow access by clients on the public Internet.

By default, `sntp` writes the local date and time (i.e., not UTC) to the standard output in the format

`1996 Oct 15 20:17:25.123 + 4.567 +/- 0.089 secs`,

where the `+ 4.567 +/- 0.089 secs` indicates the time offset and error bound of the system clock relative to the server clock.

If a NTP server address is explicitly specified, the program sends a single message to the server and waits up to delay seconds for a unicast server message. Otherwise, it sends no message and waits up to delay seconds for a broadcast server message.

#### Options

`sntp` recognizes the following options:

`-h, --help`
  displays usage information.
`-v`
  writes diagnostic messages and a limited amount of tracing to standard error. The `-v, -V` and `-W` give increasing levels of detail.
`-r`
  steps the system clock to the correct time by the Unix `settimeofday` system call. Requires root priviledge.
`-a`
  slews the system clock to the correct time by the Unix `adjtime` system call. Requires root priviledge.
`-e minerr`
  sets the minimum offset to `minerr` seconds. Measured offsets less than this are ignored. Acceptable values are from 0.001 to 1 with default 0.1 if unicast mode and 0.5 for broadcast mode.
`-E maxerr`
  sets the maximum offset to `maxerr` seconds. Measured offsets greater than this are ignored. Acceptable values are from 1 to 60 with default 5.
`-P prompt`
  sets the maximum automatic offset to `maxerr` seconds. Acceptable values are from 1 to 3600 or `no`, with default 30. If the program is being run interactively, measured offsets greater than this will prompt the user for confirmation. Specifying `no` will disable this and the correction will be made regardless.
`-c count`
  sets the maximum number of NTP packets required to count. Acceptable values are from 1 to 25 in unicast mode and 5 to 25 in broadcast mode. The default is 5 in either mode.
`-d delay`
  sets the maximum waiting time in broadcast mode to delay seconds. Acceptable values are from 1 to 3600, with default 15 in unicast mode and 300 in broadcast mode.

#### Return Value

The program returns an exit status of zero for success and non-zero otherwise.

#### Author

`sntp` was developed by N.M. Maclaren of the University of Cambridge Computing Service.