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