PTP (Precision Time Protocol) time service method and device for automatically compensating asymmetric time delay of link, and storage medium

By recording timestamps in PTP time synchronization and combining them with the refractive index of the optical channel group, the link asymmetric delay is automatically compensated, solving the time deviation problem caused by the difference in propagation speed in single-fiber bidirectional optical communication and achieving high-precision time synchronization.

CN121750137APending Publication Date: 2026-03-27SICHUAN TAIFU GROUND BEIDOU TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-11-14
Publication Date
2026-03-27

AI Technical Summary

Technical Problem

Existing PTP timing technology cannot accurately identify and compensate for asymmetric delay in the link. Especially in single-fiber bidirectional optical communication environments, the asymmetric delay problem caused by the difference in the propagation speed of light of different wavelengths cannot be effectively solved, which limits the application of PTP in higher precision timing scenarios.

Method used

By combining the timestamp recording between master and slave devices with the refractive index of the optical channel group, the one-way transmission delay of the link is automatically calculated and compensated. The hardware timestamp scheme is used to record the timestamp, and the refractive index of the optical channel group is used to distinguish the difference in transmission direction, calculate the link asymmetric delay and perform time deviation correction.

Benefits of technology

It enables precise compensation of asymmetric delay in single-fiber bidirectional transmission scenarios, improves timing accuracy, meets the requirements of 5G and time-sensitive networks for nanosecond-level synchronization accuracy, adapts to dynamic network changes, and eliminates the need for manual measurement of fiber optic link length or on-site debugging.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121750137A_ABST
    Figure CN121750137A_ABST
Patent Text Reader

Abstract

The invention discloses a PTP time service method and device for automatically compensating link asymmetric time delay and a storage medium. The method comprises the following steps: a master device records a first timestamp when sending a PTP Sync message to a slave device, and the slave device records a second timestamp when receiving the PTP Sync message; the slave device records a third timestamp when sending the PTP Delay Request message to the master device, and the master device records a fourth timestamp when receiving the PTP Delay Request message; determining a round-trip transmission delay between the master device and the slave device; based on the round-trip transmission time delay, a preset first group refractive index used for a first optical channel corresponding to a PTP Sync message transmission wavelength, and a preset second group refractive index used for a second optical channel corresponding to a PTP Delay Request message transmission wavelength. Determining a first one-way transmission time delay in a direction from the master device to the slave device and a second one-way transmission time delay in a direction from the slave device to the master device; determining the asymmetric time delay of the link; and correcting the time deviation between the master equipment and the slave equipment.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of communication technology, and in particular to a PTP timing method, apparatus and storage medium for automatically compensating for link asymmetric delay. Background Technology

[0002] Since its standard release in 2008, the IEEE 1588v2 Precision Time Protocol (PTP) has become a core time synchronization technology for cross-network time distribution due to its flexible deployment, low cost, and high synchronization accuracy. Compared with the traditional NTP time synchronization method, PTP can achieve nanosecond-level time synchronization, and therefore is widely used in industries with high-precision time requirements, including mobile networks of telecommunications operators, power communication systems of the State Grid, and communication networks for railways and urban rail transit.

[0003] The existing PTP synchronization principle calculates the link delay and the time difference between the master and slave clocks through bidirectional timestamp message exchange between the master and slave devices. In this mechanism, PTP assumes and relies on the precondition that the round-trip delay of the communication link is the same. That is, PTP assumes that the transmission delay from the master to the slave is the same as the transmission delay from the slave back to the master.

[0004] However, in real-world networks, this assumption often fails to hold true. Factors leading to different round-trip delays (i.e., asymmetric delay) include: inconsistent fiber optic or cable laying path lengths; different processing times for uplink and downlink packets by intermediate network devices; differences in the internal processing paths of optical modules; and the use of different media or different wavelengths for inter-directional transmission.

[0005] To minimize timing errors caused by asymmetric delay, the industry has made many efforts, such as using fiber optic transmission instead of copper cables, using hardware such as FPGAs at the physical layer to implement timestamps, and adopting single-fiber bidirectional methods to reduce the impact of fiber length differences.

[0006] Even with single-fiber bidirectional transmission, the use of different wavelengths of light in the transmitting and receiving directions, coupled with the varying propagation speeds of different wavelengths within the fiber, still results in unavoidable asymmetric latency due to fiber dispersion. For example, in typical communication fibers, even a link of just tens of kilometers can exhibit significant time skew. Such time skew is unacceptable for applications like 5G and Time-Sensitive Networking (TSN) that demand sub-nanosecond or even picosecond synchronization accuracy.

[0007] In summary, existing PTP timing technology cannot accurately identify and compensate for asymmetric delays in the link. In particular, in single-fiber bidirectional optical communication environments, the asymmetric delay problem caused by the difference in the propagation speed of light of different wavelengths cannot be effectively solved, thus limiting the application of PTP in higher-precision timing scenarios. Summary of the Invention

[0008] To address the aforementioned technical problems, this application provides a PTP timing method, apparatus, and storage medium for automatically compensating for asymmetric link delay.

