Skip to main content

PTP Configuration on Asterfusion Enterprise SONiC Distribution Switch

1 Overview of PTP

The Precision Time Protocol (PTP) is used to synchronize clocks across network devices with sub-microsecond accuracy. Unlike NTP, which relies on software timestamps, PTP uses hardware timestamping to achieve much higher precision, making it widely adopted in applications such as broadcasting, financial trading, industrial automation, and 5G transport networks.
In a PTP system, devices can be either PTP-aware (Ordinary Clocks, Boundary Clocks, and Transparent Clocks) or non-PTP network elements such as switches and routers.
PTP works as a distributed protocol where clocks exchange synchronization messages and form a master-slave hierarchy. At the top of this hierarchy is the Grandmaster Clock, which provides the reference time for the entire domain. Other clocks adjust their local time based on synchronization messages from their upstream master. All synchronization takes place within a logical scope called a PTP domain.

2 Clock Type

Nodes within a PTP domain are referred to as clock nodes, and the interfaces on these nodes that run the PTP protocol are called PTP interfaces. The PTP protocol defines the following three basic types of clock nodes:

  • OC (Ordinary Clock)

An Ordinary Clock has only one PTP interface participating in time synchronization within a PTP domain. This interface typically acts as a Slave, synchronizing time from an upstream clock node. When the OC acts as a time source, the same interface can also function as a Master, distributing time to downstream clock nodes.

  • BC (Boundary Clock)

A Boundary Clock has multiple PTP interfaces participating in time synchronization within the same PTP domain. One interface acts as a Slave, synchronizing time from an upstream clock node. The remaining interfaces act as Master interfaces, distributing the synchronized time to downstream clock nodes. When serving as a time source, a BC can distribute time simultaneously through multiple Master interfaces.

  • TC (Transparent Clock)

A Transparent Clock also has multiple PTP interfaces, but unlike OCs and BCs, it does not synchronize its own time through any interface. Each interface neither acts as a Master nor a Slave; they simply forward PTP messages while correcting for the residence time (the delay introduced by the device itself).

3 PTP Process

The Precision Time Protocol (PTP) synchronization process consists of two main phases:

  • Master-Slave Hierarchy Establishment

Within a PTP domain, all clock nodes are organized in a hierarchical structure. The reference time for the entire domain is provided by the Grandmaster Clock (GM), which represents the highest-level clock in the hierarchy.

Clock nodes exchange Announce messages containing information such as clock priority, clock class, and time accuracy. Based on this information, the nodes collectively elect one clock as the Grandmaster for the domain. Through this process, the master-slave relationships between nodes are established, and the master or slave role of each interface on the nodes is determined.

  • Clock Synchronization

Once the hierarchy is established, synchronization between the master and slave clocks is performed as follows:

    • The master sends a Sync message to the slave and records the send timestamp.
    • The slave receives the Sync message and records the receive timestamp.
    • The slave sends a Delay_Request message to the master and records the send timestamp.
    • The master receives the Delay_Request message and records the receive timestamp.
    • The master sends a Delay_Response message to the slave.
    • The slave calculates the path delay and offsets using all collected timestamps and adjusts its local clock to align with the master clock.
PTP-Process-Diagram

4 Configuring PTP

4.1 Configuring a PTP Domain

Command
Description
ptp instance <domain-id>
Example:
sonic(config)# ptp instance 0
sonic(config-ptp-0)#
Configuring the PTP domain number
ptp profile {smpte-2059-2|g8275.1|g8275.2|1588v2|aes67}
Example:
sonic(config)# ptp instance 0
sonic(config-ptp-0)# ptp profile
1588v2
Specifying a PTP profile
ptp delay-mode {E2E|P2P}
Example:
sonic(config)# ptp instance 0
sonic(config-ptp-0)# ptp delay-mode E2E
Specifying a delay measurement mechanism.
E2E: Specifies the Request_Response mechanism
P2P: Specifies the Peer Delay mechanism
ptp clock-step {one_step|two_step}
Example:
sonic(config)# ptp instance 0
sonic(config-ptp-0)# ptp clock-step two_step
Configuring the mode for carrying timestamps.
    one-step: The Sync message (in the Request_Response or Peer Delay mechanism) and Pdelay_Resp message (in the Peer Delay mechanism) carry their sending timestamps by themselves
    two-step: The Sync message (in the Request_Response or Peer Delay mechanism) and Pdelay_Resp message (in the Peer Delay mechanism) do not carry their sending timestamps by themselves. The subsequent messages carry their sending timestamps.
