xref: /freebsd/contrib/ntp/html/sntp.html (revision a0409676120c1e558d0ade943019934e0f15118d)
1<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
2<html>
3<head>
4<meta http-equiv="content-type" content="text/html;charset=iso-8859-1">
5<title>sntp - Simple Network Time Protocol (SNTP) Client</title>
6<!-- Changed by: Harlan &, 07-Dec-2014 -->
7<link href="scripts/style.css" type="text/css" rel="stylesheet">
8</head>
9<body>
10<h3><tt>sntp</tt> - Simple Network Time Protocol (SNTP) Client</h3>
11<img src="pic/dogsnake.gif" alt="gif" align="left"><a href="http://www.eecis.udel.edu/~mills/pictures.html">from <i>Alice's Adventures in Wonderland</i>, Lewis Carroll</a>
12<p>S is for snakeoil.</p>
13<p>Last update:
14  <!-- #BeginDate format:En2m -->1-Apr-2015  11:05<!-- #EndDate -->
15  UTC</p>
16<br clear="left">
17<hr>
18<h4>Synopsis</h4>
19<tt>sntp [{--help -?}][{-4 -6}][-a <i>keynum</i>][-b <i>bcaddress</i>][-B <i>bctimeout</i>][-c][-d][-D <i>debug-level</i>][-g <i>delay</i>][-K <i>kodfile</i>][-k <i>keyfile</i>][-l <i>logfile</i>][-M <i>steplimit</i>][-o <i>ntpver</i>][-r][-S][-s][-u <i>uctimeout</i>][--wait][--version][<i>address(es)</i>]</tt>
20<h4>Description</h4>
21<p>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 <tt>cron</tt> job. The program implements the SNTP client protocol defined in RFC 5905, including the full on-wire protocol but does not provide the sanity checks, access controls, security functions and mitigation algorithms as in the full NTP version 4 specification, also defined in RFC 5905.</p>
22<p>By default, <tt>sntp</tt> writes the local date and time (i.e., not UTC) to the standard output in the format</p>
23<p><tt>2011-08-04 00:40:36.642222 (+0000) +0.006611 +/- 0.041061  psp-os1 149.20.68.26 s3 no-leap</tt></p>
24<p>where the <tt>+0.006611 +/- 0.041061</tt> indicates the time offset and error bound of the system clock relative to the server clock, in seconds.  The hostname and/or the IP is displayed, as is the stratum of the server.  Finally, the leap indicator status is displayed.</p>
25<p>If -b <i>bcaddress</i> is not specified, the program sends a single message to each address and waits up to <i>uctimeout</i> (default 5) seconds for a unicast server response. Otherwise, it sends no message and waits up to <i>bctimeout</i> (default 68) seconds for a broadcast NTP message.</p>
26<h4>Options</h4>
27<p><tt>sntp</tt> recognizes the following options:</p>
28<dl>
29  <dt><tt>-?, --help</tt></dt>
30  <dd>displays usage information.  The short form typically requires shell quoting, such as <tt>-\?</tt>, otherwise <tt>?</tt> is consumed by the shell.</dd>
31  <dt><tt>-4, --ipv4</tt></dt>
32  <dd>When resolving hostnames to IP addresses, use IPv4 addresses only.</dd>
33  <dt><tt>-6, --ipv6</tt></dt>
34  <dd>When resolving hostnames to IP addresses, use IPv6 addresses only.</dd>
35  <dt><tt>-a <i>keynum</i>, --authentication <i>keynum</i></tt></dt>
36  <dd>Enable authentication with the key ID <i>keynum</i>.  <i>keynum</i> is a number specified in the keyfile along with an authentication secret (password or digest).  See the <tt>-k, --keyfile</tt> option for more details.</dd>
37  <dt><tt>-b <i>bcaddress</i>, --broadcast <i>bcaddress</i></tt></dt>
38  <dd>Listen for NTP packets sent to the broadcast or multicast address <i>bcaddress</i>, which can be a DNS name or IP address.  The default maximum time to listen for broadcasts/multicasts, 68 seconds, can be modified with the <tt>-B, --bctimeout</tt> option.</dd>
39  <dt><tt>-B <i>bctimeout</i>, --bctimeout <i>bctimeout</i></tt></dt>
40  <dd>Wait <i>bctimeout</i> seconds for broadcast or multicast NTP message before terminating.  The default is 68 seconds, chosen because ntpd typically transmits broadcasts/multicasts every 64 seconds.  Note that the short option is <tt>-B</tt>, an uppercase letter B.</dd>
41  <dt><tt>-c, --concurrent</tt></dt>
42  <dd>Concurrently query all addresses returned for hostname.  Requests from an NTP client to a single server should never be sent more often than once every two seconds.  By default, all addresses resolved from a single hostname are assumed to be for a single instance of ntpd, and therefore sntp will send queries to these addresses one after another, waiting two seconds between queries.  This option indicates multiple addresses returned for a hostname are on different machines, so sntp can send concurrent queries.  This is appropriate when using *.pool.ntp.org, for example.</dd>
43  <dt><tt>-d, --debug-level</tt></dt>
44  <dd>Increase debug verbosity level by one.  May be specified multiple times.  See also the <tt>-D, --set-debug-level</tt> option.</dd>
45  <dt><tt>-D <i>debug-level</i>, --set-debug-level <i>debug-level</i></tt></dt>
46  <dd>Set the debug verbosity level to <i>debug-level</i>.  The default level is zero.  Note that the short option is <tt>-D</tt>, an uppercase letter D.  See also the <tt>-d, --debug-level</tt> option.</dd>
47  <dt><tt>-g <i>delay</i>, --gap <i>delay</i></tt></dt>
48  <dd>Specify the <i>delay</i> in milliseconds between outgoing queries, defaulting to 50.  <tt>sntp</tt> sends queries to all provided hostnames/addresses in short succession, and by default terminates once the first valid response is received.  With multiple time sources provided, all but one will not be used.  To limit the number of queries whose responses will not be used, each query is separated from the preceding one by <i>delay</i> milliseconds, to allow time for responses to earlier queries to be received.  A larger <i>delay</i> reduces the query load on the time sources, increasing the time to receive a valid response if the first source attempted is slow or unreachable.</dd>
49  <dt><tt>-K <i>kodfile</i>, --kod <i>kodfile</i></tt></dt>
50  <dd>Specifies the filename <i>kodfile</i> to be used for the persistent history of KoD (Kiss Of Death, or rate-limiting) responses received from servers.  The default is <tt>/var/db/ntp-kod</tt>.  If the file does not exist, a warning message will be displayed.  The file will not be created.  Note that the short option is <tt>-K</tt>, an uppercase letter K.</dd>
51  <dt><tt>-k <i>keyfile</i>, --keyfile <i>keyfile</i></tt></dt>
52  <dd>Specifies the filename <i>keyfile</i> used with the <tt>-a</tt>/<tt>--authentication</tt> option.  The format of the file is described on the <a href="keygen.html"><tt>ntp-keygen</tt> page</a>.</dd>
53  <dt><tt>-l <i>logfile</i>, --filelog <i>logfile</i></tt></dt>
54  <dd>Specifies the filename in which to append a copy of status messages, which also appear on the terminal.</dd>
55  <dt><tt>-M <i>steplimit</i>, --steplimit <i>steplimit</i></tt></dt>
56  <dd>If both <tt>-S</tt>/<tt>--step</tt> and <tt>-s</tt>/<tt>--slew</tt> options are provided, an offset of less than <i>steplimit</i> milliseconds will be corrected by slewing the clock using adjtime(), while an offset of <i>steplimit</i> or more will be corrected by setting the clock to the corrected time.  Note that the short option is <tt>-M</tt>, an uppercase letter M.</dd>
57  <dt><tt>-o <i>ntpver</i>, --ntpversion <i>ntpver</i></tt></dt>
58  <dd>Specifies the NTP protocol version number <i>ntpver</i> to include in requests, default 4.  This option is rarely useful.</dd>
59  <dt><tt>-r, --usereservedport</tt></dt>
60  <dd>By default, <tt>sntp</tt> uses a UDP source port number selected by the operating system.  When this option is used, the reserved NTP port 123 is used, which most often requires <tt>sntp</tt> be invoked as the superuser (commonly "root").  This can help identify connectivity failures due to port-based firewalling which affect <tt>ntpd</tt>, which always uses source port 123.</dd>
61  <dt><tt>-S, --step</tt></dt>
62  <dd>By default, <tt>sntp</tt> displays the clock offset but does not attempt to correct it.  This option enables offset correction by stepping, that is, directly setting the clock to the corrected time.  This typically requires <tt>sntp</tt> be invoked as the superuser ("root").  Note that the short option is <tt>-S</tt>, an uppercase letter S.</dd>
63  <dt><tt>-s, --slew</tt></dt>
64  <dd>By default, <tt>sntp</tt> displays the clock offset but does not attempt to correct it.  This option enables offset correction by slewing using adjtime(), which changes the rate of the clock for a period long enough to accomplish the required offset (phase) correction.  This typically requires <tt>sntp</tt> be invoked as the superuser ("root").</dd>
65  <dt><tt>-u <i>uctimeout</i>, --uctimeout <i>uctimeout</i></tt></dt>
66  <dd>Specifies the maximum time <i>uctimeout</i> in seconds to wait for a unicast response before terminating.</dd>
67  <dt><tt>--wait</tt></dt>
68  <dd>When neither <tt>-S</tt>/<tt>--step</tt> nor <tt>-s</tt>/<tt>--slew</tt> options are provided, <tt>sntp</tt> will by default terminate after the first valid response is received.  This option causes <tt>sntp</tt> to instead wait for all pending queries' responses.</dd>
69  <dt><tt>--version</tt></dt>
70  <dd>Display the <tt>sntp</tt> program's version number and the date and time it was compiled.</dd>
71</dl>
72<h4>Return Value</h4>
73<p>The program returns an exit status of zero for if a valid response is received and non-zero otherwise.</p>
74<h4>Author</h4>
75<p>This <tt>sntp</tt> was originally developed by Johannes Maximilian Kuehn.  Harlan Stenn and Dave Hart modified it to query more than one server at a time.  See the file <tt>ChangeLog</tt> in the distribution for details.</p>
76<hr>
77<script type="text/javascript" language="javascript" src="scripts/footer.txt"></script>
78</body>
79</html>
80