CN110176973B - Method, system, computer device and storage medium for clock synchronization - Google Patents

Method, system, computer device and storage medium for clock synchronization Download PDF

Info

Publication number
CN110176973B
CN110176973B CN201910413972.6A CN201910413972A CN110176973B CN 110176973 B CN110176973 B CN 110176973B CN 201910413972 A CN201910413972 A CN 201910413972A CN 110176973 B CN110176973 B CN 110176973B
Authority
CN
China
Prior art keywords
network node
clock
message
instant
sync
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN201910413972.6A
Other languages
Chinese (zh)
Other versions
CN110176973A (en
Inventor
黄廉真
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Solid High Tech Co.,Ltd.
Original Assignee
GOOGOL TECHNOLOGY (SHENZHEN) Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by GOOGOL TECHNOLOGY (SHENZHEN) Ltd filed Critical GOOGOL TECHNOLOGY (SHENZHEN) Ltd
Priority to CN201910413972.6A priority Critical patent/CN110176973B/en
Publication of CN110176973A publication Critical patent/CN110176973A/en
Application granted granted Critical
Publication of CN110176973B publication Critical patent/CN110176973B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04JMULTIPLEX COMMUNICATION
    • H04J3/00Time-division multiplex systems
    • H04J3/02Details
    • H04J3/06Synchronising arrangements
    • H04J3/0635Clock or time synchronisation in a network
    • H04J3/0638Clock or time synchronisation among nodes; Internode synchronisation
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04JMULTIPLEX COMMUNICATION
    • H04J3/00Time-division multiplex systems
    • H04J3/02Details
    • H04J3/06Synchronising arrangements
    • H04J3/0635Clock or time synchronisation in a network
    • H04J3/0638Clock or time synchronisation among nodes; Internode synchronisation
    • H04J3/0647Synchronisation among TDM nodes
    • H04J3/065Synchronisation among TDM nodes using timestamps

Abstract

The present application relates to a method, system, computer device and storage medium for clock synchronization. The method comprises the steps that a port initiated by an adjacent connected network node is initialized, so that transmission delay and relative clock deviation between adjacent network nodes are determined, further, a synchronization process can be completed on a data link layer, and therefore any network node can initiate a synchronous message.

Description

Method, system, computer device and storage medium for clock synchronization
Technical Field
The present application relates to the field of communications technologies, and in particular, to a method, a system, a computer device, and a storage medium for clock synchronization.
Background
With the development of communication technology, data transmission speed is faster and faster, and the requirement for clock synchronization is higher and higher. While the traditional IEEE1588 defines synchronization between two devices, the synchronization process is generally completed by one step and one step under the master (requiring intervention of a CPU in the master).
However, with the development of industrial ethernet, the device system is formed by organically interconnecting a plurality of network industrial modules with specific functions through ethernet, and because industrial applications have their particularity and require that communication has the characteristics of rapidness, real-time performance, synchronization, reliability and the like, the conventional synchronization method of IEEE1588 is not suitable for a system formed by interconnecting a plurality of network industrial modules.
Disclosure of Invention
In view of the above, it is necessary to provide a method, a network node, a system, a computer device and a storage medium for effectively realizing clock synchronization of modules in a system, aiming at the synchronization problem of the system in which a plurality of network industrial modules are interconnected.
In order to achieve the above object, in one aspect, an embodiment of the present application provides a method for clock synchronization, where the method includes:
any network node receives a SYNC message sent by a previous network node through an Ethernet forward transmission link, wherein the SYNC message carries an instant clock of the previous network node for sending the message;
the network node adjusts the local clock of the network node according to the link transmission delay and the relative clock deviation which are acquired in advance and are between the network node and the previous network node and the instant clock of the message sent by the previous network node;
and the network node sequentially forwards the SYNC messages to the next adjacent network node, and updates the instant clock in the SYNC messages according to the instant time of receiving the messages and the instant time of sending the messages, wherein the updated instant clock of the SYNC messages is used for indicating the next network node to adjust the corresponding local clock.
In one embodiment, after the network node adjusts the local clock of the network node according to the link transmission delay and the relative clock offset between the network node and the previous network node, which are obtained in advance, and the instant clock at which the previous network node sends the packet, the method further includes: determining the clock deviation of a preset clock of the system and a local clock adjusted by the network node according to the clock deviation; if the clock deviation is zero, the synchronization of the network nodes is finished, otherwise, the clock deviation is utilized to adjust the crystal oscillator frequency of the network nodes by adopting a closed-loop feedback control method so as to enable the clock deviation to be zero.
In one embodiment, before any network node receives a SYNC message sent by an adjacent previous network node through an ethernet forward transmission link, the method further includes: after the system is powered on, any network node and the adjacent network node mutually initiate an OFFSET message, and link transmission delay and relative clock deviation between the network node and the adjacent network node are determined according to a timestamp carried in the OFFSET message.
In one embodiment, determining link transmission delay and relative clock bias between network nodes connected adjacently according to the timestamp carried in the OFFSET message includes: any network node receives an OFFSET message sent by the previous adjacent network node through a forward transmission link of the Ethernet, wherein the OFFSET message carries the instant time T1 when the previous adjacent network node sends the message, and the network node records the time T2 for receiving the OFFSET message; the network node returns a feedback message according to the OFFSET message, wherein the feedback message carries the instant time T3 when the network node sends the feedback message; the network node receives a following message sent by the previous network node according to the OFFSET message, wherein the following message carries the instant time T4 when the previous network node receives the OFFSET RESP message; the network node determines the link transmission delay and relative clock bias with the last network node that is adjacent according to T1, T2, T3, and T4.
In one embodiment, the network node adjusts a local clock of the network node according to a link transmission delay and a relative clock offset which are acquired in advance and between the network node and a previous network node, and an instant clock of a message sent by the previous network node, including: the network node calculates a local clock according to the link transmission delay and the relative clock deviation between the network node and the previous network node and the instant clock of the message sent by the previous network node; and the network node adjusts the local clock according to the calculation result.
In one embodiment, a network node sequentially forwards a SYNC message to a next network node, and updates an instant clock in the SYNC message according to a time of an instant of receiving the message and a time of an instant of sending the message, including: the network node calculates the instant clock of the network node for forwarding the SYNC message according to the calculation result of the local clock, the instant time of receiving the message and the instant time of sending the message; and the network node modifies the instant clock of the SYNC message according to the calculation result and forwards the SYNC message.
In a second aspect, an embodiment of the present application further provides a network node, including:
the SYNC message receiving module is used for receiving a SYNC message sent by the previous adjacent network node through a forward transmission link of the Ethernet, wherein the SYNC message carries an instant clock of the message sent by the previous network node;
the first synchronous adjustment module is used for adjusting a local clock according to the link transmission delay and the relative clock deviation between the first synchronous adjustment module and the last network node which are acquired in advance and the instant clock of the message sent by the last network node;
and the SYNC message forwarding module is used for forwarding the SYNC messages to the next adjacent network node in sequence and updating the instant clock of the SYNC messages according to the instant time of receiving the messages and the instant time of sending the messages, wherein the updated instant clock of the SYNC messages is used for indicating the next network node to adjust the corresponding local clock.
In a third aspect, an embodiment of the present application further provides a system for clock synchronization, including a plurality of sequentially interconnected network nodes for clock synchronization as described above.
In a fourth aspect, the present application further provides a computer device, including a memory and a processor, where the memory stores a computer program, and the processor implements the steps of the method when executing the computer program.
In a fifth aspect, the present application further provides a computer-readable storage medium, on which a computer program is stored, where the computer program, when executed by a processor, implements the steps of the method as described above.
According to the clock synchronization method, the network nodes, the system, the computer equipment and the storage medium, any network node receives the synchronous message of the last network node which is connected adjacently, completes the synchronization of the local clock according to the synchronous message, the transmission delay and the relative clock deviation, forwards the message to the next adjacent network node and modifies the message under the condition of considering the data forwarding delay, and further enables the message to be transmitted all the way, so that the synchronization of the system which is interconnected with a plurality of network nodes is realized, the problem that the data is easily influenced by unreliable factors to generate larger errors due to the fact that the data is transmitted on a physical medium is solved through synchronization on a data link layer, and the synchronization precision is improved.
Drawings
FIG. 1 is a diagram of an embodiment of an application environment for a method of clock synchronization;
FIG. 2 is a flow diagram illustrating a method for clock synchronization in one embodiment;
FIG. 3 is a schematic diagram of link transmission between adjacent network nodes in one embodiment;
FIG. 4 is a schematic diagram of link transmission between adjacent network nodes in another embodiment;
FIG. 5 is a schematic diagram of link transmission between adjacent network nodes in yet another embodiment;
FIG. 6 is a diagram illustrating link transmission within a network node, according to one embodiment;
FIG. 7 is a flowchart illustrating a method for clock synchronization in accordance with another embodiment;
FIG. 8 is a schematic diagram of an embodiment employing closed loop feedback control adjustment;
FIG. 9 is a diagram illustrating link transmission between a plurality of network nodes in an exemplary embodiment;
FIG. 10 is a block diagram of a network node in one embodiment;
FIG. 11 is a diagram illustrating an internal structure of a computer device in one embodiment.
Detailed Description
In order to make the objects, technical solutions and advantages of the present application more apparent, the present application is described in further detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative of the present application and are not intended to limit the present application.
The traditional IEEE1588 defines synchronization between two devices, which is usually completed under the control of the master CPU, that is, the synchronization process is implemented at the physical layer, and data transmitted on the physical medium is difficult to avoid errors caused by various unreliable factors, resulting in large errors in synchronization.
Based on this, the embodiment of the present application provides a clock synchronization method, which is directly and spontaneously completed on a data link layer, so as to overcome the problem that a large error is generated due to synchronization caused by the fact that data is easily affected by unreliable factors during transmission on a physical medium, and the method for synchronizing on the data link layer can be applied to a system in which a plurality of network industrial modules are interconnected, and has high synchronization accuracy.
The clock synchronization method provided by the application can be applied to a clock synchronization system as shown in fig. 1. The system for clock synchronization comprises a plurality of network nodes (network node a, network node B, network node C and network node D) which are interconnected in sequence, wherein the plurality of network nodes can be network industrial modules with specific functions, such as network drivers, network IO modules, network signal acquisition modules and the like, and specifically can be various motor devices or controller devices and the like. In this embodiment, after the system is powered on and initialized through the network port, any one of the network nodes may initiate a synchronization packet and transmit the synchronization packet all the way through a forward (direction shown by an arrow in fig. 1) transmission link of the ethernet, and each network node performs synchronization when receiving the synchronization packet.
As shown in fig. 2, the clock synchronization method provided in the present application may include the following steps:
in step 202, any network node receives a synchronization SYNC message sent by a previous network node through a forward transmission link of the ethernet. The SYNC message carries an instant clock of a message sent by an adjacent previous network node.
After the system is initialized by the port, each network node enters a working state, and the link transmission Delay and the relative clock offset Toffset between the adjacent connected network nodes can be determined. And any network node (i) can initiate a synchronous message and transmit the synchronous message through one path of a forward transmission link of the Ethernet, and each network node is synchronized when receiving the synchronous message. It should be noted that i is a natural number from 1 to n, and is a number of a network node, and for convenience of description, the forward transmission link serial number of the ethernet is taken as an example in the present embodiment.
And step 204, the network node adjusts the local clock of the network node according to the link transmission delay and the relative clock deviation between the network node and the previous network node which are acquired in advance and the instant clock of the message sent by the previous network node.
In this embodiment, each network node in the system has a Local clock Local, and assuming that the Local clock of a certain network node (0) is Local, and it receives a synchronization packet SYNC initiated by a previous network node (i.e., a reference network node), the link transmission Delay between the network node (0) and the reference network node is Delay (0), the relative clock offset is Toffset (0), the instant clock of the packet initiated from the reference network node is T _ sys, the Local clock of the packet entering the network node (0) is Local (0), and when the system is synchronized, the Local clock Local (0) of the network node (0) is calculated and adjusted by the following formula:
Local(0)=T_sys+Delay(0)+Toffset(0)。
in step 206, the network node sequentially forwards the SYNC message to the next adjacent network node, and updates the instant clock in the SYNC message according to the instant time of receiving the message and the instant time of sending the message.
In this embodiment, if the time of the instant when the network node (0) receives the message is in _ lock (0), the message is sequentially transmitted from the network node (0) to the next network node (1), and the time of the instant when the network node (0) transmits out is out _ lock (0), then the forwarding delay Delta of the data should be considered. The forwarding delay Delta is a time interval when data enters a data link layer of the network node from the PHY and is then sent to the PHY from the data link layer. As shown in FIG. 3, Delta is the total delay of the data from P1 to P2. Although the data forwarding delay is an indeterminate value, this value is measurable for each forwarding. For example, the forwarding delay Delta (0) for the network node (0) is out _ lock (0) -in _ lock (0).
Therefore, when the network node (0) forwards the packet, it modifies the forwarded packet SYNC according to the forwarding delay Delta (0), i.e. updates the instantaneous clock in the SYNC packet to T _ sys (0), and then there is T _ sys (0) which is Local (0) + Delta (0). Therefore, for any network node (i), when the SYNC message is forwarded, the instant clock in the modified message is T _ sys (i) ═ local (i) + delta (i), where delta (i) ═ out _ lock (i) -in _ lock (i).
When the network node (1) receives the updated SYNC message, the Local clock Local (1) of the network node (1) can be adjusted according to the following relation:
Local(1)=T_sys(0)+Delay(1)+Toffset(1)。
this gives:
Local(i)=T_sys(i-1)+Delay(i)+Toffset(i)。
in addition, the network node (1) can also sequentially forward the SYNC messages to the next adjacent network node (2) according to the same principle as the step 206, and the instant clock in the messages is modified according to the method during forwarding, so that the messages are transmitted all the way until the messages are lost; alternatively, the message may be returned to the network node that initiated the synchronization according to the transmission direction shown in fig. 1.
According to the clock synchronization method, any network node receives the synchronization message of the last network node which is connected adjacently, completes the synchronization of the local clock according to the synchronization message, the transmission delay and the relative clock deviation, forwards the message to the next adjacent network node and modifies the message under the condition of considering the data forwarding delay, and further enables the message to be transmitted all the way, so that the synchronization of a system which is interconnected with a plurality of network nodes is realized, and through the synchronization on a data link layer, the problem that the transmission of data on a physical medium is easily influenced by unreliable factors, the synchronization generates larger errors is solved, and the synchronization precision is improved.
In one embodiment, before any network node receives a SYNC message sent by an adjacent previous network node through an ethernet forward transmission link, the method further includes: after the system is powered on, any network node and the adjacent connected network node mutually initiate OFFSET OFFSET messages, and link transmission delay and relative clock deviation between the network node and the adjacent connected network node are determined according to the time stamp carried in the OFFSET messages.
Specifically, the link transmission delay between network nodes includes the transmission delay of PHY (Physical layer) and the total time of data transmission in the communication medium. As shown in fig. 4, the link transmission delay (B) between the network node B and the network node a refers to the time from P0 to P1, and generally, the physical transmission delay can be approximately considered to be constant in the operation of the whole system.
After the system is powered on, each network node is in an idle state, two ports of each network node are in an initial state, and two network nodes which are connected adjacently on line can mutually and actively initiate an OFFSET message to initialize the ports so as to calculate link transmission Delay and relative clock OFFSET Toffset between the adjacent network nodes. As shown in fig. 5, a network node a and a network node B are connected adjacently, where the network node a starts an OFFSET message to the network node B through a P1 point, the OFFSET message carries a time T1 at the instant of sending the message, the network node B receives the OFFSET message through a P2 point at a time T2, and returns a feedback message of the OFFSET to the network node a through a P3 at a time T3, where the feedback message of the OFFSET carries T3 and T4, the network node a receives the feedback message of the OFFSET through a P4 at a time T4, and returns a following message, and the receiving time T4 is recorded in the following message. After the above-mentioned complete process, the port initialization is completed.
In this embodiment, the link transmission delay between two directly interconnected network nodes can be measured by using the method of IEEE 1588. As shown in FIG. 5, T1, T2, T3 and T4 can be obtained from P1-P2-P3-P4. Where T1, T4 are timestamps of the network node A clock domain, and T2, T3 are timestamps of the network node B clock domain. While for fig. 6, there is a network device X on the line, if the delay of data through the device is fixed, it can be equivalent to a long line delay, and thus it can be categorized as fig. 5.
Assuming that the relative clock offset of the network node B before the network node a is toffset (B) and the transmission delay of the physical link is delay (B), the following relationship is given:
T2=T1+Delay(B)+Toffset(B);
T3=T2-Delay(B)+Toffset(B);
by calculation, the following results are obtained:
Delay(B)=((T4-T1)-(T3-T2))/2;
Toffset(B)=((T2+T3)-(T1+T4))/2。
it should be noted that Toffset (B) has a physical meaning that a network node B leads a power-on deviation of a network node a, that is, a clock deviation of a node to be synchronized with respect to a synchronization node (i.e., a reference node) is Toffset, if the time of the node to be synchronized is advanced, Toffset is a positive number, otherwise, Toffset is a negative number.
In one embodiment, as shown in fig. 7, after the step 206, the method for clock synchronization of the present application may further include the following steps:
step 702, determining the clock deviation of the preset clock of the system and the adjusted local clock of the network node according to the two clocks.
In a network system, the default clock (T _ gobal _ sys) of the system is generated by a crystal oscillator with frequency T _ gobal _ freq, and for any network node (i), its local (i) is generated by a crystal oscillator with local T _ local _ freq (i), and there may be a certain deviation T _ err _ freq (i) between the crystal oscillator frequencies. Therefore, when no adjustment is made, the error T _ err (i) between T _ gobal _ sys and local (i) becomes larger as time goes up.
Step 704, determining whether the clock deviation is zero, if yes, ending the synchronization of the current network node, otherwise, executing step 706.
Step 706, the crystal oscillator frequency of the current network node is adjusted by using the clock offset and adopting a closed-loop feedback control method, so that the clock offset is zero.
In step 708, if the clock offset is zero, the synchronization of the current network node is finished.
In this embodiment, step 708 may be executed to end the synchronization process for the current network node (i) by determining whether the offset clock t _ err (i) between the two is zero, and if so, it indicates that there is no offset between the two.
If it is determined by calculation that the deviation clock t _ err (i) between the two is not zero, it indicates that a certain deviation exists between the two, therefore, in this embodiment, a closed-loop feedback control method as shown in fig. 8 may be adopted to adjust the crystal oscillator frequency t _ local _ freq (i) of the network node (i), so that the deviation t _ err _ freq (i) of the crystal oscillator frequency between the two is zero, that is, t _ err (i) is zero, so as to implement self-adjustment of the network node (i) in the synchronization process, thereby further improving the synchronization accuracy.
Specifically, since local (i) is T _ sys (i-1) + delay (i) + toffset (i), T _ err (i) is T _ gobal _ sys-T _ sys (i-1) -toffset (i) when delay (i) is not considered. Therefore, in this embodiment, t _ err (i) can be determined according to known data only by calculating the size of toffset (i).
In one embodiment, as shown in fig. 9, the method of the present application is further described by taking a system in which 3 network nodes are sequentially interconnected (transmission lines for reverse transmission are omitted in the figure), wherein it is assumed that the network node a is a reference network node, that is, the network node a actively initiates a SYNC message. In the initialization process, for the network node B, the link transmission delay between the network node B and the last network node a connected adjacently is delay (B), and the relative clock offset is toffset (B); for network node C, the link transmission delay between it and the last network node B connected to it is delay (C), and the relative clock offset is toffset (C).
If the network node a sends a synchronization message from the point P0 at time T0, the message includes transmission delay (B) and relative clock offset toffset (B) of the network node a and the network node B, and the instant clock at which the network node a sends the message is T _ sys (a).
The synchronization packet arrives at the network node B at time T1, and the network node B considers that the local clock local (B) at this time should be T _ sys (a) which overlaps the time after the link transmission delay (B) and the relative clock offset toffset (B) of the network node a and the network node B, that is, local (B) ═ T _ sys (a) + delay (B) + toffset (B). The network node B adjusts the local clock according to the local clock (B) calculated by the synchronous message, so as to realize the synchronization with the network node A. Meanwhile, the method of fig. 7 may also be adopted to adjust the crystal oscillator frequency t _ local _ freq (B) of the network node (B), thereby implementing self-adjustment in the synchronization process and further improving the synchronization precision.
The synchronization message is forwarded to the network node C at time T2 in the network node B with a time delay of T2-T1. Therefore, the network node B modifies the relevant information T _ sys (B) in the message again while forwarding the synchronization message, and simultaneously superimposes the forwarding delay. T _ sys (b) ═ local (b) + delta (b), where delta (b) ═ T2-T1, is substituted into the above formula, T _ sys (b) ═ T _ sys (a) + delay (b) + toffset (b) + delta (b).
After receiving the synchronization packet at time T3, the network node C may obtain local (C) ═ T _ sys (B) + delay (C) + toffset (C) in a similar manner to the network node B.
Substituting the formula then: local (c) ═ T _ sys (a) + delay (b) + toffset (b) + delta (b) + delay (c) + toffset (c).
The network node C may also adjust the local clock according to the local clock (C) calculated by the synchronization packet, so as to achieve synchronization with the network node a. Meanwhile, the method of fig. 7 may also be adopted to adjust the crystal oscillator frequency t _ local _ freq (C) of the network node (C), so as to achieve self-adjustment in the synchronization process and further improve the synchronization precision.
For the network node C, after synchronization is completed, it may drop the synchronization packet, or return the synchronization packet to the originating network node a according to the forward transmission link of the ethernet, thereby completing synchronization of the whole system.
It should be understood that, although the steps in the flowcharts of fig. 2 and 9 are shown in sequence as indicated by the arrows, the steps are not necessarily performed in sequence as indicated by the arrows. The steps are not performed in the exact order shown and described, and may be performed in other orders, unless explicitly stated otherwise. Moreover, at least some of the steps in fig. 2 and 9 may include multiple sub-steps or multiple stages, which are not necessarily performed at the same time, but may be performed at different times, and the order of performing the sub-steps or stages is not necessarily sequential, but may be performed alternately or alternately with other steps or at least some of the sub-steps or stages of other steps.
In one embodiment, as shown in fig. 10, there is provided a network node comprising: a SYNC message receiving module 1001, a first synchronization adjusting module 1002, and a SYNC message forwarding module 1003, wherein:
a SYNC message receiving module 1001, configured to receive a SYNC message sent by an adjacent previous network node through a forward transmission link of an ethernet, where the SYNC message carries an instant clock of the adjacent previous network node sending the message;
a first synchronization adjustment module 1002, configured to adjust a local clock according to a link transmission delay and a relative clock offset between a previous network node and a pre-obtained link transmission delay and a relative clock offset between the previous network node and the previous network node, and an instant clock of a message sent by the previous network node;
the SYNC message forwarding module 1003 is configured to forward SYNC messages to a next adjacent network node in sequence, and update an instant clock in the SYNC message according to an instant time of receiving a message and an instant time of sending the message, where the updated instant clock of the SYNC message is used to instruct the next network node to adjust a corresponding local clock.
In an embodiment, the network node for clock synchronization may further include a second synchronization adjusting module 1004, configured to determine a clock deviation according to a preset clock and an adjusted local clock; if the clock deviation is zero, the synchronization is finished, otherwise, the clock deviation is utilized to adjust the crystal oscillator frequency by adopting a closed-loop feedback control method so as to enable the clock deviation to be zero.
For the specific definition of the network node, reference may be made to the above definition of the method for clock synchronization, which is not described herein again. The various modules in the above described clock synchronized network node may be implemented in whole or in part by software, hardware, and combinations thereof. The modules can be embedded in a hardware form or independent from a processor in the computer device, and can also be stored in a memory in the computer device in a software form, so that the processor can call and execute operations corresponding to the modules.
In one embodiment, a computer device is provided, which may be a server, and its internal structure diagram may be as shown in fig. 11. The computer device includes a processor, a memory, and a network interface connected by a system bus. Wherein the processor of the computer device is configured to provide computing and control capabilities. The memory of the computer device comprises a nonvolatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program, and a database. The internal memory provides an environment for the operation of an operating system and computer programs in the non-volatile storage medium. The network interface of the computer device is used for communicating with an external terminal through a network connection. The computer program is executed by a processor to implement a method of clock synchronization.
Those skilled in the art will appreciate that the architecture shown in fig. 11 is merely a block diagram of some of the structures associated with the disclosed aspects and is not intended to limit the computing devices to which the disclosed aspects apply, as particular computing devices may include more or less components than those shown, or may combine certain components, or have a different arrangement of components.
In one embodiment, a computer device is provided, comprising a memory and a processor, the memory having a computer program stored therein, the processor implementing the following steps when executing the computer program:
any network node receives a SYNC message sent by a previous network node through an Ethernet forward transmission link, wherein the SYNC message carries an instant clock of the previous network node for sending the message;
the network node adjusts the local clock of the network node according to the link transmission delay and the relative clock deviation which are acquired in advance and are between the network node and the previous network node and the instant clock of the message sent by the previous network node;
and the network node sequentially forwards the SYNC messages to the next adjacent network node, and updates the instant clock in the SYNC messages according to the instant time of receiving the messages and the instant time of sending the messages, wherein the updated instant clock of the SYNC messages is used for indicating the next network node to adjust the corresponding local clock.
In one embodiment, after the network node adjusts the local clock of the network node according to the link transmission delay and the relative clock offset between the network node and the previous network node, which are obtained in advance, and the instant clock at which the previous network node sends the packet, the method further includes: determining the clock deviation of a preset clock of the system and a local clock adjusted by the network node according to the clock deviation; if the clock deviation is zero, the synchronization of the network nodes is finished, otherwise, the clock deviation is utilized to adjust the crystal oscillator frequency of the network nodes by adopting a closed-loop feedback control method so as to enable the clock deviation to be zero.
In one embodiment, before any network node receives a SYNC message sent by an adjacent previous network node through an ethernet forward transmission link, the method further includes: after the system is powered on, any network node and the adjacent network node mutually initiate an OFFSET message, and link transmission delay and relative clock deviation between the network node and the adjacent network node are determined according to a timestamp carried in the OFFSET message.
In one embodiment, determining link transmission delay and relative clock bias between network nodes connected adjacently according to the timestamp carried in the OFFSET message comprises: any network node receives an OFFSET message sent by the previous adjacent network node through a forward transmission link of the Ethernet, wherein the OFFSET message carries the instant time T1 when the previous adjacent network node sends the message, and the network node records the time T2 for receiving the OFFSET message; the network node returns a feedback message according to the OFFSET message, wherein the feedback message carries the instant time T3 when the network node sends the feedback message; the network node receives a following message sent by the previous network node according to the OFFSET message, wherein the following message carries the instant time T4 when the previous network node receives the OFFSET RESP message; the network node determines the link transmission delay and relative clock bias with the last network node that is adjacent according to T1, T2, T3, and T4.
In one embodiment, the network node adjusts a local clock of the network node according to a link transmission delay and a relative clock offset which are acquired in advance and are between the network node and a previous network node, and an instant clock of a message sent by the previous network node, including: the network node calculates a local clock according to the link transmission delay and the relative clock deviation between the network node and the previous network node and the instant clock of the message sent by the previous network node; and the network node adjusts the local clock according to the calculation result.
In one embodiment, a network node sequentially forwards a SYNC message to a next network node, and updates an instant clock in the SYNC message according to a time of an instant of receiving the message and a time of an instant of sending the message, including: the network node calculates the instant clock of the network node for forwarding the SYNC message according to the calculation result of the local clock, the instant time of receiving the message and the instant time of sending the message; and the network node modifies the instant clock of the SYNC message according to the calculation result and forwards the SYNC message.
In one embodiment, a computer-readable storage medium is provided, having a computer program stored thereon, which when executed by a processor, performs the steps of:
any network node receives a SYNC message sent by a previous network node through an Ethernet forward transmission link, wherein the SYNC message carries an instant clock of the previous network node for sending the message;
the network node adjusts the local clock of the network node according to the link transmission delay and the relative clock deviation which are acquired in advance and are between the network node and the previous network node and the instant clock of the message sent by the previous network node;
and the network node sequentially forwards the SYNC messages to the next adjacent network node, and updates the instant clock in the SYNC messages according to the instant time of receiving the messages and the instant time of sending the messages, wherein the updated instant clock of the SYNC messages is used for indicating the next network node to adjust the corresponding local clock.
In one embodiment, after the network node adjusts the local clock of the network node according to the link transmission delay and the relative clock offset between the network node and the previous network node, which are obtained in advance, and the instant clock at which the previous network node sends the packet, the method further includes: determining the clock deviation of a preset clock of the system and a local clock adjusted by the network node according to the clock deviation; if the clock deviation is zero, the synchronization of the network nodes is finished, otherwise, the clock deviation is utilized to adjust the crystal oscillator frequency of the network nodes by adopting a closed-loop feedback control method so as to enable the clock deviation to be zero.
In one embodiment, before any network node receives a SYNC message sent by an adjacent previous network node through an ethernet forward transmission link, the method further includes: after the system is powered on, any network node and the adjacent network node mutually initiate an OFFSET message, and link transmission delay and relative clock deviation between the network node and the adjacent network node are determined according to a timestamp carried in the OFFSET message.
In one embodiment, determining link transmission delay and relative clock bias between network nodes connected adjacently according to the timestamp carried in the OFFSET message comprises: any network node receives an OFFSET message sent by the previous adjacent network node through a forward transmission link of the Ethernet, wherein the OFFSET message carries the instant time T1 when the previous adjacent network node sends the message, and the network node records the time T2 for receiving the OFFSET message; the network node returns a feedback message according to the OFFSET message, wherein the feedback message carries the instant time T3 when the network node sends the feedback message; the network node receives a following message sent by the previous network node according to the OFFSET message, wherein the following message carries the instant time T4 when the previous network node receives the OFFSET RESP message; the network node determines the link transmission delay and relative clock bias with the last network node that is adjacent according to T1, T2, T3, and T4.
In one embodiment, the network node adjusts a local clock of the network node according to a link transmission delay and a relative clock offset which are acquired in advance and are between the network node and a previous network node, and an instant clock of a message sent by the previous network node, including: the network node calculates a local clock according to the link transmission delay and the relative clock deviation between the network node and the previous network node and the instant clock of the message sent by the previous network node; and the network node adjusts the local clock according to the calculation result.
In one embodiment, a network node sequentially forwards a SYNC message to a next network node, and updates an instant clock in the SYNC message according to a time of an instant of receiving the message and a time of an instant of sending the message, including: the network node calculates the instant clock of the network node for forwarding the SYNC message according to the calculation result of the local clock, the instant time of receiving the message and the instant time of sending the message; and the network node modifies the instant clock of the SYNC message according to the calculation result and forwards the SYNC message.
It will be understood by those skilled in the art that all or part of the processes of the methods of the embodiments described above can be implemented by hardware instructions of a computer program, which can be stored in a non-volatile computer-readable storage medium, and when executed, can include the processes of the embodiments of the methods described above. Any reference to memory, storage, database, or other medium used in the embodiments provided herein may include non-volatile and/or volatile memory, among others. Non-volatile memory can include read-only memory (ROM), Programmable ROM (PROM), Electrically Programmable ROM (EPROM), Electrically Erasable Programmable ROM (EEPROM), or flash memory. Volatile memory can include Random Access Memory (RAM) or external cache memory. By way of illustration and not limitation, RAM is available in a variety of forms such as Static RAM (SRAM), Dynamic RAM (DRAM), Synchronous DRAM (SDRAM), Double Data Rate SDRAM (DDRSDRAM), Enhanced SDRAM (ESDRAM), Synchronous Link DRAM (SLDRAM), Rambus Direct RAM (RDRAM), direct bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM).
The technical features of the above embodiments can be arbitrarily combined, and for the sake of brevity, all possible combinations of the technical features in the above embodiments are not described, but should be considered as the scope of the present specification as long as there is no contradiction between the combinations of the technical features.
The above-mentioned embodiments only express several embodiments of the present application, and the description thereof is more specific and detailed, but not construed as limiting the scope of the invention. It should be noted that, for a person skilled in the art, several variations and modifications can be made without departing from the concept of the present application, which falls within the scope of protection of the present application. Therefore, the protection scope of the present patent shall be subject to the appended claims.

