CN114401067B - Time synchronization method for ring network communication, programmable gate array and ring network communication system - Google Patents

Time synchronization method for ring network communication, programmable gate array and ring network communication system Download PDF

Info

Publication number
CN114401067B
CN114401067B CN202111600620.5A CN202111600620A CN114401067B CN 114401067 B CN114401067 B CN 114401067B CN 202111600620 A CN202111600620 A CN 202111600620A CN 114401067 B CN114401067 B CN 114401067B
Authority
CN
China
Prior art keywords
node device
delay
module
time
message
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
CN202111600620.5A
Other languages
Chinese (zh)
Other versions
CN114401067A (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.)
Zhejiang Supcon Technology Co Ltd
Original Assignee
Zhejiang Supcon Technology Co 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 Zhejiang Supcon Technology Co Ltd filed Critical Zhejiang Supcon Technology Co Ltd
Priority to CN202111600620.5A priority Critical patent/CN114401067B/en
Publication of CN114401067A publication Critical patent/CN114401067A/en
Application granted granted Critical
Publication of CN114401067B publication Critical patent/CN114401067B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

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/0658Clock or time synchronisation among packet nodes
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L12/00Data switching networks
    • H04L12/28Data switching networks characterised by path configuration, e.g. LAN [Local Area Networks] or WAN [Wide Area Networks]
    • H04L12/42Loop networks

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Synchronisation In Digital Transmission Systems (AREA)
  • Small-Scale Networks (AREA)

Abstract

The embodiment of the application provides a time synchronization method for looped network communication, a programmable gate array and a looped network communication system, and relates to the technical field of communication. The method comprises the steps of sending a delay request message to a previous adjacent node device of the slave node device, and recording a first timestamp corresponding to the moment of sending the delay request message; receiving a delay response message sent by the previous adjacent node equipment, and recording a second timestamp corresponding to the moment of receiving the delay response message; determining a link delay between the slave node device and the previous neighboring node device; receiving a synchronous broadcast message broadcast by the master node equipment, and determining a clock offset value between the slave node equipment and the master node equipment; and according to the clock offset value, performing time synchronization on the slave node equipment. The application can complete the PTP processing in the field programmable gate array, and can also enable each message to be exchanged between each adjacent node device only to realize the time synchronization with the host.

Description