[0009] The technical solution provided in this application is described below: The first aspect of this application provides a PTP time synchronization method for automatically compensating for link asymmetric delay, the method comprising: When the master device sends a PTP Sync message to the slave device, it records a first timestamp, and when the slave device receives the PTP Sync message, it records a second timestamp. The slave device records a third timestamp when sending a PTP Delay_Request message to the master device, and the master device records a fourth timestamp when receiving the PTP Delay_Request message; The round-trip transmission delay between the master device and the slave device is determined based on the first, second, third, and fourth timestamps. Based on the round-trip transmission delay and the preset first group refractive index of the first optical channel corresponding to the PTP Sync message transmission wavelength, and the second group refractive index of the second optical channel corresponding to the PTP Delay_Request message transmission wavelength, the first one-way transmission delay from the master device to the slave device and the second one-way transmission delay from the slave device to the master device are determined. The link asymmetric delay is determined based on the first one-way transmission delay and the second one-way transmission delay; The time deviation between the master device and the slave device is corrected based on the link asymmetric delay.

[0010] Optionally, based on the round-trip transmission delay and the preset first group refractive index of the first optical channel corresponding to the PTP Sync message transmission wavelength, and the second group refractive index of the second optical channel corresponding to the PTP Delay_Request message transmission wavelength, the one-way transmission delay from the master device to the slave device and the one-way transmission delay from the slave device to the master device are determined, including: Read the first group refractive index of the first optical channel corresponding to the transmission wavelength of the PTP Sync message, and the second group refractive index of the second optical channel corresponding to the transmission wavelength of the PTP Delay_Request message; Based on the proportional relationship between the first group of refractive indices and the second group of refractive indices, the round-trip transmission delay is allocated as a first one-way transmission delay from the master device to the slave device and a second one-way transmission delay from the slave device to the master device.

[0011] Optionally, the step of allocating the round-trip transmission delay into a first one-way transmission delay from the master device to the slave device and a second one-way transmission delay from the slave device to the master device based on the proportional relationship between the first group refractive index and the second group refractive index includes: The allocation is performed using the following formula: ; ; in, This indicates the first one-way delay. S represents the second one-way delay, and S represents the round-trip transmission delay. Indicates the refractive index of the first group. This indicates the refractive index of the second group.

[0012] Optionally, determining the link asymmetric delay based on the first one-way transmission delay and the second one-way transmission delay includes: The calculation is performed using the following formula: Asym= - ; Asym represents the asymmetric delay of the link.

[0013] Optionally, the step of correcting the time deviation between the master device and the slave device based on the link asymmetric delay includes: The calculation is performed using the following formula: ; Where Asym represents the asymmetric delay of the link, Offset represents the time deviation, T1 represents the first timestamp, T2 represents the second timestamp, T3 represents the third timestamp, and T4 represents the fourth timestamp.

[0014] Optionally, the fiber optic link length can be obtained by means of: Step 1: Calculate the first optical speed of the first optical channel corresponding to the wavelength used for PTP Sync message transmission using the following formula: ; Among them, v g1 Let n represent the first speed of light, c represent the speed of light in a vacuum, and n represent the speed of light in a vacuum. g1 Indicates the refractive index of the first group; Step 2: Calculate the second optical speed of the second optical channel corresponding to the transmission wavelength of the PTP Delay_Request message using the following formula: ; Among them, v g2 Let c represent the second speed of light, and n represent the speed of light in a vacuum. g2 Indicates the refractive index of the second group; Step 3: Based on the v g1 The v g2 The first one-way transmission delay and the second one-way delay in the direction from the master device to the slave device and in the direction from the slave device to the master device are calculated using the following formulas: ; Where L represents the fiber optic link length, which is calculated using the following formula: ; Wherein, S represents the round-trip transmission delay, which is calculated using the following formula: S = (T2 - T1) + (T4 - T3); Wherein, T1 represents the first timestamp, T2 represents the second timestamp, T3 represents the third timestamp, and T4 represents the fourth timestamp.

[0015] Optionally, the time offset is used for the boundary clock BC, the master clock OC master, and the slave clock OC slave.

[0016] A second aspect of this application provides a PTP timing device for automatically compensating for link asymmetric delay, comprising: The first recording unit is used to record the first timestamp when sending a PTP Sync message to the slave device; The second recording unit is used to record a second timestamp when the PTP Sync message is received; The third recording unit is used to record a third timestamp when the master device sends a PTP Delay_Request message; The fourth recording unit is used to record a fourth timestamp when the PTP Delay_Request message is received; Round-trip delay determination unit, used to determine the round-trip transmission delay between master device and slave device based on first timestamp, second timestamp, third timestamp and fourth timestamp; A one-way delay determination unit is used to determine the first one-way transmission delay from the master device to the slave device and the second one-way transmission delay from the slave device to the master device based on the round-trip transmission delay and the preset first group refractive index of the first optical channel corresponding to the PTP Sync message transmission wavelength and the second group refractive index of the second optical channel corresponding to the PTP Delay_Request message transmission wavelength. The link delay determination unit is used to determine the link asymmetric delay based on the first one-way transmission delay and the second one-way transmission delay; A delay compensation unit is used to correct the time deviation between the master device and the slave device based on the asymmetric delay of the link.

