How does the BMCA work?
When implementing a brand-new precision timing protocol (PTP) network, you will come across the term BMCA or "Best Master Clock Algorithm" (sometimes just BMC).
The BMCA is an algorithm to help choose which clock to use as the source of timing on your network. Imagine you have one master clock on your network providing time for the entire network. What happens when you lose the GPS/GNSS signal and the clock goes offline? With a single clock, the timing network moves to a holdover state for a limited time after which time sync will be lost.
A redundant master clock on your network means that rather than losing time, in a fault the redundant master clock takes over.
This is where the BMCA comes in. The BMCA decides which of at least two clocks should act as the master. Each clock will send a message to the network to detect other clocks, and then performs a data set comparison. This compares data strings from each device and determines which clock is best to maintain the timing network.
First, you can configure a manual clock priority order so that if one clock is preferred over another (possibly due to physical proximity to the network) that clock will be set as the grandmaster by default. If the user configures both clocks to have the same priority they will then compare classes, this defines the role of the devices in use and whether it is being used as a primary reference time source or something else. If the two clocks share a class, the BMCA will then use time source accuracy. If the accuracy is shared, then the clock variance is used, and if the variance is shared then the BMCA looks to see if the clock is acting as a boundary clock or ordinary clock. Lastly, the BMCA will compare another configurable priority order. If none of the above methods of determining the best master, then the port number and MAC Address of the clock will be used instead.
- Priority 1
- Time Source
- Boundary or Ordinary
- Priority 2
- MAC Address
Once the Best Master Clock is chosen, it is then used as the primary time source. As the clock syncs the network, it also periodically sends out announce messages with the above data string included. The time between these messages can be configured, but is normally set to a couple of seconds. If a clock loses signal or quality, another clock on the network will notice this in the announce message and then take over. This handover can take a few seconds depending on configuration.
For more on PTP, see here for info on the differences and uses of 1-step vs 2-step PTP