Time synchronization method for ring network communication, programmable gate array and ring network communication system
Technical Field
The present application relates to the field of communications technologies, and in particular, to a time synchronization method for ring network communications, a programmable gate array, and a ring network communications system.
Background
Along with the continuous deepening of the integration between industrialization and informatization, the industrial ring network becomes an important component in industrial communication. In the application scene of the industrial control system, the real-time precision requirement on the data communication system is higher, so that how to improve the synchronization precision of the industrial looped network multi-node time synchronization system is one of the important development directions of the industrial looped network.
In the current industrial application, in order to meet the microsecond-level or even nanosecond-level time synchronization precision of the industrial ring network, an accurate time synchronization protocol (Precision Time Protocol, abbreviated as PTP) is the optimal protocol and scheme for time synchronization in the current network. In the prior art, the data transmission based on the PTP protocol can be realized in a software mode or a mode of combining software and hardware. The software mode obtains the time stamp through the network driving layer of the protocol stack, and attaches the time stamp into the message to exchange messages between the host and each slave in the ring network. When the data transmission based on PTP is realized by combining software and hardware, the time stamp is provided by the hardware of the host, and the host attaches the time stamp to the time synchronization instruction of each slave in the ring network, so that the time synchronization of the host and the slave is realized.
However, the load of the host in the ring network for receiving and transmitting the message is increased by using the software mode in the prior art, and the slave farther from the host is reduced in precision due to the complex state of the link, uncontrollable delay and accurate prediction. By using a mode of combining software and hardware in the prior art, as PTP messages are processed by using a software mode, message processing delay is increased, synchronization precision is reduced, and loads of a central processing unit (Central Processing Unit, CPU) are increased.
Disclosure of Invention
The application aims at providing a time synchronization method for looped network communication, a programmable gate array and a looped network communication system, wherein the processing of PTP messages is completed in a field programmable gate array (Field Programmable GATE ARRAY, FPGA), so that the time synchronization between each message and a host can be realized only by exchanging each message between adjacent node devices, and the time synchronization between a slave node and a master node can be realized with high precision, low delay and low load.
Embodiments of the application may be implemented as follows:
In a first aspect, an embodiment of the present application provides a time synchronization method for ring network communication, which is applied to a field programmable gate array in each slave node device in a ring network communication system, where the ring network communication system includes N node devices, the N node devices are connected into a ring network through a transmission medium, the N node devices include 1 master node device and N-1 slave node devices, and each node device in the N node devices includes a field programmable gate array;
The method comprises the following steps:
Sending a delay request message to a previous adjacent node device of the slave node device, and recording a first timestamp corresponding to the moment of sending the delay request message;
Receiving a delay response message sent by the previous adjacent node equipment, and recording a second timestamp corresponding to the moment of receiving the delay response message;
Determining the link delay between the slave node equipment and the previous adjacent node equipment according to the delay time difference, the first time stamp and the second time stamp contained in the delay response message;
Receiving a synchronous broadcast message broadcast by the master node device, and determining a clock offset value between the slave node device and the master node device according to a third timestamp, the link delay and a fourth timestamp, which are contained in the synchronous broadcast message and correspond to the moment when the slave node device receives the synchronous broadcast message, wherein the third timestamp is used for identifying the moment when the master node device sends the synchronous broadcast message;
And according to the clock offset value, carrying out time synchronization on the slave node equipment.
In an optional embodiment, after the time synchronization of the slave node device according to the clock offset value, the method further includes:
Modifying the third timestamp in the synchronous broadcast message to a fifth timestamp;
and forwarding the synchronous broadcast message to a next adjacent node device of the slave node device at the moment corresponding to the fifth timestamp.
In an alternative embodiment, the time synchronization of the slave node device according to the clock offset value includes:
Acquiring a current time value of a clock;
Adding the current time value and the clock offset value to obtain a corrected time value;
and adjusting the time value of the clock to the corrected time value.
In an optional implementation manner, the determining, according to the delay time difference included in the delay response message, the first timestamp and the second timestamp, the link delay between the slave node device and the previous neighboring node device includes:
subtracting the first timestamp from the second timestamp to obtain an end delay;
subtracting the time delay of the end from the time delay time difference to obtain an intermediate time delay;
and halving the intermediate delay to obtain the link delay of the slave node equipment and the previous adjacent node equipment.
In an optional implementation manner, the determining the clock offset value between the slave node device and the master node device according to the third timestamp included in the synchronous broadcast packet, the link delay, and the fourth timestamp corresponding to the time when the slave node device receives the synchronous broadcast packet includes:
adding the third timestamp and the link delay to obtain a time synchronization difference value;
And subtracting the time synchronization difference value from the fourth time stamp to obtain a clock offset value between the slave node equipment and the master node equipment.
In an alternative embodiment, the method further comprises:
receiving a delay request message sent by a next adjacent node device of the slave node device, and recording a sixth timestamp corresponding to the moment of receiving the delay request message;
sending a delay response message to the latter adjacent node equipment, and recording a seventh timestamp corresponding to the time when the delay response message is sent;
The delay response message comprises: a time delay time difference, the time delay time difference being determined by a difference between the seventh time stamp and the sixth time stamp.
In a second aspect, an embodiment of the present application provides a time synchronization device for ring network communication, where the device includes:
And the sending module is used for sending a delay request message to the previous adjacent node equipment of the slave node equipment and recording a first timestamp corresponding to the moment when the delay request message is sent.
And the receiving module is used for receiving the delay response message sent by the previous adjacent node equipment and recording a second timestamp corresponding to the moment of receiving the delay response message.
And the processing module is used for determining the link delay between the slave node equipment and the previous adjacent node equipment according to the delay time difference, the first time stamp and the second time stamp contained in the delay response message.
The processing module is further configured to receive a synchronous broadcast message broadcast by the master node device, and determine a clock offset value between the slave node device and the master node device according to a third timestamp included in the synchronous broadcast message, the link delay, and a fourth timestamp corresponding to a time when the slave node device receives the synchronous broadcast message, where the third timestamp is used to identify a time when the master node device sends the synchronous broadcast message.
The processing module is further configured to perform time synchronization on the slave node device according to the clock offset value.
The processing module is further configured to modify the third timestamp in the synchronous broadcast message to a fifth timestamp; and forwarding the synchronous broadcast message to a next adjacent node device of the slave node device at the moment corresponding to the fifth timestamp.
The processing module is specifically used for acquiring the current time value of the clock; adding the current time value and the clock offset value to obtain a corrected time value; and adjusting the time value of the clock to the corrected time value.
The processing module is specifically further configured to subtract the second timestamp from the first timestamp to obtain an end delay; subtracting the time delay of the end from the time delay time difference to obtain an intermediate time delay; and halving the intermediate delay to obtain the link delay of the slave node equipment and the previous adjacent node equipment.
The processing module is specifically further configured to add the third timestamp to the link delay to obtain a time synchronization difference value; and subtracting the time synchronization difference value from the fourth time stamp to obtain a clock offset value between the slave node equipment and the master node equipment.
The processing module is specifically further configured to receive a delay request packet sent by a next neighboring node device of the slave node device, and record a sixth timestamp corresponding to a time when the delay request packet is received; sending a delay response message to the latter adjacent node equipment, and recording a seventh timestamp corresponding to the time when the delay response message is sent; the delay response message comprises: a time delay time difference, the time delay time difference being determined by a difference between the seventh time stamp and the sixth time stamp.
In a third aspect, an embodiment of the present application provides a field programmable gate array, the field programmable gate array comprising: the device comprises a media access control port module, an analysis module, a delay acquisition module, a synchronization module, a transmission forwarding module, a transmission selection module, a central processing unit interface module and a ring network transmission module;
The medium access control port module is respectively in communication connection with the analysis module and the transmission selection module, the analysis module is respectively in communication connection with the delay acquisition module, the synchronization module, the transmission selection module and the central processing unit interface module, the delay acquisition module is respectively in communication connection with the transmission selection module, the analysis module and the synchronization module, the synchronization module is respectively in communication connection with the transmission forwarding module, the delay acquisition module, the analysis module and the central processing unit interface module, the transmission forwarding module is in communication connection with the transmission selection module, the transmission selection module is respectively in communication connection with the analysis module, the transmission forwarding module, the medium access control port module and the delay acquisition module, the central processing unit interface module is respectively in communication connection with the analysis module, the synchronization module and the ring network transmission module, and the ring network transmission module is respectively in communication connection with the central processing unit interface module and the transmission selection module;
The media access control port module is configured to mutually convert the gigabit independent media interface packet received by the physical layer and the field programmable gate array packet, write a timestamp corresponding to a sending time of the packet to be sent into the packet to be sent, and send the timestamp corresponding to a receiving time of the received packet to the parsing module;
the analysis module is used for filtering and classifying the field programmable gate array message and deleting the ring network label in the ring network data message;
The delay acquisition module is used for generating, transmitting or receiving a delay request message and a delay response message to the corresponding media access control port module, determining the link delay with the previous adjacent node equipment according to the delay request message and the delay response message, and transmitting the link delay to the synchronization module;
the synchronization module is used for performing time synchronization according to the link delay sent by the delay acquisition module and the received synchronous broadcast message;
The sending and forwarding module is configured to send the synchronous broadcast message, the delay request message, and the delay response message to the sending selection module;
The sending selection module is used for sending the synchronous broadcast message, the ring network data message, the delay request message and the delay response message to the media access control port module, and sending a timestamp corresponding to the sending moment of each message to the sending forwarding module and the delay acquisition module;
The central processing unit interface module is used for receiving and sending configuration data to the central processing unit, receiving the ring network data message sent by the central processing unit, sending the ring network data message to the central processing unit and removing the ring network label in the synchronous broadcast message;
and the ring network sending module is used for adding a new ring network label to the ring network data message and the synchronous broadcast message.
In a fourth aspect, an embodiment of the present application provides a node device, including: the field programmable gate array of the previous embodiment, and a central processing unit, wherein the field programmable gate array is communicatively connected to the central processing unit.
In a fifth aspect, an embodiment of the present application provides a ring network communication system, where the system includes: the N node devices are connected into a ring network through a transmission medium, the N node devices comprise 1 master node device and N-1 slave node devices, and each node device in the N node devices comprises a field programmable gate array;
each slave node device is configured to perform time synchronization through the time synchronization method steps of the ring network communication in any one of the foregoing embodiments.
In a sixth aspect, an embodiment of the present application provides a computer readable storage medium, where a computer program is stored, where the computer program, when executed by a processor, implements the steps of the method for time synchronization of ring network communications according to any one of the previous embodiments.
The beneficial effects of the embodiment of the application include, for example:
By adopting the time synchronization method, the programmable gate array and the looped network communication system of the looped network communication, firstly, each slave node determines the link delay with the previous adjacent node by exchanging the delay request message and the delay response message with the previous adjacent node, and determines the clock offset value with the master node equipment by the link delay and the synchronous broadcast message sent by the master node received from the previous adjacent node. Therefore, the slave node only needs to exchange messages with the adjacent node, so that time synchronization with the master node equipment is realized, error of link delay caused by complex link state is reduced, message traffic when time synchronization with the host is performed is reduced, and load of the host is reduced. Secondly, the application realizes PTP-based data transmission in the FPGA and analysis and transmission of each message, and the FPGA has high parallelism, so that the message processing speed and precision can be improved, and the load of the CPU can be reduced.
Drawings
In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings that are needed in the embodiments will be briefly described below, it being understood that the following drawings only illustrate some embodiments of the present application and therefore should not be considered as limiting the scope, and other related drawings may be obtained according to these drawings without inventive effort for a person skilled in the art.
Fig. 1 is a schematic structural diagram of a ring network communication system according to an embodiment of the present application;
Fig. 2 is a schematic diagram of a time synchronization process of a time synchronization method of ring network communication according to an embodiment of the present application;
FIG. 3 is a schematic diagram of a field programmable gate array according to an embodiment of the present application;
Fig. 4 is a flowchart illustrating steps of a method for time synchronization of ring network communication according to an embodiment of the present application;
fig. 5 is a flowchart illustrating another step of a time synchronization method for ring network communication according to an embodiment of the present application;
Fig. 6 is a flowchart illustrating another step of a time synchronization method for ring network communication according to an embodiment of the present application;
fig. 7 is a flowchart illustrating another step of a time synchronization method for ring network communication according to an embodiment of the present application;
fig. 8 is a flowchart illustrating another step of a method for time synchronization of ring network communication according to an embodiment of the present application;
fig. 9 is a flowchart illustrating another step of a time synchronization method for ring network communication according to an embodiment of the present application;
fig. 10 is a schematic structural diagram of a node device according to an embodiment of the present application;
Fig. 11 is a schematic structural diagram of a time synchronization device for ring network communication according to an embodiment of the present application.
Icon: 101-a master node device; 102-a first slave node device; 103-a second slave node device; 104-a third slave node device; 105-a fourth slave node device; 106-a fifth slave node device; 20-a field programmable gate array; 201 a-a first media access control port module; 201 b-a second media access control port module; 202 a-a first parsing module; 202 b-a second parsing module; 203 a-a first delay acquisition module; 203 b-a second delay acquisition module; 204-a synchronization module; 205-a send forwarding module; 206 a-a first transmission selection module; 206 b-a second transmission selection module; 207-a central processor interface module; 208-ring network sending module; 30-a central processing unit; 40 a-a first gigabit independent media interface; 40 b-a second gigabit independent media interface; a 50-ring network communication time synchronization device; 5001-a transmitting module; 5002-a processing module; 5003-a receiving module.
Detailed Description
For the purpose of making the objects, technical solutions and advantages of the embodiments of the present application more apparent, the technical solutions of the embodiments of the present application will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present application, and it is apparent that the described embodiments are some embodiments of the present application, but not all embodiments of the present application. The components of the embodiments of the present application generally described and illustrated in the figures herein may be arranged and designed in a wide variety of different configurations.
Thus, the following detailed description of the embodiments of the application, as presented in the figures, is not intended to limit the scope of the application, as claimed, but is merely representative of selected embodiments of the application. All other embodiments, which can be made by those skilled in the art based on the embodiments of the application without making any inventive effort, are intended to be within the scope of the application.
It should be noted that: like reference numerals and letters denote like items in the following figures, and thus once an item is defined in one figure, no further definition or explanation thereof is necessary in the following figures.
Furthermore, the terms "first," "second," and the like, if any, are used merely for distinguishing between descriptions and not for indicating or implying a relative importance.
It should be noted that the features of the embodiments of the present application may be combined with each other without conflict.
Currently, in industrial processes, a large number of distributed terminal devices connected together by a network are required to be used, and these terminal devices perform work. In this scenario, the real-time accuracy requirement for the data communication system on the terminal device is high, so the importance of the high real-time data communication system in the industrial field is increasingly improved. In the prior art, although various time synchronization algorithms exist, in order to meet microsecond-level or even nanosecond-level time synchronization accuracy of an industrial ring network, PTP is the optimal protocol and scheme for time synchronization in the current network. In the prior art, the data transmission based on the PTP protocol can be realized in a software mode or a mode of combining software and hardware. The main difference between the two modes is that the time stamp in the message is obtained by a network driving layer of a protocol stack in a software mode, and the time stamp is provided by hardware equipment on the terminal equipment in a mode of combining software and hardware.
However, the load of the host in the ring network for receiving and transmitting the message is increased by using the software mode in the prior art, and the slave farther from the host is reduced in precision due to the complex state of the link, uncontrollable delay and accurate prediction. By using the mode of combining software and hardware in the prior art, the PTP is processed by using a software mode, so that the message processing delay is increased, the synchronization precision is reduced, and the load of a CPU is increased.
Based on the above problems, the applicant has studied and proposed a time synchronization method of ring network communication, a programmable gate array and a ring network communication system, in which a slave node can realize time synchronization with a master node device only by exchanging messages with a neighboring node, and the load of a host is reduced. And through realizing PTP-based data transmission in the FPGA, each message is completely analyzed and sent by hardware, so that the message processing speed and precision are improved.
The time synchronization method, the programmable gate array and the ring network communication system for ring network communication provided by the embodiment of the application are explained below by combining a plurality of specific application examples.
Fig. 1 is a schematic structural diagram of a ring network communication system according to an embodiment of the present application, where, as shown in fig. 1, the system includes: and N node devices connected into a ring network through a transmission medium. The N node devices comprise 1 master node device 101 and N-1 slave node devices, each node device in the N node devices respectively comprises a field programmable gate array, and each slave node device is respectively used for performing time synchronization through executing the time synchronization method steps of the ring network communication provided by the embodiment of the application. The following describes the operation principle of the system in detail, taking the system including 1 master node device 101 and 5 slave node devices as an example.
Referring to fig. 1, a black arrow indicates a clockwise propagation path of a synchronous broadcast message sent by the master node device 101, a white arrow indicates a counterclockwise propagation path of a synchronous broadcast message sent by the master node device 101, a horizontal line arrow indicates a propagation path of a delay request message, and a dot arrow indicates a propagation path of a delay response message.
In the embodiment of the present application, when the master node device 101 synchronizes the broadcast messages, the synchronized broadcast messages are simultaneously sent to two neighboring slave node devices, and by way of example, the synchronized broadcast message sent to the fifth slave node device 106 is referred to as a clockwise synchronized broadcast message, the message sent to the first slave node device 102 is referred to as a counterclockwise synchronized broadcast message, and after each slave node device receives the clockwise synchronized broadcast message or the counterclockwise synchronized broadcast message sent by the previous neighboring slave node device, the message is forwarded to the next neighboring slave node device. The previous neighboring node device of a certain slave node device refers to a node device that sends a synchronous broadcast message to a certain slave node device when the synchronous broadcast message is transmitted in the system. For example, when the third slave node device 104 forwards the clockwise synchronization broadcast message to the second slave node device 103, the third slave node device 104 is the previous neighboring slave node device of the second slave node device 103. And when the second slave node device 103 forwards the counterclockwise synchronous broadcast message to the third slave node device 104, the second slave node device 103 is the previous neighboring slave node device of the third slave node device 104. Similarly, the next adjacent node device of a certain slave node device refers to a node device that receives a certain slave node device and sends a synchronous broadcast message when the synchronous broadcast message is transmitted in the system. For example, when the second slave node device 103 forwards the clockwise synchronization broadcast message to the first slave node device 102, the first slave node device 102 is the next adjacent slave node device to the second slave node device 103. And when the second slave node device 103 forwards the counterclockwise synchronous broadcast message to the third slave node device 104, the third slave node device 104 is the next neighboring slave node device to the second slave node device 103.
First, a master node device 101 in each node device in a ring network communication system is determined, the time of the clock is used as the reference time of each slave node device in the whole system, in this embodiment, each slave node device obtains the reference time through message exchange with an adjacent node device, and the time of the clock is modified to the reference time, so as to complete time synchronization with the master clock. It should be noted that, the master node device 101 may be statically designated by manual configuration, or may be dynamically selected and generated by an optimal master clock (Best Master Clock, BMC) protocol, which is not limited herein.
Then, the first slave node device 102 may send a delay request message to the master node device 101, after the master node device 101 receives the message, the first slave node device 102 returns a delay response message to the first slave node device 102, and the first slave node device 102 calculates the link delay between itself and the master node device 101 according to the delay request message and each timestamp included in the delay response message. It will be appreciated that the master node device 101 may also obtain the link delay between itself and the first slave node device 102 in the same manner through a process of actively transmitting a delay request message to the first slave node device 102 and receiving a delay response message transmitted by the first slave node device 102. In addition, the second slave node device 103 may obtain the link delay with the first slave node device 102 and the link delay with the third slave node device 104 by exchanging messages with the first slave node device 102 and the third slave node device 104, respectively. The process of obtaining the link delay by the third slave node device 104, the fourth slave node device 105, and the fifth slave node device 106 is the same as the above process, and the disclosure is not repeated here.
Finally, the master node device 101 sends the synchronous broadcast message to the adjacent slave node devices in the ring network according to the preset period, and each slave node device receives the synchronous broadcast message from the previous adjacent slave node device. Taking the second slave node device 103 as an example, the second slave node device 103 receives the clockwise synchronous broadcast message sent by the third slave node device 104 or the anticlockwise synchronous broadcast message sent by the first slave node device 102, determines a clock offset value with the master node device 101 according to the timestamp included in the synchronous broadcast message and the link delay with the third slave node device 104 or the link delay with the first slave node device 102, and modifies the time of the own clock according to the clock offset value, so as to achieve time synchronization with the master node device 101.
The steps for determining the link delay and the clock offset value by each node device are described in detail below.
As shown in fig. 2, taking the first slave node device 102 as an example, the node device sends a delay request message to the previous neighboring node device every a fixed preset time period, and marks a time stamp corresponding to the time when the message is sent as T1, namely, a first time stamp. It will be appreciated that the previous neighboring node device may be the previous slave node device or the master node device 101. In fig. 2, a previous neighboring node device is illustrated as the master node device 101. In addition, the fixed preset time period can be set according to the time synchronization requirement of the network, and the application is not limited herein.
After receiving the delay request message sent by the first slave node device 102, the master node device 101 marks a timestamp corresponding to the time when the message is received as a T2, i.e. a sixth timestamp. Then, a delay response message is sent to the first slave node device 102, and a timestamp corresponding to the time sent by the message is marked as T3, that is, a seventh timestamp, where the delay response message includes a difference between T3 and T2, which is called a delay time difference.
After the first slave node device 102 receives the delayed response message sent by the master node device 101, the timestamp corresponding to the time when the message is received is marked as T4, i.e. the second timestamp. Thus, the first slave node device 102 may follow the formula: tdelay= [ (T4-T1) - (T3-T2) ]/2 to obtain the link delay Tdelay. It may be understood that, here, the master node device 101 may also actively send a delay request packet to the first slave node device 102, and use a time stamp corresponding to a time of sending the packet as T1, and use a time stamp corresponding to a time of receiving a delay response packet from the first slave node device 102 as T4, and calculate a link delay between itself and the first slave node device 102 according to a value of T3-T2 recorded in the delay response packet.
Then, the master node device 101 broadcasts a synchronous broadcast message according to a preset actual interval, where the synchronous broadcast message includes a time stamp corresponding to a time when the message is sent from the master node device 101, which is a third time stamp, and the time stamp is T5. After the first slave node device 102 receives the synchronous broadcast packet, the time stamp corresponding to the time when the packet is received is denoted by T6, that is, the fourth time stamp. On the time axis at this time, in the case where the first slave node device 102 is time-synchronized with the master node device 101 and there is no clock offset value, T6 is a value of t5+Δt1, that is, a time when the master node device 101 sends out the synchronous broadcast message, and the link delays of the master node device 101 and the first slave node device 102 are added, that is, the dashed message path in fig. 2. However, when the master node device 101 is not synchronized with the first slave node device 102, the value of T6 is t5+Δt1+Δt2, i.e., the sum of the dashed message path and the clock offset value. Where Δt1 is the link delay Tdelay of the master node device 101 and the first slave node device 102, and Δt2 is the clock offset value of the first slave node device 102 and the master node device 101. Thus, by the formula: Δt2= (tdelay+t5) -T6 calculates a clock offset value Δt2 of the first slave node device 102 and the master node device 101. It will be appreciated that when the clock of the first slave node device 102 is delayed relative to the master node device 101, T6 is greater than the value tdelay+t5 and the calculated clock bias value Δt2 is less than zero. Conversely, when the clock of the first slave node device 102 is advanced relative to the master node device 101, T6 is less than the value of tdelay+t5, and the calculated clock offset value Δt2 is greater than zero.
Further, the first slave node device 102 adjusts the time of its own clock according to the calculated clock deviation value Δt2. Since the calculated Δt2 identifies the relative clock offset value of the first slave node device 102 with respect to the master node device 101, the following formula may be directly used: ts=ts '+Δt2, where Ts' is the time of the first slave node device 102 clock before synchronization and Ts is the time of the first slave node device 102 clock after synchronization. In this way, the slave node device completes time synchronization with the master node device 101.
Finally, the first slave node device 102 forwards the synchronous broadcast message to the next slave node device, that is, the second slave node device 103, and when the synchronous broadcast message is sent out, replaces the timestamp T5 of the synchronous broadcast message with the timestamp corresponding to the time when the synchronous broadcast message is sent out from the first slave node device 102, that is, the fifth timestamp. In this way, after the second slave node device 103 obtains the link delay with the first slave node device 102 through the exchange of the delay request message and the delay response message with the first slave node device 102, at this time, since the first slave node device 102 has completed time synchronization with the master node device 101, the second slave node device 103 may treat the first slave node device 102 as the master node device 101, and by receiving the synchronous broadcast message forwarded by the second slave node device 102, time synchronization with the master node device 101 is achieved. In this way, the slave node devices can sequentially complete time synchronization with the master node device 101.
Alternatively, the foregoing process of broadcasting the synchronous broadcast message by the master node device 101 may also be that adjacent slave node devices on both sides, for example, the first slave node device 102 and the fifth slave node device 106 unicast the synchronous broadcast message respectively, and the first slave node device 102 and the fifth slave node device 106 perform time synchronization according to the received synchronous broadcast message. Then, a new synchronous broadcast message is generated and sent to neighboring slave node devices, for example, the second slave node device 103 and the fourth slave node device 105. In this way, the synchronous broadcast messages at the two sides are transmitted to the third slave node device 104, and at this time, the third slave node device 104 can judge and discard the synchronous broadcast messages received after the judgment according to the extra sequence number of the message, so that the time synchronization of all the node devices in the ring network is completed once.
In addition, optionally, after receiving the synchronous broadcast message sent by the previous node device, a certain slave node device sends a delay request message to the node, and calculates to obtain a clock offset value according to the delay response message sent back by the node. That is, the order of receiving the synchronous broadcast message and sending the delay request message is not limited herein.
As shown in fig. 3, the embodiment of the present application further provides a field programmable gate array 20, where the field programmable gate array 20 includes: a Media Access Control (MAC) port module, an parsing module, a delay acquisition module, a synchronization module 204, a transmission forwarding module 205, a transmission selection module, a central processing unit interface module 207, and a ring network transmission module 208. The dotted line path in the figure is the path of the ring network data message, and the solid line path is the path of the PTP message.
The FPGA is arranged on each node device in the ring network communication system provided by the embodiment of the application. The modules can be in a structure determined during FPGA programming, and can be directly executed without software programs.
The medium access control port module is in communication connection with the parsing module and the transmission selection module, the parsing module is in communication connection with the delay acquisition module, the synchronization module 204, the transmission selection module and the central processing unit interface module 207, the delay acquisition module is in communication connection with the transmission selection module, the parsing module and the synchronization module 204, the synchronization module 204 is in communication connection with the transmission forwarding module 205, the delay acquisition module, the parsing module and the central processing unit interface module 207, the transmission forwarding module 205 is in communication connection with the transmission selection module, the transmission selection module is in communication connection with the parsing module, the transmission forwarding module 205, the medium access control port module and the delay acquisition module, the central processing unit interface module 207 is in communication connection with the parsing module, the synchronization module 204 and the ring network transmission module 208, and the ring network transmission module 208 is in communication connection with the central processing unit interface module 207 and the transmission selection module.
The media access control port module is used for converting the gigabit independent media interface message received by the physical layer into a field programmable gate array message, writing a timestamp corresponding to the sending time of the message to be sent into the message to be sent, and sending the timestamp corresponding to the receiving time of the received message to the analysis module. For example, in the above embodiment, when the master node device sends the synchronous broadcast packet, the media access control port module adds a third timestamp to the synchronous broadcast packet, and sends the synchronous broadcast packet at a time corresponding to the timestamp. Optionally, each FPGA includes a first media access control port module 201a and a second media access control port module 201b, which are respectively connected to adjacent nodes in a communication manner. Illustratively, the first medium access control port module 201a of the second slave node device is communicatively connected to the second medium access control port module 201b of the first slave node device, and the second medium access control port module 201b of the second slave node device is communicatively connected to the first medium access control port module 201a of the third slave node device, which in turn is communicatively connected to form a ring network. In addition, the first media access control port module 201a is configured to receive a message sent by the first gigabit independent media interface 40a, and the second media access control port module 201b is configured to receive a message sent by the second gigabit independent media interface 40 b.
And the analysis module is used for filtering and classifying the field programmable gate array message and deleting the ring network label in the ring network data message. The parsing module comprises a first parsing module 202a and a second parsing module 202b, when the node equipment where the FPGA is located receives a message, the media access control port module sends the message to the corresponding parsing module, and the parsing module filters invalid messages according to fields such as a source MAC address, a destination MAC address, a ring network label, a message type and the like of the received message, and classifies the messages. The source MAC address is the physical address of the node device sending the message, the destination MAC address is the physical address of the node device receiving the message, if the message is a ring network data message, the ring network label is used for identifying the number of the message, and the message type is used for identifying the type of the message, including a PTP message and a ring network data message. Illustratively, if the parsing module parses the synchronous broadcast message in the PTP message, the message is sent to the synchronization module 204 together with the timestamp of the received message. If the message is a delay request message or a delay response message, the message and a time stamp of the received message are sent to a corresponding delay acquisition module together. If the received message is a ring network data message, it is determined whether the ring network label needs to be modified according to the specific type and destination address of the ring network data message, and the ring network label is sent to the central processing unit interface module 207 or the sending and forwarding module 205.
The delay acquisition module is configured to generate, send or receive a delay request message and a delay response message to the corresponding media access control port module, determine a link delay with a previous neighboring node device according to the delay request message and the delay response message, and send the link delay to the synchronization module 204. That is, the delay acquisition module is used to implement the process of calculating the link delay in the above embodiment. It should be noted that each FPGA includes a first delay acquiring module 203a and a second delay acquiring module 203b, which correspond to different parsing modules and a sending selection module respectively. In addition, the delay request message and the delay response message generated by the delay acquisition module are generated based on PTP.
The synchronization module 204, the configuration of the synchronization module 204 is different for different types of node devices. When the node device is a slave node device, the synchronization module 204 is configured to perform time synchronization according to the link delay sent by the delay acquisition module and the received synchronization broadcast message. After receiving the link delay sent by the delay acquisition module, the message sent by the analysis module and the timestamp, the synchronization module 204 calculates the clock offset value between itself and the master node device according to the formula in the above embodiment. When the node device is a master node device, the synchronization module 204 is configured to generate and broadcast a synchronization broadcast message to slave node devices in the ring network through a ring network protocol and PTP at fixed preset time intervals.
The transmitting and forwarding module 205 is configured to send the synchronous broadcast message, the delay request message, and the delay response message to the transmitting and selecting module.
And the sending selection module is used for sending the synchronous broadcast message, the ring network data message, the delay request message and the delay response message to the media access control port module, and sending the time stamp corresponding to the sending moment of each message to the sending forwarding module 205 and the delay acquisition module. It should be noted that, each FPGA includes a first transmission selection module 206a and a second transmission selection module 206b, and the timestamp is obtained by the transmission selection module by the corresponding media access control port module.
The central processing unit interface module 207 is configured to receive and send configuration data to the central processing unit 30, receive a ring network data packet sent by the central processing unit 30, send the ring network data packet to the central processing unit 30, and remove a ring network tag in the synchronous broadcast packet. The data sent by the central processor 30 is a source MAC address and a destination MAC address. When the packet received by the FPGA is a ring network data packet, the central processor interface module 207 transmits it to the central processor 30. When the central processor 30 transmits a ring network data packet, the central processor interface module 207 transmits it to the ring network transmission module 208.
The ring network sending module 208 is configured to add a new ring network label to the ring network data packet and the synchronous broadcast packet. After receiving the ring network data message from the CPU or the synchronous broadcast message sent by the master node device, the ring network sending module 208 increases the local ring network label by 1 to obtain a new ring network label, writes the new ring network label into the message, and sends the message to the first sending selection module 206a and the second sending selection module 206b.
In an exemplary embodiment, after the first slave node device receives the message, the mac port module records a timestamp corresponding to the time when the message was received, and sends the timestamp to the parsing module. If the parsing message parses that the received message is a ring network data message, it is determined whether to need to receive or forward according to the specific type and destination address of the ring network data message, if so, after removing the ring network label, it is sent to the central processor interface module 207, and the ring network data message is sent to the central processor 30 by the module. If the transmission is needed, the transmission is directly transmitted to a transmission selection module corresponding to another media access control port module.
If the analysis module analyzes that the message is a delay request message or a delay response message, the message and a time stamp of the received message are sent to a corresponding delay acquisition module together. And the delay acquisition module calculates the link delay according to the delay request message and the corresponding delay response message, and then sends the calculation result to the synchronization module. In addition, if the message is a delay request message, the delay acquisition module correspondingly generates a delay response message, and the delay response message is finally sent to the adjacent node equipment by the corresponding media access control port module through the corresponding sending selection module.
If the parsing module parses that the message is a synchronous broadcast message, the message is sent to the synchronization module 204 together with the timestamp of the received message. The synchronization module 204 calculates a clock offset value according to the link delay with a certain neighboring node device and the synchronous broadcast message forwarded by the same neighboring node device, and adjusts the time of the own clock according to the clock offset value.
Fig. 4 is a flowchart of steps of a time synchronization method for ring network communication according to an embodiment of the present application, where the method is applied to a field programmable gate array in each slave node device in a ring network communication system, where the ring network communication system includes N node devices, where the N node devices are connected to form a ring network through a transmission medium, where the N node devices include 1 master node device and N-1 slave node devices, and where each node device in the N node devices includes a field programmable gate array. As shown in fig. 4, the method includes:
S301, a delay request message is sent to a previous adjacent node device of the slave node device, and a first timestamp corresponding to the moment when the delay request message is sent is recorded.
Optionally, each slave node device may generate, by the first delay acquisition module, a delay request packet at each preset time period, and forward the delay request packet via the first transmission selection module, and finally send the delay request packet by the first medium access control port module to a previous neighboring node device communicatively connected to the slave node device. The previous neighboring node device may be a node device forwarding the synchronous broadcast message to the slave node device when the synchronous broadcast Wen Shun is sent in the clockwise direction, or may be a node device forwarding the synchronous broadcast message to the slave node device when the synchronous broadcast message is sent in the counterclockwise direction. For both node devices, the slave node device may send delay request messages to both sides simultaneously. In addition, the previous node device may also be a master node device. In addition, when the first media access control port module sends out the delay request message, the corresponding first sending selection module records the first timestamp corresponding to the sending time of the message.
It can be understood that the previous neighboring node device may also be a node device that forwards the synchronous broadcast message to the node device when the synchronous broadcast message is sent counterclockwise. At this time, the second delay acquisition module generates a delay request message, the delay request message is forwarded by the second transmission selection module, and finally the delay request message is transmitted to the previous adjacent node device in communication connection with the slave node device by the second media access control port module, and a first timestamp corresponding to the time when the message is sent is recorded. The first time stamp may be two, and corresponds to a time when the delay request message is sent from the node device to the node devices on both sides. Since the paths traversed by the request message in the FPGA are identical, the two first timestamps may be identical.
Optionally, the first delay acquiring module and the second delay acquiring module may generate delay request messages simultaneously, and send the delay request messages to the previous adjacent node devices connected to the first delay acquiring module and the second delay acquiring module in a communication manner, where time stamps corresponding to sending moments may be all marked as first time stamps. Since the methods of both sides are the same, in the following steps, the first delay acquisition module side will be exemplified.
S302, receiving a delay response message sent by a previous adjacent node device, and recording a second timestamp corresponding to the moment when the delay response message is received.
As in the previous embodiment, the previous neighboring node device may be a node device on a side of the synchronous broadcast message with different directions, and it may be understood that, because network link lengths of the two neighboring node devices may be different, a second timestamp corresponding to a time when the delayed response message sent by the previous neighboring node device on the two sides is received may be different, and an operation procedure of the previous neighboring node device on one side will be described below.
When receiving a delay request message sent by a previous adjacent node device pair from a first media access control port module of the node device and sending back a delay response message, the module records a second timestamp corresponding to the entering time of the delay response message.
And then, the first analysis module analyzes the type of the message according to the fields of the source MAC address, the destination MAC address, the ring network label, the message type and the like of the message. And according to the message type field of the received message, if the message is a delay response message, sending the message and the second timestamp to a first delay acquisition module.
S303, determining the link delay between the slave node equipment and the previous adjacent node equipment according to the delay time difference, the first time stamp and the second time stamp contained in the delay response message.
After receiving the delay response message and the second timestamp sent by the first analysis module, the first delay acquisition module calculates link delay between itself and the previous node equipment according to the delay time difference written in the delay response message by the previous adjacent node equipment, the first timestamp corresponding to the moment of sending the delay request message and the second timestamp corresponding to the moment of receiving the delay response message, and sends the calculated link delay to the synchronization module.
The delay time difference is used for identifying the time delay from the time delay request message sent by the slave node device received by the previous adjacent node device to the time delay of the interval between the corresponding time delay response messages sent back. The link delay may be interpreted as a delay in which the slave node device performs message communication unidirectionally with the previous neighboring node device.
It will be appreciated that the process of calculating the delay time difference from the node device to the previous adjacent node device on the other side is the same as that described above.
S304, receiving the synchronous broadcast message broadcast by the master node device, and determining a clock offset value between the slave node device and the master node device according to a third timestamp, a link delay and a fourth timestamp corresponding to the moment when the slave node device receives the synchronous broadcast message, wherein the third timestamp is used for identifying the moment when the master node device sends the synchronous broadcast message.
The master node device may generate the synchronous broadcast message by the transmitting and forwarding module at preset time intervals, and send the synchronous broadcast message to the slave node devices on both sides in a clockwise direction and a counterclockwise direction respectively. And when the synchronous broadcast message is sent out of the master node equipment, the media access control port module writes a third timestamp corresponding to the sending time of the synchronous broadcast message into the synchronous broadcast message. It should be noted that the synchronous broadcast message may be generated based on PTP.
After the slave node equipment receives the synchronous broadcast message forwarded by the previous node equipment in the clockwise direction, the first analysis module analyzes the synchronous broadcast message, judges whether the synchronous broadcast message is received for the first time according to the ring network label field after obtaining the synchronous broadcast message according to the message type field, and if not, the slave node equipment indicates that the synchronous broadcast message is received from the previous node equipment in the anticlockwise direction, and discards the message. Otherwise, the synchronous broadcast message and a fourth timestamp corresponding to the moment of receiving the synchronous broadcast message are sent to a synchronous module, and according to the third timestamp contained in the synchronous broadcast message and the link delay sent by the first delay acquisition module, the clock offset value of the synchronous broadcast message and the master node equipment is calculated.
It will be appreciated that the node device may also accept a synchronous broadcast message in a counter-clockwise direction, with the process of calculating the clock offset value being the same as that described above.
S305, time synchronization is carried out on the slave node equipment according to the clock offset value.
The clock offset value calculated by the slave node device may be interpreted as a deviation between the time of clock display of the slave node device and the master node device. Therefore, the slave node device can adjust the time of the own clock according to the clock offset value and perform time synchronization with the master node device.
In this embodiment, each slave node determines the link delay with the previous neighboring node by exchanging a delay request message and a delay response message with the previous neighboring node, and determines the clock offset value with the master node device by the link delay and the synchronous broadcast message sent by the master node and received from the previous neighboring node on both sides. Therefore, the slave node only needs to exchange messages with the adjacent node, so that time synchronization with the master node equipment is realized, error of link delay caused by complex link state is reduced, message traffic when time synchronization with the host is performed is reduced, and load of the host is reduced. In addition, because the FPGA has high parallelism, the data transmission based on PTP and the analysis and the transmission of each message are realized in the FPGA, so that the message processing speed and the message processing precision can be improved, and the load of a CPU (central processing unit) is reduced.
Optionally, as shown in fig. 5, in step S305, after performing time synchronization on the slave node device according to the clock offset value, the method further includes the following steps:
s401, the third time stamp in the synchronous broadcast message is modified to be a fifth time stamp.
And after the clock offset value is calculated according to the synchronous broadcast message and the link delay, the synchronous broadcast message is transmitted to the next adjacent node equipment through the transmitting and forwarding module, the second transmitting and selecting module and finally the second media access control port module. When the second media access control port module sends the synchronous broadcast message, the third timestamp of the message is modified to be a fifth timestamp.
And S402, forwarding the synchronous broadcast message to the next adjacent node equipment of the slave node equipment at the moment corresponding to the fifth timestamp.
It can be understood that, as in the foregoing embodiment, the next neighboring node device may be a node device that receives the node device to forward the synchronous broadcast message when the synchronous broadcast message is sent counterclockwise, or may be a node device that receives the node device to forward the synchronous broadcast message when the synchronous broadcast Wen Shun is sent clockwise. That is, for both of these side node devices, the node device may forward the synchronized broadcast message thereto.
The fifth timestamp may be interpreted as the time that the synchronous broadcast message was sent by the slave node. Since the slave node device has completed time synchronization with the master node device at this time, there is no clock offset value with the master clock. At this time, the slave node device may be regarded as a master node device for the latter neighboring node device.
In this embodiment, the third timestamp is modified to be the fifth timestamp, so that the next adjacent node device directly exchanges messages with the slave node device, so that time synchronization with the master node device is achieved, and the problem that in the prior art, the messages of the master node device are excessively transmitted and received because each slave node device exchanges messages with the master node device directly is avoided.
Alternatively, as shown in fig. 6, in the above step S305, time synchronization of the slave node device according to the clock offset value may be performed by the following steps S501 to S503.
S501, acquiring a current time value of a clock.
It can be understood that the clock is an independent clock module in the FPGA of the node device, and each module in the FPGA can acquire the time of the clock. Here, the time value of the own FPGA clock is obtained by the synchronization module of the slave node device.
S502, adding the current time value and the clock offset value to obtain a corrected time value.
Since the clock offset value identifies the relative deviation of the time of the slave node device clock from the time of the master node device clock, adding the clock offset value to the current time value of the slave node device clock results in a corrected time value that is time synchronized with the master node device. The process may use the formula: ts=ts '+Δt2, where Ts' is the time of the slave device clock before synchronization, ts is the time of the slave device clock after synchronization, and Δt2 is the clock offset value.
S503, adjusting the time value of the clock to be a corrected time value.
The slave node device adjusts the time of the own clock to the corrected time value, so that the time synchronization with the master node device is achieved.
In this embodiment, by obtaining a corrected time value according to the clock offset value and adjusting the time value of the slave node clock accordingly, time synchronization of the slave node device and the master node device is completed. The time synchronization of a slave node device is completed after the synchronous broadcast message passes through each slave node, so that the later node device of the slave node device can take the time of the clock of the slave node device as a reference, and the time synchronization with the master node device can be realized only through the exchange between adjacent nodes.
Optionally, as shown in fig. 7, in the step S303, determining the link delay between the slave node device and the previous neighboring node device according to the delay time difference, the first timestamp and the second timestamp included in the delay response message may be implemented in the following steps S601 to S602:
s601, subtracting the second timestamp from the first timestamp to obtain the end delay.
The second timestamp may correspond to a time when the delay response message sent by the previous neighboring node device is received from the node device, and the first timestamp may correspond to a time when the delay request message sent by the previous neighboring node device is sent from the node device. The difference between the second timestamp and the first timestamp is an end delay, which can be interpreted as the time from the moment when the node device sends out the delay request message to the moment when the node device receives the delay response message, that is, the total delay of the message in the network between the node device and the previous adjacent node device.
S602, subtracting the end time delay and the time delay time difference to obtain an intermediate time delay.
The delay response message is generated by the previous adjacent node equipment and is used for responding to the delay request message sent from the node equipment. Therefore, after receiving the delay request message, the previous neighboring node device analyzes the delay request message and generates a delay response message, and then the delay response message can be sent out, and the intermediate delay is called delay time difference.
And subtracting the delay time difference of the previous adjacent node equipment from the total delay of the message, namely the end delay, of the round trip on the network between the slave node equipment and the previous adjacent node equipment to obtain the delay of the message, namely the intermediate delay, of the round trip on the link between the slave node equipment and the previous adjacent node equipment.
S603, halving the intermediate delay to obtain the link delay between the slave node device and the previous adjacent node device.
The time delay of the message in the unidirectional link between the slave node device and the previous adjacent node device, namely the link time delay, is obtained by halving the time delay of the message in the round trip on the link between the slave node device and the previous adjacent node device, namely the intermediate time delay.
It should be noted that, the steps S601 to S602 are completed by the delay acquiring module of the slave node device.
In this embodiment, the link delay is calculated by the second timestamp corresponding to the time when the slave node device receives the delay response message sent by the previous neighboring node device, the first timestamp corresponding to the time when the slave node device sends the delay request message to the previous neighboring node device, and the delay time difference. In this way, the slave node device only passes through one message exchange, and the time length required for the unidirectional propagation of the message between the slave node device and the previous adjacent node device is defined under the condition of no delay.
Optionally, as shown in fig. 8, in step S304, determining the clock offset value between the slave node device and the master node device according to the third timestamp, the link delay, and the fourth timestamp corresponding to the time when the slave node device receives the synchronous broadcast message, which are included in the synchronous broadcast message, may be implemented in steps S701 to S702 described below.
And S701, adding the third timestamp and the link delay to obtain a time synchronization difference value.
The third timestamp corresponds to the time when the synchronous broadcast message is sent out by the master node device, and the media access control port module of the master node device writes the sending time of the synchronous broadcast message into the synchronous broadcast message when the message is sent out.
The time synchronization difference may be interpreted as the time that the master node device, or the slave node device after time synchronization with the master node device, should receive the synchronization broadcast message when time synchronizing with the slave node device that receives the synchronization broadcast message.
S702, subtracting the time synchronization difference value from the fourth time stamp to obtain a clock offset value between the slave node device and the master node device.
If the slave node device receiving the synchronous broadcast message has clock deviation with the adjacent slave node device forwarding the synchronous broadcast message or the master node device broadcasting the synchronous broadcast message, the fourth time stamp corresponding to the slave node device receiving the synchronous broadcast message is not the time synchronization difference value, and the time synchronization difference value is subtracted from the fourth time stamp, so that the clock deviation value between the slave node device and the master node device is obtained.
For example, if the time of the slave device clock is advanced compared to the time of the master node device clock, the clock offset value is a positive value. If the slave node device clock time is delayed compared to the master node device clock time, the clock offset value is negative.
In this embodiment, the slave node device may calculate the clock offset value of the master node device by receiving the synchronous broadcast packet forwarded by the neighboring node device after the time synchronization of the master node device, or the synchronous broadcast packet directly received from the neighboring master node device, in combination with the link delay in the foregoing embodiment. The slave node equipment can perform time synchronization according to the calculated clock offset value only by receiving the synchronous broadcast message sent by the adjacent node equipment, so that the network load is reduced.
Optionally, as shown in fig. 9, the method for time synchronization of ring network communication provided in the embodiment of the present application further includes:
step S801, a delay request packet sent from a next neighboring node device of the node device is received, and a sixth timestamp corresponding to a time when the delay request packet is received is recorded.
Optionally, if a certain slave node device is used as a previous neighboring node of another slave node device in the ring network, when receiving the delay request message sent by the next neighboring node device, the slave node device records a timestamp corresponding to the time when the delay request message is received by the media access control port module, and the timestamp may be marked as a sixth timestamp.
Step S802, a delay response message is sent to a next adjacent node device, and a seventh timestamp corresponding to the time when the delay response message is sent is recorded, where the delay response message includes: time delay time difference, which is determined by the difference between the seventh time stamp and the sixth time stamp.
The analysis module of the slave node equipment analyzes the message, and sends the message to the delay acquisition module after the message is obtained as the delay request message through analysis. And the transmission forwarding module generates a delay response message, and finally the media access control port module sends the delay response message and records a seventh timestamp corresponding to the sending time of the message.
In addition, the media access control port module sends the message, records the seventh time stamp, and simultaneously writes the time difference value between the seventh time stamp and the sixth time stamp into a delay response message, and sends the delay response message as a delay time difference to the next adjacent node equipment.
In this embodiment, by describing the process of writing the delay time difference into the delay response message when the slave node device is used as the previous neighboring node device, the calculation of the delay time difference is clarified, so that the subsequent node device can obtain the transmission delay and the link delay of the previous node device through the delay response message, thereby reducing the network load.
Referring to fig. 10, an embodiment of the present application further provides a node device, including: the central processing unit 30 and the field programmable gate array 20 according to the foregoing embodiment, wherein the field programmable gate array 20 is communicatively connected to the central processing unit 30 for data exchange.
The central processor 30 is configured to provide the source MAC address and the destination MAC address to be written in the message to the field programmable gate array 20 according to the requirement of the field programmable gate array 20.
The field programmable gate array 20 is used for generating PTP messages according to data provided by the central processing unit 30.
Referring to fig. 11, an embodiment of the present application further provides a time synchronization device 50 for ring network communication, where the device includes:
And the sending module 5001 is configured to send a delay request packet to a previous neighboring node device of the slave node device, and record a first timestamp corresponding to a time when the delay request packet is sent.
The receiving module 5003 is configured to receive the delayed response message sent by the previous neighboring node device, and record a second timestamp corresponding to a time when the delayed response message is received.
And a processing module 5002, configured to determine a link delay between the slave node device and the previous neighboring node device according to the delay time difference, the first timestamp and the second timestamp included in the delay response message.
The processing module 5002 is further configured to receive a synchronous broadcast packet broadcast by the master node device, and determine a clock offset value between the slave node device and the master node device according to a third timestamp, which is included in the synchronous broadcast packet, a link delay, and a fourth timestamp corresponding to a time when the slave node device receives the synchronous broadcast packet, where the third timestamp is used to identify a time when the master node device sends the synchronous broadcast packet.
The processing module 5002 is further configured to time synchronize the slave node device according to the clock offset value.
The processing module 5002 is further configured to modify the third timestamp in the synchronous broadcast packet to a fifth timestamp; and forwarding the synchronous broadcast message to the next adjacent node equipment of the slave node equipment at the moment corresponding to the fifth timestamp.
The processing module 5002 is specifically further configured to obtain a current time value of the clock; adding the current time value and the clock offset value to obtain a corrected time value; the time value of the clock is adjusted to the corrected time value.
The processing module 5002 is specifically further configured to subtract the second timestamp from the first timestamp to obtain an end delay; subtracting the end time delay and the time delay time difference to obtain an intermediate time delay; and halving the intermediate delay to obtain the link delay between the slave node equipment and the previous adjacent node equipment.
The processing module 5002 is specifically further configured to add the third timestamp to the link delay to obtain a time synchronization difference value; and subtracting the time synchronization difference value from the fourth time stamp to obtain a clock offset value between the slave node equipment and the master node equipment.
The processing module 5002 is specifically further configured to receive a delay request packet sent from a next neighboring node device of the node device, and record a sixth timestamp corresponding to a time when the delay request packet is received; transmitting a delay response message to the next adjacent node equipment, and recording a seventh timestamp corresponding to the moment when the delay response message is transmitted; the delay response message comprises: time delay time difference, which is determined by the difference between the seventh time stamp and the sixth time stamp.
Optionally, the present application further provides a storage medium, on which a computer program is stored, which when being executed by a processor performs the steps of the above-described method embodiments. The specific implementation manner and the technical effect are similar, and are not repeated here.
It will be clear to those skilled in the art that, for convenience and brevity of description, specific working procedures of the above-described system and apparatus may refer to corresponding procedures in the method embodiments, and are not repeated in the present disclosure. In the several embodiments provided by the present application, it should be understood that the disclosed systems, devices, and methods may be implemented in other manners. The above-described apparatus embodiments are merely illustrative, and the division of the modules is merely a logical function division, and there may be additional divisions when actually implemented, and for example, multiple modules or components may be combined or integrated into another system, or some features may be omitted or not performed. Alternatively, the coupling or direct coupling or communication connection shown or discussed with each other may be through some communication interface, indirect coupling or communication connection of devices or modules, electrical, mechanical, or other form.
In addition, each functional unit in the embodiments of the present application may be integrated in one processing unit, or each unit may exist alone physically, or two or more units may be integrated in one unit. The functions, if implemented in the form of software functional units and sold or used as a stand-alone product, may be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application may be embodied essentially or in a part contributing to the prior art or in a part of the technical solution, in the form of a software product stored in a storage medium, comprising several instructions for causing a computer device (which may be a personal computer, a server, a network device, etc.) to perform all or part of the steps of the method according to the embodiments of the present application. And the aforementioned storage medium includes: a usb disk, a removable hard disk, a ROM, a RAM, a magnetic disk, or an optical disk, etc.
The foregoing is merely illustrative of the present application, and the present application is not limited thereto, and any changes or substitutions easily contemplated by those skilled in the art within the scope of the present application should be included in the present application. Therefore, the protection scope of the present application shall be subject to the protection scope of the claims.

