Initial import from FreeBSD RELENG_4:
[dragonfly.git] / contrib / ntp / html / ntpdc.htm
1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN">
2 <html>
3 <head>
4 <meta name="generator" content="HTML Tidy, see www.w3.org">
5 <title>ntpdc - special NTP query program</title>
6 </head>
7 <body>
8 <h3><tt>ntpdc</tt> - special NTP query program</h3>
9
10 <img align="left" src="pic/alice31.gif" alt="gif"><a href=
11 "http://www.eecis.udel.edu/~mills/pictures.htm">from <i>Alice's
12 Adventures in Wonderland</i>, Lewis Carroll</a> 
13
14 <p>This program is a big puppy.<br clear="left">
15 </p>
16
17 <hr>
18 <h4>Synopsis</h4>
19
20 <tt>ntpdc [ -ilnps ] [ -c <i>command</i> ] [ <i>host</i> ] [ ...
21 ]</tt> 
22
23 <h4>Description</h4>
24
25 <tt>ntpdc</tt> is used to query the <tt>ntpd</tt> daemon about its
26 current state and to request changes in that state. The program may
27 be run either in interactive mode or controlled using command line
28 arguments. Extensive state and statistics information is available
29 through the <tt>ntpdc</tt> interface. In addition, nearly all the
30 configuration options which can be specified at startup using
31 ntpd's configuration file may also be specified at run time using
32 <tt>ntpdc</tt>. 
33
34 <p>If one or more request options are included on the command line
35 when <tt>ntpdc</tt> is executed, each of the requests will be sent
36 to the NTP servers running on each of the hosts given as command
37 line arguments, or on localhost by default. If no request options
38 are given, <tt>ntpdc</tt> will attempt to read commands from the
39 standard input and execute these on the NTP server running on the
40 first host given on the command line, again defaulting to localhost
41 when no other host is specified. <tt>ntpdc</tt> will prompt for
42 commands if the standard input is a terminal device.</p>
43
44 <p><tt>ntpdc</tt> uses NTP mode 7 packets to communicate with the
45 NTP server, and hence can be used to query any compatable server on
46 the network which permits it. Note that since NTP is a UDP protocol
47 this communication will be somewhat unreliable, especially over
48 large distances in terms of network topology. <tt>ntpdc</tt> makes
49 no attempt to retransmit requests, and will time requests out if
50 the remote host is not heard from within a suitable timeout
51 time.</p>
52
53 <p>The operation of <tt>ntpdc</tt> are specific to the particular
54 implementation of the <tt>ntpd</tt> daemon and can be expected to
55 work only with this and maybe some previous versions of the daemon.
56 Requests from a remote <tt>ntpdc</tt> program which affect the
57 state of the local server must be authenticated, which requires
58 both the remote program and local server share a common key and key
59 identifier.</p>
60
61 <h4>Command Line Options</h4>
62
63 Specifying a command line option other than <tt>-i</tt> or <tt>
64 -n</tt> will cause the specified query (queries) to be sent to the
65 indicated host(s) immediately. Otherwise, <tt>ntpdc</tt> will
66 attempt to read interactive format commands from the standard
67 input. 
68
69 <dl>
70 <dt><tt>-c <i>command</i></tt></dt>
71
72 <dd>The following argument is interpreted as an interactive format
73 command and is added to the list of commands to be executed on the
74 specified host(s). Multiple -c options may be given.</dd>
75
76 <dt><tt>-i</tt></dt>
77
78 <dd>Force <tt>ntpdc</tt> to operate in interactive mode. Prompts
79 will be written to the standard output and commands read from the
80 standard input.</dd>
81
82 <dt><tt>-l</tt></dt>
83
84 <dd>Obtain a list of peers which are known to the server(s). This
85 switch is equivalent to <tt>-c listpeers</tt>.</dd>
86
87 <dt><tt>-n</tt></dt>
88
89 <dd>Output all host addresses in dotted-quad numeric format rather
90 than converting to the canonical host names.</dd>
91
92 <dt><tt>-p</tt></dt>
93
94 <dd>Print a list of the peers known to the server as well as a
95 summary of their state. This is equivalent to <tt>-c
96 peers</tt>.</dd>
97
98 <dt><tt>-s</tt></dt>
99
100 <dd>Print a list of the peers known to the server as well as a
101 summary of their state, but in a slightly different format than the
102 -p switch. This is equivalent to <tt>-c dmpeers</tt>.</dd>
103 </dl>
104
105 <h4>Interactive Commands</h4>
106
107 Interactive format commands consist of a keyword followed by zero
108 to four arguments. Only enough characters of the full keyword to
109 uniquely identify the command need be typed. The output of a
110 command is normally sent to the standard output, but optionally the
111 output of individual commands may be sent to a file by appending a
112 <tt>&lt;</tt>, followed by a file name, to the command line. 
113
114 <p>A number of interactive format commands are executed entirely
115 within the <tt>ntpdc</tt> program itself and do not result in NTP
116 mode 7 requests being sent to a server. These are described
117 following.</p>
118
119 <dl>
120 <dt><tt>? [ <i>command_keyword</i> ]</tt><br>
121 <tt>help [ <i>command_keyword</i> ]</tt></dt>
122
123 <dd>A <tt>?</tt> by itself will print a list of all the command
124 keywords known to this incarnation of <tt>ntpq</tt>. A <tt>?</tt>
125 followed by a command keyword will print funcation and usage
126 information about the command. This command is probably a better
127 source of information about <tt>ntpq</tt> than this manual
128 page.</dd>
129
130 <dt><tt>delay <i>milliseconds</i></tt></dt>
131
132 <dd>Specify a time interval to be added to timestamps included in
133 requests which require authentication. This is used to enable
134 (unreliable) server reconfiguration over long delay network paths
135 or between machines whose clocks are unsynchronized. Actually the
136 server does not now require timestamps in authenticated requests,
137 so this command may be obsolete.</dd>
138
139 <dt><tt>host <i>hostname</i></tt></dt>
140
141 <dd>Set the host to which future queries will be sent. Hostname may
142 be either a host name or a numeric address.</dd>
143
144 <dt><tt>hostnames [ yes | no ]</tt></dt>
145
146 <dd>If <tt>yes</tt> is specified, host names are printed in
147 information displays. If <tt>no</tt> is specified, numeric
148 addresses are printed instead. The default is <tt>yes</tt>, unless
149 modified using the command line <tt>-n</tt> switch.</dd>
150
151 <dt><tt>keyid <i>keyid</i></tt></dt>
152
153 <dd>This command allows the specification of a key number to be
154 used to authenticate configuration requests. This must correspond
155 to a key number the server has been configured to use for this
156 purpose.</dd>
157
158 <dt><tt>quit</tt></dt>
159
160 <dd>Exit <tt>ntpdc</tt>.</dd>
161
162 <dt><tt>passwd</tt></dt>
163
164 <dd>This command prompts you to type in a password (which will not
165 be echoed) which will be used to authenticate configuration
166 requests. The password must correspond to the key configured for
167 use by the NTP server for this purpose if such requests are to be
168 successful.</dd>
169
170 <dt><tt>timeout <i>millseconds</i></tt></dt>
171
172 <dd>Specify a timeout period for responses to server queries. The
173 default is about 8000 milliseconds. Note that since <tt>ntpdc</tt>
174 retries each query once after a timeout, the total waiting time for
175 a timeout will be twice the timeout value set.</dd>
176 </dl>
177
178 <h4>Control Message Commands</h4>
179
180 Query commands result in NTP mode 7 packets containing requests for
181 information being sent to the server. These are read-only commands
182 in that they make no modification of the server configuration
183 state. 
184
185 <dl>
186 <dt><tt>listpeers</tt></dt>
187
188 <dd>Obtains and prints a brief list of the peers for which the
189 server is maintaining state. These should include all configured
190 peer associations as well as those peers whose stratum is such that
191 they are considered by the server to be possible future
192 synchonization candidates.</dd>
193
194 <dt><tt>peers</tt></dt>
195
196 <dd>Obtains a list of peers for which the server is maintaining
197 state, along with a summary of that state. Summary information
198 includes the address of the remote peer, the local interface
199 address (0.0.0.0 if a local address has yet to be determined), the
200 stratum of the remote peer (a stratum of 16 indicates the remote
201 peer is unsynchronized), the polling interval, in seconds, the
202 reachability register, in octal, and the current estimated delay,
203 offset and dispersion of the peer, all in seconds. 
204
205 <p>The character in the left margin indicates the mode this peer
206 entry is operating in. A <tt>+</tt> denotes symmetric active, a
207 <tt>-</tt> indicates symmetric passive, a <tt>=</tt> means the
208 remote server is being polled in client mode, a <tt>^</tt>
209 indicates that the server is broadcasting to this address, a <tt>
210 ~</tt> denotes that the remote peer is sending broadcasts and a
211 <tt>*</tt> marks the peer the server is currently synchonizing
212 to.</p>
213
214 <p>The contents of the host field may be one of four forms. It may
215 be a host name, an IP address, a reference clock implementation
216 name with its parameter or <tt>REFCLK(<i>implementation number</i>,
217 <i>parameter</i>)</tt>. On <tt>hostnames no</tt> only IP-addresses
218 will be displayed.</p>
219 </dd>
220
221 <dt><tt>dmpeers</tt></dt>
222
223 <dd>A slightly different peer summary list. Identical to the output
224 of the <tt>peers</tt> command, except for the character in the
225 leftmost column. Characters only appear beside peers which were
226 included in the final stage of the clock selection algorithm. A
227 <tt>.</tt> indicates that this peer was cast off in the falseticker
228 detection, while a <tt>+</tt> indicates that the peer made it
229 through. A <tt>*</tt> denotes the peer the server is currently
230 synchronizing with.</dd>
231
232 <dt><tt>showpeer <i>peer_address</i> [...]</tt></dt>
233
234 <dd>Shows a detailed display of the current peer variables for one
235 or more peers. Most of these values are described in the NTP
236 Version 2 specification.</dd>
237
238 <dt><tt>pstats <i>peer_address</i> [...]</tt></dt>
239
240 <dd>Show per-peer statistic counters associated with the specified
241 peer(s).</dd>
242
243 <dt><tt>clockinfo <i>clock_peer_address</i> [...]</tt></dt>
244
245 <dd>Obtain and print information concerning a peer clock. The
246 values obtained provide information on the setting of fudge factors
247 and other clock performance information.</dd>
248
249 <dt><tt>kerninfo</tt></dt>
250
251 <dd>Obtain and print kernel phase-lock loop operating parameters.
252 This information is available only if the kernel has been specially
253 modified for a precision timekeeping function.</dd>
254
255 <dt><tt>loopinfo [ oneline | multiline ]</tt></dt>
256
257 <dd>Print the values of selected loop filter variables. The loop
258 filter is the part of NTP which deals with adjusting the local
259 system clock. The <tt>offset</tt> is the last offset given to the
260 loop filter by the packet processing code. The <tt>frequency</tt>
261 is the frequency error of the local clock in parts-per-million
262 (ppm). The <tt>time_const</tt> controls the stiffness of the
263 phase-lock loop and thus the speed at which it can adapt to
264 oscillator drift. The <tt>watchdog timer</tt> value is the number
265 of seconds which have elapsed since the last sample offset was
266 given to the loop filter. The <tt>oneline</tt> and <tt>
267 multiline</tt> options specify the format in which this information
268 is to be printed, with <tt>multiline</tt> as the default.</dd>
269
270 <dt><tt>sysinfo</tt></dt>
271
272 <dd>Print a variety of system state variables, i.e., state related
273 to the local server. All except the last four lines are described
274 in the NTP Version 3 specification, RFC-1305. 
275
276 <p>The <tt>system flags</tt> show various system flags, some of
277 which can be set and cleared by the <tt>enable</tt> and <tt>
278 disable</tt> configuration commands, respectively. These are the
279 <tt>auth</tt>, <tt>bclient</tt>, <tt>monitor</tt>, <tt>pll</tt>,
280 <tt>pps</tt> and <tt>stats</tt> flags. See the <tt>ntpd</tt>
281 documentation for the meaning of these flags. There are two
282 additional flags which are read only, the <tt>kernel_pll</tt> and
283 <tt>kernel_pps</tt>. These flags indicate the synchronization
284 status when the precision time kernel modifications are in use. The
285 <tt>kernel_pll</tt> indicates that the local clock is being
286 disciplined by the kernel, while the kernel_pps indicates the
287 kernel discipline is provided by the PPS signal.</p>
288
289 <p>The <tt>stability</tt> is the residual frequency error remaining
290 afterthe system frequency correction is applied and is intended for
291 maintenance and debugging. In most architectures, this value will
292 initially decrease from as high as 500 ppm to a nominal value in
293 the range .01 to 0.1 ppm. If it remains high for some time after
294 starting the daemon, something may be wrong with the local clock,
295 or the value of the kernel variable <tt>tick</tt> may be
296 incorrect.</p>
297
298 <p>The <tt>broadcastdelay</tt> shows the default broadcast delay,
299 as set by the <tt>broadcastdelay</tt> configuration command.</p>
300
301 <p>The <tt>authdelay</tt> shows the default authentication delay,
302 as set by the <tt>authdelay</tt> configuration command.</p>
303 </dd>
304
305 <dt><tt>sysstats</tt></dt>
306
307 <dd>Print statistics counters maintained in the protocol
308 module.</dd>
309
310 <dt><tt>memstats</tt></dt>
311
312 <dd>Print statistics counters related to memory allocation
313 code.</dd>
314
315 <dt><tt>iostats</tt></dt>
316
317 <dd>Print statistics counters maintained in the input-output
318 module.</dd>
319
320 <dt><tt>timerstats</tt></dt>
321
322 <dd>Print statistics counters maintained in the timer/event queue
323 support code.</dd>
324
325 <dt><tt>reslist</tt></dt>
326
327 <dd>Obtain and print the server's restriction list. This list is
328 (usually) printed in sorted order and may help to understand how
329 the restrictions are applied.</dd>
330
331 <dt><tt>monlist [ <i>version</i> ]</tt></dt>
332
333 <dd>Obtain and print traffic counts collected and maintained by the
334 monitor facility. The version number should not normally need to be
335 specified.</dd>
336
337 <dt><tt>clkbug <i>clock_peer_address</i> [...]</tt></dt>
338
339 <dd>Obtain debugging information for a reference clock driver. This
340 information is provided only by some clock drivers and is mostly
341 undecodable without a copy of the driver source in hand.</dd>
342 </dl>
343
344 <h4>Runtime Configuration Requests</h4>
345
346 All requests which cause state changes in the server are
347 authenticated by the server using a configured NTP key (the
348 facility can also be disabled by the server by not configuring a
349 key). The key number and the corresponding key must also be made
350 known to xtnpdc. This can be done using the keyid and passwd
351 commands, the latter of which will prompt at the terminal for a
352 password to use as the encryption key. You will also be prompted
353 automatically for both the key number and password the first time a
354 command which would result in an authenticated request to the
355 server is given. Authentication not only provides verification that
356 the requester has permission to make such changes, but also gives
357 an extra degree of protection again transmission errors. 
358
359 <p>Authenticated requests always include a timestamp in the packet
360 data, which is included in the computation of the authentication
361 code. This timestamp is compared by the server to its receive time
362 stamp. If they differ by more than a small amount the request is
363 rejected. This is done for two reasons. First, it makes simple
364 replay attacks on the server, by someone who might be able to
365 overhear traffic on your LAN, much more difficult. Second, it makes
366 it more difficult to request configuration changes to your server
367 from topologically remote hosts. While the reconfiguration facility
368 will work well with a server on the local host, and may work
369 adequately between time-synchronized hosts on the same LAN, it will
370 work very poorly for more distant hosts. As such, if reasonable
371 passwords are chosen, care is taken in the distribution and
372 protection of keys and appropriate source address restrictions are
373 applied, the run time reconfiguration facility should provide an
374 adequate level of security.</p>
375
376 <p>The following commands all make authenticated requests.</p>
377
378 <dl>
379 <dt><tt>addpeer <i>peer_address</i> [ <i>keyid</i> ] [ <i>
380 version</i> ] [ <i>prefer</i> ]</tt></dt>
381
382 <dd>Add a configured peer association at the given address and
383 operating in symmetric active mode. Note that an existing
384 association with the same peer may be deleted when this command is
385 executed, or may simply be converted to conform to the new
386 configuration, as appropriate. If the optional <tt>keyid</tt> is a
387 nonzero integer, all outgoing packets to the remote server will
388 have an authentication field attached encrypted with this key. If
389 the value is 0 (or not given) no authentication will be done. The
390 <tt>version#</tt> can be 1, 2 or 3 and defaults to 3. The <tt>
391 prefer</tt> keyword indicates a preferred peer (and thus will be
392 used primarily for clock synchronisation if possible). The
393 preferred peer also determines the validity of the PPS signal - if
394 the preferred peer is suitable for synchronisation so is the PPS
395 signal.</dd>
396
397 <dt><tt>addserver <i>peer_address</i> [ <i>keyid</i> ] [ <i>
398 version</i> ] [ <i>prefer</i> ]</tt></dt>
399
400 <dd>Identical to the addpeer command, except that the operating
401 mode is client.</dd>
402
403 <dt><tt>broadcast <i>peer_address</i> [ <i>keyid</i> ] [ <i>
404 version</i> ] [ <i>prefer</i> ]</tt></dt>
405
406 <dd>Identical to the addpeer command, except that the operating
407 mode is broadcast. In this case a valid key identifier and key are
408 required. The <tt>peer_address</tt> parameter can be the broadcast
409 address of the local network or a multicast group address assigned
410 to NTP. If a multicast address, a multicast-capable kernel is
411 required.</dd>
412
413 <dt><tt>unconfig <i>peer_address</i> [...]</tt></dt>
414
415 <dd>This command causes the configured bit to be removed from the
416 specified peer(s). In many cases this will cause the peer
417 association to be deleted. When appropriate, however, the
418 association may persist in an unconfigured mode if the remote peer
419 is willing to continue on in this fashion.</dd>
420
421 <dt><tt>fudge <i>peer_address</i> [ <i>time1</i> ] [ <i>time2</i> ]
422 [ <i>stratum</i> ] [ <i>refid</i> ]</tt></dt>
423
424 <dd>This command provides a way to set certain data for a reference
425 clock. See the source listing for further information.</dd>
426
427 <dt><tt>enable [ <i>flag</i> ] [ ... ]</tt><br>
428 <tt>disable [ <i>flag</i> ] [ ... ]</tt></dt>
429
430 <dd>These commands operate in the same way as the <tt>enable</tt>
431 and <tt>disable</tt> configuration file commands of <tt>ntpd</tt>.
432 Following is a description of the flags. Note that only the <tt>
433 auth</tt>, <tt>bclient</tt>, <tt>monitor</tt>, <tt>pll</tt>, <tt>
434 pps</tt> and <tt>stats</tt> flags can be set by <tt>ntpdc</tt>; the
435 <tt>pll_kernel</tt> and <tt>pps_kernel</tt> flags are
436 read-only.</dd>
437
438 <dd>
439 <dl>
440 <dt><tt>auth</tt></dt>
441
442 <dd>Enables the server to synchronize with unconfigured peers only
443 if the peer has been correctly authenticated using a trusted key
444 and key identifier. The default for this flag is enable.</dd>
445
446 <dt><tt>bclient</tt></dt>
447
448 <dd>Enables the server to listen for a message from a broadcast or
449 multicast server, as in the <tt>multicastclient</tt> command with
450 default address. The default for this flag is disable.</dd>
451
452 <dt><tt>monitor</tt></dt>
453
454 <dd>Enables the monitoring facility. See the <tt>ntpdc</tt> program
455 and the <tt>monlist</tt> command or further information. The
456 default for this flag is enable.</dd>
457
458 <dt><tt>pll</tt></dt>
459
460 <dd>Enables the server to adjust its local clock by means of NTP.
461 If disabled, the local clock free-runs at its intrinsic time and
462 frequency offset. This flag is useful in case the local clock is
463 controlled by some other device or protocol and NTP is used only to
464 provide synchronization to other clients. In this case, the local
465 clock driver is used. See the <a href="refclock.htm">Reference
466 Clock Drivers</a> page for further information. The default for
467 this flag is enable.</dd>
468
469 <dt><tt>pps</tt></dt>
470
471 <dd>Enables the pulse-per-second (PPS) signal when frequency and
472 time is disciplined by the precision time kernel modifications. See
473 the <a href="kern.htm">A Kernel Model for Precision Timekeeping</a>
474 page for further information. The default for this flag is
475 disable.</dd>
476
477 <dt><tt>stats</tt></dt>
478
479 <dd>Enables the statistics facility. See the <a href="monopt.htm">
480 Monitoring Options</a> page for further information. The default
481 for this flag is enable.</dd>
482
483 <dt><tt>pll_kernel</tt></dt>
484
485 <dd>When the precision time kernel modifications are installed,
486 this indicates the kernel controls the clock discipline; otherwise,
487 the daemon controls the clock discipline.</dd>
488
489 <dt><tt>pps_kernel</tt></dt>
490
491 <dd>When the precision time kernel modifications are installed and
492 a pulse-per-second (PPS) signal is available, this indicates the
493 PPS signal controls the clock discipline; otherwise, the daemon or
494 kernel controls the clock discipline, as indicated by the <tt>
495 pll_kernel</tt> flag.</dd>
496 </dl>
497 </dd>
498
499 <dt><tt>restrict <i>address mask flag</i> [ <i>flag</i> ]</tt></dt>
500
501 <dd>This command operates in the same way as the <tt>restrict</tt>
502 configuration file commands of <tt>ntpd</tt>.</dd>
503
504 <dt><tt>unrestrict <i>address mask flag</i> [ <i>flag</i>
505 ]</tt></dt>
506
507 <dd>Unrestrict the matching entry from the restrict list.</dd>
508
509 <dt><tt>delrestrict <i>address mask [ ntpport ]</i></tt></dt>
510
511 <dd>Delete the matching entry from the restrict list.</dd>
512
513 <dt><tt>readkeys</tt></dt>
514
515 <dd>Causes the current set of authentication keys to be purged and
516 a new set to be obtained by rereading the keys file (which must
517 have been specified in the <tt>ntpd</tt> configuration file). This
518 allows encryption keys to be changed without restarting the
519 server.</dd>
520
521 <dt><tt>trustedkey <i>keyid</i> [...]</tt></dt>
522
523 <dt><tt>untrustedkey <i>keyid</i> [...]</tt></dt>
524
525 <dd>These commands operate in the same way as the <tt>
526 trustedkey</tt> and <tt>untrustedkey</tt> configuration file
527 commands of <tt>ntpd</tt>.</dd>
528
529 <dt><tt>authinfo</tt></dt>
530
531 <dd>Returns information concerning the authentication module,
532 including known keys and counts of encryptions and decryptions
533 which have been done.</dd>
534
535 <dt><tt>traps</tt></dt>
536
537 <dd>Display the traps set in the server. See the source listing for
538 further information.</dd>
539
540 <dt><tt>addtrap [ <i>address</i> [ <i>port</i> ] [ <i>interface</i>
541 ]</tt></dt>
542
543 <dd>Set a trap for asynchronous messages. See the source listing
544 for further information.</dd>
545
546 <dt><tt>clrtrap [ <i>address</i> [ <i>port</i> ] [ <i>
547 interface</i>]</tt></dt>
548
549 <dd>Clear a trap for asynchronous messages. See the source listing
550 for further information.</dd>
551
552 <dt><tt>reset</tt></dt>
553
554 <dd>Clear the statistics counters in various modules of the server.
555 See the source listing for further information.</dd>
556 </dl>
557
558 <h4>Bugs</h4>
559
560 <tt>ntpdc</tt> is a crude hack. Much of the information it shows is
561 deadly boring and could only be loved by its implementer. The
562 program was designed so that new (and temporary) features were easy
563 to hack in, at great expense to the program's ease of use. Despite
564 this, the program is occasionally useful. 
565
566 <hr>
567 <a href="index.htm"><img align="left" src="pic/home.gif" alt=
568 "gif"></a>
569 <address><a href="mailto:mills@udel.edu">David L. Mills
570 &lt;mills@udel.edu&gt;</a></address>
571 </body>
572 </html>
573