rfc-5905

Network Time Protocol Version 4: Protocol and Algorithms Specification

D. Mills, J. Martin (Editor), J. Burbank, W. Kasch
date2010-06 streamIETF areaint wgntp statusPROPOSED STANDARD pages110 canonicalhttps://www.rfc-editor.org/rfc/rfc5905 doi10.17487/RFC5905 errataview
The Network Time Protocol (NTP) is widely used to synchronize computer clocks in the Internet. This document describes NTP version 4 (NTPv4), which is backwards compatible with NTP version 3 (NTPv3), described in RFC 1305, as well as previous versions of the protocol. NTPv4 includes a modified protocol header to accommodate the Internet Protocol version 6 address family. NTPv4 includes fundamental improvements in the mitigation and discipline algorithms that extend the potential accuracy to the tens of microseconds with modern workstations and fast LANs. It includes a dynamic server discovery scheme, so that in many cases, specific server configuration is not required. It corrects certain errors in the NTPv3 design and implementation and includes an optional extension mechanism.

obsoletes

updated by

Extracted elements (32)

design-rationale §1

NTP uses UDP rather than TCP because retransmissions in a reliable transport protocol would increase measured delay values and introduce errors; the returnable-time on-wire protocol depends only on measured clock offsets and is inherently tolerant of lost or reordered packets without needing retransmission.

ntp

design-rationale §8

NTPv4 encourages use of floating double arithmetic throughout the implementation. First-order timestamp differences (which are small relative to the seconds magnitude) are converted to floating double for further processing, restoring the unambiguous offset/delay computation range from 34 years (64-bit integer) to 68 years without loss of precision.

ntp

design-rationale §3

The synchronization subnet topology uses a variant of the Bellman-Ford distributed routing algorithm to compute the shortest-path spanning tree rooted at primary servers, automatically reorganizing to provide the most accurate and reliable time even when failures occur, without requiring an explicit election protocol.

ntp

interoperability-note §1

NTPv4 is backwards compatible with NTPv3 (RFC 1305) and SNTPv4 (RFC 4330), which it obsoletes; SNTPv4 is a strict subset of NTPv4. Minor changes to header fields do not affect interoperability between NTPv4 and previous versions.

ntp

interoperability-note §7.3

When an NTPv4 server uses IPv6 and serves an NTPv3 client, the Reference ID field (containing the first four octets of the MD5 hash of the IPv6 address) appears as a random value to the NTPv3 client, which may prevent detection of timing loops.

ntp

normative-requirement §2 MUST

All fully NTPv4-compliant servers and clients MUST implement the entire suite of algorithms described in the specification. Secondary servers SHOULD be fully NTPv4-compliant to maintain stability in large NTP subnets. Alternative algorithms MAY be used only if their output is identical to those specified.

ntp

normative-requirement §9.2 MUST

If authentication is implemented, the MD5-keyed hash algorithm described in RFC 1321 must be supported. The MAC is computed over the key concatenated with all NTP header and extension fields (but not the Key Identifier or Message Digest fields themselves).

ntp, crypto, security

normative-requirement §7.4 MUST NOT

KoD Receive and Transmit Timestamps MUST NOT be relied upon to contain valid values and MUST be discarded. Kiss codes beginning with 'X' are reserved for unregistered experimentation and MUST be ignored if not recognized.

ntp

normative-requirement §6 SHOULD

To minimize bias and make timestamps unpredictable to an intruder, the non-significant bits of timestamp fractions should be set to an unbiased random bit string. Clock resolution is defined as 2^(-p) seconds where p is the number of significant bits.

ntp, security

normative-requirement §7.4 MUST

Upon receiving a KoD packet with kiss code DENY or RSTR, the client MUST demobilize all associations to that server and stop sending packets to it. Upon receiving kiss code RATE, the client MUST immediately reduce its polling interval to that server and continue reducing it each time a RATE code is received.

ntp

normative-requirement §8 SHOULD