Claims (10)

1. A method for clock synchronization, wherein the method is applied to a system in which a plurality of network nodes are sequentially interconnected, the network nodes are network industrial modules, and the method is completed at a data link layer, and the method comprises:
any network node receives a synchronous SYNC message sent by an adjacent previous network node through an Ethernet forward transmission link, wherein the SYNC message carries an instant clock of the previous network node for sending the message;
the network node adjusts a local clock of the network node according to a link transmission delay and a relative clock deviation which are obtained in advance and are between the network node and the last network node, and an instant clock of the last network node for sending the message, wherein the relative clock deviation refers to a power-on time deviation of the network node relative to the last network node;
the network node sequentially forwards the SYNC messages to the next adjacent network node, and updates the instant clock in the SYNC messages according to the instant time for receiving the messages and the instant time for sending the messages, wherein the updated instant clock of the SYNC messages is used for indicating the next network node to adjust the corresponding local clock;
after the network node adjusts the local clock of the network node according to the link transmission delay and the relative clock deviation between the network node and the previous network node, which are obtained in advance, and the instant clock of the previous network node sending the packet, the method further includes: determining the clock deviation of a preset clock of the system and a local clock adjusted by the network node according to the clock deviation; and if the clock deviation is zero, finishing the synchronization of the network nodes, otherwise, adjusting the crystal oscillator frequency of the network nodes by using the clock deviation and adopting a closed-loop feedback control method so as to enable the clock deviation to be zero.
2. The method according to claim 1, wherein before the receiving, by the any network node, the SYNC packet sent by the previous network node through the ethernet forward transmission link, the method further comprises:
after the system is powered on, any network node and the adjacent connected network node mutually initiate OFFSET OFFSET messages, and link transmission delay and relative clock deviation between the network node and the adjacent connected network node are determined according to the time stamp carried in the OFFSET messages.
3. The method for clock synchronization according to claim 2, wherein the determining link transmission delay and relative clock bias between the network nodes connected adjacently according to the timestamp carried in the OFFSET message comprises:
the arbitrary network node receives an OFFSET message sent by an adjacent previous network node through a forward transmission link of the Ethernet, the OFFSET message carries the instant time T1 when the adjacent previous network node sends the message, and the network node records the time T2 for receiving the OFFSET message;
the network node returns a feedback message according to the OFFSET message, wherein the feedback message carries the instant time T3 when the network node sends the feedback message;
the network node receives a following message sent by an adjacent previous network node according to the OFFSET message, wherein the following message carries the instant time T4 when the previous network node receives the feedback message;
the network node determines link transmission delay and relative clock bias with an adjacent last network node according to the T1, T2, T3 and T4.
4. The method of claim 1, wherein the network node adjusts a local clock of the network node according to a pre-obtained link transmission delay with a previous network node, a relative clock offset, and an instant clock of the previous network node sending the packet, and the method comprises:
the network node calculates a local clock according to the link transmission delay and the relative clock deviation between the network node and the previous network node and the instant clock of the previous network node for sending the message;
and the network node adjusts the local clock according to the calculation result.
5. The method according to claim 4, wherein the network node sequentially forwards the SYNC message to a next network node adjacent to the network node, and updates an instant clock in the SYNC message according to a time of an instant of receiving the message and a time of an instant of sending the message, including:
the network node calculates the instant clock of the network node for forwarding the SYNC message according to the calculation result of the local clock, the instant time for receiving the message and the instant time for sending the message;
and the network node modifies the instant clock of the SYNC message according to the calculation result and forwards the SYNC message.
6. The method according to claim 1, wherein the previous network node is any network node in the system, and the SYNC packet is sent and transmitted through a forward transmission link over ethernet after the system is powered on and initialized through a network port.
7. A network node, wherein the network node is a network industry module, and wherein clock synchronization of the network node is performed at a data link layer, the network node comprising:
the SYNC message receiving module is used for receiving a SYNC message sent by an adjacent previous network node through a forward transmission link of the Ethernet, wherein the SYNC message carries an instant clock of the previous network node for sending the message;
a first synchronization adjustment module, configured to adjust a local clock according to a link transmission delay and a relative clock offset that are obtained in advance between the first synchronization adjustment module and a previous network node, and an instant clock of the previous network node sending the packet, where the relative clock offset is a power-on time offset of the network node relative to the previous network node; the first synchronization adjustment module is specifically configured to: determining the clock deviation of a preset clock of the system and a local clock adjusted by the network node according to the clock deviation; if the clock deviation is zero, finishing the synchronization of the network nodes, otherwise, adjusting the crystal oscillator frequency of the network nodes by using the clock deviation and adopting a closed-loop feedback control method so as to enable the clock deviation to be zero;
and the SYNC message forwarding module is used for forwarding the SYNC messages to the next adjacent network node in sequence, updating the instant clock of the SYNC messages according to the instant time for receiving the messages and the instant time for sending the messages, and the updated instant clock of the SYNC messages is used for indicating the next network node to adjust the corresponding local clock.
8. A system for clock synchronization comprising a plurality of sequentially interconnected network nodes according to claim 7.
9. A computer device comprising a memory and a processor, the memory storing a computer program, wherein the processor implements the steps of the method of any one of claims 1 to 6 when executing the computer program.
10. A computer-readable storage medium, on which a computer program is stored, which, when being executed by a processor, carries out the steps of the method of any one of claims 1 to 6.
CN201910413972.6A 2019-05-17 2019-05-17 Method, system, computer device and storage medium for clock synchronization Active CN110176973B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201910413972.6A CN110176973B (en) 2019-05-17 2019-05-17 Method, system, computer device and storage medium for clock synchronization

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201910413972.6A CN110176973B (en) 2019-05-17 2019-05-17 Method, system, computer device and storage medium for clock synchronization

