A device and method for improving PTP time synchronization accuracy

Through the combination of the FPGA delay chain module and the variable FPGA delay chain phase shift number, the problem that the PTP time synchronization accuracy is limited by the asymmetry of the master-slave node PHY link is solved, and the 1000Base-T Ethernet link is realized. High-precision time synchronization.

CN117938298BActive Publication Date: 2024-08-27INNOVATION ACAD FOR PRECISION MEASUREMENT SCI & TECH CAS
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410158602.3
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-02-02
Publication Date
2024-08-27
Estimated Expiration
2044-02-02

AI Technical Summary

Technical Problem

The accuracy of PTP time synchronization is limited by the uncertain delay problem caused by the asymmetry of the PHY link between the master and slave nodes, especially the lack of effective solutions on 1000Base-T Ethernet links.

Method used

Using the FPGA delay chain module and the variable FPGA delay chain phase shift number, the FPGA delay chain module generates the phase shift clock, and cooperates with the master node CPU processing unit and PHY chip to calculate and compensate for the path delay variation, and improve PTP time synchronization Accuracy.

Benefits of technology

It effectively compensates for the uncertain delay in the Ethernet link establishment process, improves the accuracy of PTP master-slave time synchronization, and is suitable for 1000Base-T Ethernet links.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN117938298B
    Figure CN117938298B
Patent Text Reader

Abstract

The present invention discloses a device for improving the accuracy of PTP time synchronization, comprising a master node CPU processing unit, an FPGA delay chain module, a master node FPGA PLL module, an FPGA sending end timestamp recording module, a PTP master node PHY chip and a master node clock module, and a PTP slave node comprising a PTP slave node PHY chip, an FPGA receiving end timestamp recording module, a slave node FPGA PLL module, a slave node clock module and a slave node CPU processing unit. The present invention also discloses a method for improving the accuracy of PTP time synchronization, which processes the uncertain delay introduced in the process of establishing a link between a PTP master-slave synchronization link, introduces an FPGA delay chain module, and uses the master node CPU processing unit to generate a variable FPGA delay chain phase shift number, thereby obtaining an uncertain delay amount, which can improve the accuracy of PTP master-slave time synchronization to a certain extent.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of time synchronization, and in particular to a device for improving PTP time synchronization accuracy, and also to a method for improving PTP time synchronization accuracy. Background Art

[0002] PTP (Precision Time Protocol) is a high-precision network timing protocol based on Ethernet. This protocol has the characteristics of high synchronization accuracy, low resource usage and easy configuration, so it has been widely studied and applied. PTP records timestamps at the network physical layer and exchanges message data through the master-slave link. The slave node calculates the average delay of the master-slave link and the master-slave node clock offset (Offset) based on the four timestamps t1, t2, t3, and t4 received and sent.

[0003] The PTP protocol assumes that the master-slave link is symmetrical by default, but the actual PTP master-slave link is not symmetrical. For example, when transmitting data based on Ethernet, there are multiple phase lock positions when the PHY decoding process recovers the clock and data. Each time the master and slave nodes establish a link, they will be locked in different phases, resulting in uncertain delays, which will also cause errors in the PTP slave node's recorded timestamp t2, and then cause deviations in the calculation of the master-slave clock deviation. At present, most of the solutions to the problem of uncertain delay caused by the establishment of links between master and slave nodes PHY at home and abroad are committed to using PHY chips with fixed locking phases, but there are few PHY chips with this function, and they only support up to 100Base-T Ethernet links. There is no suitable PHY chip or other very effective solution for 1000Base-T Ethernet links. This is also an important reason that limits the further improvement of PTP time synchronization accuracy. Summary of the invention

[0004] The purpose of the present invention is to provide a device for improving the PTP time synchronization accuracy and a method for improving the PTP time synchronization accuracy in view of the above-mentioned problems existing in the current PTP.

[0005] In order to achieve the above-mentioned purpose, the present invention adopts the following technical solutions:

[0006] A device for improving PTP time synchronization accuracy comprises a PTP master node, wherein a master node CPU processing unit in the PTP master node inputs an FPGA delay chain phase shift number n into an FPGA delay chain module; a master node clock module inputs a master node system clock C into the FPGA delay chain module; and the FPGA delay chain module generates a phase shift clock C according to the FPGA delay chain phase shift number n and the master node system clock C. * ; Phase shift clock C *The working clock of the sending end timestamp recording module is obtained by multiplying the frequency of the master node FPGA PLL module And the master node PHY chip working clock The sending end timestamp records the working clock of the module Input to the FPGA transmitter timestamp recording module, the master node PHY chip working clock The PTP master node PHY chip is input, the FPGA sending end timestamp recording module is connected to the PTP master node PHY chip, and the FPGA sending end timestamp recording module and the master node CPU processing unit transmit PTP messages to each other.

