Clock synchronization method of time sensitive network
Through the link delay and clock frequency ratio between the main clock server and the clock client in the computer-mounted network, the time phase error is calculated and adjusted, the problem of insufficient time synchronization accuracy in the prior art is solved, and a higher time synchronization accuracy is achieved.
Patent Information
- Application Number
- CN202411810052.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-10
- Publication Date
- 2025-04-01
- Estimated Expiration
- 2044-12-10
AI Technical Summary
The prior art is difficult to achieve high-precision time synchronization, especially in airborne networks where high real-time deterministic transmission requirements for safety critical levels cannot be met.
By calculating the link delay and clock frequency ratio between the main clock server and the clock client, the time phase error is calculated, and the local clock of the clock client is adjusted according to the error, improving the time synchronization accuracy.
A method to improve the time synchronization accuracy is realized, and the time synchronization accuracy of nodes in the network is effectively improved through compensation correction of logical registers.
Smart Images

Figure CN119743224A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of network communications, and in particular to a clock synchronization method for a time-sensitive network. Background Art
[0002] Time-Sensitive Ethernet is a standardized network technology based on standard Ethernet that provides deterministic data transmission services at the data link layer. With the increasing integration of aircraft, the real-time transmission of key data is required to be higher. Airborne networks involve safety-critical systems such as electromechanical and flight control. Compatible with communication transmissions of different safety criticality levels on a unified airborne network platform, in order to meet the high real-time deterministic transmission requirements of safety criticality levels, higher requirements are placed on the synchronization accuracy of airborne networks.
[0003] For some safety-critical application data, network transmission needs to improve the certainty and real-time performance of its data to meet the certainty and real-time indicators of the application system. Currently, there is no simple and convenient method to achieve high-precision time synchronization. Summary of the invention
[0004] In view of this, an embodiment of the present specification provides a clock synchronization method for a time-sensitive network, so as to achieve the purpose of improving the time synchronization accuracy of the time-sensitive network based on the IEEE802.1AS time synchronization mechanism.
[0005] The embodiments of this specification provide the following technical solutions:
[0006] A clock synchronization method for a time-sensitive network, comprising:
[0007] Calculate the link delay D between the master clock server and the clock client, and calculate the clock frequency ratio r between the clock client and the master clock server based on the link delay D;
[0008] The time phase error offset between the clock client and the master clock server is calculated by link delay D and clock frequency ratio r;
[0009] The second adjustment direction sign_s and the nanosecond adjustment direction sign_ns are calculated by the time phase error offset, and the time phase error of the local clock of the clock client is adjusted by the second adjustment direction sign_s and the nanosecond adjustment direction sign_ns.
[0010] The time offsetPerNsec and the frequency adjustment direction fre_sign required for each 1 nanosecond frequency error are calculated according to the clock frequency ratio r, and the frequency error of the local clock of the clock client is adjusted according to the time offsetPerNsec and the frequency adjustment direction fre_sign required for the 1 nanosecond frequency error.
[0011] Furthermore, the link delay D between the master clock server and the clock client is calculated, including:
[0012] The clock client initiates a time synchronization request, and the master clock server responds to the time synchronization request;
[0013] The clock client obtains the first time T1, the second time T2, the third time T3 and the fourth time T4 through the interaction process of the Pdelay_Req message, the Pdelay_Resp message and the Pdelay_Resp_Follow_Up message in the link delay measurement phase;
[0014] The link delay D between the clock client and the master clock server is calculated based on the first time T1, the second time T2, the third time T3 and the fourth time T4, where the link delay D is
[0015]
[0016] Furthermore, the clock frequency ratio r between the clock client and the master clock server is calculated by the link delay D, including:
[0017] The clock server sends a continuous first synchronization message SYNC_i-1 and a second synchronization message SYNC_i to the clock client, and records the first sending timestamp t1_i-1 and the second sending timestamp t1_i;
[0018] The recording clock client records a first receiving time t2_i-1 of receiving the first synchronization message SYNC_i-1 and a second receiving time t2_i of the second synchronization message SYNC_i;
[0019] The clock frequency ratio r is calculated based on the first sending timestamp t1_i-1, the second sending timestamp t1_i, the first receiving time t2_i-1 and the second receiving time t2_i, where the clock frequency ratio r is
[0020] Furthermore, the time phase error offset between the clock client and the master clock server is calculated by using the link delay D and the clock frequency ratio r, including:
[0021] The master clock server periodically sends SYNC messages and records the sending time T5, fills the sending time T5 into the Follow_up message, and sends it to the clock client;
[0022] The clock client receives the SYNC message and records the receiving time T6;
[0023] The sending time T5 is parsed on the clock client, and the time phase error offset between the clock client and the master clock server is calculated according to the clock frequency ratio r, link delay D, sending time T5 and receiving time T6, where offset = T6-(T5+D)*r.
[0024] Furthermore, the second adjustment direction sign_s and the nanosecond adjustment direction sign_ns are obtained by calculating the time phase error offset, including:
[0025] If the time phase error offset is greater than or equal to 0, the second adjustment direction sign_s is 2, and the nanosecond adjustment direction sign_ns is 1;
[0026] If the time phase error offset is less than 0, the second adjustment direction sign_s is 0, and the nanosecond adjustment direction sign_ns is 0.
[0027] Further, adjusting the time phase error of the local clock of the clock client through the second adjustment direction sign_s and the nanosecond adjustment direction sign_ns includes:
[0028] Adjust the nanosecond value of the local clock according to the nanosecond adjustment direction sign_ns, and determine whether the second carry is required;
[0029] If you need to carry in seconds, adjust the seconds value through the seconds adjustment direction sign_s, and then add 1 second;
[0030] If the second carry is not required, adjust the second value of the local clock through the second adjustment direction sign_s.
[0031] Furthermore, the time offsetPerNsec and the frequency adjustment direction fre_sign required for a 1 nanosecond frequency error are calculated according to the clock frequency ratio r, including:
[0032] Set the second setting value, and calculate the frequency offset fre_offset and the correction direction fre_sign generated between the clock client and the master clock server within one second according to the clock frequency ratio r and the second setting value;
[0033] According to the frequency offset fre_offset, the time offsetPerNsec required for a frequency error of 1 nanosecond is calculated. If the frequency offset fre_offset is not equal to the second set value, the time offsetPerNsec required for a frequency error of 1 nanosecond is 10 9 / fre_offset;
[0034] If the frequency offset fre_offset is equal to the second set value, the time offsetPerNsec required for a 1 nanosecond frequency error is equal to the second set value.
[0035] Further, according to the clock frequency ratio r and the second set value, the frequency offset fre_offset and the correction direction fre_sign generated within one second between the clock client and the master clock server are calculated, including:
[0036] If the clock frequency ratio r is less than 1, the frequency deviation Correction direction fre_sign = 2;
[0037] If the clock frequency ratio r is greater than 1, the frequency deviation Correction direction fre_sign = 1;
[0038] If the clock frequency ratio r is equal to 1, the frequency offset fre_offset=the second set value.
[0039] Furthermore, it also includes:
[0040] A clock synchronization method for a time-sensitive network is periodically executed to achieve synchronization of the time-sensitive network.
[0041] Compared with the prior art, the at least one technical solution adopted in the embodiments of this specification can achieve the following beneficial effects:
[0042] The frequency error between the master clock server and the clock client due to crystal oscillator offset is calculated by using the message transmission during the synchronization process. The frequency error calculated by the software is written into the logic register. The time error introduced by crystal oscillator drift is compensated and corrected within the logic, thereby improving the accuracy of time synchronization. BRIEF DESCRIPTION OF THE DRAWINGS
[0043] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings required for use in the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0044] Figure 1 is a schematic diagram of a clock synchronization method for a time-sensitive network according to an embodiment of the present invention;
[0045] Figure 2 This is a process of clock synchronization using the IEEE802.1AS protocol in an embodiment of the present invention;
[0046] Figure 3 4 is a diagram showing a calculation principle of a clock frequency ratio according to an embodiment of the present invention. DETAILED DESCRIPTION
[0047] The embodiments of the present application are described in detail below with reference to the accompanying drawings.
[0048] It should be noted that, in the absence of conflict, the embodiments and features in the embodiments of the present application can be combined with each other. The present invention will be described in detail below with reference to the accompanying drawings and in combination with the embodiments.
[0049] It is realized through the interaction between the master clock server and the clock client. The frequency ratio between the master clock server and the clock client can be calculated based on the periodic SYNC message. The specific implementation process is as follows: Figure 2 shown.
[0050] The time synchronization algorithm uses the PTP protocol to achieve time synchronization of nodes in the network. The time synchronization process is as follows: Figure 2 shown.
[0051] The clock client uses the frequency error and time phase error between the master clock and the client to compensate and correct these two errors through internal logic. Figure 1 shown.
[0052] A method for improving time synchronization accuracy includes the following steps:
[0053] Step 1: If Figure 2 As shown, the link delay and time phase error between the master clock server and the clock client are calculated according to the IEEE802.1AS protocol. The time synchronization algorithm consists of a master clock server and a clock client. In the protocol cycle, the clock client initiates a time request according to the request response mechanism, and the master clock server responds to the time. According to the interaction process of the Pdelay_Req message, the Pdelay_Resp message, and the Pdelay_Resp_Follow_Up message in the link delay measurement phase, the clock client obtains four times T1-T4, and calculates the link delay D between the master clock server and the master clock server according to formula 1, wherein the first time T1 is the time to send the Pdelay_Req message, the second time T2 is the time to receive the Pdelay_Req message, the third time T3 is the time to send the Pdelay_Resp_Follow_Up message, and the fourth time T4 is the time to send the Pdelay_Resp_Follow_Up message.
[0054] Link delay
[0055] Step 2: The master clock server periodically sends SYNC messages and records the sending time T5, fills the sending time T5 into the Follow_up message, and sends it to the clock client;
[0056] Step 3: The clock client receives the SYNC message and records the receiving time T6;
[0057] Step 4: Figure 3 As shown, the clock frequency ratio r between the clock client and the master clock server can be calculated through the sending and receiving process of two consecutive frames of SYNC messages. The specific process is: the clock server sends consecutive synchronization SYNC messages SYNC_i-1 and SYNC_i to the clock client, and records the sending timestamps t1_i-1 and t1_i, and the clock client records the time t2_i-1 and t2_i of receiving the SYNC_i-1 and SYNC_i messages;
[0058] Step 5. Since the link delay is stable enough, the actual time interval between the difference between the timestamps t1_i-1 and t1_i recorded by the master clock server and the difference between the timestamps t2_i-1 and t2_i recorded by the slave clock is the same from the last synchronization to this synchronization. However, due to the different frequencies, the measured values of the actual time interval by the master clock and the slave clock are inconsistent. Therefore, the master-slave frequency ratio can be calculated based on the measured values, and the clock frequency ratio r with the master clock server can be recorded. Calculation formula 2 is as follows:
[0059] t1_off=t1_i-t1_i-1
[0060] t2_off=t2_i-t2_i-1
[0061]
[0062] Step 6: Figure 2 As shown, after the clock client receives the Follow_up message, it parses the time T5 in the message, and calculates the time phase error offset between the clock client and the master clock server according to formula 3 based on the clock frequency ratio r, link delay D, T5 and T6:
[0063] offset = T6 - (T5 + D) * r (3);
[0064] Step 7: Figure 1 As shown, the clock client assigns the calculated time error offset seconds to offset_s and the nanosecond value to offset_ns, writes the seconds and nanosecond values to the corresponding seconds value module and nanosecond value module through the seconds value read and write interface and the nanosecond value read and write interface respectively, and writes the direction sign_s and nanosecond value adjustment direction sign_ns required for the seconds value adjustment according to the positive and negative values of offset_s and offset_ns:
[0065] If offset>=0:
[0066] sign_s=0x2
[0067] sign_ns=0x1
[0068] else
[0069] sign_s=0x0
[0070] sign_ns = 0x0; (4);
[0071] Step 8: After the time phase error calculated by the clock client is written into the logic, the clock client software writes the value of the time adjustment signal register (initial setting of the host software) adj_enable to indicate that the logic needs to adjust the local clock (client's clock) at this time;
[0072] Step 9: When the logic detects the rising edge of the adj_enable signal (i.e., the value is 1), it indicates that the time phase error adjustment is required at this time, and the logic adjustment state register In_adjust is set to 1 to indicate that it is in the correction state at this time. At the same time, the logic adjusts the second value counter slave_counter_second_48 according to the second value offset_s and the second value adjustment direction sign_s, and adjusts the nanosecond value counter slave_count_ns_32 according to the nanosecond value offset_ns and the nanosecond value adjustment direction sign_ns. The specific method is:
[0073] Nanosecond value adjustment: If sign_ns = 0x0, the nanosecond value counter subtracts the nanosecond value offset_ns. If sign_ns = 0x1, the nanosecond value counter adds the nanosecond value offset_ns. The adjusted nanosecond value is AdjValue_ns. When AdjValue_ns>, that is, greater than 1s, AdjValue_ns = AdjValue_ns-, and AddValue_s is set to 1, indicating that the second is carried.
[0074] Second value module adjustment: if sign_s = 0x0, the second value counter subtracts the second value offset_s; if sign_s = 0x2, the second value counter adds the second value offset_s, and the adjusted second value is AdjValue_s, and the carry of the nanosecond value is added, that is, AdjValue_s = AdjValue_s + AddValue_s;
[0075] Step 10: After the logic adjustment is completed, the logic adjustment status register In_adjust is set to 0, indicating that the time phase error correction is completed;
[0076] Step 11: The clock client calculates the clock frequency ratio r according to step 5, and calculates the frequency offset fre_offset and correction direction fre_sign generated between the clock client and the master clock server within one second according to formula 5.
[0077] If r<1
[0078]
[0079] fre_sign=2;
[0080] else if r>1
[0081]
[0082] fre_sign=1;
[0083] else
[0084] fre_offset = 0x7fffffff (5);
[0085] in, Indicates that the master clock has passed 1s (10 9 ns), the nanosecond time elapsed by the clock client;
[0086] fre_offset indicates the nanosecond value of the difference between the clock client and the clock server in a 1s time interval. When the clock frequency ratio r is equal to 1, that is, the clock frequencies of the clock client and the clock server are consistent and there is no clock frequency error, the value of fre_offset is equal to 0x7fffffff (the second set value), indicating that the clock frequency is not adjusted;
[0087] fre_sign indicates the direction of adjustment. fre_sign = 2 means that the clock client time is faster than the clock server time and needs to be slowed down, that is, the frequency offset is subtracted; fre_sign = 1 means that the clock client time is slower than the clock server time and needs to be accelerated, that is, the frequency offset is increased.
[0088] Step 12: The clock client calculates the time offsetPerNsec required to generate a frequency error of 1 nanosecond according to the fre_offset value and formula 6.
[0089] If fre_offset!=0x7fffffff
[0090] offsetPerNsec= / fre_offset;
[0091] else
[0092] offsetPerNsec = 0x7fffffff; (6);
[0093] Step 13: The clock client software writes the offsetPerNsec value and the adjustment direction fre_sign into the logic register through the nanosecond value read / write interface, and indicates that frequency adjustment is required at this time through the AdjFre_Enable signal;
[0094] Step 14: When the clock client logic detects the rising edge of the AdjFre_Enable signal, it proves that the frequency adjustment is required. Since the internal processing clock of the logic is 200MHZ, the minimum unit of the logic adjustment is 5 nanoseconds. The logic frequency adjustment counter Fre_Count is increased by 1 every offsetPerNsec. When Fre_Count accumulates to 5, the clock client and the main clock server have a frequency offset of 5 nanoseconds. At this time, the logic adjusts the local clock according to the value of fre_sign, that is, when fre_sign=2, the nanosecond value counter is subtracted by 5; when fre_sign=1, the nanosecond value counter is increased by 5.
[0095] Step 15: After the clock client logic has adjusted the clock frequency error, the AdjFre_Enable signal is set to 0 to indicate that the frequency adjustment is now complete;
[0096] Step 16: The master clock server and the clock client periodically execute steps 1-15 to achieve network synchronization.
[0097] The clock synchronization method according to the embodiment of the present invention has the following beneficial effects:
[0098] A method for improving the accuracy of time synchronization is proposed. Based on the IEEE802.1AS protocol, the time deviation of different nodes in the network is calculated through interactive message transmission, and the time deviation is written into the logic register. The time error is adjusted inside the logic to achieve time synchronization of the nodes in the network. At the same time, the frequency error between the master clock server and the clock client due to the crystal oscillator offset is calculated by using the transmission of messages during the synchronization process, and the frequency error calculated by the software is written into the logic register. The time error introduced by the crystal oscillator drift is compensated and corrected inside the logic, thereby improving the accuracy of time synchronization.
[0099] The above is only a specific embodiment of the present invention, and cannot be used to limit the scope of the invention. Therefore, the replacement of equivalent components, or equivalent changes and modifications made according to the scope of protection of the patent of the present invention, should still fall within the scope of this patent. In addition, the technical features of the present invention can be freely combined with each other, with each other, and with each other.
Claims
1. A clock synchronization method for a time-sensitive network, characterized in that: include: Calculating a link delay D between the master clock server and the clock client, and obtaining a clock frequency ratio r between the clock client and the master clock server through the link delay D; The time phase error offset between the clock client and the master clock server is calculated by using the link delay D and the clock frequency ratio r; The second adjustment direction sign_s and the nanosecond adjustment direction sign_ns are calculated by the time phase error offset, and the time phase error of the local clock of the clock client is adjusted by the second adjustment direction sign_s and the nanosecond adjustment direction sign_ns; The time offsetPerNsec and the frequency adjustment direction fre_sign required for each 1 nanosecond frequency error are calculated according to the clock frequency ratio r, and the frequency error of the local clock of the clock client is adjusted according to the time offsetPerNsec and the frequency adjustment direction fre_sign required for the 1 nanosecond frequency error.
2. The clock synchronization method for a time-sensitive network according to claim 1, characterized in that: Calculate the link delay D between the master clock server and the clock client, including: The clock client initiates a time synchronization request, and the master clock server responds to the time synchronization request; The clock client obtains the first time T1, the second time T2, the third time T3 and the fourth time T4 through the interaction process of the Pdelay_Req message, the Pdelay_Resp message and the Pdelay_Resp_Follow_Up message in the link delay measurement phase; The link delay D between the clock client and the master clock server is calculated based on the first time T1, the second time T2, the third time T3 and the fourth time T4, wherein the link delay D is 3. The clock synchronization method for a time-sensitive network according to claim 1, characterized in that: The clock frequency ratio r between the clock client and the master clock server is calculated by using the link delay D, including: The clock server sends a continuous first synchronization message SYNC_i-1 and a second synchronization message SYNC_i to the clock client, and records a first sending timestamp t1_i-1 and a second sending timestamp t1_i; Recording the first receiving time t2_i-1 of the clock client receiving the first synchronization message SYNC_i-1 and the second receiving time t2_i of the second synchronization message SYNC_i; The clock frequency ratio r is calculated based on the first sending timestamp t1_i-1, the second sending timestamp t1_i, the first receiving time t2_i-1 and the second receiving time t2_i, wherein the clock frequency ratio r is 4. The clock synchronization method for a time-sensitive network according to claim 1, characterized in that: The time phase error offset between the clock client and the master clock server is calculated by using the link delay D and the clock frequency ratio r, including: The master clock server periodically sends a SYNC message and records the sending time T5, fills the sending time T5 into a Follow_up message, and sends it to the clock client; The clock client receives the SYNC message and records the receiving time T6; The sending time T5 is parsed on the clock client, and the time phase error offset between the clock client and the master clock server is calculated according to the clock frequency ratio r, the link delay D, the sending time T5 and the receiving time T6, where offset = T6-(T5+D)*r.
5. The clock synchronization method for a time-sensitive network according to claim 1, characterized in that: The second adjustment direction sign_s and the nanosecond adjustment direction sign_ns are obtained by calculating the time phase error offset, including: If the time phase error offset is greater than or equal to 0, the second adjustment direction sign_s is 2, and the nanosecond adjustment direction sign_ns is 1; If the time phase error offset is less than 0, the second adjustment direction sign_s is 0, and the nanosecond adjustment direction sign_ns is 0.
6. The clock synchronization method for a time-sensitive network according to claim 1, characterized in that: Adjusting the time phase error of the local clock of the clock client by the second adjustment direction sign_s and the nanosecond adjustment direction sign_ns includes: Adjust the nanosecond value of the local clock according to the nanosecond adjustment direction sign_ns, and determine whether a second carry is required; If the second increment is required, adjust the second value using the second adjustment direction sign_s, and then add 1 second; If the second carry is not required, the second value of the local clock is adjusted by the second adjustment direction sign_s.
7. The clock synchronization method for a time-sensitive network according to claim 1, characterized in that: The time offsetPerNsec and the frequency adjustment direction fre_sign required for a 1 nanosecond frequency error are calculated according to the clock frequency ratio r, including: Set a second setting value, and calculate the frequency offset fre_offset and the correction direction fre_sign generated between the clock client and the master clock server within one second according to the clock frequency ratio r and the second setting value; According to the frequency offset fre_offset, the time offsetPerNsec required for a frequency error of 1 nanosecond is calculated. If the frequency offset fre_offset is not equal to the second set value, the time offsetPerNsec required for a frequency error of 1 nanosecond is =10 9 / fre_offset; If the frequency offset fre_offset is equal to the second set value, the time offsetPerNsec required for a 1 nanosecond frequency error is equal to the second set value.
8. The clock synchronization method for a time-sensitive network according to claim 7, characterized in that: According to the clock frequency ratio r and the second set value, the frequency offset fre_offset and the correction direction fre_sign generated between the clock client and the master clock server within one second are calculated, including: If the clock frequency ratio r is less than 1, the frequency offset The correction direction fre_sign=2; If the clock frequency ratio r is greater than 1, the frequency offset The correction direction fre_sign=1; If the clock frequency ratio r is equal to 1, the frequency offset fre_offset=the second set value.
9. The clock synchronization method for a time-sensitive network according to any one of claims 1 to 8, characterized in that: Also includes: The clock synchronization method of the time-sensitive network is executed periodically to achieve synchronization of the time-sensitive network.
Citation Information
Patent Citations
Method for ensuring data receiving time integrity
CN114448545A
Self-adaptive master-slave switching time synchronization method and system
CN117614580A
Technologies to compensate for errors in time synchronization due to clock drift
EP4178127A1
Time synchronization method, apparatus, electronic device and vehicle
WO2024174940A1