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