[0017] A third aspect of this application provides a PTP timing device for automatically compensating for link asymmetric delay, the device comprising: Processor, memory, input / output units, and bus; The processor is connected to the memory, the input / output unit, and the bus; The memory stores a program, which the processor invokes to execute the first aspect and any one of the optional methods in the first aspect.

[0018] A fourth aspect of this application provides a computer-readable storage medium on which a program is stored, which, when executed on a computer, performs the methods of the first aspect and any one of the first aspects.

[0019] As can be seen from the above technical solutions, this application has the following beneficial effects: 1. In this application, the one-way transmission delay of the link is automatically calculated by combining the group refractive index of the optical channel corresponding to different transmission directions through the normal PTP message exchange process between the master and slave devices, thereby automatically calculating and compensating for asymmetric delay without the need for manual measurement of the fiber optic link length or on-site debugging.

[0020] 2. This application directly calculates the one-way delay based on the timestamp of the real-time collected PTP packets, obtaining the actual delay under the current link state, rather than the theoretical or estimated value. Therefore, it can adapt to network dynamics such as equipment replacement, link adjustment, and wavelength changes.

[0021] 3. In single-fiber bidirectional transmission scenarios, fiber dispersion causes different transmission speeds in different directions because different wavelengths of optical signals are used for the outgoing and return journeys. This application introduces the refractive index of the optical channel group (a physical parameter related to the optical wavelength) to accurately reflect this propagation difference, thereby eliminating the time deviation caused by dispersion.

[0022] 4. This application can fundamentally eliminate or significantly reduce the timing error introduced by asymmetric link delay, enabling slave devices to obtain more accurate master-slave time deviation, improving PTP timing accuracy, and thus meeting the requirements of 5G, TSN, power and rail transportation for nanosecond-level synchronization accuracy.

[0023] 5. This application adopts a message exchange mechanism consistent with the existing PTP standard, and only improves the internal calculation and compensation strategies of the device. It does not change the existing PTP message format and interaction process, and can be smoothly deployed in the existing network. Attached Figure Description

[0024] To more clearly illustrate the technical solutions in this application, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0025] Figure 1 This is a schematic flowchart of an embodiment of the PTP timing method for automatically compensating for asymmetric link delay provided in this application. Figure 2 This is a schematic flowchart of an embodiment of step S104 in the PTP timing method for automatically compensating for asymmetric link delay provided in this application. Figure 3 This is a schematic diagram of an embodiment of the PTP timing device for automatically compensating for asymmetric link delay provided in this application. Figure 4 This is a schematic diagram of an embodiment of another PTP timing device for automatically compensating for link asymmetric delay provided in this application. Detailed Implementation

[0026] The method proposed in this invention will be described below with reference to embodiments. It should be understood that the embodiments are only for explaining this invention and do not constitute a limitation on the scope of protection of this invention. The method of this invention can be executed by different types of devices, such as timing devices, network devices, communication nodes, servers, controllers, or any device with time synchronization functions, and can also be implemented by software, hardware, firmware, or any combination thereof. This invention does not limit the specific executing entity, nor does it limit the location and deployment method of the executing entity. As long as the method flow of this invention can be executed, it falls within the scope of protection of this invention.

[0027] Those skilled in the art should understand that the specific names in the embodiments (such as "master device," "slave device," "PTP device," etc.) are used for ease of description only, and their specific logical roles can be undertaken by different physical devices or by the same device at different times. The execution process of this invention can be implemented by a processor executing program instructions, or by logic circuits or dedicated hardware modules.

[0028] 1. Master device In time-related information exchange, the master device serves as the side providing time reference. The master device can initiate or respond to information interactions, and the specific implementation method is not limited.

[0029] 2. Slave On the other side, which interacts with the master device, the slave device adjusts its own time state by processing the interaction results. The slave device only represents a logical role and is unrelated to the device type or form.

[0030] 3. Sync message A Sync message is an information unit used by the master device to express a certain time state during interaction. Sync messages may contain reference content for time estimation, but their specific structure is not limited.

[0031] 4. Delay_Request message A Delay_Request is an information unit used by the slave device to trigger a response from the master device during interaction. The purpose of a Delay_Request is to establish paired information exchanges, but it does not restrict the content format.

[0032] 5. Timestamps (T1, T2, T3, T4) A data identifier that records the event that occurred at a specific time when a Sync or Delay_Request message is sent. The method of generating the timestamp is not limited; it can be based on hardware, software, or a combination thereof.

[0033] 6. Optical Channel The path instances used to carry message transmission can correspond to different wavelengths or physical properties. Different optical channels may differ, but this invention does not limit their implementation.