[0007] The device for improving the PTP time synchronization accuracy as described above also includes a PTP slave node, in which a slave node clock module outputs a slave node system clock C′ to a slave node FPGA PLL module; the slave node system clock C′ is multiplied by the slave node FPGA PLL module to obtain a working clock C′ of a receiving end timestamp recording module. 125M and slave node PHY chip working clock C′ 25M , the working clock C′ of the receiving end timestamp recording module 125M Input to the timestamp recording module at the FPGA receiving end, from the node PHY chip working clock C′ 25M Input to the PTP slave node PHY chip; the FPGA receiving end timestamp recording module is connected to the PTP slave node PHY chip, and the FPGA receiving end timestamp recording module and the slave node CPU processing unit transmit PTP messages to each other;

[0008] The PTP slave node PHY chip and the PTP master node PHY chip are connected via an Ethernet link.

[0009] As mentioned above, in the PTP master node, the sending end timestamp recording module working clock The frequency is 125MHz, the master node PHY chip working clock The frequency is 25MHz;

[0010] In the PTP slave node, the receiving end timestamp recording module working clock C' 125M The frequency is 125MHz, the slave node PHY chip working clock C' 25M The frequency is 25MHz;

[0011] The FPGA sending end timestamp recording module is connected to the PTP master node PHY chip using the RGMII interface; the FPGA receiving end timestamp recording module is connected to the PTP slave node PHY chip using the RGMII interface.

[0012] A method for improving PTP time synchronization accuracy, as described above, a device for improving PTP time synchronization accuracy, comprising the following steps:

[0013] Step 1: Build a device for improving the PTP time synchronization accuracy. After the PTP master node and the PTP slave node are powered on, the PTP master node PHY chip and the PTP slave node PHY chip start synchronous Ethernet; the initial value of the FPGA delay chain phase shift number n is 0;

[0014] Step 2, the master node CPU processing unit sends the FPGA delay chain phase shift number n to the FPGA delay chain module; the PTP master node PHY chip sends a Sync message to the PTP slave node PHY chip; in the slave node CPU processing unit, the path delay change D is calculated through the time when the PTP master node PHY chip sends the Sync message and the time when the PTP slave node PHY chip receives the Sync message;

[0015] When the value of the path delay variation D jumps from 0 to equal to the working clock C′ of the timestamp recording module at the receiving end 125M At the pulse period T, the CPU processing unit of the master node records the value of the FPGA delay chain phase shift number n, which is recorded as the compensated FPGA delay chain phase shift number N, and the FPGA delay chain phase shift number n stops increasing;

[0016] In the slave node CPU processing unit, when the path delay variation D does not jump, the value of the flag signal F is 0; when the path delay variation D jumps, the value of the flag signal F is set to 1; the flag signal F is encapsulated into the Delay_Req message, and the PTP slave node PHY chip sends the Delay_Req message to the PTP master node PHY chip, and the FPGA receiving end timestamp recording module records the time when the PTP slave node PHY chip sends the Delay_Req message;

[0017] Step 3: The CPU processing unit of the master node parses the flag signal F in the Delay_Req message, and uses the flag signal F, the average delay α of the FPGA delay chain, and the phase shift number N of the compensated FPGA delay chain to calculate the delay compensation value of the i-th PTP message cycle.

[0018] Step 4: If the PTP delay compensation calibration is not completed:

[0019] The slave node CPU processing unit uses the delay compensation value of the i-th PTP message cycle Calculate the clock deviation Offset of the master and slave nodes;

[0020] when When , the value of the phase shift number n of the FPGA delay chain is increased by 1, and the process returns to step 2;

[0021] when The obtained master-slave node clock deviation Offset value is the compensated master-slave node clock deviation; at this time, the value of the FPGA delay chain phase shift number n in the master node CPU processing unit remains cleared. Assign the value of to the delay fixed compensation value And return to step 2, the PTP delay compensation calibration is completed;

[0022] If the PTP delay compensation calibration is completed:

[0023] The slave node CPU processing unit uses a fixed compensation value for delay Calculate the clock deviation Offset of the master-slave node; keep the value of the FPGA delay chain phase shift number n in the master node CPU processing unit cleared, and return to step 2.

[0024] The above step 1 also includes the following steps:

[0025] After a stable Ethernet link is established between the PTP master node PHY chip and the PTP slave node PHY chip, the PTP time synchronization calibration of the PTP master node and the PTP slave node is completed.

[0026] The calculation of the path delay variation D in step 2 as described above includes the following steps:

[0027] The FPGA sending end timestamp recording module records the time when the PTP master node PHY chip sends the Sync message, which is recorded as timestamp t 1(i) , and the timestamp t 1(i) Encapsulated into the Sync message, the PTP master node PHY chip sends the Sync message to the PTP slave node PHY chip according to the PTP message cycle;

[0028] The timestamp recording module at the FPGA receiving end records the time when the PTP slave node PHY chip receives the Sync message, which is recorded as the timestamp t 2(i) ;

[0029] Parse the timestamp t from the node CPU processing unit 1(i) Then, the master-slave node path delay of the ith PTP message cycle is calculated according to the following formula: MS(i) , and the master-slave node path delay of the i-1th PTP message cycle MS(i-1) Compare:

