Synchronize Time using PTP
1 Overview
Hesai lidar products support PTP (Precision Time Protocol), which allows users to achieve precise time synchronization among multiple sensors.
2 Application Method
The method of using PTP time synchronization feature is as follows:
- Configure PTP related settings of the lidar through web control page or LidarUtilities (see below figures, for the detailed information of each parameter setting please refer to the user manual of corresponding product):
Web control page - Settings (Pandar series/QT series/XT series)

LidarUtilities - Time Sync (OT128 / AT128P)

Note: LidarUtilities can be downloaded from Hesai's official website (OT128,AT128P).
- After connecting the lidar to the external clock source device, configure clock source to PTP master and start time synchronization between the lidar and the PTP master.
Hesai lidar products support PTP time synchronization using software simulation or dedicated hardware clock device, with the detailed application method introduced as follows:
2.1 PTP Time Synchronization through Software Simulation
Please refer to the below figure for the hardware connection method of PTP time synchronization through software simulation:

For different types of PTP protocols, the PTP master can be configured in an Ubuntu OS PC according to the following methods:
2.1.1 1588v2 Protocol
For 1588v2 protocol, the commonly used open-source PTP time synchronization simulation software includes linuxptp and ptpd, with the corresponding configuration methods introduced as follows:
2.1.1.1 linuxptp (recommended)
- Installation
sudo apt-get install linuxptp
- Use 'ethtool' command to check the PTP synchronization functions supported by the network interface of host computer
sudo apt-get install ethtool
sudo ethtool -T <network interface name>
Note: For the method of checking the network interface name of host computer, please refer to How to Check Network Interface Name of Host Computer in Ubuntu OS.
-The terminal will print the below information:

The hardware or software displayed here indicates whether the network interface has hardware timestamp capability or only supports software timestamp.The synchronization accuracy of hardware timestamps can reach several microseconds or even lower, while the time synchronization error using software timestamps is generally larger than that with hardware timestamps.
- Run the following command to configure the host computer network interface as PTP master and start time synchronization
- Network Transport -> UDP/IP
sudo ptp4l –m -4 –i <network interface name> –S
- Network Transport -> L2
sudo ptp4l –m -2 –i <network interface name> –S
- Observe the printed message in terminal, when the network interface shows the Grand Master status, it means the host computer is successfully configured as PTP master:

When the PTP status displayed on the web control page or LidarUtilities interface of the lidar is updated to Tracking or Locked, it means the time synchronization between the lidar and the PTP master has been successfully established (as shown in the below figures):
Web control page - Home (Pandar series/QT series/XT series)

LidarUtilities - Time Sync (OT128/ AT128P)

