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