[0030] delay MS(i) =t 2(i) -t 1(i)

[0031] D=|delayMS(i) -delay MS(i-1) |

[0032] Among them, delay MS(i) is the master-slave node path delay of the ith PTP message cycle, delay MS(i-1) is the master-slave node path delay of the i-1th PTP message cycle, i is a positive integer, indicating the sequence number of the PTP message cycle. When i=1, delay MS(i-1) =0; t 1(i) The timestamp of the moment when the PTP master node PHY chip sends the Sync message in the i-th PTP message period, t 2(i) is the timestamp of the moment when the PTP slave node PHY chip receives the Sync message in the i-th PTP message period, and D is the path delay change.

[0033] As mentioned above, step 3 includes the following steps:

[0034] The PTP master node PHY chip receives the Delay_Req message, and the FPGA transmitter timestamp recording module records the time when the PTP master node PHY chip receives the Delay_Req message, which is recorded as timestamp t 4(i) ; The Delay_Req message is sent to the master node CPU processing unit to parse the flag signal F, and calculate the delay compensation value of the i-th PTP message cycle according to the following formula

[0035]

[0036] in, is the delay compensation value of the ith PTP message cycle, and α is the average delay of the FPGA delay chain;

[0037] The timestamp t 4(i) and the delay compensation value of the ith PTP message cycle Embedded in the Delay_Resp message, the PTP master node PHY chip sends the Delay_Resp message to the PTP slave node PHY chip;

[0038] The PTP slave node PHY chip receives the Delay_Resp message and sends the Delay_Resp message to the slave node CPU processing unit to parse out the timestamp t 4(i) and the delay compensation value of the ith PTP message cycle

[0039] As mentioned above in step 4,

[0040] If the PTP delay compensation calibration is not completed, the master and slave node clock offset Offset is calculated by the following formula:

[0041]

[0042] Where Offset is the clock deviation between the master and slave nodes; t 1(i) The timestamp of the moment when the PTP master node PHY chip sends the Sync message in the i-th PTP message period; t 2(i) The timestamp of the moment when the PTP slave node PHY chip receives the Sync message in the i-th PTP message cycle; t 3(i) The timestamp of the moment when the PTP slave node PHY chip sends the Delay_Req message in the i-th PTP message cycle; t 4(i) The timestamp of the moment when the PTP master node PHY chip receives the Delay_Req message in the i-th PTP message period, is the delay compensation value of the i-th PTP message cycle;

[0043] If the PTP delay compensation calibration is completed, the master and slave node clock deviation Offset is calculated by the following formula:

[0044]

[0045] Compared with the prior art, the present invention has the following beneficial effects:

[0046] The present invention aims at a main factor affecting the PTP time synchronization accuracy, that is, the uncertain delay introduced in the process of establishing a link of a PTP master-slave synchronous Ethernet link, which leads to low synchronization accuracy. By introducing an FPGA delay chain module, the average delay of an FPGA delay chain in the FPGA delay chain module is determined by the FPGA delay chain characteristics, and a master node CPU processing unit is used to generate a variable FPGA delay chain phase shift number, thereby obtaining the uncertain delay, and then being able to compensate for the uncertain delay in the process of establishing a 1000Base-T Ethernet link, thereby being able to improve the PTP master-slave time synchronization accuracy to a certain extent. BRIEF DESCRIPTION OF THE DRAWINGS

[0047] Figure 1 A module diagram of a device for improving PTP time synchronization accuracy.

[0048] Among them: 1—master node CPU processing unit; 2—FPGA delay chain module; 3—master node FPGA PLL module; 4—FPGA sending end timestamp recording module; 5—PTP master node PHY chip; 6—master node clock module, generally a rubidium clock or a constant temperature crystal oscillator; 7—PTP slave node PHY chip; 8—FPGA receiving end timestamp recording module; 9—slave node FPGA PLL module; 10—slave node clock module; 11—slave node CPU processing unit, generally a rubidium clock or a constant temperature crystal oscillator;

[0049] C—Master node system clock, input clock provided by the master node clock module;

[0050] C * —Phase-shifted clock, which is the clock of the master node system clock after being delayed by the FPGA delay chain module;

[0051] —The working clock of the timestamp recording module at the sending end is obtained by multiplying the phase-shifted clock by the master node FPGA PLL module;

[0052] —The working clock of the master node PHY chip is obtained by multiplying the phase-shifted clock by the master node FPGA PLL module;

[0053] C′—slave node system clock, which is the input clock provided by the slave node clock module;

[0054] C′ 125M —The working clock of the timestamp recording module at the receiving end is obtained by multiplying the slave node system clock by the slave node FPGA PLL module;

[0055] C′ 25M —The slave node PHY chip working clock is obtained by multiplying the slave node system clock through the slave node FPGA PLL module.

[0056] Figure 2 A schematic diagram of a method for improving PTP time synchronization accuracy.

[0057] Figure 3 The figure is a schematic diagram of the PTP message cycle end-to-end single-step mode delay request-response mechanism. DETAILED DESCRIPTION

