wire / wire-format / ntp-protocol
NTP synchronizes clocks over the network. Packet format (48 bytes): LI (leap indicator, 2 bits), VN (version, 3 bits), Mode (3 bits), Stratum (1 byte), Poll (1 byte), Precision (1 byte), Root Delay (4 bytes), Root Dispersion (4 bytes), Reference ID (4 bytes), Reference Timestamp (8 bytes), Origin Timestamp (8 bytes), Receive Timestamp (8 bytes), Transmit Timestamp (8 bytes). NTP uses UDP port 123.
aka: NTP (Network Time Protocol)
spec: RFC 5905
NTP synchronizes clocks over the network. Packet format (48 bytes): LI (leap indicator, 2 bits), VN (version, 3 bits), Mode (3 bits), Stratum (1 byte), Poll (1 byte), Precision (1 byte), Root Delay (4 bytes), Root Dispersion (4 bytes), Reference ID (4 bytes), Reference Timestamp (8 bytes), Origin Timestamp (8 bytes), Receive Timestamp (8 bytes), Transmit Timestamp (8 bytes). NTP uses UDP port 123.
| field | size | meaning |
|---|---|---|
| LI (Leap Indicator) | 2 bits | 0 = no leap, 1 = 61 seconds (leap added), 2 = 59 seconds (leap removed), 3 = alarm (clock not synchronized). |
| VN (Version) | 3 bits | NTP version (3 or 4). |
| Mode | 3 bits | 0 = reserved, 1 = symmetric active, 2 = symmetric passive, 3 = client, 4 = server, 5 = broadcast, 6 = NTP control, 7 = private. |
| Stratum | 1 byte | Clock stratum: 0 = unspecified, 1 = primary (atomic clock/GPS), 2-15 = secondary (synced to stratum-1), 16 = unsynchronized. |
| Poll | 1 byte (signed) | Poll interval in log2 seconds (e.g., 6 = 64 seconds, 10 = 1024 seconds). |
| Precision | 1 byte (signed) | Clock precision in log2 seconds (e.g., -20 = ~1 microsecond). |
| Root Delay | 4 bytes (fixed-point) | Total round-trip delay to the primary reference source. |
| Root Dispersion | 4 bytes (fixed-point) | Maximum error of the local clock relative to the primary source. |
| Reference ID | 4 bytes | Identifier of the reference source (IP address for stratum 2+, or ASCII code for stratum 1: GPS, PPS, etc.). |
| Timestamps | 4 x 8 bytes | Reference, Origin, Receive, Transmit timestamps (64-bit: 32-bit seconds + 32-bit fraction, epoch 1900-01-01). |
example:
1b 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
NTP client request (mode 3, version 4, stratum 0)
agent: curl -H 'accept: application/json' wire.phall.io/wire-format/ntp-protocol
or /wire-format/ntp-protocol.json