ptp clock-type {oc|bc|tc|t-gm|t-bc|t-tsc|t-tc|t-bc-p|t-tsc-p}
Example:
sonic(config)# ptp instance 0
sonic(config-ptp-0)# ptp clock-step oc
[Optional]
Configuring clock node type.
- When the PTP profile is set to SMPTE-2059-2/1588v2/ase67 the clock type can be configured as: oc/bc/tc
- When the PTP profile is set to g8275.1 the clock type can be configured as: t-gm/t-bc/t-tsc/t-tc
- When the PTP profile is set to g8275.2 the clock type can be configured as: t-gm/t-bc-p/t-tsc-p
ptp clock-source local {accuracy|class|priority1|priority2} <value>
Example:
sonic(config)# ptp instance 0
sonic(config-ptp-0)# ptp clock-source local priority1 10
[Optional]
Configuring the priority value to use when advertising this clock. This value overrides the default criteria (clock quality, clock class, and so on) for best master clock selection. Lower values take precedence. The range is from 0-255.
Accuracy: Indicates the precision of the clock, the default value is 254
- Class: The clock’s class or level, the default value is 248
- Priority1/ Priority2: Used to determine election precedence when clocks have the same accuracy and class, the default value is 128
ptp clock-id <xxxxx.xxxx.xxxxxx>
Example:
sonic(config)# ptp instance 0
sonic(config-ptp-0)# ptp clock-id 00001.0000.000001
[Optional]
Setting clock source parameters, the default clock ID of a GM clock is 00000.0000.000000

4.2 Configuring PTP Message

Command
Description
ptp transport-mode ethernet
ptp transport-mode {udpv4|udpv6} {unicast|multicast|mixed}
Example:
sonic(config)# ptp instance 0
sonic(config-ptp-0)# ptp transport-mode udpv4 unicast
sonic(config-ptp-0)# ptp source 10.1.1.1
Specifying the UDP transport protocol or ethernet for PTP messages.
If transport-mode is configured as the UDP protocol, you must configure a source IP address for the messages.
ptp unicast master address <A.B.C.D>
Example:
sonic(config)# interface ethernet 1
sonic(config-if-1)# ptp instance 0
sonic(config-if-ptp-0)# ptp unicast master address 10.1.1.10
[Optional]
Specify the destination IP address for unicast PTP messages transmitted over IPv4 UDP.
ptp source ip <A.B.C.D>
Example:
sonic(config)# interface ethernet 1
sonic(config-if-1)# ptp instance 0
sonic(config-if-ptp-0)# ptp source ip 10.1.1.20
[Optional]
Specifying the source IP address for UDP packets.
This command can be executed either in the PTP domain view or in the PTP interface view. The interface configuration takes precedence over the PTP domain configuration
ptp dscp <value>
Example:
sonic(config)# interface ethernet 1
sonic(config-if-1)# ptp instance 0
sonic(config-if-ptp-0)# ptp dscp 10
[Optional]
Specifying the DSCP priority of PTP packets.
This command can be executed either in the PTP domain view or in the PTP interface view. The interface configuration takes precedence over the PTP domain configuration

4.3 Configuring PTP Ports

