📄 timed.ms
字号:
.\" Copyright (c) 1986, 1993.\" The Regents of the University of California. All rights reserved..\".\" Redistribution and use in source and binary forms, with or without.\" modification, are permitted provided that the following conditions.\" are met:.\" 1. Redistributions of source code must retain the above copyright.\" notice, this list of conditions and the following disclaimer..\" 2. Redistributions in binary form must reproduce the above copyright.\" notice, this list of conditions and the following disclaimer in the.\" documentation and/or other materials provided with the distribution..\" 3. All advertising materials mentioning features or use of this software.\" must display the following acknowledgement:.\" This product includes software developed by the University of.\" California, Berkeley and its contributors..\" 4. Neither the name of the University nor the names of its contributors.\" may be used to endorse or promote products derived from this software.\" without specific prior written permission..\".\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION).\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF.\" SUCH DAMAGE..\".\" @(#)timed.ms 8.1 (Berkeley) 6/8/93.\".TLTimed Installation and Operation Guide.AURiccardo Gusella, Stefano Zatti, James M. Bloom.AIComputer Systems Research GroupComputer Science DivisionDepartment of Electrical Engineering and Computer ScienceUniversity of California, BerkeleyBerkeley, CA 94720.AUKirk Smith.AIEngineering Computer NetworkDepartment of Electrical EngineeringPurdue UniversityWest Lafayette, IN 47906.FSThis work was sponsored by the Defense Advanced Research Projects Agency(DoD), monitored by the Naval Electronics SystemsCommand under contract No. N00039-84-C-0089, and by the CSELT Corporation of Italy.The views and conclusions contained in this document are those of theauthors and should not be interpreted as representing official policies,either expressed or implied, of the Defense Research Projects Agency,of the US Government, or of CSELT..FE.LP.EH 'SMM:11-%''Timed Installation and Operation'.OH 'Timed Installation and Operation''SMM:11-%'.SH Introduction.PPThe clock synchronization service for the UNIX 4.3BSD operating system is composed of a collection oftime daemons (\fItimed\fP) running on the machines in a localarea network.The algorithms implemented by the service is based on a master-slave scheme.The time daemons communicate with each other using the \fITime Synchronization Protocol\fP (TSP) whichis built on the DARPA UDP protocol and described in detail in [4]..PPA time daemon has a twofold function.First, it supports the synchronization of the clocks of the various hosts in a local area network.Second, it starts (or takes part in) the election that occursamong slave time daemons when, for any reason, the master disappears.The synchronization mechanism and the election procedure employed by the program \fItimed\fP are described in other documents [1,2,3].The next paragraphs are a brief overview of how the time daemon works.This document is mainly concerned with the administrative and technicalissues of running \fItimed\fP at a particular site..PPA \fImaster time daemon\fP measures the timedifferences between the clock of the machine on which it is running and those of all other machines.The master computes the \fInetwork time\fP as the average of the times provided by nonfaulty clocks.\**.FSA clock is considered to be faulty when its value is more than a small specifiedinterval apart from the majority of the clocks of the other machines [1,2]..FEIt then sends to each \fIslave time daemon\fP thecorrection that should be performed on the clock of its machine.This process is repeated periodically.Since the correction is expressed as a time difference rather than an absolute time, transmission delays do not interfere with the accuracy of the synchronization.When a machine comes up and joins the network,it starts a slave time daemon whichwill ask the master for the correct time and will reset the machine's clockbefore any user activity can begin.The time daemons are able to maintain a single network time in spite of the drift of clocks away from each other. The present implementation keeps processor clocks synchronized within 20 milliseconds..PPTo ensure that the service provided is continuous and reliable,it is necessary to implement an election algorithm to elect anew master should the machine running the current master crash, the masterterminate (for example, because of a run-time error), or the network be partitioned.Under our algorithm, slaves are able to realize when the master hasstopped functioning and to elect a new master from among themselves.It is important to note that, since the failure of the master resultsonly in a gradual divergence of clock values, the electionneed not occur immediately..PPThe machines that are gateways between distinct local areanetworks require particular care.A time daemon on such machines may act as a \fIsubmaster\fP.This artifact depends on the current inability oftransmission protocols to broadcast a message on a networkother than the one to which the broadcasting machine is connected.The submaster appears as a slave on one network, and as a masteron one or more of the other networks to which it is connected..PPA submaster classifies each network as one of three types.A \fIslave network\fP is a network on which the submaster acts as a slave.There can only be one slave network.A \fImaster network\fP is a network on which the submaster acts as a master.An \fIignored network\fP is any other network which already has a valid master.The submaster tries periodically to become master on an ignorednetwork, but gives up immediately if a master already exists..SHGuidelines.PPWhile the synchronization algorithm is quite general, the electionone, requiring a broadcast mechanism, puts constraints onthe kind of network on which time daemons can run.The time daemon will only work on networks with broadcast capabilityaugmented with point-to-point links.Machines that are only connected to point-to-point,non-broadcast networks may not use the time daemon..PPIf we exclude submasters, there will normally be, at most, one master time daemon in a local area internetwork.During an election, only one of the slave time daemonswill become the new master.However, because of the characteristics of its machine,a slave can be prevented from becoming the master.Therefore, a subset of machines must be designated as potential master time daemons.A master time daemon will require CPU resourcesproportional to the number of slaves, in general, more thana slave time daemon, so it may be advisable to limit master timedaemons to machines with more powerful processors or lighter loads.Also, machines with inaccurate clocks should not be used as masters.This is a purely administrative decision: an organization maywell allow all of its machines to run master time daemons..PPAt the administrative level, a time daemon on a machinewith multiple network interfaces, may be told to ignore allbut one network or to ignore one network.This is done with the \fI\-n network\fP and \fI\-i network\fPoptions respectively at start-up time.Typically, the time daemon would be instructed to ignore all butthe networks belonging to the local administrative control..PPThere are some limitations to the currentimplementation of the time daemon.It is expected that these limitations will be removed in future releases.The constant NHOSTS in /usr/src/etc/timed/globals.h limits themaximum number of machines that may be directly controlled by onemaster time daemon.The current maximum is 29 (NHOSTS \- 1).The constant must be changed and the program recompiled if a site wishes torun \fItimed\fP on a larger (inter)network..PPIn addition, there is a \fIpathological situation\fP tobe avoided at all costs, that might occur whentime daemons run on multiply-connected local area networks.In this case, as we have seen, time daemons running on gateway machineswill be submasters and they will act on some of those networks as master time daemons.Consider machines A and B that are both gateways betweennetworks X and Y.If time daemons were started on both A and B without constraints, it would bepossible for submaster time daemon A to be a slave on network Xand the master on network Y, while submaster time daemon B is a slave on network Y and the master on network X.This \fIloop\fP of master time daemons will not function properlyor guarantee a unique time on both networks, and will causethe submasters to use large amounts of system resources in the formof network bandwidth and CPU time.In fact, this kind of \fIloop\fP can also be generated with morethan two master time daemons,when several local area networks are interconnected..SHInstallation.PPIn order to start the time daemon on a given machine,the following lines should beadded to the \fIlocal daemons\fP section in the file \fI/etc/rc.local\fP:.sp 2.in 1i.nfif [ -f /etc/timed ]; then /etc/timed \fIflags\fP & echo -n ' timed' >/dev/consolefi.fi.in -1i.sp.LPIn any case, they must appear after the network is configured via ifconfig(8)..PPAlso, the file \fI/etc/services\fP should contain the followingline:.sp 2.ti 1itimed 525/udp timeserver.sp.LPThe \fIflags\fP are:.IP "-n network" 13to consider the named network..IP "-i network"to ignore the named network..IP -tto place tracing information in \fI/usr/adm/timed.log\fP..IP -Mto allow this time daemon to become a master.A time daemon run without this option will be forced in the state ofslave during an election..SHDaily Operation.PP\fITimedc(8)\fP is used to control the operation of the time daemon.It may be used to:.IP \(bumeasure the differences between machines' clocks,.IP \(bufind the location where the master \fItimed\fP is running,.IP \(bucause election timers on several machines to expire at the same time,.IP \(buenable or disable tracing of messages received by \fItimed\fP..LPSee the manual page on \fItimed\fP\|(8) and \fItimedc\fP\|(8)for more detailed information..PPThe \fIdate(1)\fP command can be used to set the network date.In order to set the time on a single machine, the \fI-n\fP flagcan be given to date(1)..bp.SHReferences.IP 1.R. Gusella and S. Zatti, \fITEMPO: A Network Time Controller for Distributed Berkeley UNIX System\fP,USENIX Summer Conference Proceedings, Salt Lake City, June 1984..IP 2.R. Gusella and S. Zatti, \fIClock Synchronization in a Local Area Network\fP,University of California, Berkeley, Technical Report, \fIto appear\fP..IP 3.R. Gusella and S. Zatti, \fIAn Election Algorithm for a Distributed Clock Synchronization Program\fP,University of California, Berkeley, CS Technical Report #275, Dec. 1985..IP 4.R. Gusella and S. Zatti,\fIThe Berkeley UNIX 4.3BSD Time Synchronization Protocol\fP,UNIX Programmer's Manual, 4.3 Berkeley Software Distribution, Volume 2c.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -