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:
- No PTP support in the switch/router: This is likely to result in extremely reduced synchronization precision [ms range], and the application of such switches should therefore be avoided. Load-dependent instability in the control characteristics may occur.
- Software-based PTP support in the switch: This is likely to result in significantly reduced synchronization precision [ms range], and we would therefore advise against using this type of switch.
- Hardware-based PTP support in the switch: The application of this type of switch is recommended.
The architectural differences between the two stages are as follows:
- IEEE-1588-2002 V1
V1 was developed in principle for testing & measurement and industrial automation. The Multicast protocol is conceived for LAN use and achieves better accuracy than NTP.
From a technical point of view higher-priced boundary clocks have to be used with V1 in order to achieve optimum results. The use of V1 is less widespread in practice. - IEEE-1588-2008 V2
V2 is an improvement on V1. It is only possible to use either V1 or V2 in a network. V2 was extended by many features, for which reason it has been well accepted by the market. The selection of devices on the market is greater than for V1. From a technical point of view simpler switches with the clock type “Transparent clock” can be used with V2.
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.
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:
- _DFLT: 224.0.1.129
- _ALT1: 224.0.1.130
- _ALT2: 224.0.1.131
- _ALT3: 224.0.1.132
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
- PTPv1:
- PTPv1 according to IEEE 1588-2002
- PTPv1 via UDP (ISO/OSI layer 3, Ethertype: UDP x0800)
- shortest Sync (synchronization) interval: 1 second
- compensation of network delays (assumption: the path and return path are time-symmetric) - PTPv2:
- PTPv2 according to IEEE 1588-2008
- PTPv2 via UDP (ISO/OSI layer 3, Ethertype: UDP x0800) or via Ethernet (layer 2, Ethertype x88F7)
- shorter Sync intervals: e.g. 500 ms
- CorrectionField: each switch component can use this field for adding up its cycle time for analysis by the slaves
- compensation of network delays (assumption: path and return patch time-asymmetric --> more realistic)
- “transparent” switches, “transparent clocks”: insert their own send time into the telegram when forwarding Sync telegrams
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.