[0034] 7. Group Refractive Index This represents a characteristic parameter involved in the transmission of light through a optical channel, and is related to the propagation behavior. The group refractive index may differ between different optical channels, and its acquisition method is not limited.

[0035] 8. Round-trip transmission delay This represents the total time involved in completing a set of interactions between the Sync and Delay_Request messages. It does not assume that the delays in both directions are the same.

[0036] 9. One-way transmission delay This parameter represents the time involved in transmitting a message along a certain direction and is used for time estimation. This invention obtains this parameter by processing the acquired data.

[0037] 10. Asymmetric delay (Asym) This represents the quantification result indicating a difference in unidirectional transmission delay between the two directions. This invention utilizes this difference to make time synchronization no longer dependent on the assumption of directional consistency.

[0038] Please see Figure 1 This application first provides an embodiment of a PTP timing method for automatically compensating for asymmetric link delay. The PTP timing method for automatically compensating for asymmetric link delay provided in this embodiment operates between a master device and a slave device that support the PTP protocol, and the two communicate through a single-fiber bidirectional optical channel.

[0039] This embodiment includes: S101. When the master device sends a PTP Sync message to the slave device, it records a first timestamp, and when the slave device receives the PTP Sync message, it records a second timestamp. The master device is responsible for sending time references to the slave device to establish synchronization.

[0040] The execution process can include the following implementation: When the master device's PTP protocol stack reaches the set synchronization period (e.g., 1 second / 128 times / second), it constructs the frame structure of the Sync message and writes it to the transmission buffer. The Sync message is sent to the network interface module (e.g., the MAC layer). During this stage, the master device simultaneously loads the current time into the timestamp preparation register. When the message is sent through the physical port, a timestamp is generated by hardware circuitry immediately adjacent to the interface physical layer, such as a frame-out event trigger signal provided by the MAC or PHY chip. This timestamp is recorded as the first timestamp T1. This timestamp recording occurs at the instant the message actually leaves the physical port, thus eliminating software delay. The Sync message enters the optical fiber along with the required wavelength signal (e.g., 1490nm). Hardware capture is triggered when the message arrives at the slave device's physical port. The moment of reception can be recorded using a hardware clock domain, bypassing the protocol stack; this time point is recorded as the second timestamp T2. To avoid jitter caused by CPU involvement, both the first and second timestamps can be directly generated by hardware components after the optical module. After recording, the timestamps are transferred to memory via DMA to reduce software interference. S102. When the slave device sends a PTP Delay_Request message to the master device, it records a third timestamp, and when the master device receives the PTP Delay_Request message, it records a fourth timestamp. Step S102 is used to construct the reverse link measurement process corresponding to Sync.

[0041] After receiving the Sync message, the slave device generates a PTP Delay_Request message for link backhaul measurement based on the synchronization cycle or the trigger condition of the received Sync message. This message can be automatically constructed by the slave device's internal PTP protocol stack, or it can be generated by the timing control module after detecting a synchronization event.

[0042] During the preparation for sending the Delay_Request message, the physical layer interface module of the slave device automatically generates a timestamp for the transmission moment when the message passes through the link layer buffer and is ready to exit the optical port, triggered by a timestamp immediately adjacent to the physical layer. This timestamp directly reflects the actual time the message leaves the transmission port, unaffected by operating system task scheduling or queue buffer latency, thus ensuring timing accuracy. This time is recorded as the third timestamp T3.

[0043] The generated Delay_Request message is then transmitted via the reverse optical channel of the fiber. This reverse optical channel can use a different wavelength signal than the Sync message; for example, when the Sync message is transmitted using the 1490nm channel, the Delay_Request message can be transmitted using the 1550nm channel. Due to the different propagation characteristics of optical fibers at different wavelengths, this transmission path may have different physical delay characteristics than the outgoing path.

[0044] When the master device receives the Delay_Request message, its receiving module triggers a hardware time capture circuit the instant the message enters the output of the photoelectric converter or the PHY layer receive buffer, recording the actual arrival time of the message. This timestamp, corresponding to the reception time of the Delay_Request message, is marked as the fourth timestamp T4.

[0045] In this embodiment, both the master and slave devices preferably employ a hardware-level timestamp scheme, such as capturing data through the time sampling logic built into the FPGA or an Ethernet PHY chip with IEEE 1588 timestamp functionality. Compared to traditional software timestamp methods, hardware timestamps can eliminate jitter caused by uncertainties such as operating system latency and driver interrupt handling, making the time records of T3 and T4 more stable and repeatable.

[0046] S103. Determine the round-trip transmission delay between the master device and the slave device based on the first timestamp, the second timestamp, the third timestamp, and the fourth timestamp; Both the master and slave devices acquire two sets of timestamps and transmit them to the computing unit via a network management interface or a message defined by the PTP protocol. The computing unit can be located on the master device, the slave device, or the management system. Specifically, it first collects the first, second, third, and fourth timestamps; then it calculates the round-trip latency of a complete Sync / Delay_Request message exchange. This round-trip latency is a measure of the overall transmission latency of the bidirectional link and does not require prior knowledge of the link length.