Publications (2)

Publication Number Publication Date
CN110176973A CN110176973A (en) 2019-08-27
CN110176973B true CN110176973B (en) 2020-12-04

Family

ID=67691517

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201910413972.6A Active CN110176973B (en) 2019-05-17 2019-05-17 Method, system, computer device and storage medium for clock synchronization

Country Status (1)

Country Link
CN (1) CN110176973B (en)

Families Citing this family (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111404632B (en) * 2020-03-24 2022-08-23 上海银欣高新技术发展股份有限公司 Offline timing method, medium, offline server and offline timing system
CN113556221A (en) * 2020-04-23 2021-10-26 西门子股份公司 Method and device for timing in redundant network
CN111555834B (en) * 2020-04-30 2021-10-01 北京邮电大学 Clock synchronization method and system of wireless network based on IEEE1588 protocol
CN112600641A (en) * 2020-12-31 2021-04-02 深圳市英特瑞半导体科技有限公司 Network equipment time synchronization method, device, equipment and storage medium
CN115348660B (en) * 2022-10-20 2022-12-20 石家庄科林电气股份有限公司 Electric energy meter time synchronization method, electric energy meter and storage medium

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101895384A (en) * 2010-07-07 2010-11-24 中兴通讯股份有限公司 Method and device for implementing boundary clock
CN103404054A (en) * 2011-03-29 2013-11-20 阿尔卡特朗讯 Method, apparatus and system for time distribution in a telecommunications network
CN106921456A (en) * 2015-12-24 2017-07-04 中国科学院沈阳自动化研究所 Multi-hop wireless backhaul network time synchronization error compensation method based on PTP protocol
CN107196724A (en) * 2017-05-05 2017-09-22 深圳市汇川技术股份有限公司 A kind of multirobot control synchronization system and method based on distributed clock

Family Cites Families (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
EP2424136B1 (en) * 2010-08-24 2013-10-02 Siemens Aktiengesellschaft System and method for time synchronization in a communication network
CN102332973B (en) * 2011-09-07 2014-07-09 上海交通大学 Real-time communication and clock synchronization method of chain network
US9665121B2 (en) * 2014-12-11 2017-05-30 Khalifa University Of Science, Technology And Research Method and devices for time transfer using peer-to-peer transparent clocks
US10313041B2 (en) * 2016-06-10 2019-06-04 Apple Inc. Determination of accuracy of a chain of clocks
CN108377265B (en) * 2018-02-07 2020-10-16 南京南瑞继保电气有限公司 Real-time synchronization method for control protection distributed system in power system

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101895384A (en) * 2010-07-07 2010-11-24 中兴通讯股份有限公司 Method and device for implementing boundary clock
CN103404054A (en) * 2011-03-29 2013-11-20 阿尔卡特朗讯 Method, apparatus and system for time distribution in a telecommunications network
CN106921456A (en) * 2015-12-24 2017-07-04 中国科学院沈阳自动化研究所 Multi-hop wireless backhaul network time synchronization error compensation method based on PTP protocol
CN107196724A (en) * 2017-05-05 2017-09-22 深圳市汇川技术股份有限公司 A kind of multirobot control synchronization system and method based on distributed clock

Also Published As

Publication number Publication date
CN110176973A (en) 2019-08-27

Similar Documents

Publication Publication Date Title
CN110176973B (en) Method, system, computer device and storage medium for clock synchronization
US11444747B2 (en) Measure and improve clock synchronization using combination of transparent and boundary clocks
US10158441B1 (en) Securing time between nodes
CN113273105B (en) Method for time synchronization of a plurality of auxiliary devices of an autonomous vehicle, computer device and storage medium
KR101152161B1 (en) Distributed synchronization method and system
JP5050057B2 (en) Time-triggered network and clock synchronization method for clusters in the network
JP2004186877A (en) Wireless access network system, wireless communication method, synchronous server, and node unit
US11965971B2 (en) Systems for timestamping events on edge devices
US20220190945A1 (en) Method, Apparatus, and System for Selecting Clock Source, and Storage Medium
US20220248353A1 (en) Synchronization method and device
CN111148211A (en) Clock synchronization method and device, computer equipment and storage medium
JP2007529163A (en) Network node
US9991981B2 (en) Method for operating a node of a communications network, a node and a communications network
JP6010802B2 (en) Time synchronization system, time synchronization method, slave node, and computer program
WO2020164100A1 (en) Clock synchronization method and device
JP6684409B1 (en) Time synchronization system
JP7143798B2 (en) Time synchronization method, communication device, time synchronization method
US20170117980A1 (en) Time synchronization for network device
JP6085864B2 (en) Time synchronization system, time synchronization method, slave node, and computer program
TWI421667B (en) Method of clock synchronization and internet system using the same
CN105025566A (en) Time synchronization method and system
WO2023236048A1 (en) Method and network device for ptp clock synchronization
CN116800366A (en) Clock synchronization method, device and storage medium
CN117544266A (en) Error compensation method for enhancing time synchronization port
JP2021100180A (en) Network system and control device

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant
CP01 Change in the name or title of a patent holder

Address after: Room W211, second floor, west block, Shenzhen Hong Kong industry university research base, South District, high tech Zone, Nanshan District, Shenzhen City, Guangdong Province

Patentee after: Solid High Tech Co.,Ltd.

Address before: Room W211, second floor, west block, Shenzhen Hong Kong industry university research base, South District, high tech Zone, Nanshan District, Shenzhen City, Guangdong Province

Patentee before: GOOGOL TECHNOLOGY (SHENZHEN) Ltd.

CP01 Change in the name or title of a patent holder