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