[0047] S104. Based on the round-trip transmission delay and the preset first group refractive index of the first optical channel corresponding to the PTP Sync message transmission wavelength, and the second group refractive index of the second optical channel corresponding to the PTP Delay_Request message transmission wavelength, determine the first one-way transmission delay from the master device to the slave device and the second one-way transmission delay from the slave device to the master device. After obtaining the round-trip transmission delay corresponding to a complete interaction between the Sync and Delay_Request messages, this embodiment employs single-fiber bidirectional optical channel technology to further distinguish the differences between the two directions of the link. The two transmission paths carry optical signals of different wavelengths, with the Sync message transmitted along the first optical channel and the Delay_Request message transmitted along the second optical channel. Since light travels at different wavelengths, the optical signals in the two directions may have different propagation characteristics, resulting in inconsistent actual transmission delays in the two directions.

[0048] In this step, a single-fiber bidirectional WDM / CWDM / DWDM optical channel can be used, with the Sync and Delay_Request messages transmitted at different wavelengths. In practice, the first and second group refractive indices corresponding to different fiber types and operating wavelengths can be pre-stored; based on the round-trip transmission delay and the different propagation characteristics of the two optical channels, the following calculations can be performed: First one-way transmission delay (master to slave device) Second one-way transmission delay (from slave device to master device) The group refractive index represents the effective speed at which light propagates within an optical fiber at different wavelengths; the higher the refractive index, the slower the propagation. Round-trip delay represents the sum of the transmission times in both directions, and these transmission times are related to the group refractive index of the corresponding optical channels. By introducing the group refractive index, a physical characteristic parameter for different directions, the proportion of transmission time allocation in each direction can be determined. This eliminates the need for the link symmetry assumption, prior knowledge of the fiber optic link length, and manual calibration of link delays, allowing for the automatic differentiation of transmission delays in both directions.

[0049] S105. Determine the link asymmetric delay based on the first one-way transmission delay and the second one-way transmission delay; After distinguishing the unidirectional transmission delay from the master device to the slave device and from the slave device to the master device, this embodiment further calculates the link asymmetry.

[0050] Due to factors such as differences in optical channel wavelength, fiber dispersion, WDM devices, and internal forwarding structures, the signal propagation time in the two directions of an optical fiber link is usually not exactly the same. Therefore, this embodiment compares the unidirectional transmission delays in the two directions to determine the asymmetric delay of the link.

[0051] Specifically, if the one-way latency from the master device to the slave device is large, it indicates that the outbound link is "slower"; if the one-way latency from the slave device to the master device is large, it indicates that the return link is "slower".

[0052] By performing a difference operation on the two unidirectional delays, the asymmetric delay of the link can be obtained. This difference can be used to accurately represent the actual difference in the transmission characteristics of the two directions of the optical fiber link.

[0053] In an optional embodiment, the calculation can be performed using the following formula: Asym= - ; Asym represents the asymmetric delay of the link.

[0054] S106. Correct the time deviation between the master device and the slave device based on the asymmetric delay of the link.

[0055] After determining the asymmetric delay of the link, this embodiment further uses this parameter to correct the time of the slave device, thereby eliminating the timing error caused by the inconsistent transmission direction of the link.

[0056] Specifically, this can include: the slave device calculating the initial time deviation (excluding link asymmetry) based on the PTP protocol standard logic using the aforementioned four timestamps (first timestamp, second timestamp, third timestamp, and fourth timestamp). This deviation represents the amount of time the slave device currently believes should be adjusted. Based on the link asymmetry delay obtained in step S105, this embodiment uses this delay as a compensation parameter, combining it with the initial time deviation. The slave device adjusts its local clock according to the corrected time deviation. This process can be achieved by directly modifying the system time within the time synchronization module or by gradually adjusting the frequency, thus achieving smooth time synchronization. This update can be completed in real time within the device without manual intervention.

[0057] In an optional embodiment, the time deviation can be calculated using the following formula: ; Where Asym represents the asymmetric delay of the link, Offset represents the time deviation, T1 represents the first timestamp, T2 represents the second timestamp, T3 represents the third timestamp, and T4 represents the fourth timestamp.

[0058] See Figure 2 Furthermore, one embodiment of step S104 includes: S1041. Read the first group refractive index of the first optical channel corresponding to the transmission wavelength of the PTP Sync message, and the second group refractive index of the second optical channel corresponding to the transmission wavelength of the PTP Delay_Request message; To differentiate the round-trip transmission delay into unidirectional transmission delays in two directions, this embodiment introduces the group refractive index parameter from optical fiber transmission characteristics. In a single-fiber bidirectional optical fiber link, the PTP Sync message and the PTP Delay_Request message are transmitted through optical channels of different wavelengths. Since light travels at different speeds in optical channels of different wavelengths, this difference can be characterized by the group refractive index of the optical channel.

[0059] S1042. Based on the proportional relationship between the first group refractive index and the second group refractive index, the round-trip transmission delay is allocated as a first unidirectional transmission delay from the master device to the slave device and a second unidirectional transmission delay from the slave device to the master device.