[0058] In order to facilitate those skilled in the art to understand and apply the present invention, the present invention is further described in detail below in conjunction with embodiments. It should be understood that the embodiments described herein are only used to illustrate and explain the present invention and are not used to limit the present invention.

[0059] Example 1

[0060] like Figure 1As shown, the present invention provides a device for improving the PTP time synchronization accuracy, including a PTP master node and a PTP slave node, wherein the PTP master node includes a master node CPU processing unit 1, an FPGA delay chain module 2, a master node FPGA PLL module 3, an FPGA sending end timestamp recording module 4, a PTP master node PHY chip 5 and a master node clock module 6, and the PTP slave node includes a PTP slave node PHY chip 7, an FPGA receiving end timestamp recording module 8, a slave node FPGA PLL module 9, a slave node clock module 10 and a slave node CPU processing unit 11.

[0061] The FPGA delay chain module 2, the master node FPGA PLL module 3, the FPGA sending end timestamp recording module 4, the FPGA receiving end timestamp recording module 8, and the slave node FPGA PLL module 9 are all implemented based on FPGA.

[0062] The connection relationship of the above components is as follows:

[0063] In this example, the master node clock module 6 provides the PTP master node with a master node system clock C with a frequency of 10 MHz, and the master node system clock C can also be other frequencies; the master node system clock C is input to the FPGA delay chain module 2; the master node CPU processing unit 1 generates the FPGA delay chain phase shift number n, and the FPGA delay chain phase shift number n is input to the FPGA delay chain module 2; the FPGA delay chain module 2 generates the phase shift clock C according to the FPGA delay chain phase shift number n and the master node system clock C * ; Phase shift clock C * The working clock of the sending end timestamp recording module is 125MHz after being tripled by the master node FPGA PLL module. and the master node PHY chip operating clock frequency is 25MHz The sending end timestamp records the working clock of the module Input to the FPGA sending end timestamp recording module 4, the main node PHY chip working clock Input to the PTP master node PHY chip 5; the FPGA sending end timestamp recording module 4 is connected to the PTP master node PHY chip 5 through the RGMII interface, the FPGA sending end timestamp recording module 4 is connected to the master node CPU processing unit 1, and the FPGA sending end timestamp recording module 4 and the master node CPU processing unit 1 transmit PTP messages to each other;

[0064] In this example, the slave node clock module 10 provides the PTP slave node with a slave node system clock C' with a frequency of 10MHz. The slave node system clock C' can also be other frequencies. The slave node system clock C' is multiplied by 9 times by the slave node FPGA PLL module to obtain the receiving end timestamp recording module working clock C' with a frequency of 125MHz. 125M and the slave node PHY chip working clock C′ with a frequency of 25MHz 25M , the working clock C′ of the receiving end timestamp recording module 125M Input to the FPGA receiving end timestamp recording module 8, from the node PHY chip working clock C' 25M Input to the PTP slave node PHY chip 7; the FPGA receiving end timestamp recording module 8 is connected to the PTP slave node PHY chip 7 through the RGMII interface, the FPGA receiving end timestamp recording module 8 is connected to the slave node CPU processing unit 11, and the FPGA receiving end timestamp recording module 8 and the slave node CPU processing unit 11 transmit PTP messages to each other;

[0065] The PTP master node PHY chip 5 and the PTP slave node PHY chip 7 are connected via an Ethernet link.

[0066] After the PTP master node and the PTP slave node are powered on, the PTP master node PHY chip 5 and the PTP slave node PHY chip 7 start synchronous Ethernet, thereby establishing a link through the Ethernet link. After the Ethernet link establishes a stable link and completes the PTP time synchronization calibration, the master node CPU processing unit 1 generates the FPGA delay chain phase shift number n, which is a non-negative integer, indicating the number of phase shift steps of the FPGA delay chain module 2 to the master node system clock C. Each increase of the FPGA delay chain phase shift number n by 1 indicates an increase in the average delay amount α of an FPGA delay chain, and the FPGA delay chain phase shift number n controls the FPGA delay chain module 2 to shift the master node system clock C. After the PTP slave node PHY chip 7 successfully receives data from the Ethernet link, it will automatically output the slave node receiving valid signal (RX_DV), so the phase shift of the master node system clock C eventually causes the PTP slave node PHY chip 7 to output the slave node receiving valid signal (RX_DV) phase shift. The phase shift accuracy depends on the characteristics of the FPGA delay chain of the FPGA delay chain module 2. The phase shift accuracy is measured by the average delay α of each FPGA delay chain. The total phase shift is obtained by multiplying the average delay α of each FPGA delay chain by the FPGA delay chain phase shift number n. Since the PTP slave node only records the working clock C′ of the module at the receiving end timestamp 125M The rising edge of the timestamp is used, and due to the uncertain delay introduced by the Ethernet link establishment process, the slave node receives the valid signal (RX_DV) relative to the receiving end timestamp recording module working clock C′125M There is an uncertain delay; when the value of the FPGA delay chain phase shift number n gradually increases from zero, the phase of the effective signal received from the node will be relative to the working clock C′ of the receiving end timestamp recording module 125M The phase lag moves, and there is a value of the FPGA delay chain phase shift number n, so that the phase of the effective signal received by the slave node is relative to the working clock C′ of the receiving end timestamp recording module 125M The amount of phase lag shift is equal to the uncertain delay generated during the Ethernet link establishment process. The initial value of the FPGA delay chain phase shift number n is 0. During the PTP delay compensation calibration period, for each PTP message cycle:

