Add the DragonFly cvs id and perform general cleanups on cvs/rcs/sccs ids. Most
[dragonfly.git] / usr.sbin / ntp / doc / ntpd.8
1 .\"
2 .\" $FreeBSD: src/usr.sbin/ntp/doc/ntpd.8,v 1.4.2.5 2003/03/11 22:31:29 trhodes Exp $
3 .\" $DragonFly: src/usr.sbin/ntp/doc/Attic/ntpd.8,v 1.2 2003/06/17 04:29:58 dillon Exp $
4 .\"
5 .Dd August  2, 2001
6 .Dt NTPD 8
7 .Os
8 .Sh NAME
9 .Nm ntpd
10 .Nd Network Time Protocol (NTP) daemon
11 .Sh SYNOPSIS
12 .Nm
13 .Op Fl aAbdgLmnPqx
14 .Op Fl c Ar conffile
15 .Op Fl D Ar level
16 .Op Fl f Ar driftfile
17 .Op Fl k Ar keyfile
18 .Op Fl l Ar logfile
19 .Op Fl N Cm high
20 .Op Fl p Ar pidfile
21 .Op Fl r Ar broadcastdelay
22 .Op Fl s Ar statsdir
23 .Op Fl t Ar key
24 .Op Fl v Ar variable
25 .Op Fl V Ar variable
26 .Sh DESCRIPTION
27 The
28 .Nm
29 utility is an operating system daemon which sets
30 and maintains the system time of day in synchronism with Internet
31 standard time servers.
32 It is a complete implementation of the
33 Network Time Protocol (NTP) version 4, but also retains
34 compatibility with version 3, as defined by RFC-1305, and version 1
35 and 2, as defined by RFC-1059 and RFC-1119, respectively.
36 .Pp
37 The
38 .Nm
39 utility does most computations in 64-bit floating point
40 arithmetic and does relatively clumsy 64-bit fixed point operations
41 only when necessary to preserve the ultimate precision, about 232
42 picoseconds.
43 While the ultimate precision, is not achievable with
44 ordinary workstations and networks of today, it may be required
45 with future gigahertz CPU clocks and gigabit LANs.
46 .Pp
47 Ordinarily,
48 .Nm
49 reads the
50 .Xr ntp.conf 5
51 configuration file at startup time in order to determine the
52 synchronization sources and operating modes.
53 It is also possible to
54 specify a working, although limited, configuration entirely on the
55 command line, obviating the need for a configuration file.
56 This may
57 be particularly useful when the local host is to be configured as a
58 broadcast/multicast client, with all peers being determined by
59 listening to broadcasts at run time.
60 .Pp
61 If NetInfo support is built into
62 .Nm ,
63 then
64 .Nm
65 will attempt to read its configuration from the
66 NetInfo if the default
67 .Xr ntp.conf 5
68 file cannot be read and no file is
69 specified by the
70 .Fl c
71 option.
72 .Pp
73 Various internal
74 .Nm
75 variables can be displayed and
76 configuration options altered while the
77 .Nm
78 is running
79 using the
80 .Xr ntpq 8
81 and
82 .Xr ntpdc 8
83 utility programs.
84 .Pp
85 When
86 .Nm
87 starts it looks at the value of
88 .Xr umask 2 ,
89 and if zero
90 .Nm
91 will set the
92 .Xr umask 2
93 to 022.
94 .Pp
95 The following options are available:
96 .Bl -tag -width indent
97 .It Fl a
98 Enable authentication mode (default).
99 .It Fl A
100 Disable authentication mode.
101 .It Fl b
102 Synchronize using NTP broadcast messages.
103 .It Fl c Ar conffile
104 Specify the name and path of the configuration file.
105 (Disable
106 netinfo?)
107 .It Fl d
108 Specify debugging mode.
109 This flag may occur multiple times,
110 with each occurrence indicating greater detail of display.
111 .It Fl D Ar level
112 Specify debugging level directly.
113 .It Fl f Ar driftfile
114 Specify the name and path of the drift file.
115 .It Fl g
116 Normally,
117 .Nm
118 exits if the offset exceeds the sanity
119 limit, which is 1000 s by default.
120 If the sanity limit is set to
121 zero, no sanity checking is performed and any offset is acceptable.
122 This option overrides the limit and allows the time to be set to
123 any value without restriction; however, this can happen only once.
124 After that,
125 .Nm
126 will exit if the limit is exceeded.
127 This
128 option can be used with the
129 .Fl q
130 option.
131 .It Fl k Ar keyfile
132 Specify the name and path of the file containing the NTP
133 authentication keys.
134 .It Fl l Ar logfile
135 Specify the name and path of the log file.
136 The default is the
137 system log facility.
138 .It Fl L
139 Listen to virtual IPs.
140 .It Fl m
141 Synchronize using NTP multicast messages on the IP multicast
142 group address 224.0.1.1 (requires multicast kernel).
143 .It Fl n
144 Don't fork.
145 .It Fl N Ar priority
146 To the extent permitted by the operating system, run the
147 .Nm
148 at a high priority.
149 .It Fl p Ar pidfile
150 Specify the name and path to record the
151 .Nm Ns 's
152 process
153 ID.
154 .It Fl P
155 Override the priority limit set by the operating system.
156 Not
157 recommended for sissies.
158 .It Fl q
159 Exit the
160 .Nm
161 just after the first time the clock is
162 set.
163 This behavior mimics that of the
164 .Xr ntpdate 8
165 program,
166 which is to be retired.
167 The
168 .Fl g
169 and
170 .Fl x
171 options can
172 be used with this option.
173 .It Fl r Ar broadcastdelay
174 Specify the default propagation delay from the
175 broadcast/multicast server and this computer.
176 This is necessary
177 only if the delay cannot be computed automatically by the
178 protocol.
179 .It Fl s Ar statsdir
180 Specify the directory path for files created by the statistics
181 facility.
182 .It Fl t Ar key
183 Add a key number to the trusted key list.
184 .It Fl v Ar variable
185 .It Fl V Ar variable
186 Add a system variable listed by default.
187 .It Fl x
188 Normally, the time is slewed if the offset is less than the
189 step threshold, which is 128 ms by default, and stepped if above
190 the threshold.
191 This option forces the time to be slewed in all
192 cases.
193 If the step threshold is set to zero, all offsets are
194 stepped, regardless of value and regardless of the
195 .Fl x
196 option.
197 In general, this is not a good idea, as it bypasses the
198 clock state machine which is designed to cope with large time and
199 frequency errors Note: Since the slew rate is limited to 0.5 ms/s,
200 each second of adjustment requires an amortization interval of 2000
201 s.
202 Thus, an adjustment of many seconds can take hours or days to
203 amortize.
204 This option can be used with the
205 .Fl q
206 option.
207 .El
208 .Ss "How NTP Operates"
209 The
210 .Nm
211 utility operates by exchanging messages with
212 one or more configured servers at designated poll intervals.
213 When
214 started, whether for the first or subsequent times, the program
215 requires several exchanges from the majority of these servers so
216 the signal processing and mitigation algorithms can accumulate and
217 groom the data and set the clock.
218 In order to protect the network
219 from bursts, the initial poll interval for each server is delayed
220 an interval randomized over 0-16s.
221 At the default initial poll
222 interval of 64s, several minutes can elapse before the clock is
223 set.
224 The initial delay to set the clock can be reduced using the
225 .Cm iburst
226 keyword with the
227 .Ic server
228 configuration
229 command, as described in
230 .Xr ntp.conf 5 .
231 .Pp
232 Most operating systems and hardware of today incorporate a
233 time-of-year (TOY) chip to maintain the time during periods when
234 the power is off.
235 When the machine is booted, the chip is used to
236 initialize the operating system time.
237 After the machine has
238 synchronized to a NTP server, the operating system corrects the
239 chip from time to time.
240 In case there is no TOY chip or for some
241 reason its time is more than 1000s from the server time,
242 .Nm
243 assumes something must be terribly wrong and the only
244 reliable action is for the operator to intervene and set the clock
245 by hand.
246 This causes
247 .Nm
248 to exit with a panic message to
249 the system log.
250 The
251 .Fl g
252 option overrides this check and the
253 clock will be set to the server time regardless of the chip time.
254 However, and to protect against broken hardware, such as when the
255 CMOS battery fails or the clock counter becomes defective, once the
256 clock has been set, an error greater than 1000s will cause
257 .Nm
258 to exit anyway.
259 .Pp
260 Under ordinary conditions,
261 .Nm
262 adjusts the clock in
263 small steps so that the timescale is effectively continuous and
264 without discontinuities.
265 Under conditions of extreme network
266 congestion, the roundtrip delay jitter can exceed three seconds and
267 the synchronization distance, which is equal to one-half the
268 roundtrip delay plus error budget terms, can become very large.
269 The
270 .Nm
271 algorithms discard sample offsets exceeding 128 ms,
272 unless the interval during which no sample offset is less than 128
273 ms exceeds 900s.
274 The first sample after that, no matter what the
275 offset, steps the clock to the indicated time.
276 In practice this
277 reduces the false alarm rate where the clock is stepped in error to
278 a vanishingly low incidence.
279 .Pp
280 As the result of this behavior, once the clock has been set, it
281 very rarely strays more than 128 ms, even under extreme cases of
282 network path congestion and jitter.
283 Sometimes, in particular when
284 .Nm
285 is first started, the error might exceed 128 ms.
286 This
287 may on occasion cause the clock to be set backwards if the local
288 clock time is more than 128 s in the future relative to the server.
289 In some applications, this behavior may be unacceptable.
290 If the
291 .Fl x
292 option is included on the command line, the clock will
293 never be stepped and only slew corrections will be used.
294 .Pp
295 The issues should be carefully explored before deciding to use
296 the
297 .Fl x
298 option.
299 The maximum slew rate possible is limited
300 to 500 parts-per-million (PPM) as a consequence of the correctness
301 principles on which the NTP protocol and algorithm design are
302 based.
303 As a result, the local clock can take a long time to
304 converge to an acceptable offset, about 2,000 s for each second the
305 clock is outside the acceptable range.
306 During this interval the
307 local clock will not be consistent with any other network clock and
308 the system cannot be used for distributed applications that require
309 correctly synchronized network time.
310 .Pp
311 In spite of the above precautions, sometimes when large
312 frequency errors are present the resulting time offsets stray
313 outside the 128-ms range and an eventual step or slew time
314 correction is required.
315 If following such a correction the
316 frequency error is so large that the first sample is outside the
317 acceptable range,
318 .Nm
319 enters the same state as when the
320 .Pa ntp.drift
321 file is not present.
322 The intent of this behavior
323 is to quickly correct the frequency and restore operation to the
324 normal tracking mode.
325 In the most extreme cases
326 (time.ien.it comes to mind), there may be occasional
327 step/slew corrections and subsequent frequency corrections.
328 It
329 helps in these cases to use the
330 .Cm burst
331 keyword when
332 configuring the server.
333 .Ss "Frequency Discipline"
334 The
335 .Nm
336 behavior at startup depends on whether the
337 frequency file, usually
338 .Pa ntp.drift ,
339 exists.
340 This file
341 contains the latest estimate of clock frequency error.
342 When the
343 .Nm
344 is started and the file does not exist, the
345 .Nm
346 enters a special mode designed to quickly adapt to
347 the particular system clock oscillator time and frequency error.
348 This takes approximately 15 minutes, after which the time and
349 frequency are set to nominal values and the
350 .Nm
351 enters
352 normal mode, where the time and frequency are continuously tracked
353 relative to the server.
354 After one hour the frequency file is
355 created and the current frequency offset written to it.
356 When the
357 .Nm
358 is started and the file does exist, the
359 .Nm
360 frequency is initialized from the file and enters normal mode
361 immediately.
362 After that the current frequency offset is written to
363 the file at hourly intervals.
364 .Ss "Operating Modes"
365 The
366 .Nm
367 utility can operate in any of several modes, including
368 symmetric active/passive, client/server broadcast/multicast and
369 manycast, as described in the
370 .Qq Association Management
371 page
372 (available as part of the HTML documentation
373 provided in
374 .Pa /usr/share/doc/ntp ) .
375 It normally operates continuously while
376 monitoring for small changes in frequency and trimming the clock
377 for the ultimate precision.
378 However, it can operate in a one-time
379 mode where the time is set from an external server and frequency is
380 set from a previously recorded frequency file.
381 A
382 broadcast/multicast or manycast client can discover remote servers,
383 compute server-client propagation delay correction factors and
384 configure itself automatically.
385 This makes it possible to deploy a
386 fleet of workstations without specifying configuration details
387 specific to the local environment.
388 .Pp
389 By default,
390 .Nm
391 runs in continuous mode where each of
392 possibly several external servers is polled at intervals determined
393 by an intricate state machine.
394 The state machine measures the
395 incidental roundtrip delay jitter and oscillator frequency wander
396 and determines the best poll interval using a heuristic algorithm.
397 Ordinarily, and in most operating environments, the state machine
398 will start with 64s intervals and eventually increase in steps to
399 1024s.
400 A small amount of random variation is introduced in order to
401 avoid bunching at the servers.
402 In addition, should a server become
403 unreachable for some time, the poll interval is increased in steps
404 to 1024s in order to reduce network overhead.
405 .Pp
406 In some cases it may not be practical for
407 .Nm
408 to run
409 continuously.
410 A common workaround has been to run the
411 .Xr ntpdate 8
412 program from a
413 .Xr cron 8
414 job at designated
415 times.
416 However, this program does not have the crafted signal
417 processing, error checking and mitigation algorithms of
418 .Nm .
419 The
420 .Fl q
421 option is intended for this purpose.
422 Setting this option will cause
423 .Nm
424 to exit just after
425 setting the clock for the first time.
426 The procedure for initially
427 setting the clock is the same as in continuous mode; most
428 applications will probably want to specify the
429 .Cm iburst
430 keyword with the
431 .Ic server
432 configuration command.
433 With this
434 keyword a volley of messages are exchanged to groom the data and
435 the clock is set in about a minute.
436 If nothing is heard after a
437 couple of minutes, the daemon times out and exits.
438 After a suitable
439 period of mourning, the
440 .Xr ntpdate 8
441 program may be
442 retired.
443 .Pp
444 When kernel support is available to discipline the clock
445 frequency, which is the case for stock Solaris, Tru64, Linux and
446 .Fx ,
447 a useful feature is available to discipline the clock
448 frequency.
449 First,
450 .Nm
451 is run in continuous mode with
452 selected servers in order to measure and record the intrinsic clock
453 frequency offset in the frequency file.
454 It may take some hours for
455 the frequency and offset to settle down.
456 Then the
457 .Nm
458 is
459 stopped and run in one-time mode as required.
460 At each startup, the
461 frequency is read from the file and initializes the kernel
462 frequency.
463 .Ss "Poll Interval Control"
464 This version of NTP includes an intricate state machine to
465 reduce the network load while maintaining a quality of
466 synchronization consistent with the observed jitter and wander.
467 There are a number of ways to tailor the operation in order enhance
468 accuracy by reducing the interval or to reduce network overhead by
469 increasing it.
470 However, the user is advised to carefully consider
471 the consequences of changing the poll adjustment range from the
472 default minimum of 64 s to the default maximum of 1,024 s.
473 The
474 default minimum can be changed with the
475 .Ic tinker
476 .Cm minpoll
477 command to a value not less than 16 s.
478 This value is used for all
479 configured associations, unless overridden by the
480 .Cm minpoll
481 option on the configuration command.
482 Note that most device drivers
483 will not operate properly if the poll interval is less than 64 s
484 and that the broadcast server and manycast client associations will
485 also use the default, unless overridden.
486 .Pp
487 In some cases involving dial up or toll services, it may be
488 useful to increase the minimum interval to a few tens of minutes
489 and maximum interval to a day or so.
490 Under normal operation
491 conditions, once the clock discipline loop has stabilized the
492 interval will be increased in steps from the minimum to the
493 maximum.
494 However, this assumes the intrinsic clock frequency error
495 is small enough for the discipline loop correct it.
496 The capture
497 range of the loop is 500 PPM at an interval of 64s decreasing by a
498 factor of two for each doubling of interval.
499 At a minimum of 1,024
500 s, for example, the capture range is only 31 PPM.
501 If the intrinsic
502 error is greater than this, the drift file
503 .Pa ntp.drift
504 will
505 have to be specially tailored to reduce the residual error below
506 this limit.
507 Once this is done, the drift file is automatically
508 updated once per hour and is available to initialize the frequency
509 on subsequent daemon restarts.
510 .Ss "The huff-n'-puff filter"
511 In scenarios where a considerable amount of data are to be
512 downloaded or uploaded over telephone modems, timekeeping quality
513 can be seriously degraded.
514 This occurs because the differential
515 delays on the two directions of transmission can be quite large.
516 In
517 many cases the apparent time errors are so large as to exceed the
518 step threshold and a step correction can occur during and after the
519 data transfer is in progress.
520 .Pp
521 The huff-n'-puff filter is designed to correct the apparent time
522 offset in these cases.
523 It depends on knowledge of the propagation
524 delay when no other traffic is present.
525 In common scenarios this
526 occurs during other than work hours.
527 The filter maintains a shift
528 register that remembers the minimum delay over the most recent
529 interval measured usually in hours.
530 Under conditions of severe
531 delay, the filter corrects the apparent offset using the sign of
532 the offset and the difference between the apparent delay and
533 minimum delay.
534 The name of the filter reflects the negative (huff)
535 and positive (puff) correction, which depends on the sign of the
536 offset.
537 .Pp
538 The filter is activated by the
539 .Ic tinker command and
540 .Cm huffpuff
541 keyword, as described in
542 .Xr ntp.conf 5 .
543 .Sh FILES
544 .Bl -tag -width /etc/ntp.drift -compact
545 .It Pa /etc/ntp.conf
546 the default name of the configuration file
547 .It Pa /etc/ntp.drift
548 the default name of the drift file
549 .It Pa /etc/ntp.keys
550 the default name of the key file
551 .El
552 .Sh SEE ALSO
553 .Xr ntp.conf 5 ,
554 .Xr ntpdate 8 ,
555 .Xr ntpdc 8 ,
556 .Xr ntpq 8
557 .Pp
558 In addition to the manual pages provided,
559 comprehensive documentation is available on the world wide web
560 at
561 .Li http://www.ntp.org/ .
562 A snapshot of this documentation is available in HTML format in
563 .Pa /usr/share/doc/ntp .
564 .Rs
565 .%A David L. Mills
566 .%T Network Time Protocol (Version 1)
567 .%O RFC1059
568 .Re
569 .Rs
570 .%A David L. Mills
571 .%T Network Time Protocol (Version 2)
572 .%O RFC1119
573 .Re
574 .Rs
575 .%A David L. Mills
576 .%T Network Time Protocol (Version 3)
577 .%O RFC1305
578 .Re
579 .Sh BUGS
580 The
581 .Nm
582 utility has gotten rather fat.
583 While not huge, it has gotten
584 larger than might be desirable for an elevated-priority
585 .Nm
586 running on a workstation, particularly since many of
587 the fancy features which consume the space were designed more with
588 a busy primary server, rather than a high stratum workstation in
589 mind.