Product SiteDocumentation Site

Chapter 15. Configuring PTP Using ptp4l

15.1. Introduction to PTP
15.1.1. Understanding PTP
15.1.2. Advantages of PTP
15.2. Using PTP
15.2.1. Checking for Driver and Hardware Support
15.2.2. Installing PTP
15.2.3. Starting ptp4l
15.3. Specifying a Configuration File
15.4. Using the PTP Management Client
15.5. Synchronizing the Clocks
15.6. Verifying Time Synchronization
15.7. Serving PTP Time with NTP
15.8. Serving NTP Time with PTP
15.9. Synchronize to PTP or NTP Time Using timemaster
15.9.1. Starting timemaster as a Service
15.9.2. Understanding the timemaster Configuration File
15.9.3. Configuring timemaster Options
15.10. Improving Accuracy
15.11. Additional Resources
15.11.1. Installed Documentation
15.11.2. Useful Websites

15.1. Introduction to PTP

The Precision Time Protocol (PTP) is a protocol used to synchronize clocks in a network. When used in conjunction with hardware support, PTP is capable of sub-microsecond accuracy, which is far better than is normally obtainable with NTP. PTP support is divided between the kernel and user space. The kernel in Fedora includes support for PTP clocks, which are provided by network drivers. The actual implementation of the protocol is known as linuxptp, a PTPv2 implementation according to the IEEE standard 1588 for Linux.
The linuxptp package includes the ptp4l and phc2sys programs for clock synchronization. The ptp4l program implements the PTP boundary clock and ordinary clock. With hardware time stamping, it is used to synchronize the PTP hardware clock to the master clock, and with software time stamping it synchronizes the system clock to the master clock. The phc2sys program is needed only with hardware time stamping, for synchronizing the system clock to the PTP hardware clock on the network interface card (NIC).

15.1.1. Understanding PTP

The clocks synchronized by PTP are organized in a master-slave hierarchy. The slaves are synchronized to their masters which may be slaves to their own masters. The hierarchy is created and updated automatically by the best master clock (BMC) algorithm, which runs on every clock. When a clock has only one port, it can be 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, which can be synchronized by using a Global Positioning System (GPS) time source. By using a GPS-based time source, disparate networks can be synchronized with a high-degree of accuracy.
PTP grandmaster, boundary, and slave Clocks
An illustration showing PTP grandmaster, boundary, and slave clocks
Figure 15.1. PTP grandmaster, boundary, and slave Clocks

15.1.2. Advantages of PTP

One of the main advantages that PTP has over the Network Time Protocol (NTP) is hardware support present in various network interface controllers (NIC) and network switches. This specialized hardware allows PTP to account for delays in message transfer, and greatly improves the accuracy of time synchronization. While it is possible to use non-PTP enabled hardware components within the network, this will often cause an increase in jitter or introduce an asymmetry in the delay resulting in synchronization inaccuracies, which add up with multiple non-PTP aware components used in the communication path. To achieve the best possible accuracy, it is recommended that all networking components between PTP clocks are PTP hardware enabled. Time synchronization in larger networks where not all of the networking hardware supports PTP might be better suited for NTP.
With hardware PTP support, the NIC has its own on-board clock, which is used to time stamp the received and transmitted PTP messages. It is this on-board clock that is synchronized to the PTP master, and the computer's system clock is synchronized to the PTP hardware clock on the NIC. With software PTP support, the system clock is used to time stamp the PTP messages and it is synchronized to the PTP master directly. Hardware PTP support provides better accuracy since the NIC can time stamp the PTP packets at the exact moment they are sent and received while software PTP support requires additional processing of the PTP packets by the operating system.