When a negative round-trip delay results from a large initial frequency offset combined with a short polling interval, the value of delta MUST be clamped to not less than s.rho (the system precision in seconds) to prevent misleading subsequent computations.

ntp

protocol-element §8

Before updating state variables on packet receipt, two sanity checks detect duplicate/replay packets (transmit timestamp t3 matches state variable T3) and bogus packets (origin timestamp t1 does not match state variable T1). To resist replay of the last transmitted packet, the xmt state variable is set to zero immediately after a successful bogus check.

ntp, security

protocol-element §7.4

Kiss-o'-Death (KoD) packets carry Stratum = 0 and a four-character left-justified zero-filled ASCII kiss code in the Reference ID field. Defined kiss codes include DENY (access denied), RSTR (local policy denial), RATE (rate exceeded), AUTH (authentication failed), CRYP (cryptographic failure), INIT (not yet synchronized), and STEP (step change occurred). The Receive and Transmit Timestamps in KoD packets are undefined.

ntp

protocol-element §3

NTP defines six association modes: Symmetric Active (1), Symmetric Passive (2), Client (3), Server (4), Broadcast Server (5), and Broadcast Client (6). A client (mode 3) sends mode-3 packets and receives mode-4 responses; symmetric active peers exchange mode-1 packets. Persistent associations are mobilized at startup; ephemeral associations are mobilized on packet arrival and demobilized on error or timeout.

ntp

protocol-element §11.3

The clock discipline algorithm is a hybrid PLL/FLL that controls both time and frequency of the system clock (modeled as a VFO). The poll exponent tau ranges from MINPOLL (4, 16 s) to MAXPOLL (17, 36 h); the loop time constant T_c = 2^tau is dynamically adjusted. The adjtime() function is used for small adjustments; settimeofday() for adjustments exceeding the step threshold.

ntp

protocol-element §10

The clock filter algorithm maintains a shift register of the eight most recent (offset, delay, dispersion, time) samples per server and selects the sample with the smallest delay as the best estimate. It outputs the statistics theta, delta, epsilon, and psi that are passed to the system process.

ntp

protocol-element §7.3

The Leap Indicator (LI) is a 2-bit field: 0 = no warning, 1 = last minute of day has 61 seconds, 2 = last minute has 59 seconds, 3 = clock unsynchronized. A value of 3 propagates through the subnet to indicate that the time source is not trusted.

ntp

protocol-element §3.1

The manycast dynamic server discovery mechanism sends client (mode 3) packets to an IPv4 broadcast/multicast or IPv6 multicast group address with TTL starting at 1 and incrementing until the minimum number of associations is reached or TTL reaches 255 (maximum). Suitable servers respond via unicast mode-4 packets; the client mobilizes ephemeral associations that compete via the mitigation algorithms.

ntp

protocol-element §8

The on-wire protocol exchanges four timestamps: t1 (client departure), t2 (server arrival), t3 (server departure), t4 (client arrival). Clock offset theta = [(T2-T1)+(T3-T4)]/2 and round-trip delay delta = (T4-T1)-(T3-T2). The protocol is inherently resistant to lost or duplicate packets and requires no reliable delivery.

ntp

protocol-element §7.3

The Reference ID (refid) field encodes the time source: for stratum 1, a left-justified zero-padded ASCII string (e.g., GPS, PPS, GOES); for stratum 2+ with IPv4, the upstream server's 4-octet IPv4 address; for stratum 2+ with IPv6, the first four octets of the MD5 hash of the IPv6 address. IANA maintains the authoritative list of stratum-1 reference identifiers.

ntp, registry

protocol-element §7.3

The Stratum field is an 8-bit integer: 0 = unspecified/invalid (KoD packets), 1 = primary server synchronized directly to a reference clock, 2–15 = secondary servers via NTP, 16 = unsynchronized, 17–255 = reserved. Received stratum 0 is mapped to MAXSTRAT (16) internally; p.stratum values >= MAXSTRAT are mapped to 0 in transmitted packets.