Note that when the PTP status of Hesai lidar products is displayed as'Tracking', it only means that the timestamp offset (Master Offset) between the current lidar and PTP master does not meet the 'Time Offset' parameter threshold corresponding to the'Locked'status (this threshold can be configured in the lidar's control page, default value is ±1μs, maximum support to ±100μs), while actually the lidar is already in a normal PTP time synchronization state.
2.1.1.2 ptpd
- Installation
sudo apt-get install ptpd
- Run the following command to configure the host computer network interface as PTP master and start time synchronization
sudo ptpd -i <network interface name> -C -M
- Observe the printed message in terminal, when the network interface shows the PTP_MASTER status, it means the host computer is successfully configured as PTP master:

When the PTP status displayed on the web control page or LidarUtilities interface of the lidar is updated to Tracking or Locked, it means the time synchronization between the lidar and the PTP master has been successfully established.
Note: For the case of synchronizing multiple lidars with 1588v2 protocol, usually only a regular switch is needed to be added to the network to achieve the forwarding of PTP messages between the PTP master and each lidars. This process won't affect the configuration methods on the PTP master as mentioned above.
2.1.2 802.1AS Protocol
2.1.2.1 PTP synchronization on a single lidar
For PTP time synchronization using 802.1AS protocol on a single lidar, it is recommended to use the LinuxPTP software tool for configuration. The operation method is as follows:
- Installation
sudo apt-get install linuxptp
- Use 'ethtool' command to check the PTP synchronization functions supported by the network interface of host computer
sudo apt-get install ethtool
sudo ethtool -T <network interface name>
- Run the following command to configure the host computer network interface as PTP master and start time synchronization
sudo ptp4l -S -i <network interface name> -m -f gPTP.cfg
The gPTP.cfg file from this command contains the basic parameter configurations required for the current PTP master. Please refer to the following information for details:
- Standard 802.1AS Profile
[global]
gmCapable 1
priority1 248
priority2 248
logAnnounceInterval 0
logSyncInterval -3
syncReceiptTimeout 3
neighborPropDelayThresh 800000
min_neighbor_prop_delay -20000000
assume_two_step 1
path_trace_enabled 1
follow_up_info 1
transportSpecific 0x1
ptp_dst_mac 01:80:C2:00:00:0E
network_transport L2
delay_mechanism P2P
domainNumber 0
Note: Some Hesai lidar products (e.g. OT128, AT128P, etc.) support the option of 802.1AS (AUTOSAR) profile, while the PTP master configurations corresponding to this option is actually the same as the standard 802.1AS profile configuration as displayed above.
- 802.1AS Automotive Profile
[global]
gmCapable 1
priority1 248
priority2 248
logAnnounceInterval 0
logSyncInterval -3
syncReceiptTimeout 3
neighborPropDelayThresh 800000
min_neighbor_prop_delay -20000000
assume_two_step 1
path_trace_enabled 1
follow_up_info 1
transportSpecific 0x1
ptp_dst_mac 01:80:C2:00:00:0E
network_transport L2
delay_mechanism P2P
domainNumber 0
#
# Automotive Profile Specific Options
#
BMCA noop
masterOnly 1
inhibit_announce 1
asCapable true
inhibit_delay_req 1
- Observe the printed message in terminal, when the network interface shows the Grand Master status, it means the host computer is successfully configured as PTP master:

When the PTP status displayed on the web control page or LidarUtilities interface of the lidar is updated to Tracking or Locked, it means the time synchronization between the lidar and the PTP master has been successfully established.
2.1.2.2 PTP synchronization on multiple lidars
To perform time synchronization on multiple lidars from the same network using 802.1AS protocol, it is necessary to first confirm whether the switch model used supports TSN (i.e. Time Sensitive Network, an extension protocol stack of IEEE 802.1 which is aimed at providing a universal time sensitive mechanism for the data link layer of Ethernet protocol to ensure real-time and reliable data transmission).
- For the switch that supports TSN, set the 'Switch Type' parameter of each lidar to 'TSN' (as shown in the figures below), and configure the host computer as the PTP master according to method introduced above for a single lidar. When the PTP status displayed on the web control page or LidarUtilities interface of the lidar is updated to Tracking or Locked, it means the time synchronization between the lidar and the PTP master has been successfully established.
Web control page - Home (Pandar series/QT series/XT series)

LidarUtilities - Time Sync (OT128/ AT128P)

- For the ordinary type switch that does not support TSN, it is not possible to directly use standard Linuxptp software to achieve gPTP time synchronization for multiple lidars. Instead, users can refer to the following method to modify part of the source code in the original LinuxPTP program and make it compatible with the network using regular switches that can achieve gPTP time synchronization on multiple lidars:
- Generate a new ptp4l.diff file according to the following code and copy it into the linuxptp folder:
diff --git a/port.c b/port.c
index b7fbfb1..3cd0ba4 100644
--- a/port.c
+++ b/port.c
@@ -2278,21 +2278,10 @@ int process_pdelay_req(struct port *p, struct ptp_message *m)
p->delayMechanism = DM_P2P;
port_set_delay_tmo(p);
pr_debug("%s: peer port id set to %s", p->log_name,
pid2str(&p->peer_portid));
rsp = msg_allocate();
if (!rsp) {
@@ -2475,8 +2464,8 @@ int process_pdelay_resp(struct port *p, struct ptp_message *m)
}
if (!p->peer_delay_req) {
pr_err("%s: rogue peer delay response", p->log_name);
return 0;
}
if (p->peer_portid_valid) {
if (!pid_eq(&p->peer_portid, &m->header.sourcePortIdentity)) }
- Compile and run in the path of linuxptp folder:
make clean
make
- Run the following command to modify the port. c file in the linuxptp folder based on the newly generated ptp4l.diff file (see figure below):
patch -p1 < ptp4l.diff

- After modifying and saving, compile and run it using the 'make' command. After compiling, check the port. c file and confirm the content has been correctly modified as highlighted in the following figure:

- Run the following command in the linuxptp folder to configure the host computer network interface as PTP master and start time synchronization:
sudo ptp4l -S -i <network interface name> -m -f gPTP.cfg
When the network interface shows the Grand Master status, it means the host computer is successfully configured as PTP master.
- Set the 'Switch Type' parameter of each lidar to 'Non-TSN' (as shown in the figures below). When the PTP status displayed on the web control page or LidarUtilities interface of the lidar is updated to Tracking or Locked, it means the time synchronization between the lidar and the PTP master has been successfully established.
Web control page - Home (Pandar series/QT series/XT series)

LidarUtilities - Time Sync (OT128 / AT128P)

2.2 PTP Time Synchronization through Hardware Device
Please refer to the below figure for the hardware connection method of PTP time synchronization through a dedicated hardware clock device:

This PTP time synchronization method can typically achieve higher time synchronization accuracy (< 1μs).Similar to the software simulation method, users needs to configure the required PTP master parameters based on the selected PTP protocol and start the time synchronization process correctly according to the operation guidance of the hardware device (the following figure shows the parameter configuration interface of Trimble Thunderbolt GM200, a dedicated PTP master device).

After the hardware device is successfully configured as PTP master and starts PTP time synchronization, it can be confirmed whether the lidar is under the normal synchronization state by monitoring the PTP status of the lidar (which should be Tracking or Locked) and the timestamp information contained in the received point cloud data.
3 Common PTP Time Synchronization Issues troubleshooting
3.1 Lidar cannot establish PTP time synchronization correctly
- Check whether the hardware connection of the PTP time synchronization network is good;
- Check whether the PTP synchronization message between the lidar and PTP master clock is correctly sent out (users can check the PTP protocol related messages in the data stream through use Wireshark software). If the message is sent out but not received, check whether the network bandwidth load could exceed the limit and cause packet loss;
- Check whether the PTP parameter configuration of the lidar is consistent with the parameter configuration of the PTP master. See detailed configuration method here.
3.2 Lidar's PTP time synchronization status is not stable
- Check whether the hardware connection of the PTP time synchronization network is good;
- Check whether the PTP master is working properly and whether there is any abnormal timestamp jump phenomenon occurred on the PTP master;
- Check whether the lidar can receive PTP Sync messages sent by the PTP master correctly (users can check the PTP protocol related messages in the data stream through use Wireshark software);
- For 1588v2 protocol, if there are multiple lidars or other devices connected to the current time synchronization network, and PTP time synchronization cannot be established or frequently switch to unlock status after synchronization, need to check whether the data volume transmitted in the network is close to the upper limit of Ethernet port bandwidth on the host computer. It is recommended to configure the parameter 'PTP Network Transport' on the lidar and PTP master to L2 to avoid the impact of IP network layer data load on the transmission of PTP messages at the receiving and transmitting Ethernet ports;
- For 802.1AS protocol, if the PTP time synchronization state of the lidar is unstable and switches between locked and unlock status, need to check whether the Sync message's period parameter (logSyncInterval) from the PTP master is consistent with this parameter from the lidar (for Hesei lidar products, this parameter is fixed at -3).
If other PTP time synchronization issues persist after following the above steps, please contact Hesai Technical Support.