Command
Description
ptp enable
Example:
sonic(config)# ptp enable
sonic(config)# interface ethernet 1
sonic(config-if-1)# ptp enable
Enable PTP function.
This command must be executed in both the system view and the interface view.
ptp instance <domain-id>
Example:
sonic(config)# interface ethernet 1
sonic(config-if-1)# ptp instance 0
sonic(config-if-ptp-0)# 
Add the interface to the PTP domain and enter the domain configuration view based on this interface.
ptp mode {master|slave}
Example:
sonic(config)# interface ethernet 1
sonic(config-if-1)# ptp instance 0
sonic(config-if-ptp-0)# ptp mode slave
[Optional]
Configuring the role of a PTP port, by default, the PTP port roles are automatically negotiated based on the BMC algorithm.
ptp delay-req-interval <interval>
Example:
sonic(config)# interface ethernet 1
sonic(config-if-1)# ptp instance 0
sonic(config-if-ptp-0)# ptp delay-req-interval -3
[Optional]
Setting the interval for sending Delay-Resp messages.
ptp pdelay-req-interval <interval>
Example:
sonic(config)# interface ethernet 1
sonic(config-if-1)# ptp instance 0
sonic(config-if-ptp-0)# ptp pdelay-req-interval -3
[Optional]
Setting the interval for sending PDelay-Resp messages.
ptp announce-interval <interval>
ptp announce-receipt-timeout <time>
Example:
sonic(config)# interface ethernet 1
sonic(config-if-1)# ptp instance 0
sonic(config-if-ptp-0)# ptp announce-interval 1
sonic(config-if-ptp-0)# ptp announce-receipt-timeout 3
Setting the interval for sending announce messages and the timeout multiplier for receiving announce messages.

4.4 Configuring PTP SM-TLV

SM-TLV (SMPTE Management TLV) is a set of management information extended by SMPTE for PTP (IEEE 1588v2), used for time synchronization and status monitoring in broadcast media networks.

Command
Description
ptp sm-tlv enable
Example:
sonic(config)# ptp instance 0
sonic(config-ptp-0)# ptp sm-tlv enable
Enable PTP SM-TLV function.
ptp sm-tlv default-frame-rates <numerator> <denominator>
Example:
sonic(config)# ptp instance 0
sonic(config-ptp-0)# ptp sm-tlv default-frame-rates 24 1
Frame Rate = numerator/ denominator.
Common frame rates include 24 fps (film), 25 fps (PAL), and 30 fps (NTSC).
ptp sm-tlv time-address-flags drop-frame
Example:
sonic(config)# ptp instance 0
sonic(config-ptp-0)# ptp sm-tlv time-address-flags drop-frame
Indicates enabling the Drop-frame timecode flag, which ensures that the timecode of NTSC (29.97 fps, etc.) video aligns with real time.
ptp sm-tlv time-address-flags color-frame
Example:
sonic(config)# ptp instance 0
sonic(config-ptp-0)# ptp sm-tlv time-address-flags color-frame
PTP uses SM-TLV to inform downstream devices that the timecode (LTC/VITC or other formats) must comply with the color-frame alignment rule.

4.5 Display PTP information

Command
Description
show ptp clock [domain ID]
View the PTP configuration information and time synchronization status.
show ptp clock sm-tlv <domain ID>
View the PTP sm-tlv configuration. 
show ptp counter [interface ID] [instance ID]
View the transmission and reception statistics of each PTP protocol message for a specified PTP domain or interface.

5 PTP Configuration Example

5.1 Configuring Layer 2 IEEE 1588v2 PTP

5.1.1 Network Topology

PTP-Configuration-Example-Network-Topology

In 5G ORAN (Open Radio Access Network), the fronthaul network requires sub-microsecond time synchronization to ensure strict alignment of RU (Radio Unit), DU (Distributed Unit), and CU (Central Unit) in radio scheduling and waveform processing.
In this scenario, switches typically operate in Layer 2 IEEE 1588v2 Transparent Clock (BC) mode and adopts a two-step time synchronization mechanism to ensure high-precision timing.

5.1.2 Configuration Step

1 Create a VLAN for PTP