[0067] The master node CPU processing unit 1 sends the FPGA delay chain phase shift number n to the FPGA delay chain module 2; the PTP master node PHY chip 5 sends the Sync message to the PTP slave node PHY chip 7; the slave node CPU processing unit 11 calculates the path delay change D through the time when the PTP master node PHY chip 5 sends the Sync message and the time when the PTP slave node PHY chip 7 receives the Sync message;

[0068] When the value of the path delay variation D jumps from 0 to equal to the working clock C′ of the timestamp recording module at the receiving end 125M At the pulse period T, the CPU processing unit 1 of the master node records the value of the FPGA delay chain phase shift number n, which is recorded as the compensated FPGA delay chain phase shift number N, and the FPGA delay chain phase shift number n stops increasing;

[0069] In the slave node CPU processing unit 11, when there is no jump in the path delay variation D, the value of the flag signal F is 0; when there is a jump in the path delay variation D, the value of the flag signal F is set to 1, and the flag signal F is encapsulated into the Delay_Req message, and the PTP slave node PHY chip 7 sends the Delay_Req message to the PTP master node PHY chip 5, and the FPGA receiving end timestamp recording module 8 records the time when the PTP slave node PHY chip 7 sends the Delay_Req message;

[0070] The CPU processing unit 1 of the master node parses the flag signal F in the Delay_Req message, and uses the flag signal F, the average delay α of the FPGA delay chain, and the phase shift number N of the compensated FPGA delay chain to calculate the delay compensation value of the i-th PTP message cycle Delay compensation value;

[0071] If the PTP delay compensation calibration is not completed: the slave node CPU processing unit 11 uses the delay compensation value of the i-th PTP message cycle Calculate the clock deviation Offset of the master and slave nodes;

[0072] when When , the value of the phase shift number n of the FPGA delay chain is increased by 1, and the process returns to step 2;

[0073] when When , the obtained master-slave node clock deviation Offset value is the compensated master-slave node clock deviation, and the value of the FPGA delay chain phase shift number n in the master node CPU processing unit 1 remains cleared; Assign the value of to the delay fixed compensation value And return to step 2, the PTP delay compensation calibration is completed;

[0074] If the PTP delay compensation calibration is completed: the slave node CPU processing unit 11 uses the delay fixed compensation value Calculate the master-slave node clock deviation Offset; keep the value of the FPGA delay chain phase shift number n in the master node CPU processing unit 1 cleared, and return to step 2.

[0075] Among them, during the calibration period, the period at which the master node CPU processing unit 1 sends the FPGA delay chain phase shift number n to the FPGA delay chain module 2 is consistent with the PTP message period, and the FPGA delay chain phase shift number n increases successively with each PTP message period.

[0076] Example 2

[0077] A method for improving PTP time synchronization accuracy, using a device for improving PTP time synchronization accuracy described in Example 1, comprises the following steps:

[0078] Step 1: construct a device for improving PTP time synchronization accuracy as described in Example 1.

[0079] Wherein, after connecting the components in the device for improving the PTP time synchronization accuracy described in Example 1, and after the PTP master node and the PTP slave node are powered on, the PTP master node PHY chip 5 and the PTP slave node PHY chip 7 start synchronous Ethernet; after a stable Ethernet link is established between the PTP master node PHY chip 5 and the PTP slave node PHY chip 7, the PTP time synchronization calibration of the PTP master node and the PTP slave node is completed; the initial value of the FPGA delay chain phase shift number n is set to 0;

[0080] The PTP master node communicates with the PTP slave node. During the PTP delay compensation calibration period, for each PTP message cycle, perform the following operations according to steps 2 to 4:

[0081] Step 2, the CPU processing unit 1 of the master node sends the FPGA delay chain phase shift number n to the FPGA delay chain module 2;

[0082] The FPGA delay chain module 2 performs phase shifting on the master node system clock C output by the master node clock module 6 according to the average delay amount α of the FPGA delay chain and the phase shift number n of the FPGA delay chain, and converts the phase shifted clock C * Output to the master node FPGA PLL module 3;

[0083] The FPGA sending end timestamp recording module 4 records the time when the PTP master node PHY chip 5 sends the Sync message, which is recorded as timestamp t 1(i) , and the timestamp t 1(i) Encapsulated into the Sync message, the PTP master node PHY chip 5 sends the Sync message to the PTP slave node PHY chip 7 according to the PTP message period;

[0084] The FPGA receiving end timestamp recording module 8 records the time when the PTP slave node PHY chip 7 receives the Sync message, which is recorded as timestamp t 2(i) ;