Claims (9)

1. The time synchronization method of the ring network communication is characterized by being applied to a field programmable gate array in each slave node device in a ring network communication system, wherein the ring network communication system comprises N node devices which are connected into a ring network through a transmission medium, the N node devices comprise 1 master node device and N-1 slave node devices, and each node device in the N node devices comprises a field programmable gate array;
The method comprises the following steps:
Sending a delay request message to a previous adjacent node device of the slave node device, and recording a first timestamp corresponding to the moment of sending the delay request message;
Receiving a delay response message sent by the previous adjacent node equipment, and recording a second timestamp corresponding to the moment of receiving the delay response message;
Determining the link delay between the slave node equipment and the previous adjacent node equipment according to the delay time difference, the first time stamp and the second time stamp contained in the delay response message;
Receiving a synchronous broadcast message broadcast by the master node device, and determining a clock offset value between the slave node device and the master node device according to a third timestamp, the link delay and a fourth timestamp, which are contained in the synchronous broadcast message and correspond to the moment when the slave node device receives the synchronous broadcast message, wherein the third timestamp is used for identifying the moment when the master node device sends the synchronous broadcast message;
According to the clock offset value, carrying out time synchronization on the slave node equipment;
After the slave node device is time-synchronized according to the clock offset value, the method further comprises:
Modifying the third timestamp in the synchronous broadcast message to a fifth timestamp;
and forwarding the synchronous broadcast message to a next adjacent node device of the slave node device at the moment corresponding to the fifth timestamp.
2. The method for time synchronization of ring network communication according to claim 1, wherein said time synchronizing the slave node device according to the clock offset value comprises:
Acquiring a current time value of a clock;
Adding the current time value and the clock offset value to obtain a corrected time value;
and adjusting the time value of the clock to the corrected time value.
3. The method for time synchronization of ring network communication according to claim 1, wherein determining the link delay between the slave node device and the previous neighboring node device according to the delay time difference, the first timestamp, and the second timestamp included in the delay response message includes:
subtracting the first timestamp from the second timestamp to obtain an end delay;
subtracting the time delay of the end from the time delay time difference to obtain an intermediate time delay;
and halving the intermediate delay to obtain the link delay of the slave node equipment and the previous adjacent node equipment.
4. The method for time synchronization of ring network communication according to claim 1, wherein determining the clock offset value between the slave node device and the master node device according to the third timestamp included in the synchronous broadcast message, the link delay, and the fourth timestamp corresponding to the time when the slave node device receives the synchronous broadcast message includes:
adding the third timestamp and the link delay to obtain a time synchronization difference value;
And subtracting the time synchronization difference value from the fourth time stamp to obtain a clock offset value between the slave node equipment and the master node equipment.
5. The method of time synchronization for ring network communication of claim 1, further comprising:
receiving a delay request message sent by a next adjacent node device of the slave node device, and recording a sixth timestamp corresponding to the moment of receiving the delay request message;
sending a delay response message to the latter adjacent node equipment, and recording a seventh timestamp corresponding to the time when the delay response message is sent;
The delay response message comprises: a time delay time difference, the time delay time difference being determined by a difference between the seventh time stamp and the sixth time stamp.
6. A field programmable gate array, the field programmable gate array comprising: the device comprises a media access control port module, an analysis module, a delay acquisition module, a synchronization module, a transmission forwarding module, a transmission selection module, a central processing unit interface module and a ring network transmission module; the field programmable gate array is a field programmable gate array in each slave node device in a ring network communication system, wherein the ring network communication system comprises N node devices, and the N node devices comprise 1 master node device and N-1 slave node devices;
The medium access control port module is respectively in communication connection with the analysis module and the transmission selection module, the analysis module is respectively in communication connection with the delay acquisition module, the synchronization module, the transmission selection module and the central processing unit interface module, the delay acquisition module is respectively in communication connection with the transmission selection module, the analysis module and the synchronization module, the synchronization module is respectively in communication connection with the transmission forwarding module, the delay acquisition module, the analysis module and the central processing unit interface module, the transmission forwarding module is in communication connection with the transmission selection module, the transmission selection module is respectively in communication connection with the analysis module, the transmission forwarding module, the medium access control port module and the delay acquisition module, the central processing unit interface module is respectively in communication connection with the analysis module, the synchronization module and the ring network transmission module, and the ring network transmission module is respectively in communication connection with the central processing unit interface module and the transmission selection module;
The media access control port module is configured to mutually convert the gigabit independent media interface packet received by the physical layer and the field programmable gate array packet, write a timestamp corresponding to a sending time of the packet to be sent into the packet to be sent, and send the timestamp corresponding to a receiving time of the received packet to the parsing module;
the analysis module is used for filtering and classifying the field programmable gate array message and deleting the ring network label in the ring network data message;
The delay acquisition module is used for generating, transmitting or receiving a delay request message and a delay response message to the corresponding media access control port module, determining the link delay with the previous adjacent node equipment according to the delay request message and the delay response message, and transmitting the link delay to the synchronization module;
the synchronization module is used for performing time synchronization according to the link delay sent by the delay acquisition module and the received synchronous broadcast message;
The sending and forwarding module is configured to send the synchronous broadcast message, the delay request message, and the delay response message to the sending selection module;
The sending selection module is used for sending the synchronous broadcast message, the ring network data message, the delay request message and the delay response message to the media access control port module, and sending a timestamp corresponding to the sending moment of each message to the sending forwarding module and the delay acquisition module;
The central processing unit interface module is used for receiving and sending configuration data to the central processing unit, receiving the ring network data message sent by the central processing unit, sending the ring network data message to the central processing unit and removing the ring network label in the synchronous broadcast message;
The ring network sending module is used for adding a new ring network label to the ring network data message and the synchronous broadcast message;
The media access control port module is further configured to modify a third timestamp in the synchronous broadcast packet to a fifth timestamp; forwarding the synchronous broadcast message to a next adjacent node device of the slave node device at a moment corresponding to the fifth timestamp; the third timestamp is used for identifying the time when the master node device sends the synchronous broadcast message.
7. A node device, the node device comprising: a central processor and the field programmable gate array of claim 6, the field programmable gate array being communicatively coupled to the central processor.
8. A ring network communication system, the system comprising: the N node devices are connected into a ring network through a transmission medium, the N node devices comprise 1 master node device and N-1 slave node devices, and each node device in the N node devices comprises a field programmable gate array;
each slave node device is configured to perform time synchronization by using the steps of the method for time synchronization of ring network communication according to any one of claims 1 to 5.
9. A computer readable storage medium, wherein a computer program is stored on the computer readable storage medium, which computer program, when executed by a processor, implements the steps of the method for time synchronization of ring network communication according to any of claims 1-5.
CN202111600620.5A 2021-12-24 2021-12-24 Time synchronization method for ring network communication, programmable gate array and ring network communication system Active CN114401067B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202111600620.5A CN114401067B (en) 2021-12-24 2021-12-24 Time synchronization method for ring network communication, programmable gate array and ring network communication system

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202111600620.5A CN114401067B (en) 2021-12-24 2021-12-24 Time synchronization method for ring network communication, programmable gate array and ring network communication system