[0060] Since the round-trip transmission delay has been determined in S103, and the propagation speeds of the two optical channels are different, this embodiment rationally allocates the round-trip transmission delay based on the proportional relationship between the first group refractive index and the second group refractive index. This allocation process can take into account the differences in propagation speeds of different channels, making the unidirectional transmission delay segmentation more in line with physical reality. If the optical channel containing Sync propagates more slowly, the first unidirectional transmission delay is greater; if the optical channel containing Delay_Request propagates more slowly, the second unidirectional transmission delay is greater.

[0061] Specifically, the allocation can be performed using the following formula: ; ; in, This indicates the first one-way delay. S represents the second one-way delay, and S represents the round-trip transmission delay. Indicates the refractive index of the first group. This indicates the refractive index of the second group.

[0062] Substituting this formula into the aforementioned Offset calculation formula, we obtain the overall formula for calculating Offset: ; Further conversion yields: (ns); In one embodiment, after obtaining the round-trip transmission delay, to further determine the true physical transmission characteristics of the link, the system further introduces optical channel parameters corresponding to different PTP message transmission wavelengths. In a single-fiber bidirectional optical fiber link, PTP Sync and PTP Delay_Request messages are transmitted using different wavelengths. The optical signals corresponding to different wavelengths propagate at different speeds in the optical fiber, and this difference is determined by the group refractive index of the optical channel.

[0063] Based on this physical law, this embodiment derives the speed of light in different wavelength optical channels through the group refractive index, and further calculates the following using the round-trip transmission delay: fiber optic link length, one-way transmission delay from master device to slave device, one-way transmission delay from slave device to master device, and the delay difference between the two directions, i.e., link asymmetric delay. Based on this, the actual time deviation between master and slave devices is obtained by combining timestamp information, achieving real-time compensation for link asymmetric delay.

[0064] This embodiment includes: Step 1: Calculate the first optical speed of the first optical channel corresponding to the wavelength used for PTP Sync message transmission using the following formula: ; Among them, v g1 Let n represent the first speed of light, c represent the speed of light in a vacuum, and n represent the speed of light in a vacuum. g1 Indicates the refractive index of the first group; Step 2: Calculate the second optical speed of the second optical channel corresponding to the transmission wavelength of the PTP Delay_Request message using the following formula: ; Among them, v g2 Let c represent the second speed of light, and n represent the speed of light in a vacuum. g2 Indicates the refractive index of the second group; Step 3: Based on the v g1 The v g2 The first one-way transmission delay and the second one-way delay in the direction from the master device to the slave device and in the direction from the slave device to the master device are calculated using the following formulas: ; Where L represents the fiber optic link length, which is calculated using the following formula: ; Wherein, S represents the round-trip transmission delay, which is calculated using the following formula: S = (T2 - T1) + (T4 - T3); Wherein, T1 represents the first timestamp, T2 represents the second timestamp, T3 represents the third timestamp, and T4 represents the fourth timestamp.

[0065] The following example uses G.652 fiber, which is commonly used in actual engineering projects. The PTPSync and PTPDelay_Request messages are transmitted using different wavelengths: Table 1. List of PTP message attributes;

[0066] For ease of explanation, the four timestamps collected in a complete time synchronization cycle are defined as follows: Table 2. List of timestamps;

[0067] Based on the four timestamps, the actual transmission time of the fiber optic link in the round trip direction is approximately: S = 1,000,050 ns; Substitute the four timestamps, along with ng1 and ng2, into the overall formula for calculating Offset: ; First item: ; The second item: ; First calculate: ; Then calculate the refractive index difference and sum: ; ; Calculate the refractive index ratio: ; ; Calculating the second term yields: Calculating the second term -0.000052097 × 1,000,050 = -52.0997; Calculate the final offset: Offset=−25−52.0997=−77.0997(ns).

[0068] In one possible implementation, the time deviation determined in this application can be used for correction by any PTP clock node in the network that has time synchronization capability, including but not limited to boundary clocks (BC), master clocks (OC master), and slave clocks (OC slave).

[0069] The foregoing embodiments have described in detail the PTP timing method for automatically compensating for asymmetric link delay provided in this application. The PTP timing device for automatically compensating for asymmetric link delay provided in this application is described below.

[0070] See Figure 3 This application provides an embodiment of a PTP timing device for automatically compensating for link asymmetric delay, the embodiment including: The first recording unit 301 is used to record a first timestamp when sending a PTP Sync message to the slave device; The second recording unit 302 is used to record a second timestamp when the PTP Sync message is received; The third recording unit 303 is used to record a third timestamp when the master device sends a PTP Delay_Request message; The fourth recording unit 304 is used to record a fourth timestamp when the PTP Delay_Request message is received; Round-trip delay determination unit 305 is used to determine the round-trip transmission delay between the master device and the slave device based on the first timestamp, the second timestamp, the third timestamp and the fourth timestamp; The one-way delay determination unit 306 is used to determine the first one-way transmission delay from the master device to the slave device and the second one-way transmission delay from the slave device to the master device based on the round-trip transmission delay and the preset first group refractive index of the first optical channel corresponding to the PTP Sync message transmission wavelength and the second group refractive index of the second optical channel corresponding to the PTP Delay_Request message transmission wavelength. The link delay determination unit 307 is used to determine the link asymmetric delay based on the first one-way transmission delay and the second one-way transmission delay; The delay compensation unit 308 is used to correct the time deviation between the master device and the slave device based on the asymmetric delay of the link.