[0085] The slave node CPU processing unit 11 parses the timestamp t 1(i) Then, the master-slave node path delay of the ith PTP message cycle is calculated according to the following formula: MS(i) , and the master-slave node path delay of the i-1th PTP message cycle MS(i-1) Compare:

[0086] delay MS(i) =t 2(i) -t 1(i)

[0087] D=|delay MS(i) -delay MS(i-1) |

[0088] Among them, delay MS(i) is the master-slave node path delay of the ith PTP message cycle, delay MS(i-1) is the master-slave node path delay of the i-1th PTP message cycle; i is a positive integer, indicating the sequence number of the PTP message cycle. When i=1, delay MS(i-1) =0; t 1(i) is the timestamp of the moment when the PTP master node PHY chip 5 sends the Sync message in the i-th PTP message period, t 2(i) is the timestamp of the moment when the PTP slave node PHY chip 7 receives the Sync message in the i-th PTP message cycle, and D is the change in path delay, which is equal to the absolute value of the change in the master-slave node path delay of the i-th PTP message cycle relative to the master-slave node path delay of the i-1-th PTP message cycle.

[0089] The initial value of the path delay variation D is 0. When the phase shift number n of the FPGA delay chain gradually increases from zero, the phase of the valid signal (RX_DV) received from the node will lag behind the working clock C' of the receiving end timestamp recording module 125M in terms of phase. Until there is a moment when the value of the path delay variation D jumps from 0 to equal the pulse period T of the working clock C' of the receiving end timestamp recording module 125M At this time, the main node CPU processing unit 1 records the value of the phase shift number n of the FPGA delay chain, denoted as the compensated FPGA delay chain phase shift number N. In this embodiment, a 1000Base-T Ethernet link is selected, and the corresponding working clock C' of the receiving end timestamp recording module 125M is 125 MHz. Therefore, the pulse period of the working clock C' of the receiving end timestamp recording module here 125M is 8 ns. After the path delay variation D jumps, the flag bit signal F is set to 1 in the slave node CPU processing unit 11, otherwise the flag bit signal F is set to 0. If the flag bit signal F is 1, the increment of the phase shift number n of the FPGA delay chain is stopped, and then the flag bit signal F is encapsulated into the Delay_Req message, and then the Delay_Req message is sent from the PTP slave node PHY chip 7 to the PTP master node PHY chip 5. The FPGA receiving end timestamp recording module 8 records the moment when the PTP slave node PHY chip 7 sends the Delay_Req message, denoted as the timestamp t 3(i) .

[0090] Step 3: The PTP master node PHY chip 5 receives the Delay_Req message, and the FPGA sending end timestamp recording module 4 records the moment when the PTP master node PHY chip 5 receives the Delay_Req message, denoted as the timestamp t 4(i) . The Delay_Req message is sent to the main node CPU processing unit 1 and the flag bit signal F is parsed out, and the delay compensation for the i-th PTP message period is calculated according to the following formula If F is 0, then let be 0.

[0091]

[0092] where is the delay compensation value for the i-th PTP message period, α is a constant representing the average delay of the FPGA delay chain, which is determined by the characteristics of the FPGA delay chain itself; theoretically, the values of α and N should satisfy α * N < T; T is the pulse period of the working clock C' of the receiving end timestamp recording module 125M .

[0093] Timestamp t 4(i) and the delay compensation value for the i-th PTP message period Embedded in the Delay_Resp message, the PTP master node PHY chip 5 sends the Delay_Resp message to the PTP slave node PHY chip 7;

[0094] The PTP slave node PHY chip 7 receives the Delay_Resp message, and sends the Delay_Resp message to the slave node CPU processing unit 11 to parse out the timestamp t 4(i) and the delay compensation value of the ith PTP message cycle

[0095] Step 4: If the PTP delay compensation calibration is not completed:

[0096] The delay compensation value of the i-th PTP message cycle The master-slave node clock deviation Offset is compensated and brought into the PTP protocol. The master-slave node clock deviation Offset is calculated in the slave node CPU processing unit 11, and the master-slave node clock deviation Offset can be calculated by the following formula:

[0097]

[0098] Where Offset is the clock deviation of the master and slave nodes; i represents the sequence number of the PTP message cycle; t 1(i) The timestamp of the moment when the PTP master node PHY chip 5 sends the Sync message in the i-th PTP message period; t 2(i) The timestamp of the moment when the PTP slave node PHY chip 7 receives the Sync message in the i-th PTP message cycle; t 3(i) The timestamp of the moment when the PTP slave node PHY chip 7 sends the Delay_Req message in the i-th PTP message cycle; t 4(i) The timestamp of the moment when the PTP master node PHY chip 5 receives the Delay_Req message in the i-th PTP message period; is the delay compensation value of the ith PTP message cycle,

[0099] when When , the value of the phase shift number n of the FPGA delay chain is increased by 1, and the process returns to step 2;

