📄 rfc1305.txt
字号:
use statistical clustering techniques such as the fault-tolerant averagealgorithm of [HAL84], the CNV algorithm of [LUN84], the majority-subsetalgorithm of [MIL85a], the non-Byzantine algorithm of [RIC88], theegocentric algorithm of [SCH86], the intersection algorithm of [MAR85]and [DEC89] and the algorithms in Section 4 of this document.Interactive-consistency algorithms are designed to detect faulty clockprocesses which might indicate grossly inconsistent offsets insuccessive readings or to different readers. These algorithms use anagreement protocol involving successive rounds of readings, possiblyrelayed and possibly augmented by digital signatures. Examples includethe fireworks algorithm of [HAL84] and the optimum algorithm of [SRI87].However, these algorithms require large numbers of messages, especiallywhen large numbers of clocks are involved, and are designed to detectfaults that have rarely been found in the Internet experience. For thesereasons they are not considered further in this document.In practice it is not possible to determine the truechimers from thefalsetickers on other than a statistical basis, especially withhierarchical configurations and a statistically noisy Internet. While itis possible to bound the maximum errors in the time-transfer procedures,assuming sufficiently generous tolerances are adopted for the hardwarecomponents, this generally results in rather poor accuracies andstabilities. The approach taken in the NTP design and its predecessorsinvolves mutually coupled oscillators and maximum-likelihood estimationand clock-selection procedures, together with a design that allowsprovable assertions on error bounds to be made relative to statedassumptions on the correctness of the primary reference sources. Fromthe analytical point of view, the system of distributed NTP peersoperates as a set of coupled phase-locked oscillators, with the updatealgorithm functioning as a phase detector and the local clock as adisciplined oscillator, but with deterministic error bounds calculatedat each step in the time-transfer process.The particular choice of offset measurement and computation proceduredescribed in Section 3 is a variant of the returnable-time system usedin some digital telephone networks [LIN80]. The clock filter andselection algorithms are designed so that the clock synchronizationsubnet self-organizes into a hierarchical-master-slave configuration[MIT80]. With respect to timekeeping accuracy and stability, thesimilarity of NTP to digital telephone systems is not accidental, sincesystems like this have been studied extensively [LIN80], [BRA80]. Whatmakes the NTP model unique is the adaptive configuration, polling,filtering, selection and correctness mechanisms which tailor thedynamics of the system to fit the ubiquitous Internet environment.System ArchitectureIn the NTP model a number of primary reference sources, synchronized bywire or radio to national standards, are connected to widely accessibleresources, such as backbone gateways, and operated as primary timeservers. The purpose of NTP is to convey timekeeping information fromthese servers to other time servers via the Internet and also to cross-check clocks and mitigate errors due to equipment or propagationfailures. Some number of local-net hosts or gateways, acting assecondary time servers, run NTP with one or more of the primary servers.In order to reduce the protocol overhead, the secondary serversdistribute time via NTP to the remaining local-net hosts. In theinterest of reliability, selected hosts can be equipped with lessaccurate but less expensive radio clocks and used for backup in case offailure of the primary and/or secondary servers or communication pathsbetween them.Throughout this document a standard nomenclature has been adopted: thestability of a clock is how well it can maintain a constant frequency,the accuracy is how well its frequency and time compare with nationalstandards and the precision is how precisely these quantities can bemaintained within a particular timekeeping system. Unless indicatedotherwise, the offset of two clocks is the time difference between them,while the skew is the frequency difference (first derivative of offsetwith time) between them. Real clocks exhibit some variation in skew(second derivative of offset with time), which is called drift; however,in this version of the specification the drift is assumed zero.NTP is designed to produce three products: clock offset, roundtrip delayand dispersion, all of which are relative to a selected reference clock.Clock offset represents the amount to adjust the local clock to bring itinto correspondence with the reference clock. Roundtrip delay providesthe capability to launch a message to arrive at the reference clock at aspecified time. Dispersion represents the maximum error of the localclock relative to the reference clock. Since most host time servers willsynchronize via another peer time server, there are two components ineach of these three products, those determined by the peer relative tothe primary reference source of standard time and those measured by thehost relative to the peer. Each of these components are maintainedseparately in the protocol in order to facilitate error control andmanagement of the subnet itself. They provide not only precisionmeasurements of offset and delay, but also definitive maximum errorbounds, so that the user interface can determine not only the time, butthe quality of the time as well.There is no provision for peer discovery or virtual-circuit managementin NTP. Data integrity is provided by the IP and UDP checksums. No flow-control or retransmission facilities are provided or necessary.Duplicate detection is inherent in the processing algorithms. Theservice can operate in a symmetric mode, in which servers and clientsare indistinguishable, yet maintain a small amount of state information,or in client/server mode, in which servers need maintain no state otherthan that contained in the client request. A lightweight association-management capability, including dynamic reachability and variable poll-rate mechanisms, is included only to manage the state information andreduce resource requirements. Since only a single NTP message format isused, the protocol is easily implemented and can be used in a variety ofsolicited or unsolicited polling mechanisms.It should be recognized that clock synchronization requires by itsnature long periods and multiple comparisons in order to maintainaccurate timekeeping. While only a few measurements are usually adequateto reliably determine local time to within a second or so, periods ofmany hours and dozens of measurements are required to resolve oscillatorskew and maintain local time to the order of a millisecond. Thus, theaccuracy achieved is directly dependent on the time taken to achieve it.Fortunately, the frequency of measurements can be quite low and almostalways non-intrusive to normal net operations.Implementation ModelIn what may be the most common client/server model a client sends an NTPmessage to one or more servers and processes the replies as received.The server interchanges addresses and ports, overwrites certain fieldsin the message, recalculates the checksum and returns the messageimmediately. Information included in the NTP message allows the clientto determine the server time with respect to local time and adjust thelocal clock accordingly. In addition, the message includes informationto calculate the expected timekeeping accuracy and reliability, as wellas select the best from possibly several servers.While the client/server model may suffice for use on local netsinvolving a public server and perhaps many workstation clients, the fullgenerality of NTP requires distributed participation of a number ofclient/servers or peers arranged in a dynamically reconfigurable,hierarchically distributed configuration. It also requires sophisticatedalgorithms for association management, data manipulation and local-clockcontrol. Throughout the remainder of this document the term host refersto an instantiation of the protocol on a local processor, while the termpeer refers to the instantiation of the protocol on a remote processorconnected by a network path.Figure 1<$&fig1> shows an implementation model for a host includingthree processes sharing a partitioned data base, with a partitiondedicated to each peer, and interconnected by a message-passing system.The transmit process, driven by independent timers for each peer,collects information in the data base and sends NTP messages to thepeers. Each message contains the local timestamp when the message issent, together with previously received timestamps and other informationnecessary to determine the hierarchy and manage the association. Themessage transmission rate is determined by the accuracy required of thelocal clock, as well as the accuracies of its peers.The receive process receives NTP messages and perhaps messages in otherprotocols, as well as information from directly connected radio clocks.When an NTP message is received, the offset between the peer clock andthe local clock is computed and incorporated into the data base alongwith other information useful for error determination and peerselection. A filtering algorithm described in Section 4 improves theaccuracy by discarding inferior data.The update procedure is initiated upon receipt of a message and at othertimes. It processes the offset data from each peer and selects the bestone using the algorithms of Section 4. This may involve manyobservations of a few peers or a few observations of many peers,depending on the accuracies required.The local-clock process operates upon the offset data produced by theupdate procedure and adjusts the phase and frequency of the local clockusing the mechanisms described in Section 5. This may result in either astep-change or a gradual phase adjustment of the local clock to reducethe offset to zero. The local clock provides a stable source of timeinformation to other users of the system and for subsequent reference byNTP itself.Network ConfigurationsThe synchronization subnet is a connected network of primary andsecondary time servers, clients and interconnecting transmission paths.A primary time server is directly synchronized to a primary referencesource, usually a radio clock. A secondary time server derivessynchronization, possibly via other secondary servers, from a primaryserver over network paths possibly shared with other services. Undernormal circumstances it is intended that the synchronization subnet ofprimary and secondary servers assumes a hierarchical-master-slaveconfiguration with the primary servers at the root and secondary serversof decreasing accuracy at successive levels toward the leaves.Following conventions established by the telephone industry [BEL86], theaccuracy of each server is defined by a number called the stratum, withthe topmost level (primary servers) assigned as one and each leveldownwards (secondary servers) in the hierarchy assigned as one greaterthan the preceding level. With current technology and available radioclocks, single-sample accuracies in the order of a millisecond can beachieved at the network interface of a primary server. Accuracies ofthis order require special care in the design and implementation of theoperating system and the local-clock mechanism, such as described inSection 5.As the stratum increases from one, the single-sample accuraciesachievable will degrade depending on the network paths and local-clockstabilities. In order to avoid the tedious calculations [BRA80]necessary to estimate errors in each specific configuration, it isuseful to assume the mean measurement errors accumulate approximately inproportion to the measured delay and dispersion relative to the root ofthe synchronization subnet. Appendix H contains an analysis of errors,including a derivation of maximum error as a function of delay anddispersion, where the latter quantity depends on the precision of thetimekeeping system, frequency tolerance of the local clock and variousresiduals. Assuming the primary servers are synchronized to standardtime within known accuracies, this provides a reliable, determisticspecification on timekeeping accuracies throughout the synchronizationsubnet.Again drawing from the experience of the telephone industry, whichlearned such lessons at considerable cost [ABA89], the synchronizationsubnet topology should be organized to produce the highest accuracy, butmust never be allowed to form a loop. An additional factor is that eachincrement in stratum involves a potentially unreliable time server whichintroduces additional measurement errors. The selection algorithm usedin NTP uses a variant of the Bellman-Ford distributed routing algorithm[37] to compute the minimum-weight spanning trees rooted on the primaryservers. The distance metric used by the algorithm consists of the(scaled) stratum plus the synchronization distance, which itselfconsists of the dispersion plus one-half the absolute delay. Thus, thesynchronization path will always take the minimum number of servers tothe root, with ties resolved on the basis of maximum error.As a result of this design, the subnet reconfigures automatically in ahierarchical-master-slave configuration to produce the most accurate andreliable time, even when one or more primary or secondary servers or thenetwork paths between them fail. This includes the case where all normalprimary servers (e.g., highly accurate WWVB radio clock operating at thelowest synchronization distances) on a possibly partitioned subnet fail,but one or more backup primary servers (e.g., less accurate WWV radioclock operating at higher synchronization distances) continue operation.However, should all primary servers throughout the subnet fail, theremaining secondary servers will synchronize among themselves whiledistances ratchet upwards to a preselected maximum <169>infinity<170>due to the well-known properties of the Bellman-Ford algorithm. Uponreaching the maximum on all paths, a server will drop off the subnet andfree-run using its last determined time and frequency. Since thesecomputations are expected to be very precise, especially in frequency,even extended outage periods can result in timekeeping errors notgreater than a few milliseconds per day with appropriately stabilizedoscillators (see Section 5).In the case of multiple primary servers, the spanning-tree computationwill usually select the server at minimum synchronization distance.However, when these servers are at approximately the same distance, thecomputation may result in random selections among them as the result ofnormal dispersive delays. Ordinarily, this does not degrade accuracy aslong as any discrepancy between the primary servers is small compared tothe synchronization distance. If not, the filter and selectionalgorithms will select the best of the available servers and cast outoutlyers as intended.Network Time ProtocolThis section consists of a formal definition of the Network TimeProtocol, including its data formats, entities, state variables, eventsand event-processing procedures. The specification is based on theimplementation model illustrated in Figure 1, but it is not intendedthat this model is the only one upon which a specification can be based.In particular, the specification is intended to illustrate and clarifythe intrinsic operations of NTP, as well as to serve as a foundation fora more rigorous, comprehensive and verifiable specification.Data FormatsAll mathematical operations expressed or implied herein are in two's-complement, fixed-point arithmetic. Data are specified as integer orfixed-point quantities, with bits numbered in big-endian fashion fromzero starting at the left, or high-order, position. Since variousimplementations may scale externally derived quantities for internaluse, neither the precision nor decimal-point placement for fixed-pointquantities is specified. Unless specified otherwise, all quantities areunsigned and may occupy the full field width with an implied zeropreceding bit zero. Hardware and software packages designed to work withsigned quantities will thus yield surprising results when the mostsignificant (sign) bit is set. It is suggested that externally derived,unsigned fixed-point quantities such as timestamps be shifted right onebit for internal use, since the precision represented by the full fieldwidth is seldom justified.Since NTP timestamps are cherished data and, in fact, represent the mainproduct of the protocol, a special timestamp format has been
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -