How PTP Uses UDP to Synchronize Network Clocks

The Precision Time Protocol (PTP), defined under IEEE 1588, provides sub-microsecond clock synchronization across distributed network devices. To achieve this high level of accuracy, PTP frequently operates over the User Datagram Protocol (UDP) on IPv4 or IPv6 networks. By leveraging UDP’s low overhead, multicast capabilities, and specific port assignments for hardware timestamping, PTP can accurately measure and compensate for network delay and clock offset between a primary clock (Master) and secondary clocks (Slaves).

Dedicated UDP Ports and Message Types

PTP separates its network traffic into two primary categories using dedicated UDP port numbers to ensure timing accuracy:

Separating these packets allows network interface cards (NICs) and switches to quickly identify Port 319 traffic and capture hardware-level timestamps at the physical layer (PHY) without packet-processing delays.

The Four-Timestamp Synchronization Process

Synchronization relies on a two-way exchange of UDP datagrams to calculate the network delay and the clock difference between the Master and Slave.

  1. Master to Slave (Sync): The Master sends a UDP Sync packet on port 319 and records its egress timestamp (\(t_1\)). The Slave receives this packet and records its ingress timestamp (\(t_2\)). If hardware limitations prevent inserting \(t_1\) directly into the Sync packet, the Master sends a standard UDP Follow_Up packet on port 320 containing the value of \(t_1\).
  2. Slave to Master (Delay Request): The Slave sends a UDP Delay_Req packet to the Master on port 319, recording its egress timestamp (\(t_3\)).
  3. Master Response (Delay Response): The Master receives the Delay_Req, records its ingress timestamp (\(t_4\)), and sends a UDP Delay_Resp packet on port 320 back to the Slave containing the value of \(t_4\).

Offset and Delay Calculation

Once the Slave collects all four timestamps (\(t_1, t_2, t_3, t_4\)) via the UDP exchanges, it calculates the mean propagation delay and clock offset assuming symmetric network transit times:

The Slave then adjusts its local clock by the calculated offset to align precisely with the Master clock.

Why PTP Uses UDP