[0100] when hour, It is equal to the uncertain delay amount generated during the establishment of the Ethernet link. The corresponding master-slave node clock deviation Offset value is the compensated master-slave node clock deviation. The value of the FPGA delay chain phase shift number n in the master node CPU processing unit 1 remains cleared. Assign the value of to the delay fixed compensation value And return to step 2, the PTP delay compensation calibration is completed;

[0101] If PTP delay compensation calibration is completed: Delay fixed compensation value The master-slave node clock deviation Offset is compensated and brought into the PTP protocol. The master-slave node clock deviation Offset is calculated in the slave node CPU processing unit 11. The master-slave node clock deviation Offset can be calculated by the following formula:

[0102]

[0103] The value of the phase shift number n of the FPGA delay chain in the CPU processing unit 1 of the master node remains cleared, and returns to step 2.

[0104] It should be noted that the specific embodiments described in the present invention are merely examples of the spirit of the present invention. Those skilled in the art may make various modifications or additions to the specific embodiments described or replace them in similar ways, but they will not deviate from the spirit of the present invention or exceed the scope defined by the attached claims.

Claims

1. A device for improving PTP time synchronization accuracy, comprising a PTP master node, characterized in that: The master node CPU processing unit (1) in the PTP master node inputs the FPGA delay chain phase shift number n into the FPGA delay chain module (2); the master node clock module (6) inputs the master node system clock C into the FPGA delay chain module (2); the FPGA delay chain module (2) generates a phase shift clock C according to the FPGA delay chain phase shift number n and the master node system clock C. * ; Phase shift clock C * The working clock of the sending end timestamp recording module is obtained by frequency multiplication by the master node FPGA PLL module (3). And the master node PHY chip working clock The sending end timestamp records the working clock of the module Input to the FPGA sending end timestamp recording module (4), the master node PHY chip working clock The PTP message is input to the PTP master node PHY chip (5), the FPGA sending end timestamp recording module (4) is connected to the PTP master node PHY chip (5), and the FPGA sending end timestamp recording module (4) and the master node CPU processing unit (1) mutually transmit the PTP message. The PTP slave node is also included. The slave node clock module (10) in the PTP slave node outputs a slave node system clock C′ to a slave node FPGA PLL module (9); the slave node system clock C′ is frequency-multiplied by the slave node FPGA PLL module (9) to obtain a receiving end timestamp recording module working clock C1′ 25M and slave node PHY chip working clock C2′ 5M , the working clock of the receiving end timestamp recording module C1′ 25M Input to the FPGA receiving end timestamp recording module (8), from the node PHY chip working clock C2' 5M Input to the PTP slave node PHY chip (7); the FPGA receiving end timestamp recording module (8) is connected to the PTP slave node PHY chip (7), and the FPGA receiving end timestamp recording module (8) and the slave node CPU processing unit (11) mutually transmit PTP messages; The PTP slave node PHY chip (7) and the PTP master node PHY chip (5) are connected via an Ethernet link.

2. A device for improving PTP time synchronization accuracy according to claim 1, characterized in that: In the PTP master node, the sending end timestamp recording module working clock The frequency is 125MHz, the master node PHY chip working clock The frequency is 25MHz; In the PTP slave node, the receiving end timestamp recording module working clock C1′ 25M The frequency is 125MHz, the slave node PHY chip working clock C2' 5M The frequency is 25MHz; The FPGA sending end timestamp recording module (4) is connected to the PTP master node PHY chip (5) using an RGMII interface; the FPGA receiving end timestamp recording module (8) is connected to the PTP slave node PHY chip (7) using an RGMII interface.

3. A method for improving PTP time synchronization accuracy, using the device for improving PTP time synchronization accuracy as described in claim 1, characterized in that: The following steps are involved: Step 1: constructing the device for improving the PTP time synchronization accuracy, after the PTP master node and the PTP slave node are powered on, the PTP master node PHY chip (5) and the PTP slave node PHY chip (7) start synchronous Ethernet; The initial value of the phase shift number n of the FPGA delay chain is 0; Step 2, the master node CPU processing unit (1) sends the FPGA delay chain phase shift number n to the FPGA delay chain module (2); the PTP master node PHY chip (5) sends a Sync message to the PTP slave node PHY chip (7); in the slave node CPU processing unit (11), the path delay variation D is calculated based on the time when the PTP master node PHY chip (5) sends the Sync message and the time when the PTP slave node PHY chip (7) receives the Sync message; When the value of the path delay variation D jumps from 0 to the value equal to the working clock C1′ of the timestamp recording module at the receiving end 25M At the pulse period T, the CPU processing unit (1) of the master node records the value of the FPGA delay chain phase shift number n, which is recorded as the compensated FPGA delay chain phase shift number N, and the FPGA delay chain phase shift number n stops increasing; In the slave node CPU processing unit (11), when the path delay variation D does not jump, the value of the flag signal F is 0; when the path delay variation D jumps, the value of the flag signal F is set to 1; the flag signal F is encapsulated into a Delay_Req message, and the PTP slave node PHY chip (7) sends the Delay_Req message to the PTP master node PHY chip (5), and the FPGA receiving end timestamp recording module (8) records the time when the PTP slave node PHY chip (7) sends the Delay_Req message; Step 3: The CPU processing unit (1) of the master node parses the flag signal F in the Delay_Req message, and calculates the delay compensation value of the i-th PTP message cycle using the flag signal F, the average delay amount α of the FPGA delay chain, and the phase shift number N of the compensated FPGA delay chain. Step 4: If the PTP delay compensation calibration is not completed: The slave node CPU processing unit (11) uses the delay compensation value of the i-th PTP message cycle Calculate the master-slave node clock offset Offset; when When , the value of the phase shift number n of the FPGA delay chain is increased by 1, and the process returns to step 2; when When the master-slave node clock deviation Offset value is obtained, the master-slave node clock deviation after compensation is obtained; at this time, the FPGA delay chain phase shift number n value in the master node CPU processing unit (1) remains cleared. Assign the value of to the delay fixed compensation value And return to step 2, the PTP delay compensation calibration is completed; If the PTP delay compensation calibration is completed: The slave node CPU processing unit (11) uses a delay fixed compensation value Calculate the master-slave node clock deviation Offset; keep the value of the FPGA delay chain phase shift number n in the master node CPU processing unit (1) cleared, and return to step 2.

