Basics IEEE1588

Definition

The PTP (Precision Time Protocol) defined in IEEE1588 is a protocol standard for synchronization of distributed clocks in networks. Each PTP clock cyclically runs the “Best Master Clock Algorithm” (BMCA) to determine the clock with the best precision. The clock with the best precision is referred to as grandmaster and is used as synchronization source for all other PTP clocks in the network. Current two standards are defined, PTPv1 and PTPv2. The PTP can be based on Ethernet as transport medium, for example.

If PTP devices are not directly connected and Ethernet traffic takes place via switches/routers instead, it is highly advisable to use PTP-capable switches/routers. If a switch supports PTP, it behaves like a slave clock vis-à-vis a connected master clock, i.e. it is synchronized by the master clock. Vis-à-vis other connected slave clocks it behaves like a master clock. The switch becomes a PTPv1/v2 boundary clock.
In addition, PTPv2 offers a transparent clock option, in which case each switch enters a time correction value in a correction field in the PTP telegram. This enables downstream slaves to calculate the influence of the switch on the transmission link.

Different implementation types are available in the switch/router:

The architectural differences between the two stages are as follows:

V1 and V2 barely differ in terms of the theoretically attainable accuracy; an accuracy of < 1 µs is attainable with both versions in the ideal case, i.e. with an optimum infrastructure. The maximally attainable accuracy depends alone on the type of time stamping that can be implemented in hardware or software.

Functioning

Time determination, 2-step procedure

A basic function in all PTP protocols is the option of allocating exact timestamps for sending and receiving of Ethernet telegrams in the Ethernet hardware. This enables the delay times between the grandmaster and the slaves to be calculated.

1. At time t1 the grandmaster sends a SyncMessage containing the estimated send time to the slaves. It arrives at the slave at time t2.
2. Shortly afterwards the grandmaster sends a FollowUp containing the actual send time t1 of the previous telegram.
3. This process is cyclically repeated at the SyncInterval, e.g. every 2 seconds. Defined/supported Sync Intervals are 1 s, 2 s, 4 s, 8 s, 16 s, 32 s (PTPv1) and 0.5 s, 1 s, 2 s, 4 s (PTPv2).

At longer intervals the slave examines the return path:

1. The slave sends a DelayRequest to the master, which receives it at time t4.
2. It responds with a DelayResponse message containing the time of arrival t4.

This can be used to calculate the latency periods on both sides and correct any drift.

In Fig. "PTPv1 traffic in 2-step mode" the grandmaster "192.168.200.2" triggers a Sync every 2 seconds. The slave "192.168.200.1" responds with a DelayRequest every 8 seconds.

Basics IEEE1588 1:
PTPv1 traffic in 2-step mode

Routing

The telegrams are usually routed via IP/UDP through multicast via ports 319 (event messages: SyncMsg, DeleyReq) and 320 (general messages: FollowUp, Announce, DelayResp, Management). These ports should be prioritized, if possible.

Four multicast domains are defined, so that up to four independent time networks can be established within a network:

The domains in the grandmaster and slave clocks must match. A dedicated IP address for the slave is only required if the PTP master requires this.

Terminology

Stratum: measure for the quality of a clock. Stratum-1 is the highest level.

Grandmaster Clock selection

A balanced PTP system according to IEEE1588 only has a single time source, the Grandmaster Clock. Each PTP clock can start off as a Master or Slave Clock. A PTP clock uses different criteria (Stratum, Preferred flag) to indicate the quality of the time it supplies, depending on whether it is based on GPS, quartz, atomic clock or similar, for example. If more than one PTP clock exists in a network, the PTP clocks select the best clock within the network as timer (Grandmaster Clock), based on the standardized BMCA, which should be integrated in the same way in all PTP clocks. The remaining clocks switch to the passive mode, as long as the selected Grandmaster Clock sends out Sync messages.
Through its parameters a PTP clock can enforce Grandmaster Clock status within a network (by setting its parameter optimally) or Slave Clock status (by setting its parameter in the worst possible way).
All devices automatically run the BMCA in each cycle (generally every few seconds). This ensures that the system can respond to changes in topology and always selects the best Grandmaster Clock.

Infrastructure

If more than two directly connected PTP clocks are used, FastEthernet switches have to be used for 100 Mbit. Since the synchronization mechanism takes into account the signal run times for compensation of network delays, irregular latency periods along the signal route have a negative effect on the synchronization precision.

Normal switches based on the store and forward concept are therefore not very suitable. The synchronization precision of special IEEE1588 switches with "boundary clocks" depends on the protocol.

PTPv1

The boundary clock switches appear as Slave Clocks relative to the Grandmaster Clock, although at their outgoing ports they appear as Grandmaster Clock relative to the connected slaves. The switches insert their own send time into the telegram and therefore act as "transparent clocks".

PTPv2

PTPv2 has a further clock type in addition to boundary clocks, the transparent clock. Transparent clock switches insert their own cycle time into the telegram. (Cycle times are added up in a CorrectionField). Transparent clocks are invisible for other PTP clocks.

PTPv1 vs. PTPv2

PTP modes

1. “SlaveOnly”:
The terminal is permanently configured as synchronization slave through lower settings and cannot become grandmaster.
The BMCA is run cyclically to determine the best available synchronization source in the network.

2. “Grandmaster”:
The terminal is configured as grandmaster through high settings and is available as synchronization source for other clocks in the network. The BMCA is also run in this mode, although it is only used to check whether another grandmaster with higher quality is available. If this is the case, terminal switches to passive mode.

3. “Best Master Clock”:
The terminal can act as master clock or slave clock.
The BMCA is run cyclically to determine the best available clock.
If no better clock is found, the terminal becomes grandmaster.