How PTP works

In a computer network, multiple nodes are interconnected by edges (connections) between these devices. By employing the Best Master Clock Algorithm (BMCA), a PTP network determines the hierarchy of clocks in the network. It removes redundant connections and organizes the entire network into a hierarchical structure resembling "a tree." This simplifies time synchronization, as circular configurations are avoided. Within such a network, a single device is designated as the grandmaster (GM), responsible for controlling precise time. Other devices receive time messages from the GM. Through the exchange of several messages among the clocks in all devices, the entire network can achieve clock accuracy in the sub-microsecond range.
  • BMC Algorithm: using some mechanisms to determine which clock is more suitable to be a master. You can see more details here

Clock types

In a PTP network, clocks are categorized into several types with varying priorities and hierarchies to ensure effective and efficient time synchronization.

Ordinary Clock(OC)

The most common types of clocks in a PTP network include Ordinary Clocks (OC), which can be further divided into four categories: masters, slaves, only-slaves, and the grandmaster. These classifications are not static, as a clock's role may change depending on its interconnections with other clocks. In a network comprised of two nodes connected by a single edge, the master clock serves as the time reference, while the slave clock receives time messages from its master. A slave-only clock continuously functions as a slave clock, being as a leaf of a tree. Conversely, the grandmaster represents the entire PTP network and is always a master, responsible for providing the time reference for the entire network.

Grandmaster(GM)

As explained above, there is ONLY one Grand Master (GM) in a single network, serving as the benchmark for time synchronization and providing standard time information to other clocks across the network. Unlike other types of clocks in the network, the GM typically receives time messages from an external time reference. However, in the case of cyberattacks or other emergencies, grandmasters must be capable of autonomously maintaining time for a long period and with great accuracy.
A rooted tree demo of a network

Transparent Clock(TC)

To enhance accuracy in time synchronization, PTP introduces the use of Transparent Clocks (TC). TCs play a crucial role in preventing congestion in the network by adjusting PTP time messages to eliminate packet processing delays, earning them the moniker "Transparent." TCs are capable of compensating for delays during message exchange between clocks, thereby ensuring precise time alignment.

Boundary Clock(BC)

The Boundary Clock (BC) is another type of clock aimed at achieving greater accuracy in PTP. While a master clock is responsible for providing time reference for too many slave clocks, latency may increase and time accuracy may decrease. BC addresses this issue by incorporating a built-in PTP master clock. As BCs can only communicate with a limited number of slaves, adding several BCs between masters and their slaves ensures that PTP masters are not over solicited, thereby enhancing time accuracy.

Time exchanging process

Above, we mentioned that devices in a PTP network can synchronize each other's clocks through exchanging time messages in the form of packets. In this section, we will explain the method used for time synchronization. Firstly, we need to understand the terms "Offset" and "Delay" in the synchronization process. "Offset" refers to the time difference between the master and slave clock, while "Delay" represents the time needed to transfer packets from the master to the slave. In the time exchange process, the master clock initially sends a sync message and records the actual time this message is sent ( T_1 ). Then, the master clock sends out a follow_up message to convey . This procedure is required because sync message alone cannot accurately record the time when it is sent. The slave clock then records both (from the follow_up message) and the time it receives the sync message ( T_2 ). At this point, the slave clock becomes aware of the time difference between itself and its master. However, it cannot adjust its time yet because it doesn't know the duration it takes for a message to travel from the master to the slave clock. Upon receiving the follow-up message from the master, the slave subsequently sends a delay_request message and records the time as \,T_3 . The master clock immideately replies with a delay_response message, including the value \,T_4 . With these four timestamps, the slave clock can calculate the Offset and Delay, enabling it to synchronize the time accurately.
Press the play button to see how PTP works!
Formula: Offset = \frac{(T_2-T_1)-(T_4-T_3)} {2}
Formula: Delay = \frac{(T_2-T_1)+(T_4-T_3)} {2}

O-RAN & PTP © 2024