4. A method for improving PTP time synchronization accuracy according to claim 3, characterized in that: The step 1 also includes the following steps: After a stable Ethernet link is established between the PTP master node PHY chip (5) and the PTP slave node PHY chip (7), the PTP time synchronization calibration of the PTP master node and the PTP slave node is completed.

5. A method for improving PTP time synchronization accuracy according to claim 4, characterized in that: Calculating the path delay variation D in step 2 includes the following steps: The FPGA sending end timestamp recording module (4) records the time when the PTP master node PHY chip (5) sends the Sync message, which is recorded as timestamp t 1(i) , and the timestamp t 1(i) Encapsulated into a Sync message, the PTP master node PHY chip (5) sends the Sync message to the PTP slave node PHY chip (7) according to the PTP message cycle; The FPGA receiving end timestamp recording module (8) records the time when the PTP slave node PHY chip (7) receives the Sync message, which is recorded as timestamp t 2(i) ; The timestamp t is parsed from the node CPU processing unit (11) 1(i) Then, the master-slave node path delay of the ith PTP message cycle is calculated according to the following formula: MS(i) , and the master-slave node path delay of the i-1th PTP message cycle MS(i-1) Compare: delay MS(i) =t 2(i) -t 1(i) D=|delay MS(i) -delay MS(i-1) | Among them, delay MS(i) is the master-slave node path delay of the ith PTP message cycle, delay MS(i-1) is the master-slave node path delay of the i-1th PTP message cycle, i is a positive integer, indicating the sequence number of the PTP message cycle. When i=1, delay MS(i-1) =0; t 1(i) is the timestamp of the moment when the PTP master node PHY chip (5) sends the Sync message in the i-th PTP message period, t 2(i) is the timestamp of the moment when the PTP slave node PHY chip (7) receives the Sync message in the i-th PTP message cycle, and D is the path delay change.

6. A method for improving PTP time synchronization accuracy according to claim 5, characterized in that: The step 3 comprises the following steps: The PTP master node PHY chip (5) receives the Delay_Req message, and the FPGA transmitting end timestamp recording module (4) records the time when the PTP master node PHY chip (5) receives the Delay_Req message, which is recorded as timestamp t 4(i) The Delay_Req message is sent to the master node CPU processing unit (1) to parse the flag signal F, and calculate the delay compensation value of the i-th PTP message cycle according to the following formula: in, is the delay compensation value of the ith PTP message cycle, and α is the average delay of the FPGA delay chain; The timestamp t 4(i) and the delay compensation value of the i-th PTP message cycle Embedded in the Delay_Resp message, the PTP master node PHY chip (5) sends the Delay_Resp message to the PTP slave node PHY chip (7); The PTP slave node PHY chip (7) receives the Delay_Resp message and sends the Delay_Resp message to the slave node CPU processing unit (11) to parse out the timestamp t 4(i) and the delay compensation value of the i-th PTP message cycle 7. A method for improving PTP time synchronization accuracy according to claim 6, characterized in that: In step 4, If the PTP delay compensation calibration is not completed, the master and slave node clock offset Offset is calculated by the following formula: Where Offset is the clock deviation between the master and slave nodes; t 1(i) The timestamp of the moment when the PTP master node PHY chip (5) sends the Sync message in the i-th PTP message period; t 2(i) The timestamp of the moment when the PTP slave node PHY chip (7) receives the Sync message in the i-th PTP message cycle; t 3(i) The timestamp of the moment when the PTP slave node PHY chip (7) sends the Delay_Req message in the i-th PTP message cycle; t 4(i) is the timestamp of the moment when the PTP master node PHY chip (5) receives the Delay_Req message in the i-th PTP message period, is the delay compensation value of the i-th PTP message cycle; If the PTP delay compensation calibration is completed, the master and slave node clock deviation Offset is calculated by the following formula: