IEEE 1588 / Precision Time Protocol
Enable Javascript to display Table of Contents.
Overview
The Precision Time Protocol (PTP) is used to synchronize the time of devices in a (mostly)
local network. In contrast to the Network Time Protocol (NTP), which works with an accuracy of about 1-50ms, the Precision Time Protocol allows a synchronization up to 10-100ns with transparent clocks (and hardware timestamps) or 1us with less than 6 PTP-unaware switches/routers.
The high precision of the PTP is realized with tree techniques:
- hardware timestamps to get accurate timestamps when the packet has arrived at the device,
- measuring peer-delays for being independent of the network path and
- having transparent clocks to eliminate pass-though times (in & out queues) in network hardware (router/switches).
Since the PTP requires specialized hardware (capable switches/routers and network cards with timestamp support) it's mostly performed in LANs only.
Master Determination
In PTP, a master clock sends multicast SYNC messages in fix intervals to synchronize all connected devices. A regular slave (ordinary clock) must be able to become a master, when either
- there is no other master (e.g. on startup or malfunction)
- or the master is of worse quality than itself (e.g. if the master looses it's GPS source)
For this reason, the master send an announce message with its capabilities in a fix interval. If either no announce message is received for a given timeout, or the slave's own capabilities are better than those of the current master, the slave will take over and becomes a master.
Software- vs Hardware-Timestamps
PTP can be implemented in software, so that the receive-timestamp is generated when the PTP packet has passed the input queue and the IP stack. Both - the queues and the IP stack - can generate a jitter which worsens the accuracy. The same applies when the packet is sent - in this case the timestamp is generated without the knowledge of the exact time when the packet will be sent.
Image: Using software (left) or hardware timestamps
For more precision, the software can acquire the exact time when a packet arrives or is being sent. This must be supported by the network hardware (NIC). In this case, the jitter of the input/output queues and the software stack has no impact on the accuracy.
Delay Measurement Algorithms
In PTP there are two ways to measure the network delay:
In PTPv1 (IEEE 1588-2002) the round-trip-time between the master and the slave is measured - this is called End-to-End measurement. With the assumption that the transfer times (to and from the master) are symmetric, the round-trip-time is simply divided by 2.
With PTPv2 (from IEEE 1588-2008) a new method was introduced: The Peer-to-Peer measurement measures only the delay to the next PTP device (e.g. a switch or a boundary clock). When the SYNC messages passes a PTP device (e.g. a switch) the peer delay is written to the SYNC message. So the timestamp arrives correctly, independent which network path it took.
Source: mainbergglobal.com
Transparent Clocks
Next to having different network paths for the SYNC message and the round-trip-time measurement packets, the queues inside of devices on the track (e.g. switches or routers) have a big impact on the accuracy of PTP. In PTPv2 (from IEEE 1588-2008) transparent clocks were introduced. They take a timestamp when the packet arrives at their network card and a second just before sending it, and add the difference to the passing SYNC packet. Thus independent of a processing time of 0.1ms or 3ms - the SYNC message arrives always with the correct value at the save.
Source: meinbergglobal.com
Additional Information