• Home
  • Resources
  • Blog
  • Best Master Clock Algorithm – A critical Component of PTP
Clocks properties

There are numerous protocols for synchronising clocks within a network infrastructure. The most known are NTP (network Time Protocol) and SNTP (Simple NTP), but when the utmost precision is required, the PTP (Precision Time Protocol) is chosen.

PTP was introduced in 2002 (in the IEEE 1588 standard) and has undergone numerous evolutions since (the latest version of the standard dates from 2019).

One of the most important algorithmic components of PTP is the BMCA (Best Master Clock Algorithm). BMCA allows you to establish a hierarchy of clocks (also called timing hierarchy or timing tree) and selects, within this hierarchy, the best master clock amongst all other clocks in the network. This master clock will then provide the time reference for all devices in the network.

Clocks properties

BMCA is a distributed leader selection algorithm. It aims to establish a Grandmaster Clock, that is, a specific clock that will serve as the reference for all others in the network.

In the following, we describe the steps of the selection algorithm. Each clock in a PTP network can be described using a few items: clock class, clock accuracy, clock stability, and priority level. These properties are to evaluate the eligibility of a clock to be the best master clock.

Each clock is defined by:

  • A priority level set by the user, which allows manual overriding of the algorithm to fix the Grandmaster Clock. A low priority level indicates that a clock should not be elected as master clock, even if its other properties are good.
  • clock's class This is a numerical criterion that characterises the level of quality and precision of the clock. For instance, a server directly connected to a reference clock (atomic clock or GPS) would be in class 6. The smaller the class value, the higher the priority in selecting the reference clock. Possible values range from 6 to 255, with 248 being the default value.
  • The clock's accuracy (in nanoseconds).
  • The clock's stability This indicator characterises the ability to maintain precise time over a given period.
  • A unique identifier used to distinguish between clocks with otherwise identical characteristics. It would typically be an 8 bytes number (in IEEE EUI64 format).

The clock that ranks first based on the properties is selected as the Best Master Clock. All other clocks become slave clocks and synchronise their time to it.

Selection process

The selection is done as follows. First, each clock broadcasts its properties to the other clocks in the network. The clocks then compare their properties against one another. There is an order in this comparison. Priority levels are compared first. If there is a tie, they move on to comparing clock class, accuracy, stability, and finally, the unique identifier if all other properties are equal. Note that using a high priority level for a given clock is something that must be done with extreme caution.

The clock that “wins” the selection process announces itself as the Best Master Clock. This clock becomes the reference time for the network. All devices in the network adjust their time to match the Best Master Clock time. This synchronisation ensures that all devices in the network are operating on the same precise time.

When is the BMCA Active?

The selection algorithm is active at the network's startup. However, this is not the only time the algorithm is used. It is continuously checked for changes in the network, such as the addition of new clocks, changes in clock properties, or loss of the current Master Clock. If any of these events occur, the BMCA will re-run the selection process to ensure that the best possible clock is always serving as the Master Clock. This continuous evaluation and adjustment mechanism is crucial for maintaining the highest level of time synchronisation and precision across the network.

BMCA Effectiveness and network topology

The effectiveness of BMCA is influenced by the underlying network topology. Different topologies introduce varying levels of delays in the networking system. Topologies with multiple paths can help reduce latency and improve time precision. For example, topologies with redundancy, such as mesh, provide greater fault tolerance. BMCA can then quickly re-elect a new master clock in case of failures, maintaining synchronisation. As networks grow, the topology must support scalable BMCA operations. Mesh and tree topologies offer better scalability compared to star topologies.

Additionally, jitter (variability in time delay as each message travels through devices in the network) can affect the precision of time synchronisation. To robustify the selection and synchronisation processes, some devices can take the role of boundary or transparent clock. A boundary clock is a device that allows for the synchronisation of multiple devices while saving a lot of the messaging between slaves. A transparent clock is a clock that removes message jitter by using a timer on message processing.

Alternative BMCA

The canonical BMCA algorithm from the IEEE 1588 standard can be adapted to consider different characteristics for selecting the reference clock. For example, one can create a BMCA that favours long-term stability over immediate precision or a variant that offers better fault tolerance for networks prone to frequent failures. This approach has been implemented in the G.8275.1 standard, which allows, in the context of mobile networks, the presence of multiple Grandmaster Clocks simultaneously.

Share the article