ntp

protocol-element §11.2

The system process runs three sub-algorithms: the selection algorithm applies Byzantine fault detection to discard falsetickers and retain truechimers; the cluster algorithm uses statistical principles to select the most accurate subset; the combine algorithm computes a weighted-average final offset from the surviving truechimers. The synchronization distance LAMBDA = EPSILON + DELTA/2 represents the maximum error.

ntp

registry §16

IANA has assigned NTP UDP port 123 and allocated IPv4 multicast address 224.0.1.1 and IPv6 multicast address ending :101 (prefix determined by scoping rules) for NTP use. Any non-allocated multicast address may also be used in addition to these.

ntp, registry

registry §16

IANA maintains the authoritative list of NTP Reference Identifiers (four-character ASCII strings identifying stratum-1 reference clock sources, e.g., GPS, PPS, GOES, WWV). ASCII strings beginning with 'X' are reserved for unregistered experimentation. IANA also maintains the NTP kiss code registry (stratum-0 Reference ID values used in KoD packets).

ntp, registry

security-consideration §9.2

A crypto-NAK is returned when authentication fails on a received packet; it consists of a normal NTP header with a MAC of four zero octets. The receiving client MAY accept or reject the data in the message, and must decide whether to continue using the unauthenticated time values.

ntp, security

security-consideration §15

KoD DENY/RSTR packets can be spoofed by off-path attackers to cause clients to demobilize legitimate server associations, constituting a denial-of-service attack on time synchronization. Implementations should authenticate KoD packets where possible before acting on them.

ntp, security

security-consideration §15

NTP is vulnerable to replay attacks: replaying a client request packet causes the server to generate a fresh response with new T2 and T3 values, producing incorrect offset and delay at the client. This can be mitigated by zeroing the xmt state variable after computing offset and delay, ensuring a replayed response is rejected as bogus.

ntp, security

security-consideration §15

The symmetric key MD5 authentication scheme carried over from NTPv3 provides data origin authentication but does not prevent all forms of timing attack. The Autokey public key authentication scheme new to NTPv4 provides stronger security and is described separately in RFC 5906.

ntp, security, crypto

state-machine §9.2

The peer dispatch table governs packet processing based on (association mode × packet mode): valid pairings dispatch to PROC (process the packet), while invalid ones result in DSCRD (discard), ERR (discard and demobilize symmetric passive association), FXMIT (stateless server response), MANY (manycast server response), NEWPS (mobilize symmetric passive), or NEWBC (mobilize broadcast client). ERR is a fatal protocol violation.

ntp

wire-format §6

NTP defines three time formats: a 128-bit date format (64-bit signed seconds split into 32-bit Era Number and 32-bit Era Offset, plus 64-bit fraction resolving 0.05 attoseconds), a 64-bit timestamp format (32-bit unsigned seconds spanning 136 years, 32-bit fraction resolving 232 picoseconds), and a 32-bit short format (16-bit seconds, 16-bit fraction). The prime epoch is 0h 1 January 1900 UTC; a value of zero indicates unknown or unsynchronized time.

ntp

wire-format §7.5

NTP extension fields consist of a 16-bit Field Type, a 16-bit Length (total octets including padding), a variable-length Value, and zero-padding to a 4-octet word boundary. The minimum field length is 16 octets. A MAC must always be present when an extension field is present.

ntp

wire-format §7.3

The NTP packet header is a UDP datagram of 12 32-bit words (48 octets) in network byte order, containing LI (2 bits), VN (3 bits), Mode (3 bits), Stratum (8 bits), Poll (8 bits), Precision (8 bits), Root Delay (32 bits NTP short format), Root Dispersion (32 bits NTP short format), Reference ID (32 bits), and four 64-bit timestamps (Reference, Origin, Receive, Transmit). Optional extension fields and an optional MAC (32-bit Key Identifier + 128-bit MD5 digest) may follow.

ntp