BSD 4_4 development
[unix-history] / .ref-BSD-4_3_Reno / usr / src / share / doc / smm / 08.timedop / timed.ms
CommitLineData
409e5ca0
KB
1.\" Copyright (c) 1986 The Regents of the University of California.
2.\" All rights reserved.
bf8928b7 3.\"
409e5ca0
KB
4.\" Redistribution and use in source and binary forms are permitted
5.\" provided that the above copyright notice and this paragraph are
6.\" duplicated in all such forms and that any documentation,
7.\" advertising materials, and other materials related to such
8.\" distribution and use acknowledge that the software was developed
9.\" by the University of California, Berkeley. The name of the
10.\" University may not be used to endorse or promote products derived
11.\" from this software without specific prior written permission.
12.\" THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
13.\" IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
14.\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
15.\"
1c15e888 16.\" @(#)timed.ms 6.2 (Berkeley) 3/7/89
bf8928b7
KM
17.\"
18.TL
19Timed Installation and Operation Guide
20.AU
21Riccardo Gusella, Stefano Zatti, James M. Bloom
22.AI
23Computer Systems Research Group
24Computer Science Division
25Department of Electrical Engineering and Computer Science
26University of California, Berkeley
27Berkeley, CA 94720
28.AU
29Kirk Smith
30.AI
31Engineering Computer Network
32Department of Electrical Engineering
33Purdue University
34West Lafayette, IN 47906
35.FS
36This work was sponsored by the Defense Advanced Research Projects Agency
37(DoD), monitored by the Naval Electronics Systems
38Command under contract No. N00039-84-C-0089, and by the CSELT
39Corporation of Italy.
40The views and conclusions contained in this document are those of the
41authors and should not be interpreted as representing official policies,
42either expressed or implied, of the Defense Research Projects Agency,
43of the US Government, or of CSELT.
44.FE
45.LP
46.EH 'SMM:8-%''Timed Installation and Operation'
47.OH 'Timed Installation and Operation''SMM:8-%'
48.SH
49Introduction
50.PP
51The clock synchronization service for
52the UNIX 4.3BSD operating system is composed of a collection of
53time daemons (\fItimed\fP) running on the machines in a local
54area network.
55The algorithms implemented by the service is based on a master-slave scheme.
56The time daemons communicate with each other using the
57\fITime Synchronization Protocol\fP (TSP) which
58is built on the DARPA UDP protocol and described in detail in [4].
59.PP
60A time daemon has a twofold function.
61First, it supports the synchronization of the clocks
62of the various hosts in a local area network.
63Second, it starts (or takes part in) the election that occurs
64among slave time daemons when, for any reason, the master disappears.
65The synchronization mechanism and the election procedure
66employed by the program \fItimed\fP are described
67in other documents [1,2,3].
68The next paragraphs are a brief overview of how the time daemon works.
69This document is mainly concerned with the administrative and technical
70issues of running \fItimed\fP at a particular site.
71.PP
72A \fImaster time daemon\fP measures the time
73differences between the clock of the machine on which it
74is running and those of all other machines.
75The master computes the \fInetwork time\fP as the average of the
76times provided by nonfaulty clocks.\**
77.FS
78A clock is considered to be faulty when its value
79is more than a small specified
80interval apart from the majority of the clocks
81of the other machines [1,2].
82.FE
83It then sends to each \fIslave time daemon\fP the
84correction that should be performed on the clock of its machine.
85This process is repeated periodically.
86Since the correction is expressed as a time difference rather than an
87absolute time, transmission delays do not interfere with
88the accuracy of the synchronization.
89When a machine comes up and joins the network,
90it starts a slave time daemon which
91will ask the master for the correct time and will reset the machine's clock
92before any user activity can begin.
93The time daemons are able to maintain a single network time in spite of
94the drift of clocks away from each other.
95The present implementation keeps processor clocks synchronized
96within 20 milliseconds.
97.PP
98To ensure that the service provided is continuous and reliable,
99it is necessary to implement an election algorithm to elect a
100new master should the machine running the current master crash, the master
101terminate (for example, because of a run-time error), or
102the network be partitioned.
103Under our algorithm, slaves are able to realize when the master has
104stopped functioning and to elect a new master from among themselves.
105It is important to note that, since the failure of the master results
106only in a gradual divergence of clock values, the election
107need not occur immediately.
108.PP
109The machines that are gateways between distinct local area
110networks require particular care.
111A time daemon on such machines may act as a \fIsubmaster\fP.
112This artifact depends on the current inability of
113transmission protocols to broadcast a message on a network
114other than the one to which the broadcasting machine is connected.
115The submaster appears as a slave on one network, and as a master
116on one or more of the other networks to which it is connected.
117.PP
118A submaster classifies each network as one of three types.
119A \fIslave network\fP is a network on which the submaster acts as a slave.
120There can only be one slave network.
121A \fImaster network\fP is a network on which the submaster acts as a master.
122An \fIignored network\fP is any other network which already has a valid master.
123The submaster tries periodically to become master on an ignored
124network, but gives up immediately if a master already exists.
125.SH
126Guidelines
127.PP
128While the synchronization algorithm is quite general, the election
129one, requiring a broadcast mechanism, puts constraints on
130the kind of network on which time daemons can run.
131The time daemon will only work on networks with broadcast capability
132augmented with point-to-point links.
133Machines that are only connected to point-to-point,
134non-broadcast networks may not use the time daemon.
135.PP
136If we exclude submasters, there will normally be, at most, one master time
137daemon in a local area internetwork.
138During an election, only one of the slave time daemons
139will become the new master.
140However, because of the characteristics of its machine,
141a slave can be prevented from becoming the master.
142Therefore, a subset of machines must be designated as potential
143master time daemons.
144A master time daemon will require CPU resources
145proportional to the number of slaves, in general, more than
146a slave time daemon, so it may be advisable to limit master time
147daemons to machines with more powerful processors or lighter loads.
148Also, machines with inaccurate clocks should not be used as masters.
149This is a purely administrative decision: an organization may
150well allow all of its machines to run master time daemons.
151.PP
152At the administrative level, a time daemon on a machine
153with multiple network interfaces, may be told to ignore all
154but one network or to ignore one network.
155This is done with the \fI\-n network\fP and \fI\-i network\fP
156options respectively at start-up time.
157Typically, the time daemon would be instructed to ignore all but
158the networks belonging to the local administrative control.
159.PP
160There are some limitations to the current
161implementation of the time daemon.
162It is expected that these limitations will be removed in future releases.
163The constant NHOSTS in /usr/src/etc/timed/globals.h limits the
164maximum number of machines that may be directly controlled by one
165master time daemon.
166The current maximum is 29 (NHOSTS \- 1).
167The constant must be changed and the program recompiled if a site wishes to
168run \fItimed\fP on a larger (inter)network.
169.PP
170In addition, there is a \fIpathological situation\fP to
171be avoided at all costs, that might occur when
172time daemons run on multiply-connected local area networks.
173In this case, as we have seen, time daemons running on gateway machines
174will be submasters and they will act on some of those
175networks as master time daemons.
176Consider machines A and B that are both gateways between
177networks X and Y.
178If time daemons were started on both A and B without constraints, it would be
179possible for submaster time daemon A to be a slave on network X
180and the master on network Y, while submaster time daemon B is a slave on
181network Y and the master on network X.
182This \fIloop\fP of master time daemons will not function properly
183or guarantee a unique time on both networks, and will cause
184the submasters to use large amounts of system resources in the form
185of network bandwidth and CPU time.
186In fact, this kind of \fIloop\fP can also be generated with more
187than two master time daemons,
188when several local area networks are interconnected.
189.SH
190Installation
191.PP
192In order to start the time daemon on a given machine,
193the following lines should be
194added to the \fIlocal daemons\fP section in the file \fI/etc/rc.local\fP:
195.sp 2
196.in 1i
197.nf
198if [ -f /etc/timed ]; then
199 /etc/timed \fIflags\fP & echo -n ' timed' >/dev/console
200fi
201.fi
202.in -1i
203.sp
204.LP
205In any case, they must appear after the network
206is configured via ifconfig(8).
207.PP
208Also, the file \fI/etc/services\fP should contain the following
209line:
210.sp 2
211.ti 1i
212timed 525/udp timeserver
213.sp
214.LP
215The \fIflags\fP are:
216.IP "-n network" 13
217to consider the named network.
218.IP "-i network"
219to ignore the named network.
220.IP -t
221to place tracing information in \fI/usr/adm/timed.log\fP.
222.IP -M
223to allow this time daemon to become a master.
224A time daemon run without this option will be forced in the state of
225slave during an election.
226.SH
227Daily Operation
228.PP
229\fITimedc(8)\fP is used to control the operation of the time daemon.
230It may be used to:
231.IP \(bu
232measure the differences between machines' clocks,
233.IP \(bu
234find the location where the master \fItimed\fP is running,
235.IP \(bu
236cause election timers on several machines to expire at the same time,
237.IP \(bu
238enable or disable tracing of messages received by \fItimed\fP.
239.LP
240See the manual page on \fItimed\fP\|(8) and \fItimedc\fP\|(8)
241for more detailed information.
242.PP
243The \fIdate(1)\fP command can be used to set the network date.
244In order to set the time on a single machine, the \fI-n\fP flag
245can be given to date(1).
246.bp
247.SH
248References
249.IP 1.
250R. Gusella and S. Zatti,
251\fITEMPO: A Network Time Controller for Distributed Berkeley UNIX System\fP,
252USENIX Summer Conference Proceedings, Salt Lake City, June 1984.
253.IP 2.
254R. Gusella and S. Zatti, \fIClock Synchronization in a Local Area Network\fP,
255University of California, Berkeley, Technical Report, \fIto appear\fP.
256.IP 3.
257R. Gusella and S. Zatti,
258\fIAn Election Algorithm for a Distributed Clock Synchronization Program\fP,
259University of California, Berkeley, CS Technical Report #275, Dec. 1985.
260.IP 4.
261R. Gusella and S. Zatti,
262\fIThe Berkeley UNIX 4.3BSD Time Synchronization Protocol\fP,
263UNIX Programmer's Manual, 4.3 Berkeley Software Distribution, Volume 2c.