[0071] Optionally, the one-way delay determination unit 306 is specifically used for: Read the first group refractive index of the first optical channel corresponding to the transmission wavelength of the PTP Sync message, and the second group refractive index of the second optical channel corresponding to the transmission wavelength of the PTP Delay_Request message; Based on the proportional relationship between the first group of refractive indices and the second group of refractive indices, the round-trip transmission delay is allocated as a first one-way transmission delay from the master device to the slave device and a second one-way transmission delay from the slave device to the master device.

[0072] Optionally, the one-way delay determination unit 306 is specifically used for: The allocation is performed using the following formula: ; ; in, This indicates the first one-way delay. S represents the second one-way delay, and S represents the round-trip transmission delay. Indicates the refractive index of the first group. This indicates the refractive index of the second group.

[0073] Optionally, the link delay determination unit 307 is specifically used for: The calculation is performed using the following formula: Asym= - ; Asym represents the asymmetric delay of the link.

[0074] Optionally, the delay compensation unit 308 is specifically used for: The calculation is performed using the following formula: ; Where Asym represents the asymmetric delay of the link, Offset represents the time deviation, T1 represents the first timestamp, T2 represents the second timestamp, T3 represents the third timestamp, and T4 represents the fourth timestamp.

[0075] Optional, optional, the one-way delay determination unit 306 is specifically used for: Step 1: Calculate the first optical speed of the first optical channel corresponding to the wavelength used for PTP Sync message transmission using the following formula: ; Among them, v g1 Let n represent the first speed of light, c represent the speed of light in a vacuum, and n represent the speed of light in a vacuum. g1 Indicates the refractive index of the first group; Step 2: Calculate the second optical speed of the second optical channel corresponding to the transmission wavelength of the PTP Delay_Request message using the following formula: ; Among them, v g2 Let c represent the second speed of light, and n represent the speed of light in a vacuum. g2 Indicates the refractive index of the second group; Step 3: Based on the v g1 The v g2 The first one-way transmission delay and the second one-way delay in the direction from the master device to the slave device and in the direction from the slave device to the master device are calculated using the following formulas: ; Where L represents the fiber optic link length, which is calculated using the following formula: ; Wherein, S represents the round-trip transmission delay, which is calculated using the following formula: S = (T2 - T1) + (T4 - T3); Wherein, T1 represents the first timestamp, T2 represents the second timestamp, T3 represents the third timestamp, and T4 represents the fourth timestamp.

[0076] Please see Figure 4 This application also provides a PTP timing device for automatically compensating for link asymmetric delay, comprising: Processor 401, memory 402, input / output unit 403, bus 404; The processor 401 is connected to the memory 402, the input / output unit 403, and the bus 404; The memory 402 stores a program, and the processor 401 calls the program to execute any of the methods described above.

[0077] This application also relates to a computer-readable storage medium on which a program is stored, which, when run on a computer, causes the computer to perform any of the methods described above.

[0078] Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the specific working processes of the systems, devices, and units described above can be referred to the corresponding processes in the foregoing method embodiments, and will not be repeated here.

[0079] In the several embodiments provided in this application, it should be understood that the disclosed systems, apparatuses, and methods can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative; for instance, the division of units is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be an indirect coupling or communication connection between apparatuses or units through some interfaces, and may be electrical, mechanical, or other forms.

[0080] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.

[0081] Furthermore, the functional units in the various embodiments of this application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit.

[0082] If the integrated unit is implemented as a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or all or part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of this application. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.

Claims

1. A PTP timing method for automatically compensating for asymmetric link delay, characterized in that, The method includes: When the master device sends a PTP Sync message to the slave device, it records a first timestamp, and when the slave device receives the PTP Sync message, it records a second timestamp. The slave device records a third timestamp when sending a PTP Delay_Request message to the master device, and the master device records a fourth timestamp when receiving the PTP Delay_Request message; The round-trip transmission delay between the master device and the slave device is determined based on the first, second, third, and fourth timestamps. Based on the round-trip transmission delay and the preset first group refractive index of the first optical channel corresponding to the PTP Sync message transmission wavelength, and the second group refractive index of the second optical channel corresponding to the PTP Delay_Request message transmission wavelength, the first one-way transmission delay from the master device to the slave device and the second one-way transmission delay from the slave device to the master device are determined. The link asymmetric delay is determined based on the first one-way transmission delay and the second one-way transmission delay; The time deviation between the master device and the slave device is corrected based on the link asymmetric delay.