sonic# configure
sonic(config)# vlan 10
sonic(config)# interface ethernet 1
sonic(config-if-1) switchport trunk vlan 10
sonic(config)# interface ethernet 25
sonic(config-if-25)# switchport trunk vlan 10

2 Configuring PTP domain

sonic(config)# ptp enable
sonic(config)# ptp instance 0
sonic(config-ptp-0)# ptp profile 1588v2
sonic(config-ptp-0)# ptp clock-type bc
sonic(config-ptp-0)# ptp clock-step two_step
sonic(config-ptp-0)# ptp transport-mode ethernet
sonic(config-ptp-0)# ptp delay-mode p2p
sonic(config-ptp-0)# exit

3 Configuring interface

sonic(config)# interface ethernet 1
sonic(config-if-1)# ptp instance 0
sonic(config-if-ptp-0)# ptp enable
sonic(config)# interface ethernet 25
sonic(config-if-25)# ptp instance 0
sonic(config-if-ptp-0)# ptp enable

Display PTP Configuration information

Use the show ptp clock to verify the time-properties.

sonic# show ptp clock
Domain: 0
Profile: smpte-2059-2
PTP Version: 2.1
Clock Type: BC
Clock Step: two_step
Delay Mode: P2P
Transport Mode: ethernet
Local Clock Identity: 000000.0000.00000
Local Clock Accuracy: 0xFE
Local Clock Class: 248
Local Clock Priority1: 128
Local Clock Priority2: 128
ports: Ethernet1,Ethernet25
Grandmaster Clock Identity: 000000.0000.001549
Grandmaster Clock Accuracy: 0xfe
Grandmaster Clock Class: 248
Grandmaster Clock Priority1: 128
Grandmaster Clock Priority2: 128
Parent Port Identity: 3
Servo State: locked
Offset To Master: -6
Path Delay: 260
Max Steps Removed: 255
Local Time: 85526343602446

5.2 Configuring SMPTE PTP in Multicast Mode

5.2.1 Network Topology

Configuring-SMPTE-PTP-in-Multicast-Mode-Network-Topology

This network supports IP-based transmission of multiple high-definition video, audio, and ancillary data streams, requiring precise audio-video synchronization, low latency, and high timing accuracy. PTP (Precision Time Protocol) provides a unified clock to achieve end-to-end synchronization in accordance with the SMPTE 2110 standard. The network is configured with both primary and backup clock sources, allowing automatic switchover to the backup clock in the event of a primary clock failure, ensuring continuous and stable synchronization.

5.2.1 Configuration Step

As an example, the following configuration illustrates two Spine switches. The Leaf switch configuration follows the same pattern.

Configuring Spine A

1 Specify the PTP Profile

sonic(config)# ptp enable
sonic(config)# ptp instance 0
sonic(config-ptp-0)# ptp profile smpte-2059-2
sonic(config-ptp-0)# ptp clock-type bc
sonic(config-ptp-0)# ptp delay-mode e2e

# Configure the source IP address for multicast PTP transport

sonic(config-ptp-0)# ptp transport-mode udpv4 multicast
sonic(config-ptp-0)# ptp source ip 10.10.1.1/32
sonic(config-ptp-0)# exit

# Modify the PTP priority

sonic(config-ptp-0)# ptp clock-source local priority1 10

2 Enable PTP on interface

sonic(config)# interface ethernet 1
sonic(config-if-1)# ptp instance 0
sonic(config-if-ptp-0)# ptp enable
sonic(config)# interface ethernet 2
sonic(config-if-2)# ptp instance 0
sonic(config-if-ptp-0)# ptp enable
sonic(config)# interface ethernet 3
sonic(config-if-3)# ptp instance 0
sonic(config-if-ptp-0)# ptp enable
sonic(config)# interface ethernet 5
sonic(config-if-5)# ptp instance 0
sonic(config-if-ptp-0)# ptp enable

Configuring Spine B

1 Specify the PTP Profile

sonic(config)# ptp enable
sonic(config)# ptp instance 0
sonic(config-ptp-0)# ptp profile smpte-2059-2
sonic(config-ptp-0)# ptp clock-type bc
sonic(config-ptp-0)# ptp delay-mode e2e

