Everything You Have To Know About PTP or Precision Time Protocol?
May 13, 2022

Introduction

Several time synchronization mechanisms can be used in a network. The most common standards are Network Time Protocol (NTP) and Precision Time Protocol (PTP). NTP, which is the older, well-known protocol, is currently in its fourth version.
NTP was primarily developed to achieve accuracy in the submillisecond range and is widely implemented for network timekeeping. Because NTP is based on software timestamping [It’ll be explained later in this article], it can be less accurate for certain industrial applications that require high levels of synchronization.

PTP is more accurate than NTP because it uses hardware timestamping. It also accounts for device latency while synchronizing time. NTP synchronizes clocks with millisecond accuracy

What is PTP?

Precision Time Protocol (PTP) is a network-based time synchronization standard that is designed for distributing precise time and frequency from a clock source over packet-based networks. PTP enables switches and routers to deliver synchronization with a higher level of accuracy than NTP. It is suitable for today’s cloud networks and data center infrastructures.

PTP is capable of synchronizing multiple clocks to better than 100 nanoseconds on a network specifically designed for IEEE-1588

PTP Clock Types

The types of clocks available are as follows:

  • Grand Master Clock (GMC): the reference time source derived from an accurate clock such as a GNSS driven clock (i.e. GPS, GLONASS, GALILEO)
  • Boundary Clock (BC): A network device that acts as slave to its master and as master to its slaves. 
  • Ordinary Clock (OC): A clock that operates either as a Master or a Slave. In the case of a slave, the end point whose clock is been synced (normally a host/server).
  • Master Clock (MC): A clock that operates as a Master and derives its timing capabilities from the clock chain up to the GMC. It typically serves as a port on a BC connected to a host running as a slave.
  • Transparent Clock (TC): A device that calculates the residence time of the PTP event message and updates the correction field (CF) of the event message before forwarding the message. The ports are not in any specific state.

 

PTP device types (Source: Nvidia)

So, GM usually has a precise time source, such as a GPS, that functions as the reference clock. Boundary Clock (BC) acts as a secondary clock at the port that connects to the primary and distributes time to all other downstream devices. The secondary port synchronizes the time from the upstream PTP device. Transparent Clock (TC) forwards the PTP message after updating the residence time of a PTP event message.

PTP TimeStamp

The Master clock provides synchronization messages that the Slaves use to correct their local clocks. Precise timestamps are captured at the Master and Slave clocks. These timestamps are used to determine the network latency which is required to synchronize the Slave to the Master. There is a sync message transmitted typically every two seconds from the Master, and a delay request message from the Slave less frequently, about one request per minute. Four timestamps are captured between the Master and Slave clock. The timestamps are required for the Slave offset calculation. The timestamps are commonly referred to as T1, T2, T3, and T4.

PTP Timestamps

Two delay paths must be calculated, the Master to Slave and the Slave to Master.

First, find the Master to Slave difference: The first timestamp is T1.
It is the precise time of the sync message from the Master. This timestamp is sent in the follow-up message since the time of T1 was sampled when the sync message was transmitted on the Ethernet port. The second timestamp is T2. It is the precise time of the sync message as it is received at the Slave.
The Master-Slave difference can be calculated once T1 and T2 are available at the Slave:

Master to Slave difference = T2 – T1

Second, find the Slave to Master difference: The third timestamp is T3.
It is the precise time of the delay request message from the Slave. The fourth timestamp is T4.
It is the precise time of the delay request message when received at the Master. The Slave to Master difference can be calculated once T3 and T4 are available at the Slave.

Slave to Master difference = T4 – T3

The one-way delay can be calculated once the Master to Slave and Slave to Master difference is available at the Slave:

One-way delay = (Master to Slave difference + Slave to Master difference) / 2

The offset is used to correct the Slave clock:

Offset = Master to Slave difference – One-way delay or

Offset = ((T2 – T1) – (T4 – T3)) / 2