2. The PTP timing method for automatically compensating for link asymmetric delay as described in claim 1, characterized in that, The determination of the one-way transmission delay from the master device to the slave device and the one-way transmission delay from the slave device to the master device based on the round-trip transmission delay and the preset first group refractive index of the first optical channel corresponding to the PTP Sync message transmission wavelength, and the second group refractive index of the second optical channel corresponding to the PTP Delay_Request message transmission wavelength, includes: Read the first group refractive index of the first optical channel corresponding to the transmission wavelength of the PTP Sync message, and the second group refractive index of the second optical channel corresponding to the transmission wavelength of the PTP Delay_Request message; Based on the proportional relationship between the first group of refractive indices and the second group of refractive indices, the round-trip transmission delay is allocated as a first one-way transmission delay from the master device to the slave device and a second one-way transmission delay from the slave device to the master device.

3. The PTP timing method for automatically compensating for link asymmetric delay as described in claim 2, characterized in that, The allocation of the round-trip transmission delay into a first one-way transmission delay from the master device to the slave device and a second one-way transmission delay from the slave device to the master device, based on the proportional relationship between the first group refractive index and the second group refractive index, includes: The allocation is performed using the following formula: ; ; in, This indicates the first one-way delay. S represents the second one-way delay, and S represents the round-trip transmission delay. Indicates the refractive index of the first group. This indicates the refractive index of the second group.

4. The PTP timing method for automatically compensating for link asymmetric delay as described in claim 1, characterized in that, The step of determining the link asymmetric delay based on the first one-way transmission delay and the second one-way transmission delay includes: The calculation is performed using the following formula: Asym= - ; Asym represents the asymmetric delay of the link.

5. The PTP timing method for automatically compensating for link asymmetric delay as described in claim 1, characterized in that, The step of correcting the time deviation between the master device and the slave device based on the link asymmetric delay includes: The calculation is performed using the following formula: ; Where Asym represents the asymmetric delay of the link, Offset represents the time deviation, T1 represents the first timestamp, T2 represents the second timestamp, T3 represents the third timestamp, and T4 represents the fourth timestamp.

6. The PTP timing method for automatically compensating for link asymmetric delay as described in claim 3, characterized in that, include: Step 1: Calculate the first optical speed of the first optical channel corresponding to the wavelength used for PTP Sync message transmission using the following formula: ; Among them, v g1 Let n represent the first speed of light, c represent the speed of light in a vacuum, and n represent the speed of light in a vacuum. g1 Indicates the refractive index of the first group; Step 2: Calculate the second optical speed of the second optical channel corresponding to the transmission wavelength of the PTP Delay_Request message using the following formula: ; Among them, v g2 Let c represent the second speed of light, and n represent the speed of light in a vacuum. g2 Indicates the refractive index of the second group; Step 3: Based on the v g1 The v g2 The first one-way transmission delay and the second one-way delay in the direction from the master device to the slave device and in the direction from the slave device to the master device are calculated using the following formulas: ; Where L represents the fiber optic link length, which is calculated using the following formula: ; Wherein, S represents the round-trip transmission delay, which is calculated using the following formula: S = (T2 - T1) + (T4 - T3); Wherein, T1 represents the first timestamp, T2 represents the second timestamp, T3 represents the third timestamp, and T4 represents the fourth timestamp.

7. The PTP timing method for automatically compensating for link asymmetric delay according to any one of claims 1-6, characterized in that, The time offset is used for boundary clock BC, master clock OC master, and slave clock OC slave.

8. A PTP timing device for automatically compensating for link asymmetric delay, characterized in that, include: The first recording unit is used to record the first timestamp when sending a PTP Sync message to the slave device; The second recording unit is used to record a second timestamp when the PTP Sync message is received; The third recording unit is used to record a third timestamp when the master device sends a PTP Delay_Request message; The fourth recording unit is used to record a fourth timestamp when the PTP Delay_Request message is received; Round-trip delay determination unit, used to determine the round-trip transmission delay between master device and slave device based on first timestamp, second timestamp, third timestamp and fourth timestamp; A one-way delay determination unit is used to determine the first one-way transmission delay from the master device to the slave device and the second one-way transmission delay from the slave device to the master device based on the round-trip transmission delay and the preset first group refractive index of the first optical channel corresponding to the PTP Sync message transmission wavelength and the second group refractive index of the second optical channel corresponding to the PTP Delay_Request message transmission wavelength. The link delay determination unit is used to determine the link asymmetric delay based on the first one-way transmission delay and the second one-way transmission delay; A delay compensation unit is used to correct the time deviation between the master device and the slave device based on the asymmetric delay of the link.

9. A PTP timing method for automatically compensating for asymmetric link delay, characterized in that, The device includes: Processor, memory, input / output units, and bus; The processor is connected to the memory, the input / output unit, and the bus; The memory stores a program, which the processor invokes to perform the method as described in any one of claims 1 to 7.

10. A computer-readable storage medium, characterized in that, The computer-readable storage medium contains a program that, when executed on a computer, performs the method as described in any one of claims 1 to 7.