# Configure the source IP address for multicast PTP transport

sonic(config-ptp-0)# ptp transport-mode udpv4 multicast
sonic(config-ptp-0)# ptp source ip 10.10.1.4/32
sonic(config-ptp-0)# exit

# Modify the PTP priority

sonic(config-ptp-0)# ptp clock-source local priority1 20
sonic(config-ptp-0)# exit

2 Enable PTP on the interface

sonic(config)# interface ethernet 1
sonic(config-if-1)# ptp instance 0
sonic(config-if-ptp-0)# ptp enable
sonic(config)# interface ethernet 2
sonic(config-if-2)# ptp instance 0
sonic(config-if-ptp-0)# ptp enable
sonic(config)# interface ethernet 3
sonic(config-if-3)# ptp instance 0
sonic(config-if-ptp-0)# ptp enable
sonic(config)# interface ethernet 5
sonic(config-if-5)# ptp instance 0
sonic(config-if-ptp-0)# ptp enable

Display PTP Configuration information

Use the show ptp interface command to display brief information about PTP interfaces:

# Spine A

sonic# show ptp interface
Ethernet: Ethernet1
Enable: true
Domain: 0
Index: 2
Dscp: 56
Source IP Address: 0.0.0.0
Announce Interval: 0
Announce Receipt Timeout: 3
Delay Req Interval: -3
Pdelay Req Interval: -3
Sync Interval: -3
Mode: slave
Delay Mode: E2E

Ethernet: Ethernet2
Enable: true
Domain: 0
Index: 3
Dscp: 56
Source IP Address: 0.0.0.0
Announce Interval: 0
Announce Receipt Timeout: 3
Delay Req Interval: -3
Pdelay Req Interval: -3
Sync Interval: -3
Mode: master
Delay Mode: E2E

Ethernet: Ethernet3
Enable: true
Domain: 0
Index: 3
Dscp: 56
Source IP Address: 0.0.0.0
Announce Interval: 0
Announce Receipt Timeout: 3
Delay Req Interval: -3
Pdelay Req Interval: -3
Sync Interval: -3
Mode: master
Delay Mode: E2E

Ethernet: Ethernet5
Enable: true
Domain: 0
Index: 3
Dscp: 56
Source IP Address: 0.0.0.0
Announce Interval: 0
Announce Receipt Timeout: 3
Delay Req Interval: -3
Pdelay Req Interval: -3
Sync Interval: -3
Mode: master
Delay Mode: E2E

# Spine B

sonic# show ptp interface
Ethernet: Ethernet1
Enable: true
Domain: 0
Index: 2
Dscp: 56
Source IP Address: 0.0.0.0
Announce Interval: 0
Announce Receipt Timeout: 3
Delay Req Interval: -3
Pdelay Req Interval: -3
Sync Interval: -3
Mode: passive
Delay Mode: E2E

Ethernet: Ethernet2
Enable: true
Domain: 0
Index: 3
Dscp: 56
Source IP Address: 0.0.0.0
Announce Interval: 0
Announce Receipt Timeout: 3
Delay Req Interval: -3
Pdelay Req Interval: -3
Sync Interval: -3
Mode: master
Delay Mode: E2E

Ethernet: Ethernet3
Enable: true
Domain: 0
Index: 3
Dscp: 56
Source IP Address: 0.0.0.0
Announce Interval: 0
Announce Receipt Timeout: 3
Delay Req Interval: -3
Pdelay Req Interval: -3
Sync Interval: -3
Mode: master
Delay Mode: E2E

Ethernet: Ethernet5
Enable: true
Domain: 0
Index: 3
Dscp: 56
Source IP Address: 0.0.0.0
Announce Interval: 0
Announce Receipt Timeout: 3
Delay Req Interval: -3
Pdelay Req Interval: -3
Sync Interval: -3
Mode: slave
Delay Mode: E2E