draft-ietf-ntp-ntpv4-proto-09.txt   draft-ietf-ntp-ntpv4-proto-10.txt 
NTP WG J. Burbank, Ed. NTP WG J. Burbank, Ed.
Internet-Draft W. Kasch, Ed. Internet-Draft W. Kasch, Ed.
Obsoletes: RFC 4330, RFC 1305 JHU/APL Obsoletes: RFC 4330, RFC 1305 JHU/APL
(if approved) J. Martin, Ed. (if approved) J. Martin, Ed.
Intended status: Standards Track Woven Intended status: Standards Track Woven
Expires: August 28, 2008 D. Mills Expires: January 15, 2009 D. Mills
U. Delaware U. Delaware
February 25, 2008 July 14, 2008
Network Time Protocol Version 4 Protocol And Algorithms Specification Network Time Protocol Version 4 Protocol And Algorithms Specification
draft-ietf-ntp-ntpv4-proto-09 draft-ietf-ntp-ntpv4-proto-10
Status of this Memo Status of this Memo
By submitting this Internet-Draft, each author represents that any By submitting this Internet-Draft, each author represents that any
applicable patent or other IPR claims of which he or she is aware applicable patent or other IPR claims of which he or she is aware
have been or will be disclosed, and any of which he or she becomes have been or will be disclosed, and any of which he or she becomes
aware will be disclosed, in accordance with Section 6 of BCP 79. aware will be disclosed, in accordance with Section 6 of BCP 79.
Internet-Drafts are working documents of the Internet Engineering Internet-Drafts are working documents of the Internet Engineering
Task Force (IETF), its areas, and its working groups. Note that Task Force (IETF), its areas, and its working groups. Note that
skipping to change at page 1, line 38 skipping to change at page 1, line 38
and may be updated, replaced, or obsoleted by other documents at any and may be updated, replaced, or obsoleted by other documents at any
time. It is inappropriate to use Internet-Drafts as reference time. It is inappropriate to use Internet-Drafts as reference
material or to cite them other than as "work in progress." material or to cite them other than as "work in progress."
The list of current Internet-Drafts can be accessed at The list of current Internet-Drafts can be accessed at
http://www.ietf.org/ietf/1id-abstracts.txt. http://www.ietf.org/ietf/1id-abstracts.txt.
The list of Internet-Draft Shadow Directories can be accessed at The list of Internet-Draft Shadow Directories can be accessed at
http://www.ietf.org/shadow.html. http://www.ietf.org/shadow.html.
This Internet-Draft will expire on August 28, 2008. This Internet-Draft will expire on January 15, 2009.
Abstract Abstract
The Network Time Protocol (NTP) is widely used to synchronize The Network Time Protocol (NTP) is widely used to synchronize
computer clocks in the Internet. This document describes NTP Version computer clocks in the Internet. This document describes NTP Version
4 (NTPv4), which is backwards compatible with NTP Version 3 (NTPv3) 4 (NTPv4), which is backwards compatible with NTP Version 3 (NTPv3)
described in RFC 1305, as well as previous versions of the protocol. described in RFC 1305, as well as previous versions of the protocol.
NTPv4 includes a modified protocol header to accommodate the Internet NTPv4 includes a modified protocol header to accommodate the Internet
Protocol Version 6 address family. NTPv4 includes fundamental Protocol Version 6 address family. NTPv4 includes fundamental
improvements in the mitigation and discipline algorithms which extend improvements in the mitigation and discipline algorithms which extend
skipping to change at page 2, line 31 skipping to change at page 2, line 31
7.2. Global Parameters . . . . . . . . . . . . . . . . . . . . 16 7.2. Global Parameters . . . . . . . . . . . . . . . . . . . . 16
7.3. Packet Header Variables . . . . . . . . . . . . . . . . . 17 7.3. Packet Header Variables . . . . . . . . . . . . . . . . . 17
7.4. The Kiss-o'-Death Packet . . . . . . . . . . . . . . . . 23 7.4. The Kiss-o'-Death Packet . . . . . . . . . . . . . . . . 23
7.5. NTP Extension Field Format . . . . . . . . . . . . . . . 25 7.5. NTP Extension Field Format . . . . . . . . . . . . . . . 25
8. On Wire Protocol . . . . . . . . . . . . . . . . . . . . . . 26 8. On Wire Protocol . . . . . . . . . . . . . . . . . . . . . . 26
9. Peer Process . . . . . . . . . . . . . . . . . . . . . . . . 30 9. Peer Process . . . . . . . . . . . . . . . . . . . . . . . . 30
9.1. Peer Process Variables . . . . . . . . . . . . . . . . . 31 9.1. Peer Process Variables . . . . . . . . . . . . . . . . . 31
9.2. Peer Process Operations . . . . . . . . . . . . . . . . . 33 9.2. Peer Process Operations . . . . . . . . . . . . . . . . . 33
10. Clock Filter Algorithm . . . . . . . . . . . . . . . . . . . 37 10. Clock Filter Algorithm . . . . . . . . . . . . . . . . . . . 37
11. System Process . . . . . . . . . . . . . . . . . . . . . . . 39 11. System Process . . . . . . . . . . . . . . . . . . . . . . . 39
11.1. System Process Variables . . . . . . . . . . . . . . . . 39 11.1. System Process Variables . . . . . . . . . . . . . . . . 40
11.2. System Process Operations . . . . . . . . . . . . . . . . 40 11.2. System Process Operations . . . . . . . . . . . . . . . . 41
11.2.1. Selection Algorithm . . . . . . . . . . . . . . . . 43 11.2.1. Selection Algorithm . . . . . . . . . . . . . . . . 43
11.2.2. Cluster Algorithm . . . . . . . . . . . . . . . . . 44 11.2.2. Cluster Algorithm . . . . . . . . . . . . . . . . . 44
11.2.3. Combine Algorithm . . . . . . . . . . . . . . . . . 45 11.2.3. Combine Algorithm . . . . . . . . . . . . . . . . . 45
11.3. Clock Discipline Algorithm . . . . . . . . . . . . . . . 47 11.3. Clock Discipline Algorithm . . . . . . . . . . . . . . . 47
12. Clock Adjust Process . . . . . . . . . . . . . . . . . . . . 51 12. Clock Adjust Process . . . . . . . . . . . . . . . . . . . . 51
13. Poll Process . . . . . . . . . . . . . . . . . . . . . . . . 51 13. Poll Process . . . . . . . . . . . . . . . . . . . . . . . . 51
13.1. Poll Process Variables . . . . . . . . . . . . . . . . . 51 13.1. Poll Process Variables . . . . . . . . . . . . . . . . . 51
13.2. Poll Process Operations . . . . . . . . . . . . . . . . . 52 13.2. Poll Process Operations . . . . . . . . . . . . . . . . . 52
14. Simple Network Time Protocol (SNTP) . . . . . . . . . . . . . 54 14. Simple Network Time Protocol (SNTP) . . . . . . . . . . . . . 54
15. Security Considerations . . . . . . . . . . . . . . . . . . . 55 15. Security Considerations . . . . . . . . . . . . . . . . . . . 55
skipping to change at page 4, line 45 skipping to change at page 4, line 45
which is more responsive to system clock hardware frequency which is more responsive to system clock hardware frequency
fluctuations. Typical primary servers using modern machines are fluctuations. Typical primary servers using modern machines are
precise within a few tens of microseconds. Typical secondary servers precise within a few tens of microseconds. Typical secondary servers
and clients on fast LANs are within a few hundred microseconds with and clients on fast LANs are within a few hundred microseconds with
poll intervals up to 1024 seconds, which was the maximum with NTPv3. poll intervals up to 1024 seconds, which was the maximum with NTPv3.
With NTPv4, servers and clients are precise within a few tens of With NTPv4, servers and clients are precise within a few tens of
milliseconds with poll intervals up to 36 hours. milliseconds with poll intervals up to 36 hours.
The main body of this document describes the core protocol and data The main body of this document describes the core protocol and data
structures necessary to interoperate between conforming structures necessary to interoperate between conforming
implementations. Appendix A contains additional detail in the form implementations. Appendix A contains a full featured example in the
of a skeleton program, including data structures and code segments form of a skeleton program, including data structures and code
for the core algorithms as well as the mitigation algorithms used to segments for the core algorithms as well as the mitigation algorithms
enhance reliability and accuracy. While the skeleton program and used to enhance reliability and accuracy. While the skeleton program
other descriptions in this document apply to a particular and other descriptions in this document apply to a particular
implementation, they are not intended as the only way the required implementation, they are not intended as the only way the required
functions can be implemented. While the NTPv3 symmetric key functions can be implemented. While the NTPv3 symmetric key
authentication scheme described in this document has been carried authentication scheme described in this document has been carried
over from NTPv3, the Autokey public key authentication scheme new to over from NTPv3, the Autokey public key authentication scheme new to
NTPv4 is described in [ref3]. NTPv4 is described in [ref3].
The NTP protocol includes modes of operation described in Section 2 The NTP protocol includes modes of operation described in Section 2
using data types described in Section 6 and data structures described using data types described in Section 6 and data structures described
in Section 7. The implementation model described in Section 5 is in Section 7. The implementation model described in Section 5 is
based on a threaded, multi-process architecture, although other based on a threaded, multi-process architecture, although other
skipping to change at page 16, line 10 skipping to change at page 16, line 10
In the description of state variables to follow, explicit reference In the description of state variables to follow, explicit reference
to integer type implies a 32-bit unsigned integer. This simplifies to integer type implies a 32-bit unsigned integer. This simplifies
bounds checks, since only the upper limit needs to be defined. bounds checks, since only the upper limit needs to be defined.
Without explicit reference, the default type is 64-bit floating Without explicit reference, the default type is 64-bit floating
double. Exceptions will be noted as necessary. double. Exceptions will be noted as necessary.
7. Data Structures 7. Data Structures
The NTP protocol state machines described in the following sections The NTP protocol state machines are defined in the following
are defined using state variables and code fragments defined in sections. State variables are separated into classes according to
Appendix A. State variables are separated into classes according to
their function in packet headers, peer and poll processes, the system their function in packet headers, peer and poll processes, the system
process and the clock discipline process. Packet variables represent process and the clock discipline process. Packet variables represent
the NTP header values in transmitted and received packets. Peer and the NTP header values in transmitted and received packets. Peer and
poll variables represent the contents of the association for each poll variables represent the contents of the association for each
server separately. System variables represent the state of the server separately. System variables represent the state of the
server as seen by its dependent clients. Clock discipline variables server as seen by its dependent clients. Clock discipline variables
represent the internal workings of the clock discipline algorithm. represent the internal workings of the clock discipline algorithm.
Additional parameters and variable classes are defined in Appendix A. An example is described in Appendix A.
7.1. Structure Conventions 7.1. Structure Conventions
In order to distinguish between different variables of the same name In order to distinguish between different variables of the same name
but used in different processes, the naming convention summarized in but used in different processes, the naming convention summarized in
Figure 5 is adopted. A receive packet variable v is a member of the Figure 5 is adopted. A receive packet variable v is a member of the
packet structure r with fully qualified name r.v. In a similar packet structure r with fully qualified name r.v. In a similar
manner x.v is a transmit packet variable, p.v is a peer variable, s.v manner x.v is a transmit packet variable, p.v is a peer variable, s.v
is a system variable and c.v is a clock discipline variable. There is a system variable and c.v is a clock discipline variable. There
is a set of peer variables for each association; there is only one is a set of peer variables for each association; there is only one
skipping to change at page 17, line 21 skipping to change at page 17, line 21
| MINPOLL | 4 | minimum poll exponent (16 s) | | MINPOLL | 4 | minimum poll exponent (16 s) |
| MAXPOLL | 17 | maximum poll exponent (36 h) | | MAXPOLL | 17 | maximum poll exponent (36 h) |
| MAXDISP | 16 | maximum dispersion (16 s) | | MAXDISP | 16 | maximum dispersion (16 s) |
| MINDISP | .005 | minimum dispersion increment (s) | | MINDISP | .005 | minimum dispersion increment (s) |
| MAXDIST | 1 | distance threshold (1 s) | | MAXDIST | 1 | distance threshold (1 s) |
| MAXSTRAT | 16 | maximum stratum number | | MAXSTRAT | 16 | maximum stratum number |
+-----------+-------+----------------------------------+ +-----------+-------+----------------------------------+
Figure 6: Global Parameters Figure 6: Global Parameters
While these are the only global parameters needed in this document, a While these are the only global parameters needed for
larger collection is necessary in the skeleton and larger still for interoperability, a larger collection is necessary in any
any implementation. Appendix A.1.1 contains those used by the implementation. Appendix A.1.1 contains those used by the skeleton
skeleton for the mitigation algorithms, clock discipline algorithm for the mitigation algorithms, clock discipline algorithm and related
and related implementation-dependent functions. Some of these implementation-dependent functions. Some of these parameter values
parameter values are cast in stone, like the NTP port number assigned are cast in stone, like the NTP port number assigned by the IANA and
by the IANA and the version number assigned NTPv4 itself. Others the version number assigned NTPv4 itself. Others like the frequency
like the frequency tolerance (also called PHI), involve an assumption tolerance (also called PHI), involve an assumption about the worst
about the worst case behavior of a system clock once synchronized and case behavior of a system clock once synchronized and then allowed to
then allowed to drift when its sources have become unreachable. The drift when its sources have become unreachable. The minimum and
minimum and maximum parameters define the limits of state variables maximum parameters define the limits of state variables as described
as described in later sections of this document. in later sections of this document.
While shown with fixed values in this document, some implementations While shown with fixed values in this document, some implementations
may make them variables adjustable by configuration commands. For may make them variables adjustable by configuration commands. For
instance, the reference implementation computes the value of instance, the reference implementation computes the value of
PRECISION as log2 of the minimum time in several iterations to read PRECISION as log2 of the minimum time in several iterations to read
the system clock. the system clock.
7.3. Packet Header Variables 7.3. Packet Header Variables
The most important state variables from an external point of view are The most important state variables from an external point of view are
skipping to change at page 20, line 8 skipping to change at page 20, line 8
| | | |
| MAC (128) | | MAC (128) |
| | | |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
Figure 8: Packet Header Format Figure 8: Packet Header Format
The extension fields are used to add optional capabilities, for The extension fields are used to add optional capabilities, for
example, the Autokey security protocol [ref3]. The extension field example, the Autokey security protocol [ref3]. The extension field
format is presented in order that the packet can be parsed without format is presented in order that the packet can be parsed without
knowledge of the extension field functions. The MAC is used by both knowledge of the extension field functions. The MAC is used by both
Autokey and the symmetric key authentication scheme described in Autokey and the symmetric key authentication scheme.
Appendix A.
A list of the packet header variables is shown in Figure 7 and A list of the packet header variables is shown in Figure 7 and
described in detail below. Except for a minor variation when using described in detail below. Except for a minor variation when using
the IPv6 address family, these fields are backwards compatible with the IPv6 address family, these fields are backwards compatible with
NTPv3. The packet header fields apply to both transmitted packets (x NTPv3. The packet header fields apply to both transmitted packets (x
prefix) and received packets (r prefix). In Figure 8 the size of prefix) and received packets (r prefix). In Figure 8 the size of
some multiple-word fields is shown in bits if not the default 32 some multiple-word fields is shown in bits if not the default 32
bits. The basic header extends from the beginning of the packet to bits. The basic header extends from the beginning of the packet to
the end of the Transmit Timestamp field. the end of the Transmit Timestamp field.
skipping to change at page 21, line 39 skipping to change at page 21, line 39
| 16 | unsynchronized | | 16 | unsynchronized |
| 17-255 | reserved | | 17-255 | reserved |
+--------+-----------------------------------------------------+ +--------+-----------------------------------------------------+
Figure 11: Packet Stratum Figure 11: Packet Stratum
It is customary to map the stratum value 0 in received packets to It is customary to map the stratum value 0 in received packets to
MAXSTRAT (16) in the peer variable p.stratum and to map p.stratum MAXSTRAT (16) in the peer variable p.stratum and to map p.stratum
values of MAXSTRAT or greater to 0 in transmitted packets. This values of MAXSTRAT or greater to 0 in transmitted packets. This
allows reference clocks, which normally appear at stratum 0, to be allows reference clocks, which normally appear at stratum 0, to be
conveniently mitigated using the same algorithms used for external conveniently mitigated using the same clock selection algorithms used
sources (See Appendix A.5.5.1). for external sources (See Appendix A.5.5.1 for an example).
Poll: 8-bit signed integer representing the maximum interval between Poll: 8-bit signed integer representing the maximum interval between
successive messages, in log2 seconds. Suggested default limits for successive messages, in log2 seconds. Suggested default limits for
minimum and maximum poll intervals are 6 and 10, respectively. minimum and maximum poll intervals are 6 and 10, respectively.
Precision: 8-bit signed integer representing the precision of the Precision: 8-bit signed integer representing the precision of the
system clock, in log2 seconds. For instance a value of -18 system clock, in log2 seconds. For instance a value of -18
corresponds to a precision of about one microsecond. The precision corresponds to a precision of about one microsecond. The precision
can be determined when the service first starts up as the minimum can be determined when the service first starts up as the minimum
time of several iterations to read the system clock. time of several iterations to read the system clock.
skipping to change at page 33, line 14 skipping to change at page 33, line 14
by the on-wire protocol in Section 8. The t variable is the seconds by the on-wire protocol in Section 8. The t variable is the seconds
counter c.t associated with these values. The c.t variable is counter c.t associated with these values. The c.t variable is
maintained by the clock adjust process described in Section 12. It maintained by the clock adjust process described in Section 12. It
counts the seconds since the service was started. The variables counts the seconds since the service was started. The variables
defined in Figure 19 include the statistics computed by the defined in Figure 19 include the statistics computed by the
clock_filter() routine described in Section 10. The tp variable is clock_filter() routine described in Section 10. The tp variable is
the seconds counter associated with these values. the seconds counter associated with these values.
9.2. Peer Process Operations 9.2. Peer Process Operations
The receive() routine in Appendix A.5.1 shows the peer process code The receive routine defines the process flow upon the arrival of a
flow upon the arrival of a packet. The access() routine in packet. An example is described by the receive() routine in
Appendix A.5.4 implements access restrictions using an access control Appendix A.5.1. There is no specific method required for access
list (ACL). There is no specific method required for access control, control, although it is recommended that implementations include such
although it is recommended that implementations include such a a scheme, which is similar to many others now in widespread use. The
scheme, which is similar to many others now in widespread use. access() routine in Appendix A.5.4 describes a method of implementing
Format checks require correct field length and alignment, acceptable access restrictions using an access control list (ACL). Format
version number (1-4) and correct extension field syntax, if present. checks require correct field length and alignment, acceptable version
number (1-4) and correct extension field syntax, if present.
There is no specific requirement for authentication; however, if There is no specific requirement for authentication; however, if
authentication is implemented, the symmetric key scheme described in authentication is implemented, then the MD5 keyed hash algorithm
Appendix A.2 must be among the supported schemes. This scheme uses described in [RFC1321] must be supported.
the MD5 keyed hash algorithm described in [RFC1321].
Next, the association table is searched for matching source address Next, the association table is searched for matching source address
and source port using the find_assoc() routine in Appendix A.5.1. and source port, for example using the find_assoc() routine in
Figure 20 is a dispatch table where the columns correspond to the Appendix A.5.1. Figure 20 is a dispatch table where the columns
packet mode and rows correspond to the association mode. The correspond to the packet mode and rows correspond to the association
intersection of the association and packet modes dispatches mode. The intersection of the association and packet modes
processing to one of the following steps. dispatches processing to one of the following steps.
+------------------+---------------------------------------+ +------------------+---------------------------------------+
| | Packet Mode | | | Packet Mode |
+------------------+-------+-------+-------+-------+-------+ +------------------+-------+-------+-------+-------+-------+
| Association Mode | 1 | 2 | 3 | 4 | 5 | | Association Mode | 1 | 2 | 3 | 4 | 5 |
+------------------+-------+-------+-------+-------+-------+ +------------------+-------+-------+-------+-------+-------+
| No Association 0 | NEWPS | DSCRD | FXMIT | MANY | NEWBC | | No Association 0 | NEWPS | DSCRD | FXMIT | MANY | NEWBC |
| Symm. Active 1 | PROC | PROC | DSCRD | DSCRD | DSCRD | | Symm. Active 1 | PROC | PROC | DSCRD | DSCRD | DSCRD |
| Symm. Passive 2 | PROC | ERR | DSCRD | DSCRD | DSCRD | | Symm. Passive 2 | PROC | ERR | DSCRD | DSCRD | DSCRD |
| Client 3 | DSCRD | DSCRD | DSCRD | PROC | DSCRD | | Client 3 | DSCRD | DSCRD | DSCRD | PROC | DSCRD |
skipping to change at page 34, line 16 skipping to change at page 34, line 16
ERR. This indicates a fatal violation of protocol as the result of a ERR. This indicates a fatal violation of protocol as the result of a
programming error, long delayed packet or replayed packet. The peer programming error, long delayed packet or replayed packet. The peer
process discards the packet, demobilizes the symmetric passive process discards the packet, demobilizes the symmetric passive
association and exits. association and exits.
FXMIT. This indicates a client (mode 3) packet matching no FXMIT. This indicates a client (mode 3) packet matching no
association (mode 0). If the destination address is not a broadcast association (mode 0). If the destination address is not a broadcast
address, the server constructs a server (mode 4) packet and returns address, the server constructs a server (mode 4) packet and returns
it to the client without retaining state. The server packet header it to the client without retaining state. The server packet header
is constructed by the fast_xmit() routine in Appendix A.5.3. The is constructed. An example is described by the fast_xmit() routine
packet header is assembled from the receive packet and system in Appendix A.5.3. The packet header is assembled from the receive
variables as shown in Figure 21. If the s.rootdelay and s.rootdisp packet and system variables as shown in Figure 21. If the
system variables are stored in floating double, they must be s.rootdelay and s.rootdisp system variables are stored in floating
converted to NTP short format first. double, they must be converted to NTP short format first.
+-----------------------------------+ +-----------------------------------+
| Packet Variable --> Variable | | Packet Variable --> Variable |
+-----------------------------------+ +-----------------------------------+
| r.leap --> p.leap | | r.leap --> p.leap |
| r.mode --> p.mode | | r.mode --> p.mode |
| r.stratum --> p.stratum | | r.stratum --> p.stratum |
| r.poll --> p.ppoll | | r.poll --> p.ppoll |
| r.rootdelay --> p.rootdelay | | r.rootdelay --> p.rootdelay |
| r.rootdisp --> p.rootdisp | | r.rootdisp --> p.rootdisp |
skipping to change at page 35, line 12 skipping to change at page 35, line 12
MANY: This indicates a server (mode 4) packet matching no MANY: This indicates a server (mode 4) packet matching no
association. Ordinarily, this can happen only as the result of a association. Ordinarily, this can happen only as the result of a
manycast server reply to a previously sent multicast client packet. manycast server reply to a previously sent multicast client packet.
If the packet is valid, an ordinary client (mode 3) association is If the packet is valid, an ordinary client (mode 3) association is
mobilized and operation continues as if the association was mobilized mobilized and operation continues as if the association was mobilized
by the configuration file. by the configuration file.
NEWBC. This indicates a broadcast (mode 5) packet matching no NEWBC. This indicates a broadcast (mode 5) packet matching no
association. The client mobilizes either a client (mode 3) or association. The client mobilizes either a client (mode 3) or
broadcast client (mode 6) association as shown in the mobilize() and broadcast client (mode 6) association. Examples are shown in the
clear() routines in Appendix A.2. Then the packet() routine in mobilize() and clear() routines in Appendix A.2. Then the packet is
Appendix A.5.1.1 validates the packet and initializes the peer validated and the peer variables initialized. An example is provided
variables. by the packet() routine in Appendix A.5.1.1.
If the implementation supports no additional security or calibration If the implementation supports no additional security or calibration
functions, the association mode is set to broadcast client (mode 6) functions, the association mode is set to broadcast client (mode 6)
and the peer process exits. Implementations supporting public key and the peer process exits. Implementations supporting public key
authentication MAY run the Autokey or equivalent security protocol. authentication MAY run the Autokey or equivalent security protocol.
Implementations SHOULD set the association mode to 3 and run a short Implementations SHOULD set the association mode to 3 and run a short
client/server exchange to determine the propagation delay. Following client/server exchange to determine the propagation delay. Following
the exchange the association mode is set to 6 and the peer process the exchange the association mode is set to 6 and the peer process
continues in listen-only mode. Note the distinction between a mode-6 continues in listen-only mode. Note the distinction between a mode-6
packet, which is reserved for the NTP monitor and control functions, packet, which is reserved for the NTP monitor and control functions,
and a mode-6 association. and a mode-6 association.
NEWPS. This indicates a symmetric active (mode 1) packet matching no NEWPS. This indicates a symmetric active (mode 1) packet matching no
association. The client mobilizes a symmetric passive (mode 2) association. The client mobilizes a symmetric passive (mode 2)
association as shown in the mobilize() routine and clear() routines association. An example is shown in the mobilize() and clear()
in Appendix A.2. Processing continues in the PROC section below. routines in Appendix A.2. Processing continues in the PROC section
below.
PROC. This indicates a packet matching an existing association. The PROC. This indicates a packet matching an existing association. The
packet timestamps are carefully checked to avoid invalid, duplicate packet timestamps are carefully checked to avoid invalid, duplicate
or bogus packets. Additional checks are summarized in Figure 22. or bogus packets. Additional checks are summarized in Figure 22.
Note that all packets, including a crypto-NAK, are considered valid Note that all packets, including a crypto-NAK, are considered valid
only if they survive these tests. only if they survive these tests.
+--------------------------+----------------------------------------+ +--------------------------+----------------------------------------+
| Packet Type | Description | | Packet Type | Description |
+--------------------------+----------------------------------------+ +--------------------------+----------------------------------------+
skipping to change at page 36, line 30 skipping to change at page 36, line 30
| | the source. | | | the source. |
| 5 authentication failure | The cryptographic message digest does | | 5 authentication failure | The cryptographic message digest does |
| | not match the MAC. | | | not match the MAC. |
| 6 unsynchronized | The server is not synchronized to a | | 6 unsynchronized | The server is not synchronized to a |
| | valid source. | | | valid source. |
| 7 bad header data | One or more header fields are invalid. | | 7 bad header data | One or more header fields are invalid. |
+--------------------------+----------------------------------------+ +--------------------------+----------------------------------------+
Figure 22: Packet Error Checks Figure 22: Packet Error Checks
Processing continues in the packet() routine in Appendix A.5.1.1. It Processing continues by coping the packet variables to the peer
copies the packet variables to the peer variables as shown in variables as shown in Figure 21. An example is described by the
Figure 21 and the packet() routine in Appendix A.5.2. The receive() packet() routine in Appendix A.5.1.1. The receive() routine
routine implements tests 1-5 in Figure 22; the packet() routine implements tests 1-5 in Figure 22; the packet() routine implements
implements tests 6-7. If errors are found the packet is discarded tests 6-7. If errors are found the packet is discarded and the peer
and the peer process exits. process exits.
The on-wire protocol calculates the clock offset theta and round trip The on-wire protocol calculates the clock offset theta and round trip
delay delta from the four most recent timestamps as described in delay delta from the four most recent timestamps as described in
Section 8. While it is in principle possible to do all calculations Section 8. While it is in principle possible to do all calculations
except the first-order timestamp differences in fixed-point except the first-order timestamp differences in fixed-point
arithmetic, it is much easier to convert the first-order differences arithmetic, it is much easier to convert the first-order differences
to floating doubles and do the remaining calculations in that to floating doubles and do the remaining calculations in that
arithmetic, and this will be assumed in the following description. arithmetic, and this will be assumed in the following description.
Next, the 8-bit p.reach shift register in the poll process described Next, the 8-bit p.reach shift register in the poll process described
in Section 13 is used to determine whether the server is reachable in Section 13 is used to determine whether the server is reachable
and the data are fresh. The register is shifted left by one bit when and the data are fresh. The register is shifted left by one bit when
a packet is sent and the rightmost bit is set to zero. As valid a packet is sent and the rightmost bit is set to zero. As valid
packets arrive, the packet() routine sets the rightmost bit to one. packets arrive, the rightmost bit is set to one. If the register
If the register contains any nonzero bits, the server is considered contains any nonzero bits, the server is considered reachable;
reachable; otherwise, it is unreachable. Since the peer poll otherwise, it is unreachable. Since the peer poll interval might
interval might have changed since the last packet, the poll_update() have changed since the last packet, the host poll interval is
routine in Appendix A.5.7.2 is called to redetermine the host poll reviewed. An example is provided by the poll_update() routine in
interval. Appendix A.5.7.2.
The dispersion statistic epsilon(t) represents the maximum error due The dispersion statistic epsilon(t) represents the maximum error due
to the frequency tolerance and time since the last packet was sent. to the frequency tolerance and time since the last packet was sent.
It is initialized It is initialized
epsilon(t_0) = r.rho + s.rho + PHI * (T4-T1) epsilon(t_0) = r.rho + s.rho + PHI * (T4-T1)
when the measurement is made at t_0 according to the seconds counter. when the measurement is made at t_0 according to the seconds counter.
Here r.rho is the packet precision described in Section 7.3 and s.rho Here r.rho is the packet precision described in Section 7.3 and s.rho
is the system precision described in Section 11.1, both expressed in is the system precision described in Section 11.1, both expressed in
skipping to change at page 37, line 28 skipping to change at page 37, line 28
The dispersion then grows at constant rate PHI; in other words, at The dispersion then grows at constant rate PHI; in other words, at
time t, epsilon(t) = epsilon(t_0) + PHI * (t-t_0). With the default time t, epsilon(t) = epsilon(t_0) + PHI * (t-t_0). With the default
value PHI = 15 PPM, this amounts to about 1.3 s per day. With this value PHI = 15 PPM, this amounts to about 1.3 s per day. With this
understanding, the argument t will be dropped and the dispersion understanding, the argument t will be dropped and the dispersion
represented simply as epsilon. The remaining statistics are computed represented simply as epsilon. The remaining statistics are computed
by the clock filter algorithm described in the next section. by the clock filter algorithm described in the next section.
10. Clock Filter Algorithm 10. Clock Filter Algorithm
The clock filter algorithm, part of the peer process, is implemented The clock filter algorithm is part of the peer process. It grooms
in the clock_filter() routine of Appendix A.5.2. It grooms the the stream of on-wire data to select the samples most likely to
stream of on-wire data to select the samples most likely to represent represent accurate time. The algorithm produces the variables shown
accurate time. The algorithm produces the variables shown in in Figure 19, including the offset (theta), delay (delta), dispersion
Figure 19, including the offset (theta), delay (delta), dispersion
(epsilon), jitter (psi) and time of arrival (t). These data are used (epsilon), jitter (psi) and time of arrival (t). These data are used
by the mitigation algorithms to determine the best and final offset by the mitigation algorithms to determine the best and final offset
used to discipline the system clock. They are also used to determine used to discipline the system clock. They are also used to determine
the server health and whether it is suitable for synchronization. the server health and whether it is suitable for synchronization.
The clock filter algorithm saves the most recent sample tuples The clock filter algorithm saves the most recent sample tuples
(theta, delta, epsilon, t) in the filter structure, which functions (theta, delta, epsilon, t) in the filter structure, which functions
as an 8-stage shift register. The tuples are saved in the order that as an 8-stage shift register. The tuples are saved in the order that
packets arrive. Here t is the packet time of arrival according to packets arrive. Here t is the packet time of arrival according to
the seconds counter and should not be confused with the peer variable the seconds counter and should not be confused with the peer variable
skipping to change at page 39, line 25 skipping to change at page 39, line 24
available from each server. available from each server.
It is important to note that, unlike NTPv3, NTPv4 associations do not It is important to note that, unlike NTPv3, NTPv4 associations do not
show a timeout condition by setting the stratum to 16 and leap show a timeout condition by setting the stratum to 16 and leap
indicator to 3. The association variables retain the values indicator to 3. The association variables retain the values
determined upon arrival of the last packet. In NTPv4 lambda determined upon arrival of the last packet. In NTPv4 lambda
increases with time, so eventually the synchronization distance increases with time, so eventually the synchronization distance
exceeds the distance threshold MAXDIST, in which case the association exceeds the distance threshold MAXDIST, in which case the association
is considered unfit for synchronization. is considered unfit for synchronization.
An example implementation of the clock filter algorithm is shown in
the clock_filter() routine of Appendix A.5.2.
11. System Process 11. System Process
As each new sample (theta, delta, epsilon, jitter, t) is produced by As each new sample (theta, delta, epsilon, jitter, t) is produced by
the clock filter algorithm, all peer processes are scanned by the the clock filter algorithm, all peer processes are scanned by the
mitigation algorithms consisting of the selection, cluster, combine mitigation algorithms consisting of the selection, cluster, combine
and clock discipline algorithms in the system process. The selection and clock discipline algorithms in the system process. The selection
algorithm scans all associations and casts off the falsetickers, algorithm scans all associations and casts off the falsetickers,
which have demonstrably incorrect time, leaving the truechimers as which have demonstrably incorrect time, leaving the truechimers as
result. In a series of rounds the cluster algorithm discards the result. In a series of rounds the cluster algorithm discards the
association statistically furthest from the centroid until a association statistically furthest from the centroid until a
skipping to change at page 40, line 32 skipping to change at page 40, line 38
+-----------+------------+------------------------+ +-----------+------------+------------------------+
Figure 23: System Process Variables Figure 23: System Process Variables
Except for the t, p, offset and jitter variables and the NMIN and Except for the t, p, offset and jitter variables and the NMIN and
CMIN constants, the variables have the same format and interpretation CMIN constants, the variables have the same format and interpretation
as the peer variables of the same name. The NMIN and CMIN parameters as the peer variables of the same name. The NMIN and CMIN parameters
are used by the selection and cluster algorithms described in the are used by the selection and cluster algorithms described in the
next section. next section.
The t variable is the seconds counter at the last update determined The t variable is the seconds counter at the time of the last update.
by the clock_update() routine in Appendix A.5.5.4. The p variable is An example is shown by the clock_update() routine in
the system peer identifier determined by the cluster() routine in Appendix A.5.5.4. The p variable is the system peer identifier
Section 11.2.2. The precision variable has the same format as the determined by the cluster() routine in Section 11.2.2. The precision
packet variable of the same name. The precision is defined as the variable has the same format as the packet variable of the same name.
larger of the resolution and time to read the clock, in log2 units. The precision is defined as the larger of the resolution and time to
For instance, the precision of a mains-frequency clock incrementing read the clock, in log2 units. For instance, the precision of a
at 60 Hz is 16 ms, even when the system clock hardware representation mains-frequency clock incrementing at 60 Hz is 16 ms, even when the
is to the nanosecond. system clock hardware representation is to the nanosecond.
The offset and jitter variables are determined by the combine() The offset and jitter variables are determined by the combine
routine in Section 11.2.3. These values represent the best and final algorithm in Section 11.2.3. These values represent the best and
offset and jitter used to discipline the system clock. Initially, final offset and jitter used to discipline the system clock.
all variables are cleared to zero, then the leap is set to 3 Initially, all variables are cleared to zero, then the leap is set to
(unsynchronized) and stratum is set to MAXSTRAT (16). Remember that 3 (unsynchronized) and stratum is set to MAXSTRAT (16). Remember
MAXSTRAT is mapped to zero in the transmitted packet. that MAXSTRAT is mapped to zero in the transmitted packet.
11.2. System Process Operations 11.2. System Process Operations
Figure 24 summarizes the system process operations performed by the Figure 24 summarizes the system process operations performed by the
clock_select() routine. The selection algorithm described in clock select routine. The selection algorithm described in
Section 11.2.1 produces a majority clique of presumed correct Section 11.2.1 produces a majority clique of presumed correct
candidates (truechimers) based on agreement principles. The cluster candidates (truechimers) based on agreement principles. The cluster
algorithm described in Section 11.2.2 discards outlyers to produce algorithm described in Section 11.2.2 discards outlyers to produce
the most accurate survivors. The combine algorithm described in the most accurate survivors. The combine algorithm described in
Section 11.2.3 provides the best and final offset for the clock Section 11.2.3 provides the best and final offset for the clock
discipline algorithm described in Appendix A.5.5.6. If the selection discipline algorithm. An example is described in Appendix A.5.5.6.
algorithm cannot produce a majority clique, or if it cannot produce If the selection algorithm cannot produce a majority clique, or if it
at least CMIN survivors, the system process exits without cannot produce at least CMIN survivors, the system process exits
disciplining the system clock. If successful, the cluster algorithm without disciplining the system clock. If successful, the cluster
selects the statistically best candidate as the system peer and its algorithm selects the statistically best candidate as the system peer
variables are inherited as the system variables. and its variables are inherited as the system variables.
+-----------------+ +-----------------+
| clock_select() | | clock_select() |
+-----------------+ +-----------------+
................................|........... ................................|...........
. V . . V .
. yes +---------+ +-----------------+ . . yes +---------+ +-----------------+ .
. +--| accept? | | scan candidates | . . +--| accept? | | scan candidates | .
. | +---------+ | | . . | +---------+ | | .
. V no | | | . . V no | | | .
skipping to change at page 42, line 47 skipping to change at page 42, line 47
+-----------------+ V no +-----------------+ V no
| s.p = NULL | +-------------------+ | s.p = NULL | +-------------------+
+-----------------+ | s.p = v_0.p | +-----------------+ | s.p = v_0.p |
| +-------------------+ | +-------------------+
V | V |
+-----------------+ V +-----------------+ V
| return (UNSYNC) | +-------------------+ | return (UNSYNC) | +-------------------+
+-----------------+ | return (SYNC) | +-----------------+ | return (SYNC) |
+-------------------+ +-------------------+
Figure 24: clock_select() Routine Figure 24: Clock Select Routine
11.2.1. Selection Algorithm 11.2.1. Selection Algorithm
Note that the selection and cluster algorithms are described Note that the selection and cluster algorithms are described
separately, but combined in the code skeleton. The selection separately, but combined in the code skeleton. The selection
algorithm operates to find an intersection interval containing a algorithm operates to find an intersection interval containing a
majority clique of truechimers using Byzantine agreement principles majority clique of truechimers using Byzantine agreement principles
originally proposed by Marzullo [ref6], but modified to improve originally proposed by Marzullo [ref6], but modified to improve
accuracy. An overview of the algorithm is given below and in the accuracy. An overview of the algorithm is given below and described
first half of the clock_select() routine in Appendix A.5.5.1. in the first half of the clock_select() routine in Appendix A.5.5.1.
First, those servers which are unusable according to the rules of the First, those servers which are unusable according to the rules of the
protocol are detected and discarded by the accept() routine in protocol are detected and discarded as shown by the accept() routine
Appendix A.5.5.3. Next, a set of tuples (p, type, edge) is generated in Appendix A.5.5.3. Next, a set of tuples (p, type, edge) is
for the remaining candidates. Here, p is the association identifier generated for the remaining candidates. Here, p is the association
and type identifies the upper (+1), middle (0) and lower (-1) identifier and type identifies the upper (+1), middle (0) and lower
endpoints of a correctness interval centered on theta for that (-1) endpoints of a correctness interval centered on theta for that
candidate. This results in three tuples, lowpoint (p, -1, theta - candidate. This results in three tuples, lowpoint (p, -1, theta -
lambda), midpoint (p, 0, theta) and highpoint (p, +1, theta + lambda), midpoint (p, 0, theta) and highpoint (p, +1, theta +
lambda), where lambda is the root synchronization distance calculated lambda), where lambda is the root synchronization distance. An
on each use by the rootdist() routine in Appendix A.5.1.1. The steps example of this calculation is shown by the rootdist() routine in
of the algorithm are: Appendix A.5.1.1. The steps of the algorithm are:
1. For each of m associations, place three tuples as defined above 1. For each of m associations, place three tuples as defined above
on the candidate list. on the candidate list.
2. Sort the tuples on the list by the edge component. Order the 2. Sort the tuples on the list by the edge component. Order the
lowpoint, midpoint and highpoint of these intervals from lowest to lowpoint, midpoint and highpoint of these intervals from lowest to
highest. Set the number of falsetickers f = 0. highest. Set the number of falsetickers f = 0.
3. Set the number of midpoints d = 0. Set c = 0. Scan from lowest 3. Set the number of midpoints d = 0. Set c = 0. Scan from lowest
endpoint to highest. Add one to c for every lowpoint, subtract one endpoint to highest. Add one to c for every lowpoint, subtract one
skipping to change at page 44, line 32 skipping to change at page 44, line 32
default value for CMIN is one. default value for CMIN is one.
11.2.2. Cluster Algorithm 11.2.2. Cluster Algorithm
The candidates of the majority clique are placed on the survivor list The candidates of the majority clique are placed on the survivor list
v in the form of tuples (p, theta_p, psi_p, lambda_p), where p is an v in the form of tuples (p, theta_p, psi_p, lambda_p), where p is an
association identifier, theta_p, psi_p, and stratum_p the current association identifier, theta_p, psi_p, and stratum_p the current
offset, jitter and stratum of association p, respectively, and offset, jitter and stratum of association p, respectively, and
lambda_p is a merit factor equal to stratum_p * MAXDIST + lambda, lambda_p is a merit factor equal to stratum_p * MAXDIST + lambda,
where lambda is the root synchronization distance for association p. where lambda is the root synchronization distance for association p.
The list is processed by the cluster algorithm below and the second The list is processed by the cluster algorithm below. An example is
half of the clock_select() algorithm in Appendix A.5.5.1. shown by the second half of the clock_select() algorithm in
Appendix A.5.5.1.
1. Let (p, theta_p, psi_p, lambda_p) represent a survivor candidate. 1. Let (p, theta_p, psi_p, lambda_p) represent a survivor candidate.
2. Sort the candidates by increasing lambda_p. Let n be the number 2. Sort the candidates by increasing lambda_p. Let n be the number
of candidates and NMIN the minimum required number of survivors. of candidates and NMIN the minimum required number of survivors.
3. For each candidate compute the selection jitter psi_s: 3. For each candidate compute the selection jitter psi_s:
+----- -----+^1/2 +----- -----+^1/2
| n-1 | | n-1 |
skipping to change at page 45, line 28 skipping to change at page 45, line 28
The algorithm operates in a series of rounds where each round The algorithm operates in a series of rounds where each round
discards the statistical outlyer with maximum selection jitter psi_s. discards the statistical outlyer with maximum selection jitter psi_s.
However, if psi_s is less than the minimum peer jitter psi_p, no However, if psi_s is less than the minimum peer jitter psi_p, no
improvement is possible by discarding outlyers. This and the minimum improvement is possible by discarding outlyers. This and the minimum
number of survivors represent the terminating conditions of the number of survivors represent the terminating conditions of the
algorithm. Upon termination, the final value of psi_max is saved as algorithm. Upon termination, the final value of psi_max is saved as
the system selection jitter PSI_s for use later. the system selection jitter PSI_s for use later.
11.2.3. Combine Algorithm 11.2.3. Combine Algorithm
The remaining survivors are processed by the clock_combine() routine The clock combine route processes the remaining survivors to produce
in Appendix A.5.5.5 to produce the best and final data for the clock the best and final data for the clock discipline algorithm. The
discipline algorithm. The clock_combine() routine processes peer routine processes peer offset and jitter statistics to produce the
offset and jitter statistics to produce the combined system offset combined system offset THETA and system peer jitter PSI_p, where each
THETA and system peer jitter PSI_p, where each server statistic is server statistic is weighted by the reciprocal of the root
weighted by the reciprocal of the root synchronization distance and synchronization distance and the result normalized. An example is
the result normalized. shown by the clock_combine() routine in Appendix A.5.5.5
The combined THETA is passed to the clock_update() routine in The combined THETA is passed to the clock update routine. The first
Appendix A.5.5.4. The first candidate on the survivor list is candidate on the survivor list is nominated as the system peer with
nominated as the system peer with identifier p. The system peer identifier p. The system peer jitter PSI_p is a component of the
jitter PSI_p is a component of the system jitter PSI. It is used system jitter PSI. It is used along with the selection jitter PSI_s
along with the selection jitter PSI_s to produce the system jitter: to produce the system jitter:
PSI = [(PSI_s)^2 + (PSI_p)^2]^1/2 PSI = [(PSI_s)^2 + (PSI_p)^2]^1/2
Each time an update is received from the system peer, the Each time an update is received from the system peer, the clock
clock_update() routine in Appendix A.5.5.4 is called. By rule, an update routine is called. By rule, an update is discarded if its
update is discarded if its time of arrival p.t is not strictly later time of arrival p.t is not strictly later than the last update used
than the last update used s.t. The labels IGNOR, PANIC, ADJ and STEP s.t. The labels IGNOR, PANIC, ADJ and STEP refer to return codes
refer to return codes from the local_clock() routine described in the from the local clock routine described in the next section.
next section.
IGNORE means the update has been ignored as an outlyer. PANIC means IGNORE means the update has been ignored as an outlyer. PANIC means
the offset is greater than the panic threshold PANICT (1000 s) and the offset is greater than the panic threshold PANICT (1000 s) and
SHOULD cause the program to exit with a diagnostic message to the SHOULD cause the program to exit with a diagnostic message to the
system log. STEP means the offset is less than the panic threshold, system log. STEP means the offset is less than the panic threshold,
but greater than the step threshold STEPT (125 ms). In this case the but greater than the step threshold STEPT (125 ms). In this case the
clock is stepped to the correct offset, but since this means all peer clock is stepped to the correct offset, but since this means all peer
data have been invalidated, all associations MUST be reset and the data have been invalidated, all associations MUST be reset and the
client begins as at initial start. client begins as at initial start.
skipping to change at page 47, line 4 skipping to change at page 46, line 50
as nominal performance statistics. The system offset THETA is the as nominal performance statistics. The system offset THETA is the
clock offset relative to the available synchronization sources. The clock offset relative to the available synchronization sources. The
system jitter PSI is an estimate of the error in determining this system jitter PSI is an estimate of the error in determining this
value, elsewhere called the expected error. The root delay DELTA is value, elsewhere called the expected error. The root delay DELTA is
the total round trip delay relative to the primary server. The root the total round trip delay relative to the primary server. The root
dispersion EPSILON is the dispersion accumulated over the network dispersion EPSILON is the dispersion accumulated over the network
from the primary server. Finally, the root synchronization distance from the primary server. Finally, the root synchronization distance
is defined is defined
LAMBDA = EPSILON + DELTA / 2, LAMBDA = EPSILON + DELTA / 2,
which represents the maximum error due all causes and is designated which represents the maximum error due all causes and is designated
the root synchronization distance. the root synchronization distance.
An example of the clock update routine is provided
inAppendix A.5.5.4.
11.3. Clock Discipline Algorithm 11.3. Clock Discipline Algorithm
The NTPv4 clock discipline algorithm, shortened to discipline in the The NTPv4 clock discipline algorithm, shortened to discipline in the
following, functions as a combination of two philosophically quite following, functions as a combination of two philosophically quite
different feedback control systems. In a phase-locked loop (PLL) different feedback control systems. In a phase-locked loop (PLL)
design, periodic phase updates at update intervals mu seconds are design, periodic phase updates at update intervals mu seconds are
used directly to minimize the time error and indirectly the frequency used directly to minimize the time error and indirectly the frequency
error. In a frequency-locked loop (FLL) design, periodic frequency error. In a frequency-locked loop (FLL) design, periodic frequency
updates at intervals mu are used directly to minimize the frequency updates at intervals mu are used directly to minimize the frequency
error and indirectly the time error. As shown in [ref7], a PLL error and indirectly the time error. As shown in [ref7], a PLL
skipping to change at page 49, line 29 skipping to change at page 49, line 29
| WATCH | 900 | stepout thresh(s) | | WATCH | 900 | stepout thresh(s) |
| PANICT | 1000 | panic threshold (1000 s) | | PANICT | 1000 | panic threshold (1000 s) |
| LIMIT | 30 | hysteresis limit | | LIMIT | 30 | hysteresis limit |
| PGATE | 4 | hysteresis gate | | PGATE | 4 | hysteresis gate |
| TC | 16 | time constant scale | | TC | 16 | time constant scale |
| AVG | 8 | averaging constant | | AVG | 8 | averaging constant |
+--------+------------+--------------------------+ +--------+------------+--------------------------+
Figure 27: Clock Discipline Variables and Parameters Figure 27: Clock Discipline Variables and Parameters
The discipline is implemented by the local_clock() routine, which is The process terminates immediately if the offset is greater than the
called from the clock_update() routine. The local_clock() routine in panic threshold PANICT (1000 s). The state transition function is
Appendix A.5.5.6 has two parts; the first implements the clock state described by the rstclock() function in Appendix A.5.5.7. Figure 28
machine and the second determines the time constant and thus the poll shows the state transition function used by this routine. It has
interval. four columns showing respectively the state name, predicate and
action if the offset theta is less than the step threshold, the
The local_clock() routine exits immediately if the offset is greater predicate and actions otherwise, and finally some comments.
than the panic threshold PANICT (1000 s). The state transition
function is implemented by the rstclock() function in
Appendix A.5.5.7. Figure 28 shows the state transition function used
by this routine. It has four columns showing respectively the state
name, predicate and action if the offset theta is less than the step
threshold, the predicate and actions otherwise, and finally some
comments.
+-------+---------------------+-------------------+--------------+ +-------+---------------------+-------------------+--------------+
| State | theta < STEP | theta > STEP | Comments | | State | theta < STEP | theta > STEP | Comments |
+-------+---------------------+-------------------+--------------+ +-------+---------------------+-------------------+--------------+
| NSET | ->FREQ | ->FREQ | no frequency | | NSET | ->FREQ | ->FREQ | no frequency |
| | adjust time | step time | file | | | adjust time | step time | file |
+-------+---------------------+-------------------+--------------+ +-------+---------------------+-------------------+--------------+
| FSET | ->SYNC | ->SYNC | frequency | | FSET | ->SYNC | ->SYNC | frequency |
| | adjust time | step time | file | | | adjust time | step time | file |
+-------+---------------------+-------------------+--------------+ +-------+---------------------+-------------------+--------------+
skipping to change at page 51, line 7 skipping to change at page 51, line 7
the current offset theta. If the offset is greater than PGATE (4) the current offset theta. If the offset is greater than PGATE (4)
times the clock jitter, the hysteresis counter hyster is reduced by times the clock jitter, the hysteresis counter hyster is reduced by
two; otherwise, it is increased by one. If hyster increases to the two; otherwise, it is increased by one. If hyster increases to the
upper limit LIMIT (30), tau is increased by one; if it decreases to upper limit LIMIT (30), tau is increased by one; if it decreases to
the lower limit -LIMIT (-30), tau is decreased by one. Normally, tau the lower limit -LIMIT (-30), tau is decreased by one. Normally, tau
hovers near MAXPOLL, but quickly decreases if a temperature spike hovers near MAXPOLL, but quickly decreases if a temperature spike
causes a frequency surge. causes a frequency surge.
12. Clock Adjust Process 12. Clock Adjust Process
The actual clock adjustment is performed by the clock_adjust() The actual clock adjustment process runs at one-second intervals to
routine in Appendix A.5.6.1. It runs at one-second intervals to add add the frequency correction and a fixed percentage of the residual
the frequency correction and a fixed percentage of the residual
offset theta_r. The theta_r is in effect the exponential decay of offset theta_r. The theta_r is in effect the exponential decay of
the theta value produced by the loop filter at each update. The TC the theta value produced by the loop filter at each update. The TC
parameter scales the time constant to match the poll interval for parameter scales the time constant to match the poll interval for
convenience. Note that the dispersion EPSILON increases by PHI at convenience. Note that the dispersion EPSILON increases by PHI at
each second. each second.
The clock adjust process includes a timer interrupt facility driving The clock adjust process includes a timer interrupt facility driving
the seconds counter c.t. It begins at zero when the service starts the seconds counter c.t. It begins at zero when the service starts
and increments once each second. At each interrupt the and increments once each second. At each interrupt the
clock_adjust() routine is called to incorporate the clock discipline clock_adjust() routine is called to incorporate the clock discipline
time and frequency adjustments, then the associations are scanned to time and frequency adjustments, then the associations are scanned to
determine if the seconds counter equals or exceeds the p.next state determine if the seconds counter equals or exceeds the p.next state
variable defined in the next section. If so, the poll process is variable defined in the next section. If so, the poll process is
called to send a packet and compute the next p.next value. called to send a packet and compute the next p.next value.
An example of the clock adjustment process is shown by the
clock_adjust() routine in Appendix A.5.6.1.
13. Poll Process 13. Poll Process
Each association supports a poll process that runs at regular Each association supports a poll process that runs at regular
intervals to construct and send packets in symmetric, client and intervals to construct and send packets in symmetric, client and
broadcast server associations. It runs continuously, whether or not broadcast server associations. It runs continuously, whether or not
servers are reachable in order to manage the clock filter and reach servers are reachable in order to manage the clock filter and reach
register. register.
13.1. Poll Process Variables 13.1. Poll Process Variables
skipping to change at page 52, line 42 skipping to change at page 52, line 42
is to be sent is to be sent
reach: 8-bit integer shift register shared by the peer and poll reach: 8-bit integer shift register shared by the peer and poll
processes processes
unreach: integer representing the number of seconds the server has unreach: integer representing the number of seconds the server has
been unreachable been unreachable
13.2. Poll Process Operations 13.2. Poll Process Operations
As described previously, once each second the clock_adjust() routine As described previously, once each second the clock adjust process is
in the clock adjust process is called. This routine calls the poll() called. This routine calls the poll routine for each association in
routine in Appendix A.5.7.1 for each association in turn. If the turn. If the time for the next poll message is greater than the
time for the next poll message is greater than the seconds counter, seconds counter, the routine returns immediately. Symmetric (modes
the routine returns immediately. Symmetric (modes 1, 2), client 1, 2), client (mode 3) and broadcast server (mode 5) associations
(mode 3) and broadcast server (mode 5) associations routinely send routinely send packets. A broadcast client (mode 6) association runs
packets. A broadcast client (mode 6) association runs the routine to the routine to update the reach and unreach variables, but does not
update the reach and unreach variables, but does not send packets. send packets. The poll process calls the transmit process to send a
The poll() routine calls the peer_xmit() routine in Appendix A.5.7.3 packet. If in a burst (burst > 0), nothing further is done except
to send a packet. If in a burst (burst > 0), nothing further is done call the poll update routine to set the next poll interval.
except call the poll_update() routine to set the next poll interval.
If not in a burst, the reach variable is shifted left by one bit, If not in a burst, the reach variable is shifted left by one bit,
with zero replacing the rightmost bit. If the server has not been with zero replacing the rightmost bit. If the server has not been
heard for the last three poll intervals, the clock_filter() routine heard for the last three poll intervals, the clock filter routine is
is called to increase the dispersion as described in called to increase the dispersion. An example is shown in
Appendix A.5.7.3. Appendix A.5.7.3.
If the BURST flag is lit and the server is reachable and a valid If the BURST flag is lit and the server is reachable and a valid
source of synchronization is available, the client sends a burst of source of synchronization is available, the client sends a burst of
BCOUNT (8) packets at each poll interval. The interval between BCOUNT (8) packets at each poll interval. The interval between
packets in the burst is two seconds. This is useful to accurately packets in the burst is two seconds. This is useful to accurately
measure jitter with long poll intervals. If the IBURST flag is lit measure jitter with long poll intervals. If the IBURST flag is lit
and this is the first packet sent when the server has been and this is the first packet sent when the server has been
unreachable, the client sends a burst. This is useful to quickly unreachable, the client sends a burst. This is useful to quickly
reduce the synchronization distance below the distance threshold and reduce the synchronization distance below the distance threshold and
skipping to change at page 53, line 41 skipping to change at page 53, line 41
The poll() routine includes a feature that backs off the poll The poll() routine includes a feature that backs off the poll
interval if the server becomes unreachable. If reach is nonzero, the interval if the server becomes unreachable. If reach is nonzero, the
server is reachable and unreach is set to zero; otherwise, unreach is server is reachable and unreach is set to zero; otherwise, unreach is
incremented by one for each poll to the maximum UNREACH. Thereafter incremented by one for each poll to the maximum UNREACH. Thereafter
for each poll hpoll is increased by one, which doubles the poll for each poll hpoll is increased by one, which doubles the poll
interval up to the maximum MAXPOLL determined by the poll_update() interval up to the maximum MAXPOLL determined by the poll_update()
routine. When the server again becomes reachable, unreach is set to routine. When the server again becomes reachable, unreach is set to
zero, hpoll is reset to the tc system variable and operation resumes zero, hpoll is reset to the tc system variable and operation resumes
normally. normally.
A packet is sent by the xmit_packet() routine in Appendix A.3. Some A packet is sent by the transmit process. Some header values are
header values are copied from the peer variables left by a previous copied from the peer variables left by a previous packet and others
packet and others from the system variables. Figure 30 shows which from the system variables. Figure 30 shows which values are copied
values are copied to each header field. In those implementations to each header field. In those implementations using floating double
using floating double data types for root delay and root dispersion, data types for root delay and root dispersion, these must be
these must be converted to NTP short format. All other fields are converted to NTP short format. All other fields are either copied
either copied intact from peer and system variables or struck as a intact from peer and system variables or struck as a timestamp from
timestamp from the system clock. the system clock.
+-----------------------------------+ +-----------------------------------+
| Packet Variable <-- Variable | | Packet Variable <-- Variable |
+-----------------------------------+ +-----------------------------------+
| x.leap <-- s.leap | | x.leap <-- s.leap |
| x.version <-- s.version | | x.version <-- s.version |
| x.mode <-- s.mode | | x.mode <-- s.mode |
| x.stratum <-- s.stratum | | x.stratum <-- s.stratum |
| x.poll <-- s.poll | | x.poll <-- s.poll |
| x.precision <-- s.precision | | x.precision <-- s.precision |
skipping to change at page 54, line 27 skipping to change at page 54, line 27
| x.reftime <-- s.reftime | | x.reftime <-- s.reftime |
| x.org <-- p.xmt | | x.org <-- p.xmt |
| x.rec <-- p.dst | | x.rec <-- p.dst |
| x.xmt <-- clock | | x.xmt <-- clock |
| x.keyid <-- p.keyid | | x.keyid <-- p.keyid |
| x.digest <-- md5 digest | | x.digest <-- md5 digest |
+-----------------------------------+ +-----------------------------------+
Figure 30: xmit_packet Packet Header Figure 30: xmit_packet Packet Header
The poll_update() routine shown in Appendix A.5.7.2 is called when a The poll update routine is called when a valid packet is received and
valid packet is received and immediately after a poll message has immediately after a poll message has been sent. If in a burst, the
been sent. If in a burst, the poll interval is fixed at 2 s; poll interval is fixed at 2 s; otherwise, the host poll exponent
otherwise, the host poll exponent hpoll is set to the minimum of hpoll is set to the minimum of ppoll from the last packet received
ppoll from the last packet received and hpoll from the poll() and hpoll from the poll routine, but not less than MINPOLL nor
routine, but not less than MINPOLL nor greater than MAXPOLL. Thus greater than MAXPOLL. Thus the clock discipline can be oversampled,
the clock discipline can be oversampled, but not undersampled. This but not undersampled. This is necessary to preserve subnet dynamic
is necessary to preserve subnet dynamic behavior and protect against behavior and protect against protocol errors.
protocol errors.
The poll exponent is converted to an interval which when added to the The poll exponent is converted to an interval which when added to the
last variable determines the next variable and thus the time for the last poll time variable determines the value of the next poll time
next poll. Finally, the last variable is set to the current seconds variable. Finally, the last poll time variable is set to the current
counter. seconds counter.
14. Simple Network Time Protocol (SNTP) 14. Simple Network Time Protocol (SNTP)
Primary servers and clients complying with a subset of NTP, called Primary servers and clients complying with a subset of NTP, called
the Simple Network Time Protocol (SNTPv4) [RFC4330], do not need to the Simple Network Time Protocol (SNTPv4) [RFC4330], do not need to
implement the mitigation algorithms described in Section 9 and implement the mitigation algorithms described in Section 9 and
following sections. SNTP is intended for primary servers equipped following sections. SNTP is intended for primary servers equipped
with a single reference clock, as well as for clients with a single with a single reference clock, as well as for clients with a single
upstream server and no dependent clients. The fully developed NTPv4 upstream server and no dependent clients. The fully developed NTPv4
implementation is intended for secondary servers with multiple implementation is intended for secondary servers with multiple
 End of changes. 43 change blocks. 
178 lines changed or deleted 176 lines changed or added

This html diff was produced by rfcdiff 1.35. The latest version is available from http://tools.ietf.org/tools/rfcdiff/