Awareness | How PTPv1 and PTPv2 grandmaster election works

Find out how grandmaster clock election works in PTPv1/PTPv2 and how they are different.

Updated at July 30th, 2024

Information


PTPv2

Let's start with PTPv2 first as Q-SYS follows the AES67 standard which utilizes PTPv2 for time synchronization. 

PTPv2 (IEEE 1588-2008) utilizes a hierarchical selection algorithm known as the Best Master Clock Algorithm (BMCA) to determine the best PTPv2 clock within a network. Devices capable of acting as a PTPv2 grandmaster, such as Q-SYS cores, external grandmaster clocks, certain Cisco switches, and AES67-enabled Dante devices, employ BMCA based on the following properties, in the specified order:

  1. Priority 1 – the user can assign a specific static-designed priority to each clock, preemptively defining a priority among them. Smaller numeric values indicate higher priority.
  2. Class – each clock is a member of a given class, and each class gets its own priority.
  3. Accuracy – precision between clock and UTC, in nanoseconds (ns)
  4. Variance – variability of the clock
  5. Priority 2 – final-defined priority, defining backup order in case the other criteria were not sufficient. Smaller numeric values indicate higher priority.
  6. Unique identifier – MAC address-based selection is used as a tiebreaker when all other properties are equal.

Q-SYS Designer Software allows modification of Priority 1 and Priority 2 values to adjust the grandmaster of the PTP clock domain, so we primarily focus on these two values when it comes to the PTP grandmaster clock election.

Here is a scenario: There is a Core-110f (core1) on the network performing PTPv2, and this is the only device on the network utilizing PTPv2. Since it is the only device on the network, it will be elected as a PTPv2 leader, and there is no doubt about it.

The PTPv2 grandmaster will periodically send out a PTPv2 Announce Message (Q-SYS core sends this out every 2 seconds), and the grandmaster will also send out Sync Messages (Q-SYS core sends this out every 0.125 seconds) to the network.

Let's introduce another Core-110f (core2) to this network participating in the PTPv2 domain with a lower Priority 1 value (higher priority). In theory, the newly added Core-110f (core2) will be elected as the grandmaster.

This is correct. Core2 will eventually get elected as the grandmaster clock. In this article, we will focus on this grandmaster election process.

When core2 is added to the network, both cores will advertise themselves as the leaders of the PTPv2 domain, potentially causing clock drift events if there are clock followers on the network. However, there is no need to worry about it. Both cores will evaluate the other core's PTP properties to decide whether they should continue to be the grandmaster or stop sending out PTP Announce Messages and Sync Messages.

So, how do cores evaluate the other core's PTP properties?

The answer lies in the PTP Announce Message. The PTP Announce Message includes the PTP properties, and here is a sample PTP Announce Message.

In the scenario above, after core1 finishes comparing the PTP properties, it will become a clock follower and no longer send out Announce Messages and Sync Messages.

 
 

PTPv1

PTPv1 is an older PTP protocol released in 2002. Although Q-SYS utilizes PTPv2, understanding how PTPv1 works is important, as Audinate/Dante uses PTPv1.

It's also crucial to note that if there's a Software Dante Receiver/Transmitter in the design, the Q-SYS core will participate in the PTPv1 domain as well.

While we've learned that in PTPv2, PTP clocks compare properties by checking the PTP Announce Message, in PTPv1, there's no such thing as a PTP Announce Message, as it was introduced in PTPv2.

So, how do cores evaluate each other's PTP properties in PTPv1?

The answer lies in the PTPv1 Sync Message, and here's a sample:

This packet includes a flag named PTP_EXT_SYNC and two fields named grandmasterPreferred and grandmasterClockStratum

The PTP_EXT_SYNC field indicates whether the device derives its clock from an external word clock from its host equipment to tune its onboard VCXO.

The grandmasterPreferred value indicates whether the device generating the PTPv1 Sync Message is one of the preferred PTPv1 grandmasters on the network. A value of 1 signifies that it is one of the preferred PTPv1 clocks on the network, whereas a value of 0 indicates that it is not one of the preferred PTPv1 clocks on the network.

The grandmasterClockStratum value in the PTPv1 Sync Message denotes the PTPv1 priority within the network. A lower value suggests a higher likelihood of the device being elected as a PTPv1 grandmaster. The grandmasterClockStratum value actually derives from the localClockStratum value. They are the same if the device itself is a grandmaster clock instead of a boundary clock. For example, let's suppose a Q-SYS 110f core named core2 has both QLAN and Software Dante components in the design, is clocking to another PTPv2 grandmaster on LAN A (core1), and is acting as a PTPv1 grandmaster on LAN B. 

In the diagram above, core2 is functioning as a boundary clock and has different grandmasterClockStratum value and localClockStratum value. It will have its own localClockStratum value derived from its user-configured PTP priority values, while the grandmasterClockStratum value is derived from its PTPv2 master's localClockStratum value, which is core1.

I believe we now have a good understanding of the three most important values in the PTPv1 grandmaster election process. Next, we will dive into how the election occurs.

In PTPv1, devices always first consider the PTP_EXT_SYNC flag. If a PTPv1 clock has this flag set to True, the device will become the PTPv1 clock leader.

If there is more than one PTPv1 clock that is clocking to an external word clock, or if there are no clocks syncing to an external word clock, the devices will then consider the grandmasterPreferred value.  If one or more preferred PTPv1 clocks exist on the network, non-preferred PTPv1 clocks will not participate in the clock election, regardless of their lower grandmasterClockStratum values. Only among preferred PTPv1 clocks will the election proceed by comparing the grandmasterClockStratum values.

How to configure a Dante device as a preferred clock?

Open Dante Controller > Clock Status and check the Preferred Leader option.

 

Q-SYS Core as a preferred clock

Q-SYS cores cannot be selected as a Preferred Leader in Dante Controller. If the PTP Priority 1 value of a Q-SYS core is less than or equal to 127, it will automatically designate itself as a Preferred Leader.

 

In conclusion, unlike PTPv2, PTPv1 doesn't have an Announce Message and uses the PTP_EXT_SYNC flag, grandmasterPreferred value, and the grandmasterClockStratum value in the Sync Message to announce its eligibility to become a PTP grandmaster and its clock priority.

PTPv1 (IEEE 1588-2002) uses similar properties as PTPv2 listed at the beginning of this article, so lowering the Priority 1 and Priority 2 values in Q-SYS Designer Software will lower the localClockStratum value.

The lower the grandmasterClockStratum value, the higher the chance the device will get elected as a PTPv1 grandmaster.

 
 

Please Create a Case with Q-SYS Support if you encounter any clocking issues with our products.