Language and Page Formatting Options
Chapter 23. Configuring PTP Using ptp4l
23.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,
PTPis capable of sub-microsecond accuracy, which is far better than is normally obtainable with
PTPsupport is divided between the kernel and user space. The kernel in Red Hat Enterprise Linux 6 now includes support for
PTPclocks, which are provided by network drivers. The actual implementation of the protocol is known as linuxptp, a
PTPv2implementation 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
PTPboundary clock and ordinary clock. With hardware time stamping, it is used to synchronize the
PTPhardware 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
PTPhardware clock on the network interface card (NIC).
23.1.1. Understanding PTP
The clocks synchronized by
PTPare 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.
Figure 23.1. PTP grandmaster, boundary, and slave Clocks
23.1.2. Advantages of PTP
One of the main advantages that
PTPhas over the Network Time Protocol (NTP) is hardware support present in various network interface controllers (NIC) and network switches. This specialized hardware allows
PTPto 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
PTPhardware enabled. Time synchronization in larger networks where not all of the networking hardware supports
PTPmight be better suited for
PTPsupport, the NIC has its own on-board clock, which is used to time stamp the received and transmitted
PTPmessages. It is this on-board clock that is synchronized to the
PTPmaster, and the computer's system clock is synchronized to the
PTPhardware clock on the NIC. With software
PTPsupport, the system clock is used to time stamp the
PTPmessages and it is synchronized to the
PTPmaster directly. Hardware
PTPsupport provides better accuracy since the NIC can time stamp the
PTPpackets at the exact moment they are sent and received while software
PTPsupport requires additional processing of the
PTPpackets by the operating system.