Publications (2)

Publication Number Publication Date
CN114401067A CN114401067A (en) 2022-04-26
CN114401067B true CN114401067B (en) 2024-06-11

Family

ID=81226465

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202111600620.5A Active CN114401067B (en) 2021-12-24 2021-12-24 Time synchronization method for ring network communication, programmable gate array and ring network communication system

Country Status (1)

Country Link
CN (1) CN114401067B (en)

Families Citing this family (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2024069643A1 (en) * 2022-09-28 2024-04-04 Coreel Technologies India Private Limited Method and a system for creating multi-port network synchronization bridge
CN115348660B (en) * 2022-10-20 2022-12-20 石家庄科林电气股份有限公司 Electric energy meter time synchronization method, electric energy meter and storage medium
CN115580542B (en) * 2022-12-06 2023-03-03 苏州浪潮智能科技有限公司 Information exchange method and related device of multi-Ethernet switch
CN116208289B (en) * 2023-04-28 2023-07-21 北京邮电大学 Time synchronization method and device based on white box switch and electronic equipment
CN116938379B (en) * 2023-09-18 2023-12-15 湖北芯擎科技有限公司 Method, device, electronic equipment and computer readable storage medium for time synchronization

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102238056A (en) * 2010-04-30 2011-11-09 中兴通讯股份有限公司 Automatic ring network protection topology structure discovery method and device
CN102833061A (en) * 2012-08-31 2012-12-19 北京东土科技股份有限公司 Method for improving clock accuracy based on seamless redundancy ring network and node
CN102833062A (en) * 2012-09-25 2012-12-19 广东电网公司珠海供电局 Time synchronization method and system for synchronous messages of IEEE1588 (Precision Time Protocol) master-slave clocks of intelligent transformer substation
CN105471691A (en) * 2014-06-17 2016-04-06 上海联影医疗科技有限公司 Synchronization control method, synchronization control device and synchronization control system for topology network
CN105978652A (en) * 2016-04-27 2016-09-28 刘巍 Synchronous time comparing equipment of redundant Ethernet, system and method thereof
CN110113242A (en) * 2019-05-07 2019-08-09 南京磐能电力科技股份有限公司 Multi-node synchronization sampling and data transmission method in ring-type communication network

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US8879586B2 (en) * 2012-12-20 2014-11-04 Broadcom Corporation Inband timestamping

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102238056A (en) * 2010-04-30 2011-11-09 中兴通讯股份有限公司 Automatic ring network protection topology structure discovery method and device
CN102833061A (en) * 2012-08-31 2012-12-19 北京东土科技股份有限公司 Method for improving clock accuracy based on seamless redundancy ring network and node
CN102833062A (en) * 2012-09-25 2012-12-19 广东电网公司珠海供电局 Time synchronization method and system for synchronous messages of IEEE1588 (Precision Time Protocol) master-slave clocks of intelligent transformer substation
CN105471691A (en) * 2014-06-17 2016-04-06 上海联影医疗科技有限公司 Synchronization control method, synchronization control device and synchronization control system for topology network
CN105978652A (en) * 2016-04-27 2016-09-28 刘巍 Synchronous time comparing equipment of redundant Ethernet, system and method thereof
CN110113242A (en) * 2019-05-07 2019-08-09 南京磐能电力科技股份有限公司 Multi-node synchronization sampling and data transmission method in ring-type communication network

Also Published As

Publication number Publication date
CN114401067A (en) 2022-04-26

Similar Documents

Publication Publication Date Title
CN114401067B (en) Time synchronization method for ring network communication, programmable gate array and ring network communication system
US9628209B2 (en) Time synchronization in distributed network testing equipment
US9742514B2 (en) Method, apparatus, and system for generating timestamp
US8879586B2 (en) Inband timestamping
CN111800213B (en) High-speed TTE (time to live) cascade network 1588 synchronization method, system and device
CN102104476B (en) Clock synchronization device and method
US9698926B2 (en) Distributed two-step clock
EP2242236B1 (en) Method for measuring frame loss, system for measuring frame loss, and device for measuring frame loss
US8018972B2 (en) Timing over packet performance
CN111385048A (en) Time synchronization method and system
US9485045B2 (en) Communication control equipment
US20160149658A1 (en) Method and device for detecting fault in synchronization link
WO2005096794A2 (en) Method and apparatus for precisely measuring a packet transmission time
JP5127482B2 (en) Timing synchronization method, synchronization apparatus, synchronization system, and synchronization program
WO2010057398A1 (en) Device and method for implementing clock transparent transmission
CN113259038A (en) Time synchronization method, node, device and storage medium
EP3260949B1 (en) An integrated circuit and method for processing synchronized network frames using a hardware synchronization circuit
EP2709298A1 (en) Synchronization method and electronic apparatus using redundant links
FI119310B (en) Procedure and equipment for transmitting time marking information
JP6227888B2 (en) Communication system, synchronization system, and communication method
CN113014515B (en) Method and switch for supporting heterogeneous network time synchronization delay compensation
CN110266422B (en) Method, device, equipment and medium for processing message residence time of intermediate clock equipment
EP3806391A1 (en) Synchronization information transmission method, sending end device, receiving end device and storage medium
CN102957528B (en) Pass through the synchronous method and system of third party's synchronizing network
CN106161121B (en) Method, device and system for measuring message forwarding time delay

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