Hardware Timestamping Vs. Software Timestamping

The IEEE-1588 protocol does not define how to implement PTP into a Master or Slave. Two methods have been adopted for PTP over Ethernet: PTP software timestamps and PTP hardware timestamps. The following paragraphs describe these methods.

Grandmaster with Hardware Timestamping

While locked to GPS, the Grandmaster clock can provide precise nanosecond timestamp resolution and accuracy better than 30 nanoseconds referenced to GPS. A Grandmaster clock incorporates a local reference oscillator that is disciplined to GPS. This oscillator is the reference clock used with dedicated hardware for the precise timestamp of the incoming delay request and outgoing sync packets. Using an oscilloscope, the 1PPS (1 pulse-per-second) output from the Grandmaster can be compared to a 1PPS output from a hardware slave to measure synchronization accuracy. The dedicated hardware approach is unaffected by the operating system or network traffic latency.

Slave with Hardware Timestamping

Hardware timestamps with a PTP software daemon provide precise nanosecond timestamp resolution with dedicated hardware typically in a PCIe form factor. The hardware slave solution has many advantages over the software slave such as an improved oscillator, a 1PPS output for measurements compared to the master, and dedicated hardware that is unaffected by the operating system latency. Synchronization of better than 100 nanoseconds is achievable using either a crossover cable or a 1588 Ethernet switch.

PTP Slave with Hardware Timestamping

Slave with Software Timestamping

Software-only implementations utilize existing computer hardware and a PTP daemon. The slave software solution must compensate for the internal oscillator on the computer motherboard using software timestamping. The local oscillator on the motherboard is typical of poor quality and the software timestamping is affected by the operating system latency. Measuring the software slave to the master is limited to log file statistics, as there is no 1PPS output to compare with the master. Synchronization of 10 microseconds is achievable with a software slave to a master with typical results between 10 to 100 microseconds.

PTP Slave with Software Timestamping

PTP Messages

The protocol defines the event and general messages. Event messages are timed messages in which an accurate timestamp is generated at both transmit and receive time. General messages do not require accurate timestamps.

Event messages

  • Sync: Sent by the primary to distribute the time of day.
  • Delay_Req: Sent by the secondary to the primary for end-to-end delay measurement (request-response delay mechanism).
  • Pdelay_Req: Sent by link node A for peer-to-peer delay measurement.
  • Pdelay_Resp: Sent by link node B for peer-to-peer delay measurement.

General messages

  • Follow_Up: Sent by two-step clock primary following the sync message.
  • Delay_Resp: Sent by primary for end-to-end delay measurement.
  • Pdelay_Resp_FollowUp: Sent by link node B for peer-to-peer delay measurement.
  • Announce: Sent by the primary to establish a synchronization hierarchy. The Best Primary Clock Algorithm decides the best primary clock based on the clock properties in the announce message.
  • Management: Sent by the management node to the clock for updating and querying the PTP datasets maintained by the clock.
  • Signaling: Sent by clock A to clock B for the purpose such as the unicast negotiation.

Conclusion

The clocks managed by PTP follow a master-slave hierarchy. The slaves are synchronized to their masters. The hierarchy is updated by the best master clock (BMC) algorithm, which runs on every clock. The clock with only one port can be either master or slave. Such a clock is called an ordinary clock (OC). A clock with multiple ports can be master on one port and slave on another. Such a clock is called a boundary clock (BC). The top-level master is called the grandmaster clock. The grandmaster clock can be synchronized with a Global Positioning System (GPS). This way disparate networks can be synchronized with a high degree of accuracy.

The hardware support is the main advantage of PTP. It is supported by various network switches and network interface controllers (NIC). While it is possible to use non-PTP-enabled hardware within the network, having network components between all PTP clocks PTP hardware-enabled achieves the best possible accuracy.

References

  • Dell Technologies.
  • Nvidia
  • SUSE.
  • EndRun Technologies.

Support & Share