⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 timed.ms

📁 早期freebsd实现
💻 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.\".TLThe Berkeley.UX.brTime Synchronization Protocol.AURiccardo Gusella, Stefano Zatti, and James M. Bloom.AIComputer Systems Research GroupComputer Science DivisionDepartment of Electrical Engineering and Computer ScienceUniversity of California, BerkeleyBerkeley, CA 94720.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 Italian CSELT Corporation.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.OH 'The Berkeley UNIX Time Synchronization Protocol''SMM:12-%'.EH 'SMM:12-%''The Berkeley UNIX Time Synchronization Protocol'.SH Introduction.PPThe Time Synchronization Protocol (TSP) has been designed for specific use by the program \fItimed\fP,a local area network clock synchronizer for the UNIX 4.3BSD operatingsystem.Timed is built on the DARPA UDP protocol [4] andis based on a master slave scheme..PPTSP serves a dual purpose.First, it supports messages for the synchronization of the clocks of the various hosts in a local area network.Second, it supports messages for 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 timed are described in other documents [1,2,3]..PPBriefly, the synchronization software, which works in a local area network, consists of a collection of \fItime daemons\fP(one per machine) and is based on a master-slavestructure.The present implementation keeps processor clocks synchronized within 20 milliseconds.A \fImaster time daemon\fP measures the timedifference between the clock of the machine on which it is running and those of all other machines.  The current implementationuses ICMP \fITime Stamp Requests\fP [5] to measure the clock differencebetween 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 machines on the same network.See [1,2] for more details..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 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 therefore maintain a single network time in spite of the drift of clocks away from each other. .PPAdditionally, a time daemon on gateway machines may run as a \fIsubmaster\fP.A submaster time daemon functions as a slave on one network thatalready has a master and as master on other networks.In addition, a submaster is responsible for propagating broadcastpackets from one network to the other..PPTo ensure that service provided is continuous and reliable,it is necessary to implement an election algorithm that will elect anew master should the machine running the current master crash, the masterterminate (for example, because of a run-time error), or the network bepartitioned.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..PPAll the communication occurring among time daemons uses the TSPprotocol.While some messages need not be sent in a reliable way,most communication in TSP requires reliability not provided by the underlyingprotocol.Reliability is achieved by the use of acknowledgements, sequence numbers, andretransmission when message losses occur.When a message that requires acknowledgment is not acknowledged aftermultiple attempts,the time daemon that has sent the message will assume that theaddressee is down.This document will not describe the details of how reliability isimplemented, but will only point out whena message type requires a reliable transport mechanism..PPThe message format in TSP is the same for all message types;however, in some instances, one or more fields are not used. The next section describes the message format.The following sections describein detail the different message types, their use and the contentsof each field.  NOTE:  The message format is likely to change infuture versions of timed..sp 2.SHMessage Format.PPAll fields are based upon 8-bit bytes.  Fields should be sent innetwork byte order if they are more than one byte long.The structure of a TSP message is the following:.IP 1)A one byte message type..IP 2)A one byte version number, specifying the protocol version which themessage uses..IP 3)A two byte sequence number to be used for recognizing duplicate messagesthat occur when messages are retransmitted..IP 4)Eight bytes of packet specific data.  This field contains two 4 byte timevalues, a one byte hop count, or may be unused depending on the typeof the packet..IP 5)A zero-terminated string of up to 256 \s-2ASCII\s+2 characters with the name of the machine sending the message..PPThe following charts describe the message types,show their fields, and explain their usages.For the purpose of the following discussion, a time daemon can be considered to be inone of three states: slave, master, or candidate for election to master.Also, the term \fIbroadcast\fP refers tothe sending of a message to all active time daemons..sp 1.DS L.SHAdjtime Message.so time.LPType: TSP_ADJTIME (1).sp 1.PPThe master sends this message to a slave to communicate the difference between the clock of the slave andthe network time the master has just computed. The slave will accordinglyadjust the time of its machine.This message requires an acknowledgment..sp 1.DE.DS L.SHAcknowledgment Message.so unused.LPType: TSP_ACK (2).sp 1.PPBoth the master and the slaves use this message foracknowledgment only.It is used in several different contexts, for examplein reply to an Adjtime message..sp 1.DE.DS L.SHMaster Request Message.so unused.LPType: TSP_MASTERREQ (3).sp 1.PPA newly-started time daemon broadcasts this message tolocate a master.  No other action is implied by this packet.It requires a Master Acknowledgment..sp 1.DE.DS L.SHMaster Acknowledgement.so unused.LPType: TSP_MASTERACK (4).sp 1.PPThe master sends this message to acknowledge the Master Request messageand the Conflict Resolution Message..sp 1.DE.DS L.SHSet Network Time Message.so date.LPType: TSP_SETTIME (5).sp 1.PPThe master sends this message to slave time daemons to set their time.This packet is sent to newly started time daemons and when the networkdate is changed.It contains the master's time as an approximation of the network time.It requires an acknowledgment.The nextsynchronization round will eliminate the small time differencecaused by the random delay in the communication channel..sp 1.DE.DS L.SHMaster Active Message.so unused.LPType: TSP_MASTERUP (6).sp 1.PPThe master broadcasts this message to solicit the names of the active slaves.Slaves will reply with a Slave Active message..sp 1.DE.DS L.SHSlave Active Message.so unused.LPType: TSP_SLAVEUP (7).sp 1.PPA slave sends this message to the master in answer to a Master Active message.This message is also sent when a new slave starts up to inform the master thatit wants to be synchronized..sp 1.DE.DS L.SHMaster Candidature Message.so unused.LPType: TSP_ELECTION (8).sp 1.PPA slave eligible to become a master broadcasts this message when its electiontimer expires.The message declares that the slave wishes to become the new master..sp 1.DE.DS L.SHCandidature Acceptance Message.so unused.LPType: TSP_ACCEPT (9).sp 1.PPA slave sends this message to accept the candidature of the time daemonthat has broadcast an Election message.The candidate will add the slave's name to the list of machines that itwill control should it become the master..sp 1.DE.DS L.SHCandidature Rejection Message.so unused.LPType: TSP_REFUSE (10).sp 1.PPAfter a slave accepts the candidature of a time daemon, it will replyto any election messages from other slaveswith this message.This rejects any candidature other than the first received..sp 1.DE.DS L.SHMultiple Master Notification Message.so unused.LPType: TSP_CONFLICT (11).sp 1.PPWhen two or more masters reply to a Master Request message, the slaveuses this message to inform one of them that more than one master exists..sp 1.DE.DS L.SHConflict Resolution Message .so unused.LPType: TSP_RESOLVE (12).sp 1.PPA master which has been informed of the existence of other mastersbroadcasts this message to determine who the other masters are..sp 1.DE.DS L.SHQuit Message.so unused.LPType: TSP_QUIT (13).sp 1.PPThis message is sent by the master in three different contexts:1) to a candidate that broadcasts an Master Candidature message,2) to another master when notified of its existence,3) to another master if a loop is detected.In all cases, the recipient time daemon will become a slave.This message requires an acknowledgement..sp 1.DE.DS L.SHSet Date Message.so date.LPType: TSP_SETDATE (22).sp 1.PPThe program \fIdate\fP\|(1) sends this message to the local time daemonwhen a super-user wants to set the network date.If the local time daemon is the master, it will set the date;if it is a slave, it will communicate the desired date to the master..sp 1.DE.DS L.SHSet Date Request Message.so date.LPType: TSP_SETDATEREQ (23).sp 1.PPA slave that has received a Set Date message will communicate thedesired date to the master using this message..sp 1.DE.DS L.SHSet Date Acknowledgment Message.so unused.LPType: TSP_DATEACK (16).sp 1.PPThe master sends this message to a slave in acknowledgment of aSet Date Request Message.The same message is sent by the local time daemon to the program\fIdate(1)\fP to confirm that the network date has been set by themaster..sp 1.DE.DS L.SHStart Tracing Message.so unused.LPType: TSP_TRACEON (17).sp 1.PPThe controlling program \fItimedc\fP sends this message to the localtime daemon to start the recording in a system file ofall messages received..sp 1.DE.DS L.SHStop Tracing Message.so unused.LPType: TSP_TRACEOFF (18).sp 1.PP\fITimedc\fP sends this message to the localtime daemon to stop the recording ofmessages received..sp 1.DE.DS L.SHMaster Site Message.so unused.LPType: TSP_MSITE (19).sp 1.PP\fITimedc\fP sends this message to the local time daemon to find outwhere the master is running..sp 1.DE.DS L.SHRemote Master Site Message.so unused.LPType: TSP_MSITEREQ (20).sp 1.PPA local time daemon broadcasts this message to find the locationof the master.It then uses the Acknowledgement message to communicate this location to \fItimedc\fP..sp 1.DE.DS L.SHTest Message.so unused.LPType: TSP_TEST (21).sp 1.PPFor testing purposes, \fItimedc\fP sends this message to a slaveto cause its election timer to expire.  NOTE: \fItimed\fPis not normally compiled to support this..sp 1.DE.SH.DS L.SHLoop Detection Message.so loop.LPType: TSP_LOOP (24).sp 1.PPThis packet is initiated by all masters occasionally to attempt to detect loops.All submasters forward this packet onto the networks over which they are master.If a master receives a packet it sent out initially,it knows that a loop exists and tries to correct the problem..DE.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.Postel, J., \fIUser Datagram Protocol\fP, RFC 768.Network Information Center, SRI International, Menlo Park, California,August 1980..IP 5.Postel, J., \fIInternet Control Message Protocol\fP, RFC 792.Network Information Center, SRI International, Menlo Park, California,September 1981.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -