Protocol 38 of 81Layer 7FrameAssembly v3.1.2
llms-full.txt
ntpNetwork Time Protocol v1–v4

Stratum-1 GPS Clocks & Drift Debugging (client <-> clock ntp UDP 123)

Default Port / Protocol
UDP 123
Host Endpoint Rule
Dual-Stack IPv4/IPv6
Wireshark Display Filter
ntp
Standards & Specs
RFC 5905
Wire Stack:Ethernet II[802.1Q / QinQ / MPLS]IPv4 / IPv6UDP 123NTPv4

What It Does on the Wire

When Kerberos tickets start failing because two servers drifted five minutes apart, everyone stares at UDP 123. ntp writes clean 48-byte RFC 5905 packets right down to signed precision and ASCII refid.

Network Time Protocol (ntp, RFC 5905) synchronizes system clocks across routers, servers, financial engines, and Kerberos/TLS infrastructure over UDP dstport 123. Every standard NTPv4 packet is a fixed 48-byte binary structure packing Leap Indicator (li), Version (vn), Mode (mode), stratum, poll, signed log2 precision, Root Delay/Dispersion, 4-byte refid ("GPS", "PPS", "ATOM", or kiss-o'-death "RATE"), and 64-bit NTP epoch timestamps.

Stratum 1 GPS / Atomic Clock Sync & Kiss-o'-Death (stratum 0) Testing

Generate mode 3 client requests paired with mode 4 stratum 1 refid "GPS" responses—or stratum 0 refid "RATE" Kiss-o'-Death rate-limiting replies.

NTP Mode 6 (monlist / Control) DDoS Amplification Firewall Filters

Craft ntp vn 2 mode 6 or mode 7 packets on UDP 123 to verify edge ACLs block legacy NTP control/private amplification queries while permitting mode 3/4.

Router Symmetric-Active (mode 1) Peer Verification

Test core router NTP peerings (srcport 123 dstport 123, mode 1 / mode 2) with dscp 48 (CS6) QoS markings.

Minimal Quickstart (ntp_quickstart.frasm)

Hit Preview Packets to compile in-browser and eyeball timestamps + wire byte lengths, or ship it straight to the Playground.

ntp_quickstart.frasm7 lines
Open in Playground
host app_srv { ip 10.10.20.40 }
host time_appliance { ip 10.10.20.123 }
compile {
app_srv -> time_appliance ntp vn 4 mode 3 poll 6 wait 2ms
app_srv <- time_appliance ntp li 0 vn 4 mode 4 stratum 1 poll 6 precision -20 refid "GPS" txtimestamp 0xe9b4c20000000000
}

What the Compiler Calculates So You Don't Have To

  • Packs the first byte (li << 6) | (vn << 3) | mode cleanly (0x23 for li 0 vn 4 mode 3 client; 0x24 for mode 4 server) inside a 48-byte RFC 5905 header.
  • Zero-pads 4-character ASCII refid strings ("GPS\0", "PPS\0", "RATE") for Stratum 0/1 servers.
  • Reverses ephemeral srcport <-> 123 automatically across -> and <- statements.
Multi-Frame Lab · Ready to Compile

Stratum 1 Synchronization + Kiss-o'-Death Rate-Limit & Mode 6 Audit Probe

Captures normal NTPv4 client/server clock sync, a stratum 0 refid "RATE" Kiss-o'-Death response, and a blocked mode 6 control query for IDS testing.

ntp_sync_and_security_audit.frasm12 lines
Open in Playground
host branch_rtr { ip 172.16.30.1 }
host ntp_core { ip 172.16.30.123 }
compile {
// 1. Standard NTPv4 Client (mode 3) -> Stratum 1 GPS Server (mode 4)
branch_rtr -> ntp_core ntp vn 4 mode 3 poll 6 precision -18 dscp 48 wait 2ms
branch_rtr <- ntp_core ntp li 0 vn 4 mode 4 stratum 1 poll 6 precision -24 refid "GPS" txtimestamp 0xe9b4d01080000000 dscp 48 wait 5ms
// 2. RFC 5905 Kiss-o'-Death (stratum 0, li 3, refid "RATE")
branch_rtr <- ntp_core ntp li 3 vn 4 mode 4 stratum 0 refid "RATE" wait 5ms
// 3. Mode 6 NTP Control query probe (tested against perimeter IDS/firewall)
branch_rtr -> ntp_core ntp vn 2 mode 6
}
Terminal Commands (FrameAssembly CLI v3.1.2)
# 1. Eyeball relative timestamps, ports & wire lengths in your terminal
frameassembly show ntp_sync_and_security_audit.frasm

# 2. Compile .frasm -> classic .pcap (tcpdump/tcpreplay/Suricata) or nanosecond .pcapng
frameassembly ntp_sync_and_security_audit.frasm ntp_sync_and_security_audit.pcap
frameassembly ntp_sync_and_security_audit.frasm ntp_sync_and_security_audit.pcapng

# 3. Round-trip .pcap <-> .frasm whenever you want to scrub or tweak an existing capture
frameassembly reverse ntp_sync_and_security_audit.pcap ntp_sync_and_security_audit_edited.frasm

All ntp Keywords & Header Options

Every sub-keyword and header option is lowercase [a-z0-9]+ with zero underscores — mix and match them in any order after ntp:

src_host -> dst_host ntp [li <0..3>] [vn <1..4>] [mode <0..7>] [stratum <0..16>] [poll <0..255>] [precision <-128..127>] [refid "<text>"] [txtimestamp <number>]
Keyword / OptionAccepted ValueDefaultEffect on Packet
li <0..3>2-bit Leap Indicator0 (no warning)Sets bits 7..6 of byte 0 (0=no leap, 1=61s minute, 2=59s minute, 3=unsynchronized/alarm).
vn <1..4>3-bit NTP Version Number4 (NTPv4)Sets bits 5..3 of byte 0 (1..4).
mode <0..7>3-bit Association Mode3 (Client)Sets bits 2..0 of byte 0 (1=Symmetric Active, 2=Passive, 3=Client, 4=Server, 5=Broadcast, 6=Control, 7=Private).
stratum <0..16>Whole number (0..255)0 (client) / 1 (when refid set)Sets Clock Stratum (0=unspecified/KoD, 1=primary GPS/PPS, 2..15=secondary, 16=unsynchronized).
poll <0..255> | precision <-128..127>poll: u8 log2 seconds, precision: signed i8 (-128..127)poll 6 (64s), precision -20 (~1us)Sets 8-bit Poll Interval exponent and signed 8-bit two's-complement Clock Precision.
refid "<text>"Up to 4 ASCII chars ("GPS", "PPS", "ATOM", "RATE")"LOCL" / zeroedWrites the 4-byte Reference Identifier in bytes 12..15.
txtimestamp <number>64-bit NTP timestamp (32b sec since 1900 + 32b frac)Non-zero deterministic epochWrites the 8-byte Transmit Timestamp in bytes 40..47.

Cross-Layer Wrappers Valid with ntp

802.1Q VLAN / QinQ / MPLS tags, IPv4/IPv6 QoS & TTL fields, wait gaps, and transport overrides allowed on this protocol

10 options
OptionRange / FormatDefaultEffect on Packet
wait <number><ns|us|ms|s|m>Time gap (ns, us, ms, s, m)10msAdvances the packet timestamp clock after sending this packet and before the next packet (wait 0ns sends back-to-back).
payload "<text>" | hexpayload "<hex>"Quoted text or hex bytes (choose one)OmittedAppends or overrides raw payload bytes ("deadbeef" or "de:ad:be:ef") and updates packet lengths and checksums.
srcmac <mac> | dstmac <mac>Colon, hyphen, or Cisco dot MACHost MAC / RFC multicast MACOverrides the 14-byte Ethernet II source or destination MAC address for this single packet.
vlan <0..4095> [pcp <0..7>] [dei <0|1>]VLAN ID 0..4095, PCP 0..7, DEI 0..1UntaggedWraps the packet in an IEEE 802.1Q VLAN tag (0x8100) with optional 802.1p QoS priority.
qinq <0..4095> [innervlan <0..4095>]Outer S-VLAN 0..4095, Inner C-VLAN 0..4095Untagged (innervlan 1 when qinq is set)Double-tags the packet with outer IEEE 802.1ad S-Tag (0x88a8) plus inner IEEE 802.1Q C-Tag (0x8100).
mpls <0..1048575> [exp|tc <0..7>] [bos <0|1>] [mplsttl <0..255>]Label 0..1048575, exp/tc 0..7, bos 0..1, ttl 0..255Unlabeled (at most 1 mpls tag per packet)Inserts a 32-bit MPLS label header (0x8847) ahead of the Layer 3 header.
ttl <0..255> [dscp <0..63>] [ecn <0..3>]TTL/Hop Limit 0..255, DSCP 0..63, ECN 0..3ttl 64, dscp 0, ecn 0Sets IPv4 TTL or IPv6 Hop Limit plus DiffServ (DSCP) and ECN QoS markings.
ipid <0..65535> [df] [mf] [fragoffset <0..8191>]IPv4 ID, DF/MF flags, fragment offset 0..8191ipid 1, flags 0, fragoffset 0Sets IPv4 Identification, Do-Not-Fragment (df), More-Fragments (mf), and fragment offset (ignored over IPv6).
flowlabel <0..1048575>20-bit IPv6 Flow Label (0..1048575)0Sets the 20-bit IPv6 Flow Label for ECMP routing tests (ignored when running over IPv4 hosts).
srcport <0..65535> | dstport <0..65535>Port number 0..65535srcport 49152 (remembered), UDP 123Overrides source or destination port and remembers the port pair automatically on <- replies.

Gotchas & Quick Fixes

Signed precision Accepts Negative Integers Directly (precision -20)

Avoid
app_srv <- time_appliance ntp mode 4 precision "-20"
Valid v3.1.2 Syntax
app_srv <- time_appliance ntp mode 4 precision -20

precision expects an unquoted signed 8-bit integer (-20 represents $2^{-20} \approx 0.95\,\mu\text{s}$).

Set mode 4 Explicitly on Server Replies

Avoid
app_srv <- time_appliance ntp stratum 1 refid "GPS"
Valid v3.1.2 Syntax
app_srv <- time_appliance ntp mode 4 stratum 1 refid "GPS"

ntp defaults to mode 3 (Client); always specify mode 4 on <- server responses so Wireshark labels the packet NTP Version 4, server.

Field Guide 04
Encrypted SNMPv3 Traps, Syslog & NetFlow From Your Desk