WO2020135857A1 - Time synchronization method, system and device, and storage medium - Google Patents
Time synchronization method, system and device, and storage medium Download PDFInfo
- Publication number
- WO2020135857A1 WO2020135857A1 PCT/CN2019/129789 CN2019129789W WO2020135857A1 WO 2020135857 A1 WO2020135857 A1 WO 2020135857A1 CN 2019129789 W CN2019129789 W CN 2019129789W WO 2020135857 A1 WO2020135857 A1 WO 2020135857A1
- Authority
- WO
- WIPO (PCT)
- Prior art keywords
- time
- clock
- message
- time message
- slave device
- Prior art date
Links
Images
Classifications
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04J—MULTIPLEX COMMUNICATION
- H04J3/00—Time-division multiplex systems
- H04J3/02—Details
- H04J3/06—Synchronising arrangements
- H04J3/0635—Clock or time synchronisation in a network
- H04J3/0638—Clock or time synchronisation among nodes; Internode synchronisation
- H04J3/0658—Clock or time synchronisation among packet nodes
- H04J3/0661—Clock or time synchronisation among packet nodes using timestamps
- H04J3/0667—Bidirectional timestamps, e.g. NTP or PTP for compensation of clock drift and for compensation of propagation delays
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04J—MULTIPLEX COMMUNICATION
- H04J3/00—Time-division multiplex systems
- H04J3/02—Details
- H04J3/06—Synchronising arrangements
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04W—WIRELESS COMMUNICATION NETWORKS
- H04W56/00—Synchronisation arrangements
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04W—WIRELESS COMMUNICATION NETWORKS
- H04W56/00—Synchronisation arrangements
- H04W56/001—Synchronization between nodes
Definitions
- the embodiments of the present application relate to the field of communication technologies, for example, to a time synchronization method, system, device, and storage medium.
- the requirements for network time synchronization become very high. For example, the synchronization accuracy of a single node device carrying the network will reach the nanosecond level. Moreover, multiple devices in the bearer network use clusters, multiple virtual one and other technical methods to increase capacity and speed, and as a single node in the network, it is necessary to provide high-precision time synchronization.
- Embodiments of the present application provide a time synchronization method, system, device, and storage medium, which can realize fast and efficient high-precision time synchronization among multiple devices.
- An embodiment of the present application provides a time synchronization method, including: a clock master device sending a first time message to a clock slave device; a clock master device receiving a second time stamp and a third time stamp sent by the clock slave device. Two time messages, and put the fourth time stamp recorded by the clock master device into the second time message when the second time message enters the port of the clock master device; the clock master device copies the second time message to generate the third time report And send a third time message to the clock slave device; where the first time message carries the first time stamp recorded by the clock master device when the first time message exits the port of the clock master device; the second time stamp is used to Indicates the time when the clock slave device receives the first time message, and the third time stamp is used to indicate the time when the clock slave device sends the second time message.
- An embodiment of the present application provides a time synchronization method, including: a clock slave device receiving a first time message carrying a first time stamp sent by a clock master device, and inputting the first time message into a port of the clock slave device The second time stamp recorded by the device is placed in the first time message; the clock slave device copies the first time message to generate the second time message, sends the second time message to the clock master, and sends the second time message out
- the third time stamp recorded by the clock slave device is placed in the second time message when the clock slave device's port is clocked;
- the clock slave device receives the third time message sent by the clock master device, and according to the first time obtained from the third time message Timestamp, second timestamp, third timestamp, and fourth timestamp to calculate the time deviation between the clock slave device and the clock master device; the clock slave device adjusts the time of the clock slave device according to the time deviation; where, the first The time stamp is used to indicate the time when the clock master sends the first time message; the fourth time stamp
- An embodiment of the present application provides a time synchronization system, including: a clock master device and a clock slave device; the clock master device is configured to send a first time message to the clock slave device, where the first time message carries the first The first time stamp recorded by the clock master device when a time packet exits the port of the clock master device; the clock slave device is set to the clock slave device when the first time message is entered into the port of the clock slave device Put the recorded second timestamp into the first time message, copy the first time message to generate the second time message, send the second time message to the clock master, and send the second time message out of the clock slave
- the third time stamp recorded by the clock slave device is placed in the second time message when the port of the device is set; the clock master device is also set to record when the second time message is entered into the port of the clock master device Put the fourth timestamp into the second time message, copy the second time message to generate the third time message, and send the third time message to the clock slave device; the clock slave device is also set to receive the third time
- An embodiment of the present application provides a time master device, including: a first memory and a first processor, the first memory is configured to store a time synchronization program, and the time synchronization program is implemented by the first processor to achieve the above Time synchronization method on the time master device side.
- An embodiment of the present application provides a time slave device, including: a second memory and a second processor, the second memory is configured to store a time synchronization program, and the time synchronization program is implemented when the second processor executes the above Time synchronization method from the device side.
- An embodiment of the present application provides a computer-readable medium that stores a time synchronization program, and when the time synchronization program is executed by a processor, the time synchronization method on the time master device side is implemented.
- An embodiment of the present application provides a computer-readable medium that stores a time synchronization program, and when the time synchronization program is executed by a processor, the time synchronization method on the time slave device side is implemented.
- Figure 1 is a schematic diagram of a master-slave clock for message interaction through the 1588 protocol
- FIG. 2 is an interactive schematic diagram of a time synchronization system provided by an embodiment of the present application.
- FIG. 3 is a schematic structural diagram of a time message provided by an embodiment of this application.
- FIG. 5 is a schematic diagram of a time synchronization system provided by an embodiment of this application.
- FIG. 6 is a schematic diagram of another time synchronization system provided by an embodiment of the present application.
- FIG. 7 is a flowchart of a time synchronization method provided by an embodiment of the present application.
- FIG. 9 is a schematic diagram of an application networking provided by an embodiment of this application.
- FIG. 10 is a schematic diagram of another application networking provided by an embodiment of this application.
- FIG. 11 is a schematic diagram of a clock master device provided by an embodiment of this application.
- FIG. 12 is a schematic diagram of a clock slave device provided by an embodiment of the present application.
- the clock time can be transmitted through the Global Positioning System (GPS) input and output ports (Serial port 1 second pulse (Pulse Per Per Second, PPS) + time information (Time Of Of Day, TOD)).
- GPS Global Positioning System
- PPS Pulse Per Per Second
- TOD Time Of Of Day
- FIG. 1 is a schematic diagram of a master-slave clock for message interaction through the 1588 protocol.
- the master clock sends a synchronization (Sync) message to the slave clock, which can carry the timestamp T1 of the synchronization message sent by the master clock; after the slave clock receives the synchronization message, it can get the time from the synchronization message Poke T1 and record the arrival timestamp T2 of the synchronization message; the slave clock can send a delay request (Delayreq) message and record the timestamp T3 of the delay request message; the master clock receives the delay request message After the text, record the arrival timestamp T4 of the delay request message, and carry the timestamp T4 in the delay response (Delayresp) message and send it to the slave clock; the slave clock can get the time stamp from the delay response message T4, and calculate the time deviation
- the time stamps T1 to T4 need to be collected by the slave clock, and the collection steps are cumbersome. Moreover, the slave clock needs to pass the 1588 data set of the comparison message to obtain the same group. Four time stamps.
- the embodiments of the present application provide a time synchronization method, system, device and storage medium, which can realize fast and efficient high-precision time synchronization between multiple devices, and greatly reduce the complexity and cost of implementing time synchronization between devices.
- Multi-device can be simple Flexible networking and easy management to meet the ultra-high precision time synchronization requirements of multi-device cluster systems in the 5G era.
- An embodiment of the present application provides a time synchronization system, including: a clock master device and a clock slave device; wherein, the clock master device is configured to send a first time message to the clock slave device, and the first time message carries the record recorded when the port exits First timestamp; the clock slave device is set to put the second timestamp recorded when the first time message enters the port into the first time message, copy the first time message to generate the second time message, and send it to the clock master Send the second time packet, and put the third time stamp recorded when the second time packet exits the port into the second time packet; the clock master is also set to the fourth recorded when the second time packet enters the port Put the timestamp into the second time message, copy the second time message to generate the third time message, and send the third time message to the clock slave device; the clock slave device is also set to receive the third time message according to The first timestamp, the second timestamp, the third timestamp, and the fourth timestamp obtained by the third time message calculate the time deviation between the clock slave
- the first to fourth time stamps are carried in the time message through the interaction of the time message between the clock master device and the clock slave device, thereby facilitating the clock slave device to collect multiple time stamps, It is convenient to obtain the same set of time stamps directly, so as to achieve fast and efficient high-precision time synchronization between devices.
- FIG. 2 is an interactive schematic diagram of a time synchronization system provided by an embodiment of the present application. As shown in FIG. 2, the interaction process of the time synchronization system provided by this embodiment includes the following steps:
- Step 2010 The clock master sends a first time message, and records an accurate first time stamp T1 when the first time message exits the port, and places the first time stamp T1 on the first time stamp of the first time message Field.
- Step 2020 the clock slave device records an accurate second time stamp T2 when the first time packet enters the port, and places the second time stamp T2 in the second time stamp field of the first time packet; the clock slave device copies The first time message generates a second time message, and sends the second time message out, recording an accurate third time stamp T3 when the second time message exits the port, and placing the third time stamp T3 in the second In the third timestamp field of the time message.
- Step 2030 the clock master device records an accurate fourth time stamp T4 when the second time message enters the port, and places the fourth time stamp T4 in the fourth time stamp field of the second time message;
- the second time message generates a third time message, and sends the third time message.
- Step 2040 The clock slave device obtains the first time stamp T1, the second time stamp T2, the third time stamp T3, and the fourth time stamp T4 from the received third time message, and calculates the clock master device and the clock slave device Time deviation between.
- Step 2050 The clock slave device adjusts its time according to the calculated time deviation, and completes time synchronization with the clock master device.
- the first timestamp, the second timestamp, the third timestamp, and the fourth timestamp may all include: second bits, nanosecond bits, and sub-nanosecond bits .
- the format of any time stamp can be 48 bits (seconds) + 32 bits nanoseconds + 16 bits sub-nanoseconds, where 1 nanosecond is equal to 0x10000.
- FIG. 3 is a schematic structural diagram of a time message provided by an embodiment of the present application.
- the format of the first time message, the second time message, and the third time message may be consistent.
- the time message may include the following fields: message header, receiving port number, sending port number, time message type (for example, first time message, second time message, or third time message ), first timestamp, second timestamp, third timestamp, fourth timestamp.
- the format of the time message defined in this embodiment can simplify the processing of sending and receiving packets.
- FIG. 4 is an interaction flowchart of another time synchronization system provided by an embodiment of the present application. As shown in FIG. 4, the interaction process of the time synchronization system provided by this exemplary embodiment includes the following steps:
- Step 4010 multiple devices confirm the port connection relationship; each device (as the sending end) will send the first time message carrying port information through its own port; each device (as the receiving end) receives the sending end After the first time message, extract the port information carried in it, get the port information of the peer, and determine the port connection relationship.
- the clock master-slave synchronization relationship between multiple devices can be distributed through software management.
- the port of the device may be an Ethernet optical port.
- the port information field can be defined in the first time packet, and after the ports of multiple devices are connected, the first time packet carrying port information can be sent to each other; the receiving end The port information of the peer can be extracted from the first time message, so that the port connection is not restricted during networking, and the port connection can be selected at will.
- the upper layer software can distribute the clock master-slave synchronization relationship according to the port connection relationship.
- this step can be omitted, and the port connection relationship can be confirmed manually.
- Step 4020 The clock master sends a first time message, records an accurate first time stamp T1 when the first time message exits the port, and places the first time stamp T1 on the first time stamp of the first time message Field.
- the clock master device after confirming the master-slave relationship of the clock in step 4010, the clock master device sends the first time message.
- the first time message in this step is the same as the first time message in step 4010.
- the format can be consistent, which can simplify the package delivery.
- the frame start delimiter (SFD) arrival string of the first time message can be obtained
- the time stamp at the parallel data entry of the serial transceiver (SERializer/DESerialize, SERDES) and compensates for all the delay of the SERDES sender for the obtained time stamp, so as to obtain the high-precision first time stamp T1.
- Step 4030 The clock slave device records an accurate second time stamp T2 when the first time packet enters the port, and places the second time stamp T2 in the second time stamp field of the first time packet; A time message generates a second time message, and sends the second time message out, recording an accurate third time stamp T3 when the second time message exits the port, and placing the third time stamp T3 at the second time In the third timestamp field of the message.
- the clock slave device when recording the accurate second time stamp T2 of the input port of the first time packet, the clock slave device needs to identify and estimate the time stamp of the SFD of the first time packet reaching the parallel data exit of SERDES, The timestamp is compensated for all delays at the receiving end of the SERDES, thereby obtaining an accurate second timestamp T2.
- the second time stamp T2 need not be stored in the clock slave device, but directly added to the second time stamp field of the first time message.
- the clock slave device copies the first time message to generate the second time message, and sends the second time message out.
- an accurate third time stamp T3 is recorded.
- the three time stamps are placed in the third time stamp field of the second time message.
- the second time message sent by the clock slave device contains three time stamps T1, T2, and T3.
- the timestamp at which the SFD of the second time packet arrives at the parallel data entry of SERDES can be obtained, and the The timestamp compensates for all delays at the sending end of the SERDES, thereby obtaining a highly accurate third timestamp T3.
- Step 4040 The clock master device records an accurate fourth time stamp T4 when the second time message enters the port, and places the fourth time stamp T4 in the fourth time stamp field of the second time message; the clock master device copies the first The second time message generates a third time message, and sends the third time message.
- the third time message sent by the clock master device includes four time stamps T1, T2, T3, and T4.
- the clock slave device when recording the accurate fourth time stamp T4 of the input port of the second time packet, the clock slave device needs to identify and estimate that the SFD of the second time packet reaches the parallel data outlet of the SERDES Time stamp, and compensate all the delays of the SERDES receiving end to the time stamp, so as to obtain the accurate fourth time stamp T4.
- the fourth time stamp T4 does not need to be stored in the clock master device, but is directly added to the fourth time stamp field of the second time message.
- Step 4050 The clock slave device obtains four time stamps T1, T2, T3, and T4 in the received third time message, and calculates the time deviation and path delay between the clock master and slave devices.
- the clock slave device can directly calculate the time deviation between the clock master and slave devices according to the time stamps T1 to T4, or the clock slave device can calculate the path delay between the clock master and slave devices according to the time stamps T1 to T4, Calculate the time deviation according to the path delay. This application is not limited to this.
- T1, T2, T3, and T4 obtained through the third time message are the same set of time stamps, which can avoid the time stamps being stored in the clock master device and the clock slave device respectively.
- the clock slave device needs to identify key field matches The process of the same set of time stamps saves storage and computing logic resources.
- the time offset and path delay can be calculated from the time stamps T1 to T4 using the following formula:
- pathdelay (T2-T1+T4-T3)/2;
- offset is the time deviation
- pathdelay is the path delay
- Step 4060 The clock slave device adjusts its time according to the calculated time deviation to complete time synchronization.
- the time synchronization accuracy completed according to the above steps can reach ns level or below.
- FIG. 5 is a schematic diagram of a time synchronization system provided by an embodiment of the present application.
- the time synchronization system provided by this embodiment includes: a clock master device 50 and a clock slave device 52; wherein, the clock master device 50 may include a first time message processing module 502 and a third time message processing module 503; The first time message processing module 502 and the third time message processing module 503 are set to process message sending and receiving and recording time stamps on the clock master device side.
- the first time message processing module 502 may be set to control the clock master device 50 to send the first time message, and put the first time stamp recorded when the first time message is output from the port into the first time message;
- the three-time message processing module 503 may be set to put the fourth time stamp recorded when the second time message enters the port into the second time message, copy the second time message to generate the third time message, and send the clock to the clock
- the device 52 sends the third time message.
- the clock slave device 52 may include a second time message processing module 522, a time synchronization calculation module 523, and a time synchronization adjustment module 524.
- the second time message processing module 522 is configured to process message sending and receiving and time stamp recording of the clock slave device
- the time synchronization calculation module 523 is configured to calculate time deviation of the clock slave device
- the time synchronization adjustment module 524 is configured to time of the clock slave device Adjustment.
- the second time message processing module 522 is configured to put the second time stamp recorded when the first time message enters the port into the first time message, copy the first time message to generate the second time message, and send the
- the clock master device 50 sends the second time message, and puts the third time stamp recorded when the second time message exits the port into the second time message.
- the time synchronization calculation module 523 is configured to calculate the time between the clock slave device 52 and the clock master device 50 based on the first time stamp, the second time stamp, the third time stamp, and the fourth time stamp obtained from the third time message. Time deviation.
- the time synchronization adjustment module 524 is set to adjust the time of the clock slave 52 according to the time deviation.
- FIG. 6 is a schematic diagram of another time synchronization system provided by an embodiment of the present application.
- the clock master 52 may further include: a first port relationship processing module 601 configured to send port information The first time message; and extract the port information from the received first time message carrying the port information, and determine the port connection relationship of the clock master 50 according to the port information.
- the clock master device 52 may further include: a second port relationship processing module 621 configured to send a first time message carrying port information; and, from the received first time message carrying port information The port information is extracted from, and the port connection relationship of the clock slave device 52 is determined according to the port information.
- the time synchronization method provided by this embodiment includes:
- Step 7010 The clock master device sends a first time message to the clock slave device, and the first time message carries the first time stamp recorded when the port exits.
- Step 7020 the clock master device receives the second time message carrying the second time stamp and the third time stamp from the clock slave device, and puts the fourth time stamp recorded when the second time message is entered into the port into the second time report
- the second time stamp is used to indicate the moment when the clock receives the first time message from the device
- the third time stamp is used to indicate the moment when the clock sends the second time message from the device.
- Step 7030 The clock master device copies the second time message to generate a third time message, and sends the third time message to the clock slave device.
- the third time message sent by the clock master device may carry a first time stamp, a second time stamp, a third time stamp, and a fourth time stamp.
- the first timestamp, the second timestamp, the third timestamp, and the fourth timestamp may include second bits, nanosecond bits, and sub-nanosecond bits, thereby achieving the transfer of high-precision time information .
- the time synchronization method of this embodiment may further include: the clock master device sends a first time message carrying port information; the clock master device receives the first port message carrying port information from the first The port information is extracted from the time message, and the port connection relationship is determined according to the port information.
- the clock master device and other devices can pass the port information to determine the port connection relationship, so that the upper layer software can distribute the clock master-slave synchronization relationship through the port connection relationship.
- the time synchronization method of this embodiment may further include: determining the first time stamp by: determining the time stamp at which the SFD of the first time message arrives at the parallel data entry of SERDES, and giving the time The timestamp compensates for all delays at the SERDES sender, and gets the first timestamp. In this way, a high-precision time stamp can be obtained.
- the time synchronization method of this embodiment may further include: determining a fourth time stamp by: determining a time stamp at which the SFD of the second time message arrives at the parallel data exit of SERDES, and giving the time The timestamp compensates all delays at the receiving end of the SERDES and obtains the fourth time stamp. In this way, a high-precision time stamp can be obtained.
- the clock master device and the clock slave device belong to the same cluster system.
- the time synchronization method of this embodiment high-precision time synchronization of the cluster system can be achieved, and the cluster networking is simple and flexible and easy to manage.
- FIG. 8 is a flowchart of another time synchronization method provided by an embodiment of the present application. As shown in FIG. 8, the time synchronization method provided in this embodiment includes:
- Step 8010 The clock slave device receives the first time message carrying the first time stamp from the clock master device, and puts the second time stamp recorded when the first time message enters the port into the first time message; A time stamp is used to indicate the time when the clock master sends the first time message.
- Step 8020 the clock slave device copies the first time message to generate a second time message, sends the second time message to the clock master device, and puts the third time stamp recorded when the second time message is out of the port into the second Time message.
- Step 8030 The clock slave device receives the third time message from the clock master device, and calculates the clock slave according to the first time stamp, the second time stamp, the third time stamp, and the fourth time stamp obtained from the third time message.
- Step 8040 The clock slave device adjusts its own time according to the time deviation.
- the first time stamp, the second time stamp, the third time stamp, and the fourth time stamp may all include second bits, nanosecond bits, and sub-nanosecond bits.
- the time synchronization method of this embodiment may further include: the clock slave device sends a first time packet carrying port information; the clock slave device receives the first port message carrying port information The port information is extracted from the time message, and the port connection relationship is determined according to the port information. Among them, the clock slave device and other devices can pass the port information to determine the port connection relationship, so that the upper layer software can distribute the clock master-slave synchronization relationship through the port connection relationship.
- the time synchronization method of this embodiment may further include: determining the second time stamp by: determining the time stamp at which the SFD of the first time message arrives at the parallel data exit of SERDES, and giving the time The timestamp compensates all delays at the receiving end of the SERDES and obtains the second timestamp.
- the time synchronization method of this embodiment may further include: determining a third time stamp by: determining a time stamp at which the SFD of the second time message arrives at the parallel data entry of SERDES, and giving the time The timestamp compensates for all delays at the SERDES sender, and a third timestamp is obtained.
- the clock master device and the clock slave device belong to the same cluster system.
- the time synchronization method of this embodiment high-precision time synchronization of the cluster system can be achieved, and the cluster networking is simple and flexible and easy to manage.
- FIG. 9 is a schematic diagram of an application networking provided by an embodiment of the present application. Among them, an application manner of the time synchronization method provided in this embodiment in a cluster system is described.
- a cluster system including two central frames (physical equipment) and multiple service frames (physical equipment) is taken as an example for description. Since multiple separated devices need to be presented as a single time node after forming a cluster, time synchronization must be guaranteed between multiple frames in the cluster.
- the central frame 1 and the central frame 2, and each central frame and service frame are connected by the time synchronization method provided in this embodiment, wherein the central frame 1 and the central frame 2 are mutually backup.
- the time synchronization process in this embodiment includes the following steps:
- Step 9010 GPS or 1588 time is input from the central frame 1.
- the central frame 1 serves as the time source of the cluster system and needs to be synchronized to the central frame 2 and the service frames 1 to n, where n is an integer greater than 1.
- Step 9020 multiple central frames and multiple service frames (as sending ends) all send the first time message, which includes port information.
- multiple central frames and service frames (as receiving ends) extract the port information carried in them, and obtain their own port connection relationship according to the extracted port information.
- the software manages the distribution of the clock master-slave synchronization relationship.
- the center frame 1 can be selected as the clock master device, and the remaining frames (center frame 2 and service frames 1 to n) can be selected as clock slave devices.
- a time synchronization process is performed between the center frame 1 and the remaining frames (the center frame 2 and the service frames 1 to n), so that the remaining frames are time synchronized with the center frame 1.
- the following takes the time synchronization process between the central frame 1 and the service frame 1 as an example for description.
- Step 9030 The central box 1 sends a first time message to the service box 1, and records an accurate first time stamp T1 at the egress port, and places it in the first time stamp field of the first time message.
- Step 9040 the service block 1 records an accurate second time stamp T2 when the first time packet enters the port, and places it in the second time stamp field of the first time packet.
- Service box 1 can copy the first time message to generate a second time message, and send it out, record the accurate third time stamp T3 when leaving the port, and place the third time stamp T3 in the third of the second time message Timestamp field.
- Step 9050 the central box 1 records an accurate fourth time stamp T4 when the second time message enters the port, and places the fourth time stamp T4 in the fourth time stamp field of the second time message; copy the second time The message generates a third time message and sends it out.
- Step 9060 the service frame 1 obtains four time stamps T1, T2, T3, and T4 in the received third time message, and calculates the time deviation and path of the master-slave device (that is, between the center frame 1 and the service frame 1) Delay.
- Step 9070 the service frame 1 adjusts its own time according to the calculated time deviation, and completes time synchronization with the center frame 1.
- Step 9080 completing the time synchronization between the central frame 1 and the central frame 2, and between the central frame 1 and other service frames.
- steps 9030 to 9070 For the time synchronization process between the central frame 1 and the central frame 2 and between the central frame 1 and other service frames, reference may be made to steps 9030 to 9070, so they will not be repeated here.
- Step 9090 multiple service frames may provide multiple 1588 master ports to synchronize downstream slave devices.
- the time synchronization method provided in this embodiment can be used to achieve high-precision time synchronization between the devices in the cluster system, and the cluster system can use the 1588 protocol for time synchronization to avoid internal and external cluster systems.
- FIG. 10 is a schematic diagram of another application networking provided by an embodiment of this application.
- a cluster system including two central frames and multiple service frames is used as an example for description. Since multiple separated devices need to be presented as a single time node after forming a cluster, time synchronization must be guaranteed between multiple frames in the cluster.
- the central frame 1 and the central frame 2, and each central frame and service frame are connected by the time synchronization method provided in this embodiment, wherein the central frame 1 and the central frame 2 are mutually backup.
- the time synchronization process in this embodiment includes the following steps:
- Step 10010 GPS or 1588 time is input from the service box 1, and the service box 1 serves as the time source of the cluster system, and needs to be synchronized to the center box 1, the center box 2, and other service boxes (for example, service boxes 2 to n, where n is Integer greater than 1).
- Step 10020 multiple central frames and multiple service frames (as sending ends) all send a first time message, which includes port information.
- multiple center frames and service frames (as receiving ends) extract the port information carried in them, and obtain their own port connection relationship according to the extracted new port.
- the software manages and distributes the clock master-slave synchronization relationship. According to the application scenario of this example, you can select the service box 1 as the clock master device and the center box 1 as the clock slave device; at the same time, the center box 1 serves as the clock master device, and the center box 2 and the remaining service boxes 2 to service box n are clock slave devices equipment.
- the following describes the time synchronization process between the service frame 1 and the center frame 1 as an example.
- Step 10030 The service box 1 sends a first time message to the central box 1, and records an accurate first time stamp T1 at the egress port, and puts it in the first time stamp field of the first time message.
- Step 10040 The central box 1 records an accurate second time stamp T2 when the first time message enters the port, and places it in the second time stamp field of the first time message.
- the central box 1 can copy the first time message to generate the second time message, and send it out, record the accurate third time stamp T3 when leaving the port, and place the third time stamp T3 in the third of the second time message Timestamp field.
- Step 10050 the service box 1 records the accurate fourth time stamp T4 when the second time message enters the port, puts the fourth time stamp T4 in the fourth time stamp field of the second time message, and copies the second time The message generates a third time message and sends it out.
- Step 10060 The central frame 1 obtains four time stamps T1, T2, T3, and T4 in the received third time message, and calculates the time deviation and path of the master-slave device (that is, between the service frame 1 and the central frame 1) Delay.
- Step 10070 The central box 1 adjusts its own time according to the calculated time deviation, and completes time synchronization with the business box 1.
- Step 10080 Complete the time synchronization between the central frame 1 and the central frame 2, and the central frame 1 and the business frame 2 to the business frame n, respectively.
- Step 10080 Complete the time synchronization between the central frame 1 and the central frame 2, and the central frame 1 and the business frame 2 to the business frame n, respectively.
- Step 10090 multiple service frames may provide multiple 1588 master ports to synchronize downstream salve devices.
- the time synchronization method provided in this embodiment can be used to achieve high-precision time synchronization between the devices within the cluster system, and the cluster system can use the 1588 protocol to synchronize time externally, thereby avoiding the internal and external cluster system All conflicts exist when using 1588 protocol for time synchronization, which is easy to manage.
- FIG. 11 is a schematic diagram of a clock master device provided by an embodiment of the present application.
- the clock master device 1100 provided in this embodiment includes: a first memory 1101 and a first processor 1102; the first memory 1101 is set to store a time synchronization program, which is synchronized by the first processor 1102 During execution, the time synchronization method shown in FIG. 7 can be realized.
- the structure of the clock master device 1100 shown in FIG. 11 does not constitute a limitation on the clock master device, and may include more or fewer components than shown, or combine some components, or provide different component arrangements.
- the first processor 1102 may include a program processing module (for example, a microprocessor (Microcontroller Unit, MCU), a programmable logic device (Field Programmable Gate Array, FPGA), or an integrated circuit with a message processing function (Integrated Circuit (IC) chip, etc.) and time stamp processing module (for example, FPGA, or IC chip with time stamp processing function, etc.).
- a program processing module for example, a microprocessor (Microcontroller Unit, MCU), a programmable logic device (Field Programmable Gate Array, FPGA), or an integrated circuit with a message processing function (Integrated Circuit (IC) chip, etc.) and time stamp processing module (for example, FPGA, or IC chip with time stamp processing function, etc.).
- IC Integrated Circuit
- time stamp processing module for example, FPGA, or IC chip with time stamp processing function, etc.
- the first processor 1102 may include an FPGA or IC chip with message processing and time stamp processing functions.
- the first memory 1101 may be configured to store software programs and modules of application software, such as program instructions or modules corresponding to the time synchronization method in this embodiment, and the first processor 1102 runs the software stored in the first memory 1101 by Programs and modules to execute various functional applications and data processing, such as implementing the time synchronization method provided in this embodiment.
- the first memory 1101 may include a high-speed random access memory, and may also include a non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory.
- the first memory 1101 may include memories remotely provided with respect to the first processor 1102, and these remote memories may be connected to the terminal device through a network. Examples of the aforementioned network include, but are not limited to, the Internet, intranet, local area network, mobile communication network, and combinations thereof.
- the clock slave device 1200 provided in this embodiment includes: a second memory 1201 and a second processor 1202; the second memory 1201 is configured to store a time synchronization program, which is synchronized by the second processor 1202
- the time synchronization method shown in FIG. 8 can be implemented during execution.
- embodiments of the present application also provide a computer-readable medium that stores a time synchronization program that implements the steps of the above time synchronization method when executed by a processor, such as the time synchronization method shown in FIG. 7 or FIG. 8 .
- All or some of the steps, systems, and functional modules/units in the method disclosed above may be implemented as software, firmware, hardware, and appropriate combinations thereof.
- the division between the functional modules/units mentioned in the above description does not necessarily correspond to the division of physical components; for example, a physical component may have multiple functions, or a function or step may be composed of some physical
- the components are executed in cooperation.
- Some or all components may be implemented as software executed by a processor, such as a digital signal processor or microprocessor, or as hardware, or as an integrated circuit, such as an application specific integrated circuit.
- Such software may be distributed on computer-readable media, which may include computer storage media (or non-transitory media) and communication media (or transitory media).
- Computer storage media includes volatile and nonvolatile, removable and non-removable implemented in any method or technology for storing information such as computer readable instructions, data structures, program modules or other data medium.
- Computer storage media include but are not limited to Random Access Memory (RAM), Read-Only Memory (ROM), Erasable Programmable Read-Only Memory (Electrically Programmable Read-Only Memory, EEPROM) , Flash memory or other memory technology, compact disc read-only memory (Compact Disc Read-Only Memory, CD-ROM), digital versatile disc (Digital Video Disc, DVD) or other optical disc storage, magnetic box, magnetic tape, magnetic disk storage or other magnetic A storage device, or any other medium that can be used to store desired information and can be accessed by a computer.
- communication media typically contains computer readable instructions, data structures, program modules, or other data in a modulated data signal such as a carrier wave or other transmission mechanism, and may include any information delivery media.
Landscapes
- Engineering & Computer Science (AREA)
- Computer Networks & Wireless Communication (AREA)
- Signal Processing (AREA)
- Synchronisation In Digital Transmission Systems (AREA)
- Electric Clocks (AREA)
Abstract
Disclosed are a time synchronization method, system and device, and a storage medium. The time synchronization method comprises: a clock master device sending, to a clock slave device, a first time message carrying a first timestamp, wherein the first time message carries the first timestamp recorded by the clock master device when the first time message exits from a port of the clock master device; the clock master device receiving a second time message that is sent by the clock slave device and carries a second timestamp and a third timestamp, and putting, in the second time message, a fourth timestamp recorded by the clock master device when the second time message enters from the port of the clock master device, wherein the second timestamp is used for indicating the moment when the clock slave device receives the first time message, and the third timestamp is used for indicating the moment when the clock slave device sends the second time message; and the clock master device copying the second time message to generate a third time message, and sending the third time message to the clock slave device.
Description
本申请要求在2018年12月29日提交中国专利局、申请号为201811633978.6的中国专利申请的优先权,该申请的全部内容通过引用结合在本申请中。This application requires the priority of the Chinese patent application filed on December 29, 2018, with the application number 201811633978.6, and the entire content of the application is incorporated by reference in this application.
本申请实施例涉及通信技术领域,例如涉及一种时间同步方法、***、设备及存储介质。The embodiments of the present application relate to the field of communication technologies, for example, to a time synchronization method, system, device, and storage medium.
在第五代移动通信***(the Fifth-Generation mobile communication system,5G)网络通信中,对网络时间同步的要求变得很高,比如,承载网络的单个节点设备同步精度将达到纳秒级。而且,承载网络中多台设备通过集群、多虚一等技术方法来提高容量和速度,并作为网络中的单个节点时,需要提供高精度的时间同步。In the fifth-generation mobile communication system (the Fifth-Generation mobile communication system, 5G) network communication, the requirements for network time synchronization become very high. For example, the synchronization accuracy of a single node device carrying the network will reach the nanosecond level. Moreover, multiple devices in the bearer network use clusters, multiple virtual one and other technical methods to increase capacity and speed, and as a single node in the network, it is necessary to provide high-precision time synchronization.
发明内容Summary of the invention
本申请实施例提供一种时间同步方法、***、设备及存储介质,可以实现多设备间快速有效的高精度时间同步。Embodiments of the present application provide a time synchronization method, system, device, and storage medium, which can realize fast and efficient high-precision time synchronization among multiple devices.
本申请实施例提供一种时间同步方法,包括:时钟主设备向时钟从设备发送第一时间报文;时钟主设备接收所述时钟从设备发送的携带第二时间戳和第三时间戳的第二时间报文,并将第二时间报文入时钟主设备的端口时时钟主设备记录的第四时间戳放入第二时间报文;时钟主设备复制第二时间报文生成第三时间报文,并向时钟从设备发送第三时间报文;其中,第一时间报文携带第一时间报文出时钟主设备的端口时时钟主设备记录的第一时间戳;第二时间戳用于指示时钟从设备接收到第一时间报文的时刻,第三时间戳用于指示时钟从设备发送第二时间报文的时刻。An embodiment of the present application provides a time synchronization method, including: a clock master device sending a first time message to a clock slave device; a clock master device receiving a second time stamp and a third time stamp sent by the clock slave device. Two time messages, and put the fourth time stamp recorded by the clock master device into the second time message when the second time message enters the port of the clock master device; the clock master device copies the second time message to generate the third time report And send a third time message to the clock slave device; where the first time message carries the first time stamp recorded by the clock master device when the first time message exits the port of the clock master device; the second time stamp is used to Indicates the time when the clock slave device receives the first time message, and the third time stamp is used to indicate the time when the clock slave device sends the second time message.
本申请实施例提供一种时间同步方法,包括:时钟从设备接收时钟主设备发送的携带第一时间戳的第一时间报文,并将第一时间报文入时钟从设备的端口时时钟从设备记录的第二时间戳放入第一时间报文;时钟从设备复制第一时间报文生成第二时间报文,向时钟主设备发送第二时间报文,并将第二时间报文出时钟从设备的端口时时钟从设备记录的第三时间戳放入第二时间报文;时钟从设备接收时钟主设备发送的第三时间报文,并根据从第三时间报文获取的第一时间戳、第二时间戳、第三时间戳以及第四时间戳,计算时钟从设备与时 钟主设备之间的时间偏差;时钟从设备根据时间偏差,调整时钟从设备的时间;其中,第一时间戳用于指示时钟主设备发送第一时间报文的时刻;第四时间戳用于指示时钟主设备接收到第二时间报文的时刻。An embodiment of the present application provides a time synchronization method, including: a clock slave device receiving a first time message carrying a first time stamp sent by a clock master device, and inputting the first time message into a port of the clock slave device The second time stamp recorded by the device is placed in the first time message; the clock slave device copies the first time message to generate the second time message, sends the second time message to the clock master, and sends the second time message out The third time stamp recorded by the clock slave device is placed in the second time message when the clock slave device's port is clocked; the clock slave device receives the third time message sent by the clock master device, and according to the first time obtained from the third time message Timestamp, second timestamp, third timestamp, and fourth timestamp to calculate the time deviation between the clock slave device and the clock master device; the clock slave device adjusts the time of the clock slave device according to the time deviation; where, the first The time stamp is used to indicate the time when the clock master sends the first time message; the fourth time stamp is used to indicate the time when the clock master receives the second time message.
本申请实施例提供一种时间同步***,包括:时钟主设备以及时钟从设备;时钟主设备设置为向时钟从设备发送第一时间报文,其中,所述第一时间报文携带所述第一时间报文出所述时钟主设备的端口时所述时钟主设备记录的第一时间戳;时钟从设备设置为将第一时间报文入所述时钟从设备的端口时所述时钟从设备记录的第二时间戳放入第一时间报文,复制第一时间报文生成第二时间报文,向时钟主设备发送第二时间报文,并将第二时间报文出所述时钟从设备的端口时所述时钟从设备记录的第三时间戳放入第二时间报文;时钟主设备还设置为将第二时间报文入所述时钟主设备的端口时所述时钟主设备记录的第四时间戳放入第二时间报文,复制第二时间报文生成第三时间报文,并向时钟从设备发送第三时间报文;时钟从设备还设置为接收第三时间报文,根据从第三时间报文获取的第一时间戳、第二时间戳、第三时间戳以及第四时间戳,计算时钟从设备与时钟主设备之间的时间偏差;根据时间偏差,调整所述时钟从设备的时间。An embodiment of the present application provides a time synchronization system, including: a clock master device and a clock slave device; the clock master device is configured to send a first time message to the clock slave device, where the first time message carries the first The first time stamp recorded by the clock master device when a time packet exits the port of the clock master device; the clock slave device is set to the clock slave device when the first time message is entered into the port of the clock slave device Put the recorded second timestamp into the first time message, copy the first time message to generate the second time message, send the second time message to the clock master, and send the second time message out of the clock slave The third time stamp recorded by the clock slave device is placed in the second time message when the port of the device is set; the clock master device is also set to record when the second time message is entered into the port of the clock master device Put the fourth timestamp into the second time message, copy the second time message to generate the third time message, and send the third time message to the clock slave device; the clock slave device is also set to receive the third time message , Based on the first timestamp, second timestamp, third timestamp, and fourth timestamp obtained from the third time message, calculate the time deviation between the clock slave device and the clock master device; State the time of the clock slave device.
本申请实施例提供一种时间主设备,包括:第一存储器和第一处理器,所述第一存储器设置为存储时间同步程序,所述时间同步程序被所述第一处理器执行时实现上述时间主设备侧的时间同步方法。An embodiment of the present application provides a time master device, including: a first memory and a first processor, the first memory is configured to store a time synchronization program, and the time synchronization program is implemented by the first processor to achieve the above Time synchronization method on the time master device side.
本申请实施例提供一种时间从设备,包括:第二存储器和第二处理器,所述第二存储器设置为存储时间同步程序,所述时间同步程序被所述第二处理器执行时实现上述时间从设备侧的时间同步方法。An embodiment of the present application provides a time slave device, including: a second memory and a second processor, the second memory is configured to store a time synchronization program, and the time synchronization program is implemented when the second processor executes the above Time synchronization method from the device side.
本申请实施例提供一种计算机可读介质,存储有时间同步程序,所述时间同步程序被处理器执行时实现上述时间主设备侧的时间同步方法。An embodiment of the present application provides a computer-readable medium that stores a time synchronization program, and when the time synchronization program is executed by a processor, the time synchronization method on the time master device side is implemented.
本申请实施例提供一种计算机可读介质,存储有时间同步程序,所述时间同步程序被处理器执行时实现上述时间从设备侧的时间同步方法。An embodiment of the present application provides a computer-readable medium that stores a time synchronization program, and when the time synchronization program is executed by a processor, the time synchronization method on the time slave device side is implemented.
图1为一种主从时钟通过1588协议进行报文交互的示意图;Figure 1 is a schematic diagram of a master-slave clock for message interaction through the 1588 protocol;
图2为本申请实施例提供的一种时间同步***的交互示意图;2 is an interactive schematic diagram of a time synchronization system provided by an embodiment of the present application;
图3为本申请实施例提供的一种时间报文的结构示意图;3 is a schematic structural diagram of a time message provided by an embodiment of this application;
图4为本申请实施例提供的另一种时间同步***的交互流程图;4 is an interaction flowchart of another time synchronization system provided by an embodiment of the present application;
图5为本申请实施例提供的一种时间同步***的示意图;5 is a schematic diagram of a time synchronization system provided by an embodiment of this application;
图6为本申请实施例提供的另一种时间同步***的示意图;6 is a schematic diagram of another time synchronization system provided by an embodiment of the present application;
图7为本申请实施例提供的一种时间同步方法的流程图;7 is a flowchart of a time synchronization method provided by an embodiment of the present application;
图8为本申请实施例提供的另一种时间同步方法的流程图;8 is a flowchart of another time synchronization method provided by an embodiment of the present application;
图9为本申请实施例提供的一种应用组网示意图;9 is a schematic diagram of an application networking provided by an embodiment of this application;
图10为本申请实施例提供的另一种应用组网示意图;10 is a schematic diagram of another application networking provided by an embodiment of this application;
图11为本申请实施例提供的一种时钟主设备的示意图;11 is a schematic diagram of a clock master device provided by an embodiment of this application;
图12为本申请实施例提供的一种时钟从设备的示意图。12 is a schematic diagram of a clock slave device provided by an embodiment of the present application.
下面将结合附图对本申请的实施例进行说明。The embodiments of the present application will be described below with reference to the drawings.
在附图的流程图示出的步骤可以在诸如一组计算机可执行指令的计算机***中执行。并且,虽然在流程图中示出了逻辑顺序,但是在一些情况下,可以以不同于此处的顺序执行所示出或描述的步骤。The steps shown in the flowcharts of the figures can be performed in a computer system such as a set of computer-executable instructions. And, although a logical order is shown in the flowchart, in some cases, the steps shown or described may be performed in an order different from here.
多个物理设备间可以通过全球定位***(Global Positioning System,GPS)输入输出端口(串行口1秒脉冲(Pulse Per Second,PPS)+时间信息(Time Of Day,TOD))来传递时钟时间,此实现方式简单且成本低廉。设备上一般均存在此端口,通过网线即可完成组网互联。然而,该方案已不能满足5G时代的高精度时间同步要求。如RJ45接口传输422差分电平的1PPS,仅器件输出延时就会达20至30纳秒(ns),加上线缆和接收延时,时间同步精度将完全无法保证。即使加入延时补偿和校准,理想情况下时间同步也会是几十纳秒级。而且,通过上述方式进行的组网繁复,每根互联线均需要单独测量时延,不利于后续更新维护。Between multiple physical devices, the clock time can be transmitted through the Global Positioning System (GPS) input and output ports (Serial port 1 second pulse (Pulse Per Per Second, PPS) + time information (Time Of Of Day, TOD)). This implementation is simple and inexpensive. This port usually exists on the device, and the network interconnection can be completed through the network cable. However, this solution can no longer meet the high-precision time synchronization requirements of the 5G era. If the RJ45 interface transmits 1PPS of 422 differential levels, the output delay of the device alone will reach 20 to 30 nanoseconds (ns). With the cable and the reception delay, the time synchronization accuracy will not be guaranteed at all. Even if delay compensation and calibration are added, ideally, time synchronization will be in the order of tens of nanoseconds. Moreover, the networking through the above-mentioned methods is complicated, and each interconnection line requires a separate measurement of delay, which is not conducive to subsequent update and maintenance.
另外,可以通过网络接口运行精确时间同步协议(电器与电子工程师协会(Institute of Electrical and Electronics Engineers,IEEE)1588)来完成时间同步。图1为一种主从时钟通过1588协议进行报文交互的示意图。如图1所示,主时钟向从时钟发送同步(Sync)报文,其中可以携带主时钟发送同步报文的时间戳T1;从时钟接收到同步报文后,可以从同步报文中得到时间戳T1,并记录该同步报文的到达时间戳T2;从时钟可以发送延时请求(Delayreq)报文,并记录该延时请求报文的发送时间戳T3;主时钟接收到延时请求报文后,记录该延时请求报文的到达时间戳T4,并将时间戳T4携带在延时响应(Delayresp)报文中发送给从时钟;从时钟可以从延时响应报文中得到时间戳T4,并根据得到的时间戳T1至T4计算时间偏差,进而调整时间,以实现和主时钟同步。然而,采用1588协议进行报文交互的过程中,时间戳T1至T4需要由从时钟进行收集, 收集步骤较繁琐,而且,从时钟需要通过比对报文的1588数据集才能获得属于同一组的四个时间戳。In addition, accurate time synchronization protocol (Institute of Electrical and Electronic Engineers, IEEE 1588) can be run through the network interface to complete time synchronization. FIG. 1 is a schematic diagram of a master-slave clock for message interaction through the 1588 protocol. As shown in Figure 1, the master clock sends a synchronization (Sync) message to the slave clock, which can carry the timestamp T1 of the synchronization message sent by the master clock; after the slave clock receives the synchronization message, it can get the time from the synchronization message Poke T1 and record the arrival timestamp T2 of the synchronization message; the slave clock can send a delay request (Delayreq) message and record the timestamp T3 of the delay request message; the master clock receives the delay request message After the text, record the arrival timestamp T4 of the delay request message, and carry the timestamp T4 in the delay response (Delayresp) message and send it to the slave clock; the slave clock can get the time stamp from the delay response message T4, and calculate the time deviation according to the obtained time stamps T1 to T4, and then adjust the time to achieve synchronization with the main clock. However, in the process of using the 1588 protocol for message interaction, the time stamps T1 to T4 need to be collected by the slave clock, and the collection steps are cumbersome. Moreover, the slave clock needs to pass the 1588 data set of the comparison message to obtain the same group. Four time stamps.
而且,采用IEEE 1588完成时间同步时,设备的物理端口上都需要运行一套完整的1588协议,这将会占用较多的资源,实现成本较高。此外,针对多个设备组成的集群,由于在网络中该集群属于单个时钟节点,若在该集群内通过运行1588协议进行多个设备的时间同步,将会出现与该集群对外呈现的1588端口冲突的情况。比如,集群中会有多个主(master)和从(slave)端口,从而造成主从逻辑关系复杂和混乱,不利于管理。Moreover, when time synchronization is completed using IEEE 1588, a complete set of 1588 protocol needs to be run on the physical port of the device, which will occupy more resources and achieve higher cost. In addition, for a cluster composed of multiple devices, since the cluster belongs to a single clock node in the network, if the time synchronization of multiple devices is performed in the cluster by running the 1588 protocol, a conflict with the 1588 port presented by the cluster will appear. Case. For example, there will be multiple master and slave ports in the cluster, resulting in complicated and chaotic logical relationships between master and slave, which is not conducive to management.
本申请实施例提供一种时间同步方法、***、设备及存储介质,可以实现多设备间快速有效的高精度时间同步,而且极大地降低设备间时间同步的实现复杂度和成本,多设备可以简单灵活组网,易于管理,从而满足多设备的集群***在5G时代超高精度的时间同步要求。The embodiments of the present application provide a time synchronization method, system, device and storage medium, which can realize fast and efficient high-precision time synchronization between multiple devices, and greatly reduce the complexity and cost of implementing time synchronization between devices. Multi-device can be simple Flexible networking and easy management to meet the ultra-high precision time synchronization requirements of multi-device cluster systems in the 5G era.
本申请实施例提供一种时间同步***,包括:时钟主设备和时钟从设备;其中,时钟主设备设置为向时钟从设备发送第一时间报文,第一时间报文携带出端口时记录的第一时间戳;时钟从设备设置为将第一时间报文入端口时记录的第二时间戳放入第一时间报文,复制第一时间报文生成第二时间报文,向时钟主设备发送第二时间报文,并将第二时间报文出端口时记录的第三时间戳放入第二时间报文;时钟主设备还设置为将第二时间报文入端口时记录的第四时间戳放入第二时间报文,复制第二时间报文生成第三时间报文,并向时钟从设备发送第三时间报文;时钟从设备还设置为接收第三时间报文,根据从第三时间报文获取的第一时间戳、第二时间戳、第三时间戳以及第四时间戳,计算时钟从设备与时钟主设备之间的时间偏差;根据时间偏差,调整自身的时间。如此一来,时钟主设备和时钟从设备之间可以通过交互携带第一至第四时间戳的时间报文,实现快速有效的高精度时间同步。An embodiment of the present application provides a time synchronization system, including: a clock master device and a clock slave device; wherein, the clock master device is configured to send a first time message to the clock slave device, and the first time message carries the record recorded when the port exits First timestamp; the clock slave device is set to put the second timestamp recorded when the first time message enters the port into the first time message, copy the first time message to generate the second time message, and send it to the clock master Send the second time packet, and put the third time stamp recorded when the second time packet exits the port into the second time packet; the clock master is also set to the fourth recorded when the second time packet enters the port Put the timestamp into the second time message, copy the second time message to generate the third time message, and send the third time message to the clock slave device; the clock slave device is also set to receive the third time message according to The first timestamp, the second timestamp, the third timestamp, and the fourth timestamp obtained by the third time message calculate the time deviation between the clock slave device and the clock master device; and adjust its own time according to the time deviation. In this way, the clock master device and the clock slave device can carry time messages with the first to fourth timestamps through interaction, to achieve fast and efficient high-precision time synchronization.
在本申请实施例中,通过时钟主设备和时钟从设备之间的时间报文的交互,将第一至第四时间戳携带在时间报文中,从而方便时钟从设备收集多个时间戳,便于直接获得同一组时间戳,从而实现设备间快速有效的高精度时间同步。In the embodiment of the present application, the first to fourth time stamps are carried in the time message through the interaction of the time message between the clock master device and the clock slave device, thereby facilitating the clock slave device to collect multiple time stamps, It is convenient to obtain the same set of time stamps directly, so as to achieve fast and efficient high-precision time synchronization between devices.
图2为本申请实施例提供的一种时间同步***的交互示意图。如图2所示,本实施例提供的时间同步***的交互过程包括以下步骤:FIG. 2 is an interactive schematic diagram of a time synchronization system provided by an embodiment of the present application. As shown in FIG. 2, the interaction process of the time synchronization system provided by this embodiment includes the following steps:
步骤2010、时钟主设备发出第一时间报文,并在第一时间报文出端口时记录精确的第一时间戳T1,将第一时间戳T1放在第一时间报文的第一时间戳字段中。Step 2010: The clock master sends a first time message, and records an accurate first time stamp T1 when the first time message exits the port, and places the first time stamp T1 on the first time stamp of the first time message Field.
步骤2020、时钟从设备在第一时间报文入端口时记录精确的第二时间戳T2, 并将第二时间戳T2放在第一时间报文的第二时间戳字段中;时钟从设备复制第一时间报文生成第二时间报文,并将第二时间报文发送出去,在第二时间报文出端口时记录精确的第三时间戳T3,将第三时间戳T3放在第二时间报文的第三时间戳字段中。Step 2020, the clock slave device records an accurate second time stamp T2 when the first time packet enters the port, and places the second time stamp T2 in the second time stamp field of the first time packet; the clock slave device copies The first time message generates a second time message, and sends the second time message out, recording an accurate third time stamp T3 when the second time message exits the port, and placing the third time stamp T3 in the second In the third timestamp field of the time message.
步骤2030、时钟主设备在第二时间报文入端口时记录精确的第四时间戳T4,将第四时间戳T4放在第二时间报文的第四时间戳字段中;时钟主设备复制第二时间报文生成第三时间报文,并将第三时间报文发送出去。Step 2030, the clock master device records an accurate fourth time stamp T4 when the second time message enters the port, and places the fourth time stamp T4 in the fourth time stamp field of the second time message; The second time message generates a third time message, and sends the third time message.
步骤2040、时钟从设备从收到的第三时间报文中获取第一时间戳T1、第二时间戳T2、第三时间戳T3及第四时间戳T4,并计算时钟主设备和时钟从设备之间的时间偏差。Step 2040: The clock slave device obtains the first time stamp T1, the second time stamp T2, the third time stamp T3, and the fourth time stamp T4 from the received third time message, and calculates the clock master device and the clock slave device Time deviation between.
步骤2050、时钟从设备根据算出的时间偏差调整自身的时间,完成与时钟主设备之间的时间同步。Step 2050: The clock slave device adjusts its time according to the calculated time deviation, and completes time synchronization with the clock master device.
在一示例性实施例中,为了传递高精度的时间戳,第一时间戳、第二时间戳、第三时间戳和第四时间戳均可以包括:秒比特、纳秒比特以及亚纳秒比特。比如,任一时间戳的格式可以为48比特(bit)秒+32bit纳秒+16bit亚纳秒,其中,1纳秒等于0x10000。In an exemplary embodiment, in order to transfer a high-precision timestamp, the first timestamp, the second timestamp, the third timestamp, and the fourth timestamp may all include: second bits, nanosecond bits, and sub-nanosecond bits . For example, the format of any time stamp can be 48 bits (seconds) + 32 bits nanoseconds + 16 bits sub-nanoseconds, where 1 nanosecond is equal to 0x10000.
图3为本申请实施例提供的一种时间报文的结构示意图。本实施例中,第一时间报文、第二时间报文以及第三时间报文的报文格式可以一致。如图3所示,时间报文可以包括以下字段:报文头、收端口号、发端口号、时间报文类型(比如,第一时间报文、第二时间报文或第三时间报文)、第一时间戳、第二时间戳、第三时间戳、第四时间戳。通过本实施例定义的时间报文的格式可以简化收发包处理。FIG. 3 is a schematic structural diagram of a time message provided by an embodiment of the present application. In this embodiment, the format of the first time message, the second time message, and the third time message may be consistent. As shown in FIG. 3, the time message may include the following fields: message header, receiving port number, sending port number, time message type (for example, first time message, second time message, or third time message ), first timestamp, second timestamp, third timestamp, fourth timestamp. The format of the time message defined in this embodiment can simplify the processing of sending and receiving packets.
图4为本申请实施例提供的另一种时间同步***的交互流程图。如图4所示,本示例性实施例提供的时间同步***的交互过程包括以下步骤:FIG. 4 is an interaction flowchart of another time synchronization system provided by an embodiment of the present application. As shown in FIG. 4, the interaction process of the time synchronization system provided by this exemplary embodiment includes the following steps:
步骤4010、多个设备确认端口连接关系;其中,每个设备(作为发送端)均会通过自己的端口发送携带端口信息的第一时间报文;每个设备(作为接收端)收到发送端的第一时间报文后提取其中携带的端口信息,得到对端的端口信息,并确定端口连接关系。其中,可以通过软件管理分配多个设备之间的时钟主从同步关系。本示例性实施例中,设备的端口可以为以太网光口。 Step 4010, multiple devices confirm the port connection relationship; each device (as the sending end) will send the first time message carrying port information through its own port; each device (as the receiving end) receives the sending end After the first time message, extract the port information carried in it, get the port information of the peer, and determine the port connection relationship. Among them, the clock master-slave synchronization relationship between multiple devices can be distributed through software management. In this exemplary embodiment, the port of the device may be an Ethernet optical port.
本示例性实施例中,多个设备通过端口互联时,在初始状态并不清楚主从关系及端口互联关系。在本步骤中,为了便于时钟组网的管理,在第一时间报文中可以定义端口信息字段,在多个设备的端口连接后,可以互相发送携带端口信息的第一时间报文;接收端可以从第一时间报文提取出对端的端口信息, 这样在组网时端口连线不受限制,可随意选择端口连接。上层软件可根据端口连接关系分配时钟主从的同步关系。然而,本申请对此并不限定。在其他实现方式中,可以省去本步骤,通过人工方式确认端口连接关系。In this exemplary embodiment, when multiple devices are interconnected through ports, the master-slave relationship and the port interconnection relationship are not clear in the initial state. In this step, in order to facilitate the management of the clock network, the port information field can be defined in the first time packet, and after the ports of multiple devices are connected, the first time packet carrying port information can be sent to each other; the receiving end The port information of the peer can be extracted from the first time message, so that the port connection is not restricted during networking, and the port connection can be selected at will. The upper layer software can distribute the clock master-slave synchronization relationship according to the port connection relationship. However, this application is not limited to this. In other implementations, this step can be omitted, and the port connection relationship can be confirmed manually.
步骤4020、时钟主设备发出第一时间报文,在第一时间报文出端口时记录精确的第一时间戳T1,并将第一时间戳T1放在第一时间报文的第一时间戳字段中。Step 4020: The clock master sends a first time message, records an accurate first time stamp T1 when the first time message exits the port, and places the first time stamp T1 on the first time stamp of the first time message Field.
在本示例性实施例中,在步骤4010中确认时钟的主从关系后,由时钟主设备发送第一时间报文,本步骤的第一时间报文与步骤4010中的第一时间报文的格式可以一致,可简化发包。In this exemplary embodiment, after confirming the master-slave relationship of the clock in step 4010, the clock master device sends the first time message. The first time message in this step is the same as the first time message in step 4010. The format can be consistent, which can simplify the package delivery.
在一示例性实施方式中,为了获得高精度的时间戳,在第一时间报文出端口时,可以获取第一时间报文的帧起始定界符(Start of Frame Delimiter,SFD)到达串行收发器(SERializer/DESerialize,SERDES)的并行数据入口处的时间戳,并对获取的时间戳补偿SERDES发送端的所有延时,从而得到高精度的第一时间戳T1。In an exemplary embodiment, in order to obtain a high-precision timestamp, when the first time message exits the port, the frame start delimiter (SFD) arrival string of the first time message can be obtained The time stamp at the parallel data entry of the serial transceiver (SERializer/DESerialize, SERDES), and compensates for all the delay of the SERDES sender for the obtained time stamp, so as to obtain the high-precision first time stamp T1.
步骤4030、时钟从设备在第一时间报文入端口时记录精确的第二时间戳T2,将第二时间戳T2放在第一时间报文的第二时间戳字段中;时钟从设备复制第一时间报文生成第二时间报文,并将第二时间报文发送出去,在第二时间报文出端口时记录精确的第三时间戳T3,将第三时间戳T3放在第二时间报文的第三时间戳字段中。Step 4030: The clock slave device records an accurate second time stamp T2 when the first time packet enters the port, and places the second time stamp T2 in the second time stamp field of the first time packet; A time message generates a second time message, and sends the second time message out, recording an accurate third time stamp T3 when the second time message exits the port, and placing the third time stamp T3 at the second time In the third timestamp field of the message.
在本步骤中,时钟从设备在记录第一时间报文的入端口的精确第二时间戳T2时,需识别到并推算第一时间报文的SFD到达SERDES的并行数据出口处的时间戳,并给该时间戳补偿SERDES接收端的所有延时,从而得到精确的第二时间戳T2。其中,第二时间戳T2不用存储在时钟从设备,而是直接加入第一时间报文的第二时间戳字段中。In this step, when recording the accurate second time stamp T2 of the input port of the first time packet, the clock slave device needs to identify and estimate the time stamp of the SFD of the first time packet reaching the parallel data exit of SERDES, The timestamp is compensated for all delays at the receiving end of the SERDES, thereby obtaining an accurate second timestamp T2. Among them, the second time stamp T2 need not be stored in the clock slave device, but directly added to the second time stamp field of the first time message.
本步骤中,时钟从设备复制第一时间报文生成第二时间报文,并将第二时间报文发送出去,在第二时间报文出端口时记录精确的第三时间戳T3,将第三时间戳放在第二时间报文的第三时间戳字段中。此时,时钟从设备发出的第二时间报文中包含T1、T2、T3三个时间戳。In this step, the clock slave device copies the first time message to generate the second time message, and sends the second time message out. When the second time message exits the port, an accurate third time stamp T3 is recorded. The three time stamps are placed in the third time stamp field of the second time message. At this time, the second time message sent by the clock slave device contains three time stamps T1, T2, and T3.
在一示例性实施方式中,为了获得高精度的时间戳,在第二时间报文出端口时,可以获取第二时间报文的SFD到达SERDES的并行数据入口处的时间戳,并对获取的时间戳补偿SERDES发送端的所有延时,从而得到高精度的第三时间戳T3。In an exemplary embodiment, in order to obtain a high-precision timestamp, when the second time packet exits the port, the timestamp at which the SFD of the second time packet arrives at the parallel data entry of SERDES can be obtained, and the The timestamp compensates for all delays at the sending end of the SERDES, thereby obtaining a highly accurate third timestamp T3.
步骤4040、时钟主设备在第二时间报文入端口时记录精确的第四时间戳T4, 将第四时间戳T4放在第二时间报文的第四时间戳字段中;时钟主设备复制第二时间报文生成第三时间报文,并将第三时间报文发送出去。此时,时钟主设备发出的第三时间报文中包含T1、T2、T3、T4四个时间戳。Step 4040: The clock master device records an accurate fourth time stamp T4 when the second time message enters the port, and places the fourth time stamp T4 in the fourth time stamp field of the second time message; the clock master device copies the first The second time message generates a third time message, and sends the third time message. At this time, the third time message sent by the clock master device includes four time stamps T1, T2, T3, and T4.
在一示例性实施例中,时钟从设备在记录第二时间报文的入端口的精确第四时间戳T4时,需识别到并推算第二时间报文的SFD到达SERDES的并行数据出口处的时间戳,并给该时间戳补偿SERDES接收端的所有延时,从而得到精确的第四时间戳T4。其中,第四时间戳T4不用存储在时钟主设备端,而是直接加入第二时间报文的第四时间戳字段中。In an exemplary embodiment, when recording the accurate fourth time stamp T4 of the input port of the second time packet, the clock slave device needs to identify and estimate that the SFD of the second time packet reaches the parallel data outlet of the SERDES Time stamp, and compensate all the delays of the SERDES receiving end to the time stamp, so as to obtain the accurate fourth time stamp T4. Among them, the fourth time stamp T4 does not need to be stored in the clock master device, but is directly added to the fourth time stamp field of the second time message.
步骤4050、时钟从设备在收到的第三时间报文中获取T1、T2、T3、T4四个时间戳,计算时钟主从设备之间的时间偏差和路径时延。示例性地,时钟从设备可以根据时间戳T1至T4直接计算时钟主从设备之间的时间偏差,或者,时钟从设备可以根据时间戳T1至T4计算时钟主从设备之间的路径时延,根据路径时延计算时间偏差。本申请对此并不限定。Step 4050: The clock slave device obtains four time stamps T1, T2, T3, and T4 in the received third time message, and calculates the time deviation and path delay between the clock master and slave devices. Exemplarily, the clock slave device can directly calculate the time deviation between the clock master and slave devices according to the time stamps T1 to T4, or the clock slave device can calculate the path delay between the clock master and slave devices according to the time stamps T1 to T4, Calculate the time deviation according to the path delay. This application is not limited to this.
本步骤中,通过第三时间报文获取的T1、T2、T3、T4为同一组时间戳,可以避免时间戳分别存储在时钟主设备和时钟从设备,时钟从设备需要进行识别关键字段匹配为同一组时间戳的过程,节省了存储和运算逻辑资源。In this step, T1, T2, T3, and T4 obtained through the third time message are the same set of time stamps, which can avoid the time stamps being stored in the clock master device and the clock slave device respectively. The clock slave device needs to identify key field matches The process of the same set of time stamps saves storage and computing logic resources.
本步骤中,由时间戳T1至T4可通过下面的式子计算出时间偏差和路径时延:In this step, the time offset and path delay can be calculated from the time stamps T1 to T4 using the following formula:
offset=(T2-T1-T4+T3)/2;offset=(T2-T1-T4+T3)/2;
pathdelay=(T2-T1+T4-T3)/2;pathdelay=(T2-T1+T4-T3)/2;
其中,offset为时间偏差,pathdelay为路径时延。Among them, offset is the time deviation, pathdelay is the path delay.
步骤4060、时钟从设备根据算出的时间偏差调整自身的时间,完成时间同步。Step 4060: The clock slave device adjusts its time according to the calculated time deviation to complete time synchronization.
本示例性实施例中,按照上述步骤完成的时间同步精度可达ns级及以下。In the present exemplary embodiment, the time synchronization accuracy completed according to the above steps can reach ns level or below.
图5为本申请实施例提供的一种时间同步***的示意图。如图5所示,本实施例提供的时间同步***包括:时钟主设备50和时钟从设备52;其中,时钟主设备50可以包括第一时间报文处理模块502及第三时间报文处理模块503;第一时间报文处理模块502和第三时间报文处理模块503设置为处理时钟主设备端的报文收发和记录时间戳。其中,第一时间报文处理模块502可以设置为控制时钟主设备50发出第一时间报文,并将第一时间报文出端口时记录的第一时间戳放入第一时间报文;第三时间报文处理模块503可以设置为将第二时间报文入端口时记录的第四时间戳放入第二时间报文,复制第二时间报文生成第三时间报文,并向时钟从设备52发送第三时间报文。FIG. 5 is a schematic diagram of a time synchronization system provided by an embodiment of the present application. As shown in FIG. 5, the time synchronization system provided by this embodiment includes: a clock master device 50 and a clock slave device 52; wherein, the clock master device 50 may include a first time message processing module 502 and a third time message processing module 503; The first time message processing module 502 and the third time message processing module 503 are set to process message sending and receiving and recording time stamps on the clock master device side. The first time message processing module 502 may be set to control the clock master device 50 to send the first time message, and put the first time stamp recorded when the first time message is output from the port into the first time message; The three-time message processing module 503 may be set to put the fourth time stamp recorded when the second time message enters the port into the second time message, copy the second time message to generate the third time message, and send the clock to the clock The device 52 sends the third time message.
如图5所示,时钟从设备52可以包括第二时间报文处理模块522、时间同步计算模块523及时间同步调整模块524。第二时间报文处理模块522设置为处理时钟从设备端的报文收发和时间戳记录,时间同步计算模块523设置为时钟从设备端的时间偏差计算,时间同步调整模块524设置为时钟从设备端的时间调整。其中,第二时间报文处理模块522,设置为将第一时间报文入端口时记录的第二时间戳放入第一时间报文,复制第一时间报文生成第二时间报文,向时钟主设备50发送第二时间报文,并将第二时间报文出端口时记录的第三时间戳放入第二时间报文。时间同步计算模块523,设置为根据从第三时间报文获取的第一时间戳、第二时间戳、第三时间戳以及第四时间戳,计算时钟从设备52与时钟主设备50之间的时间偏差。时间同步调整模块524,设置为根据时间偏差,调整时钟从设备52的时间。As shown in FIG. 5, the clock slave device 52 may include a second time message processing module 522, a time synchronization calculation module 523, and a time synchronization adjustment module 524. The second time message processing module 522 is configured to process message sending and receiving and time stamp recording of the clock slave device, the time synchronization calculation module 523 is configured to calculate time deviation of the clock slave device, and the time synchronization adjustment module 524 is configured to time of the clock slave device Adjustment. The second time message processing module 522 is configured to put the second time stamp recorded when the first time message enters the port into the first time message, copy the first time message to generate the second time message, and send the The clock master device 50 sends the second time message, and puts the third time stamp recorded when the second time message exits the port into the second time message. The time synchronization calculation module 523 is configured to calculate the time between the clock slave device 52 and the clock master device 50 based on the first time stamp, the second time stamp, the third time stamp, and the fourth time stamp obtained from the third time message. Time deviation. The time synchronization adjustment module 524 is set to adjust the time of the clock slave 52 according to the time deviation.
关于本实施例提供的时间同步***的处理流程可以参照图2和图4对应的实施例,故于此不再赘述。For the processing flow of the time synchronization system provided by this embodiment, reference may be made to the embodiments corresponding to FIG. 2 and FIG. 4, so details are not described herein again.
图6为本申请实施例提供的另一种时间同步***的示意图。如图6所示,相较于图5所示的时间同步***,本实施例提供的时间同步***中,时钟主设备52还可以包括:第一端口关系处理模块601,设置为发送携带端口信息的第一时间报文;以及,从接收到的携带端口信息的第一时间报文中提取端口信息,并根据端口信息,确定时钟主设备50的端口连接关系。如图6所示,时钟主设备52还可以包括:第二端口关系处理模块621,设置为发送携带端口信息的第一时间报文;以及,从接收到的携带端口信息的第一时间报文中提取端口信息,并根据端口信息,确定时钟从设备52的端口连接关系。FIG. 6 is a schematic diagram of another time synchronization system provided by an embodiment of the present application. As shown in FIG. 6, compared to the time synchronization system shown in FIG. 5, in the time synchronization system provided by this embodiment, the clock master 52 may further include: a first port relationship processing module 601 configured to send port information The first time message; and extract the port information from the received first time message carrying the port information, and determine the port connection relationship of the clock master 50 according to the port information. As shown in FIG. 6, the clock master device 52 may further include: a second port relationship processing module 621 configured to send a first time message carrying port information; and, from the received first time message carrying port information The port information is extracted from, and the port connection relationship of the clock slave device 52 is determined according to the port information.
关于本实施例提供的时间同步***的相关说明可以参照图5所示实施例的描述,故于此不再赘述。For the relevant description of the time synchronization system provided by this embodiment, reference may be made to the description of the embodiment shown in FIG. 5, so details are not described here.
图7为本申请实施例提供的一种时间同步方法的流程图。如图7所示,本实施例提供的时间同步方法,包括:7 is a flowchart of a time synchronization method provided by an embodiment of the present application. As shown in FIG. 7, the time synchronization method provided by this embodiment includes:
步骤7010、时钟主设备向时钟从设备发送第一时间报文,第一时间报文携带出端口时记录的第一时间戳。Step 7010: The clock master device sends a first time message to the clock slave device, and the first time message carries the first time stamp recorded when the port exits.
步骤7020、时钟主设备从时钟从设备接收携带第二时间戳和第三时间戳的第二时间报文,并将第二时间报文入端口时记录的第四时间戳放入第二时间报文;其中,第二时间戳用于指示时钟从设备接收到第一时间报文的时刻,第三时间戳用于指示时钟从设备发送第二时间报文的时刻。 Step 7020, the clock master device receives the second time message carrying the second time stamp and the third time stamp from the clock slave device, and puts the fourth time stamp recorded when the second time message is entered into the port into the second time report Wherein, the second time stamp is used to indicate the moment when the clock receives the first time message from the device, and the third time stamp is used to indicate the moment when the clock sends the second time message from the device.
步骤7030、时钟主设备复制第二时间报文生成第三时间报文,并向时钟从设备发送第三时间报文。Step 7030: The clock master device copies the second time message to generate a third time message, and sends the third time message to the clock slave device.
本实施例中,时钟主设备发送的第三时间报文可以携带第一时间戳、第二时间戳、第三时间戳及第四时间戳。In this embodiment, the third time message sent by the clock master device may carry a first time stamp, a second time stamp, a third time stamp, and a fourth time stamp.
在一示例性实施例中,第一时间戳、第二时间戳、第三时间戳以及第四时间戳均可以包括秒比特、纳秒比特以及亚纳秒比特,从而实现高精度时间信息的传递。In an exemplary embodiment, the first timestamp, the second timestamp, the third timestamp, and the fourth timestamp may include second bits, nanosecond bits, and sub-nanosecond bits, thereby achieving the transfer of high-precision time information .
在一示例性实施例中,步骤7010之前,本实施例的时间同步方法还可以包括:时钟主设备发送携带端口信息的第一时间报文;时钟主设备从接收到的携带端口信息的第一时间报文中提取端口信息,并根据端口信息,确定端口连接关系。其中,时钟主设备与其他设备之间可以通过传递端口信息,来确定端口连接关系,以便于上层软件通过端口连接关系分配时钟主从的同步关系。In an exemplary embodiment, before step 7010, the time synchronization method of this embodiment may further include: the clock master device sends a first time message carrying port information; the clock master device receives the first port message carrying port information from the first The port information is extracted from the time message, and the port connection relationship is determined according to the port information. Among them, the clock master device and other devices can pass the port information to determine the port connection relationship, so that the upper layer software can distribute the clock master-slave synchronization relationship through the port connection relationship.
在一示例性实施例中,本实施例的时间同步方法还可以包括:通过以下方式确定第一时间戳:确定第一时间报文的SFD到达SERDES的并行数据入口处的时间戳,给该时间戳补偿SERDES发送端的所有延时,得到第一时间戳。如此,可以获得高精度的时间戳。In an exemplary embodiment, the time synchronization method of this embodiment may further include: determining the first time stamp by: determining the time stamp at which the SFD of the first time message arrives at the parallel data entry of SERDES, and giving the time The timestamp compensates for all delays at the SERDES sender, and gets the first timestamp. In this way, a high-precision time stamp can be obtained.
在一示例性实施例中,本实施例的时间同步方法还可以包括:通过以下方式确定第四时间戳:确定第二时间报文的SFD到达SERDES的并行数据出口处的时间戳,给该时间戳补偿SERDES接收端的所有延时,得到第四时间戳。如此,可以获得高精度的时间戳。In an exemplary embodiment, the time synchronization method of this embodiment may further include: determining a fourth time stamp by: determining a time stamp at which the SFD of the second time message arrives at the parallel data exit of SERDES, and giving the time The timestamp compensates all delays at the receiving end of the SERDES and obtains the fourth time stamp. In this way, a high-precision time stamp can be obtained.
在一示例性实施例中,时钟主设备和时钟从设备属于同一个集群***。其中,同一个集群***内的多个设备采用本实施例的时间同步方法后,可以实现集群***的高精度时间同步,而且集群组网简单灵活,易于管理。In an exemplary embodiment, the clock master device and the clock slave device belong to the same cluster system. Among them, after multiple devices in the same cluster system adopt the time synchronization method of this embodiment, high-precision time synchronization of the cluster system can be achieved, and the cluster networking is simple and flexible and easy to manage.
图8为本申请实施例提供的另一种时间同步方法的流程图。如图8所示,本实施例提供的时间同步方法,包括:FIG. 8 is a flowchart of another time synchronization method provided by an embodiment of the present application. As shown in FIG. 8, the time synchronization method provided in this embodiment includes:
步骤8010、时钟从设备从时钟主设备接收携带第一时间戳的第一时间报文,并将第一时间报文入端口时记录的第二时间戳放入第一时间报文;其中,第一时间戳用于指示时钟主设备发送第一时间报文的时刻。Step 8010: The clock slave device receives the first time message carrying the first time stamp from the clock master device, and puts the second time stamp recorded when the first time message enters the port into the first time message; A time stamp is used to indicate the time when the clock master sends the first time message.
步骤8020、时钟从设备复制第一时间报文生成第二时间报文,向时钟主设备发送第二时间报文,并将第二时间报文出端口时记录的第三时间戳放入第二时间报文。 Step 8020, the clock slave device copies the first time message to generate a second time message, sends the second time message to the clock master device, and puts the third time stamp recorded when the second time message is out of the port into the second Time message.
步骤8030、时钟从设备从时钟主设备接收第三时间报文,并根据从第三时间报文获取的第一时间戳、第二时间戳、第三时间戳以及第四时间戳,计算时钟从设备与时钟主设备之间的时间偏差;其中,第四时间戳用于指示时钟主设备接收到第二时间报文的时刻。Step 8030: The clock slave device receives the third time message from the clock master device, and calculates the clock slave according to the first time stamp, the second time stamp, the third time stamp, and the fourth time stamp obtained from the third time message. The time deviation between the device and the clock master; where the fourth timestamp is used to indicate the moment when the clock master receives the second time message.
步骤8040、时钟从设备根据时间偏差,调整自身的时间。Step 8040: The clock slave device adjusts its own time according to the time deviation.
在一示例性实施例中,第一时间戳、第二时间戳、第三时间戳以及第四时间戳均可以包括秒比特、纳秒比特以及亚纳秒比特。In an exemplary embodiment, the first time stamp, the second time stamp, the third time stamp, and the fourth time stamp may all include second bits, nanosecond bits, and sub-nanosecond bits.
在一示例性实施例中,步骤8010之前,本实施例的时间同步方法还可以包括:时钟从设备发送携带端口信息的第一时间报文;时钟从设备从接收到的携带端口信息的第一时间报文中提取端口信息,并根据端口信息,确定端口连接关系。其中,时钟从设备与其他设备之间可以通过传递端口信息,来确定端口连接关系,以便于上层软件通过端口连接关系分配时钟主从的同步关系。In an exemplary embodiment, before step 8010, the time synchronization method of this embodiment may further include: the clock slave device sends a first time packet carrying port information; the clock slave device receives the first port message carrying port information The port information is extracted from the time message, and the port connection relationship is determined according to the port information. Among them, the clock slave device and other devices can pass the port information to determine the port connection relationship, so that the upper layer software can distribute the clock master-slave synchronization relationship through the port connection relationship.
在一示例性实施例中,本实施例的时间同步方法还可以包括:通过以下方式确定第二时间戳:确定第一时间报文的SFD到达SERDES的并行数据出口处的时间戳,给该时间戳补偿SERDES接收端的所有延时,得到第二时间戳。In an exemplary embodiment, the time synchronization method of this embodiment may further include: determining the second time stamp by: determining the time stamp at which the SFD of the first time message arrives at the parallel data exit of SERDES, and giving the time The timestamp compensates all delays at the receiving end of the SERDES and obtains the second timestamp.
在一示例性实施例中,本实施例的时间同步方法还可以包括:通过以下方式确定第三时间戳:确定第二时间报文的SFD到达SERDES的并行数据入口处的时间戳,给该时间戳补偿SERDES发送端的所有延时,得到第三时间戳。In an exemplary embodiment, the time synchronization method of this embodiment may further include: determining a third time stamp by: determining a time stamp at which the SFD of the second time message arrives at the parallel data entry of SERDES, and giving the time The timestamp compensates for all delays at the SERDES sender, and a third timestamp is obtained.
在一示例性实施例中,时钟主设备和时钟从设备属于同一个集群***。其中,同一个集群***内的多个设备采用本实施例的时间同步方法后,可以实现集群***的高精度时间同步,而且集群组网简单灵活,易于管理。In an exemplary embodiment, the clock master device and the clock slave device belong to the same cluster system. Among them, after multiple devices in the same cluster system adopt the time synchronization method of this embodiment, high-precision time synchronization of the cluster system can be achieved, and the cluster networking is simple and flexible and easy to manage.
图9为本申请实施例提供的一种应用组网示意图。其中,说明本实施例提供的时间同步方法在集群***中的一种应用方式。9 is a schematic diagram of an application networking provided by an embodiment of the present application. Among them, an application manner of the time synchronization method provided in this embodiment in a cluster system is described.
本示例性实施例中,以包括两个中心框(物理设备)和多个业务框(物理设备)的集群***为例进行说明。由于多个分离的设备在组成集群后对外需呈现为一个单独的时间节点,因此集群内多个框间必须保证时间同步。本实施例中,中心框1与中心框2、每个中心框与业务框间均通过本实施例提供的时间同步方法相连,其中,中心框1与中心框2互为备份。In this exemplary embodiment, a cluster system including two central frames (physical equipment) and multiple service frames (physical equipment) is taken as an example for description. Since multiple separated devices need to be presented as a single time node after forming a cluster, time synchronization must be guaranteed between multiple frames in the cluster. In this embodiment, the central frame 1 and the central frame 2, and each central frame and service frame are connected by the time synchronization method provided in this embodiment, wherein the central frame 1 and the central frame 2 are mutually backup.
如图9所示,本实施例中的时间同步过程包括以下步骤:As shown in FIG. 9, the time synchronization process in this embodiment includes the following steps:
步骤9010、GPS或者1588时间从中心框1输入,中心框1作为集群***的时间源,需同步到中心框2及业务框1至n,n为大于1的整数。Step 9010, GPS or 1588 time is input from the central frame 1. The central frame 1 serves as the time source of the cluster system and needs to be synchronized to the central frame 2 and the service frames 1 to n, where n is an integer greater than 1.
步骤9020、多个中心框及多个业务框(作为发送端)均发送第一时间报文,其中包含端口信息。多个中心框及业务框(作为接收端)收到第一时间报文后提取其中携带的端口信息,根据提取的端口信息,得到自己的端口连接关系。由软件管理分配时钟主从的同步关系。根据本示例的应用场景,可以选择中心框1作为时钟主设备,其余框(中心框2及业务框1至n)作为时钟从设备。Step 9020, multiple central frames and multiple service frames (as sending ends) all send the first time message, which includes port information. After receiving the first time message, multiple central frames and service frames (as receiving ends) extract the port information carried in them, and obtain their own port connection relationship according to the extracted port information. The software manages the distribution of the clock master-slave synchronization relationship. According to the application scenario of this example, the center frame 1 can be selected as the clock master device, and the remaining frames (center frame 2 and service frames 1 to n) can be selected as clock slave devices.
中心框1与其余框(中心框2及业务框1至n)之间分别进行时间同步处理过程,使得其余框均与中心框1实现时间同步。下面以中心框1与业务框1之间的时间同步过程为例进行说明。A time synchronization process is performed between the center frame 1 and the remaining frames (the center frame 2 and the service frames 1 to n), so that the remaining frames are time synchronized with the center frame 1. The following takes the time synchronization process between the central frame 1 and the service frame 1 as an example for description.
步骤9030、中心框1向业务框1发送第一时间报文,并在出端口时记录精确的第一时间戳T1,放在第一时间报文的第一时间戳字段中。Step 9030: The central box 1 sends a first time message to the service box 1, and records an accurate first time stamp T1 at the egress port, and places it in the first time stamp field of the first time message.
步骤9040、业务框1在第一时间报文入端口时记录精确的第二时间戳T2,放在第一时间报文的第二时间戳字段中。业务框1可以复制第一时间报文生成第二时间报文,并发送出去,在出端口时记录精确的第三时间戳T3,将第三时间戳T3放在第二时间报文的第三时间戳字段中。Step 9040, the service block 1 records an accurate second time stamp T2 when the first time packet enters the port, and places it in the second time stamp field of the first time packet. Service box 1 can copy the first time message to generate a second time message, and send it out, record the accurate third time stamp T3 when leaving the port, and place the third time stamp T3 in the third of the second time message Timestamp field.
步骤9050、中心框1在第二时间报文入端口时记录精确的第四时间戳T4,并将第四时间戳T4放在第二时间报文的第四时间戳字段中;复制第二时间报文生成第三时间报文,并发送出去。Step 9050, the central box 1 records an accurate fourth time stamp T4 when the second time message enters the port, and places the fourth time stamp T4 in the fourth time stamp field of the second time message; copy the second time The message generates a third time message and sends it out.
步骤9060、业务框1在收到的第三时间报文中获取四个时间戳T1、T2、T3、T4,计算主从设备(即中心框1与业务框1之间)的时间偏差和路径时延。Step 9060, the service frame 1 obtains four time stamps T1, T2, T3, and T4 in the received third time message, and calculates the time deviation and path of the master-slave device (that is, between the center frame 1 and the service frame 1) Delay.
步骤9070、业务框1根据算出的时间偏差调整自身的时间,完成和中心框1之间的时间同步。Step 9070, the service frame 1 adjusts its own time according to the calculated time deviation, and completes time synchronization with the center frame 1.
步骤9080、完成中心框1与中心框2,以及中心框1与其他业务框之间的时间同步。其中,关于中心框1与中心框2,以及中心框1与其他业务框之间的时间同步过程可以参照步骤9030至步骤9070,故于此不再赘述。Step 9080, completing the time synchronization between the central frame 1 and the central frame 2, and between the central frame 1 and other service frames. For the time synchronization process between the central frame 1 and the central frame 2 and between the central frame 1 and other service frames, reference may be made to steps 9030 to 9070, so they will not be repeated here.
步骤9090、多个业务框可提供多个1588的master端口同步下游的slave设备。Step 9090, multiple service frames may provide multiple 1588 master ports to synchronize downstream slave devices.
在本实施例的集群***中,在集群***内部的设备之间可以采用本实施例提供的时间同步方法实现高精度的时间同步,集群***对外可以采用1588协议进行时间同步,从而避免集群***内外均采用1588协议进行时间同步时存在的冲突情况,便于管理。In the cluster system of this embodiment, the time synchronization method provided in this embodiment can be used to achieve high-precision time synchronization between the devices in the cluster system, and the cluster system can use the 1588 protocol for time synchronization to avoid internal and external cluster systems. The conflicts exist when using 1588 protocol for time synchronization, which is easy to manage.
图10为本申请实施例提供的另一种应用组网示意图。本示例性实施例中,以包括两个中心框和多个业务框的集群***为例进行说明。由于多个分离的设备在组成集群后对外需呈现为一个单独的时间节点,因此集群内多个框间必须保证时间同步。本实施例中,中心框1与中心框2、每个中心框与业务框间均通过本实施例提供的时间同步方法相连,其中,中心框1与中心框2互为备份。10 is a schematic diagram of another application networking provided by an embodiment of this application. In this exemplary embodiment, a cluster system including two central frames and multiple service frames is used as an example for description. Since multiple separated devices need to be presented as a single time node after forming a cluster, time synchronization must be guaranteed between multiple frames in the cluster. In this embodiment, the central frame 1 and the central frame 2, and each central frame and service frame are connected by the time synchronization method provided in this embodiment, wherein the central frame 1 and the central frame 2 are mutually backup.
如图10所示,本实施例中的时间同步过程包括以下步骤:As shown in FIG. 10, the time synchronization process in this embodiment includes the following steps:
步骤10010、GPS或者1588时间从业务框1输入,业务框1作为集群*** 的时间源,需同步到中心框1、中心框2及其他业务框(比如,业务框2至n,其中,n为大于1的整数)。Step 10010, GPS or 1588 time is input from the service box 1, and the service box 1 serves as the time source of the cluster system, and needs to be synchronized to the center box 1, the center box 2, and other service boxes (for example, service boxes 2 to n, where n is Integer greater than 1).
步骤10020、多个中心框及多个业务框(作为发送端)均发送第一时间报文,其中包含端口信息。多个中心框及业务框(作为接收端)收到第一时间报文后提取其中携带的端口信息,根据提取的端口新,得到自己的端口连接关系。由软件管理分配时钟主从同步关系。根据本示例的应用场景,可以选择业务框1作为时钟主设备,中心框1作为时钟从设备;同时中心框1又作为时钟主设备,中心框2及其余业务框2至业务框n为时钟从设备。Step 10020, multiple central frames and multiple service frames (as sending ends) all send a first time message, which includes port information. After receiving the first time message, multiple center frames and service frames (as receiving ends) extract the port information carried in them, and obtain their own port connection relationship according to the extracted new port. The software manages and distributes the clock master-slave synchronization relationship. According to the application scenario of this example, you can select the service box 1 as the clock master device and the center box 1 as the clock slave device; at the same time, the center box 1 serves as the clock master device, and the center box 2 and the remaining service boxes 2 to service box n are clock slave devices equipment.
下面以业务框1与中心框1之间的时间同步过程为例进行说明。The following describes the time synchronization process between the service frame 1 and the center frame 1 as an example.
步骤10030、业务框1向中心框1发送第一时间报文,在出端口时记录精确的第一时间戳T1,放在第一时间报文的第一时间戳字段中。Step 10030. The service box 1 sends a first time message to the central box 1, and records an accurate first time stamp T1 at the egress port, and puts it in the first time stamp field of the first time message.
步骤10040、中心框1在第一时间报文入端口时记录精确的第二时间戳T2,放在第一时间报文的第二时间戳字段中。中心框1可以复制第一时间报文生成第二时间报文,并发送出去,在出端口时记录精确的第三时间戳T3,将第三时间戳T3放在第二时间报文的第三时间戳字段中。Step 10040. The central box 1 records an accurate second time stamp T2 when the first time message enters the port, and places it in the second time stamp field of the first time message. The central box 1 can copy the first time message to generate the second time message, and send it out, record the accurate third time stamp T3 when leaving the port, and place the third time stamp T3 in the third of the second time message Timestamp field.
步骤10050、业务框1在第二时间报文入端口时记录精确的第四时间戳T4,将第四时间戳T4放在第二时间报文的第四时间戳字段中,并复制第二时间报文生成第三时间报文,并发送出去。Step 10050, the service box 1 records the accurate fourth time stamp T4 when the second time message enters the port, puts the fourth time stamp T4 in the fourth time stamp field of the second time message, and copies the second time The message generates a third time message and sends it out.
步骤10060、中心框1在收到的第三时间报文中获取四个时间戳T1、T2、T3、T4,计算主从设备(即业务框1与中心框1之间)的时间偏差和路径时延。Step 10060. The central frame 1 obtains four time stamps T1, T2, T3, and T4 in the received third time message, and calculates the time deviation and path of the master-slave device (that is, between the service frame 1 and the central frame 1) Delay.
步骤10070、中心框1根据算出的时间偏差调整自身的时间,完成和业务框1之间的时间同步。Step 10070. The central box 1 adjusts its own time according to the calculated time deviation, and completes time synchronization with the business box 1.
步骤10080、完成中心框1与中心框2、中心框1分别与业务框2至业务框n之间的时间同步。关于本步骤的相关描述可以参照图9所示实施例的说明,故于此不再赘述。Step 10080: Complete the time synchronization between the central frame 1 and the central frame 2, and the central frame 1 and the business frame 2 to the business frame n, respectively. For the relevant description of this step, please refer to the description of the embodiment shown in FIG. 9, so it will not be repeated here.
步骤10090、多个业务框可提供多个1588的master端口同步下游的salve设备。Step 10090, multiple service frames may provide multiple 1588 master ports to synchronize downstream salve devices.
在本实施例的集群***中,在集群***内部的设备之间可以采用本实施例提供的时间同步方法实现高精度的时间同步,集群***对外可以采用1588协议进行时间同步,从而避免集群***内外均采用1588协议进行时间同步时存在的冲突情况,便于管理。In the cluster system of this embodiment, the time synchronization method provided in this embodiment can be used to achieve high-precision time synchronization between the devices within the cluster system, and the cluster system can use the 1588 protocol to synchronize time externally, thereby avoiding the internal and external cluster system All conflicts exist when using 1588 protocol for time synchronization, which is easy to manage.
图11为本申请实施例提供的一种时钟主设备的示意图。如图11所示,本 实施例提供的时钟主设备1100,包括:第一存储器1101和第一处理器1102;第一存储器1101设置为存储时间同步程序,该时间同步程序被第一处理器1102执行时可以实现图7所示的时间同步方法。FIG. 11 is a schematic diagram of a clock master device provided by an embodiment of the present application. As shown in FIG. 11, the clock master device 1100 provided in this embodiment includes: a first memory 1101 and a first processor 1102; the first memory 1101 is set to store a time synchronization program, which is synchronized by the first processor 1102 During execution, the time synchronization method shown in FIG. 7 can be realized.
图11中所示的时钟主设备1100的结构并不构成对时钟主设备的限定,可以包括比图示更多或更少的部件,或者组合一些部件,或者提供不同的部件布置。The structure of the clock master device 1100 shown in FIG. 11 does not constitute a limitation on the clock master device, and may include more or fewer components than shown, or combine some components, or provide different component arrangements.
示例性地,第一处理器1102可以包括程序处理模块(例如,微处理器(Microcontroller Unit,MCU)、可编程逻辑器件(Field Programmable Gate Array,FPGA)、或者具有报文处理功能的集成电路(Integrated Circuit,IC)芯片等)和时间戳处理模块(例如,FPGA、或者具有时间戳处理功能的IC芯片等)。然而,本申请对此并不限定。例如,第一处理器1102可以包括具有报文处理和时间戳处理功能的FPGA或IC芯片。Exemplarily, the first processor 1102 may include a program processing module (for example, a microprocessor (Microcontroller Unit, MCU), a programmable logic device (Field Programmable Gate Array, FPGA), or an integrated circuit with a message processing function ( Integrated Circuit (IC) chip, etc.) and time stamp processing module (for example, FPGA, or IC chip with time stamp processing function, etc.). However, this application is not limited to this. For example, the first processor 1102 may include an FPGA or IC chip with message processing and time stamp processing functions.
其中,第一存储器1101可设置为存储应用软件的软件程序以及模块,如本实施例中的时间同步方法对应的程序指令或模块,第一处理器1102通过运行存储在第一存储器1101内的软件程序以及模块,从而执行多种功能应用以及数据处理,比如实现本实施例提供的时间同步方法。第一存储器1101可包括高速随机存储器,还可包括非易失性存储器,如一个或者多个磁性存储装置、闪存、或者其他非易失性固态存储器。在一些示例中,第一存储器1101可包括相对于第一处理器1102远程设置的存储器,这些远程存储器可以通过网络连接至终端设备。上述网络的实例包括但不限于互联网、企业内部网、局域网、移动通信网及其组合。The first memory 1101 may be configured to store software programs and modules of application software, such as program instructions or modules corresponding to the time synchronization method in this embodiment, and the first processor 1102 runs the software stored in the first memory 1101 by Programs and modules to execute various functional applications and data processing, such as implementing the time synchronization method provided in this embodiment. The first memory 1101 may include a high-speed random access memory, and may also include a non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some examples, the first memory 1101 may include memories remotely provided with respect to the first processor 1102, and these remote memories may be connected to the terminal device through a network. Examples of the aforementioned network include, but are not limited to, the Internet, intranet, local area network, mobile communication network, and combinations thereof.
图12为本申请实施例提供的一种时钟从设备的示意图。如图12所示,本实施例提供的时钟从设备1200,包括:第二存储器1201和第二处理器1202;第二存储器1201设置为存储时间同步程序,该时间同步程序被第二处理器1202执行时可以实现图8所示的时间同步方法。12 is a schematic diagram of a clock slave device provided by an embodiment of the present application. As shown in FIG. 12, the clock slave device 1200 provided in this embodiment includes: a second memory 1201 and a second processor 1202; the second memory 1201 is configured to store a time synchronization program, which is synchronized by the second processor 1202 The time synchronization method shown in FIG. 8 can be implemented during execution.
关于第二存储器1201和第二处理器1202的相关说明可以参照上述第一存储器1101和第一处理器1102的说明,故于此不再赘述。For the related descriptions of the second memory 1201 and the second processor 1202, reference may be made to the descriptions of the first memory 1101 and the first processor 1102, so they will not be repeated here.
此外,本申请实施例还提供一种计算机可读介质,存储有时间同步程序,该时间同步程序被处理器执行时实现上述时间同步方法的步骤,比如图7或图8所示的时间同步方法。In addition, embodiments of the present application also provide a computer-readable medium that stores a time synchronization program that implements the steps of the above time synchronization method when executed by a processor, such as the time synchronization method shown in FIG. 7 or FIG. 8 .
上文中所公开方法中的全部或一些步骤、***、装置中的功能模块/单元可以被实施为软件、固件、硬件及其适当的组合。在硬件实施方式中,在以上描述中提及的功能模块/单元之间的划分不一定对应于物理组件的划分;例如,一 个物理组件可以具有多个功能,或者一个功能或步骤可以由一些物理组件合作执行。一些组件或所有组件可以被实施为由处理器,如数字信号处理器或微处理器执行的软件,或者被实施为硬件,或者被实施为集成电路,如专用集成电路。这样的软件可以分布在计算机可读介质上,计算机可读介质可以包括计算机存储介质(或非暂时性介质)和通信介质(或暂时性介质)。术语计算机存储介质包括在用于存储信息(诸如计算机可读指令、数据结构、程序模块或其他数据)的任何方法或技术中实施的易失性和非易失性、可移除和不可移除介质。计算机存储介质包括但不限于随机存取存储器(Random Access Memory,RAM)、只读存储器(Read-Only Memory,ROM)、带电可擦可编程只读存储器(Electrically Erasable Programmable Read-Only Memory,EEPROM)、闪存或其他存储器技术、光盘只读存储器(Compact Disc Read-Only Memory,CD-ROM)、数字多功能盘(Digital Video Disc,DVD)或其他光盘存储、磁盒、磁带、磁盘存储或其他磁存储装置、或者可以用于存储期望的信息并且可以被计算机访问的任何其他的介质。此外,通信介质通常包含计算机可读指令、数据结构、程序模块或者诸如载波或其他传输机制之类的调制数据信号中的其他数据,并且可包括任何信息递送介质。All or some of the steps, systems, and functional modules/units in the method disclosed above may be implemented as software, firmware, hardware, and appropriate combinations thereof. In a hardware implementation, the division between the functional modules/units mentioned in the above description does not necessarily correspond to the division of physical components; for example, a physical component may have multiple functions, or a function or step may be composed of some physical The components are executed in cooperation. Some or all components may be implemented as software executed by a processor, such as a digital signal processor or microprocessor, or as hardware, or as an integrated circuit, such as an application specific integrated circuit. Such software may be distributed on computer-readable media, which may include computer storage media (or non-transitory media) and communication media (or transitory media). The term computer storage media includes volatile and nonvolatile, removable and non-removable implemented in any method or technology for storing information such as computer readable instructions, data structures, program modules or other data medium. Computer storage media include but are not limited to Random Access Memory (RAM), Read-Only Memory (ROM), Erasable Programmable Read-Only Memory (Electrically Programmable Read-Only Memory, EEPROM) , Flash memory or other memory technology, compact disc read-only memory (Compact Disc Read-Only Memory, CD-ROM), digital versatile disc (Digital Video Disc, DVD) or other optical disc storage, magnetic box, magnetic tape, magnetic disk storage or other magnetic A storage device, or any other medium that can be used to store desired information and can be accessed by a computer. In addition, communication media typically contains computer readable instructions, data structures, program modules, or other data in a modulated data signal such as a carrier wave or other transmission mechanism, and may include any information delivery media.
Claims (23)
- 一种时间同步方法,包括:A time synchronization method, including:时钟主设备向时钟从设备发送第一时间报文,其中,所述第一时间报文携带所述第一时间报文出所述时钟主设备的端口时所述时钟主设备记录的第一时间戳;The clock master device sends a first time message to the clock slave device, where the first time message carries the first time message and records the first time recorded by the clock master device when the first time message exits the port of the clock master device stamp;所述时钟主设备接收所述时钟从设备发送的携带第二时间戳和第三时间戳的第二时间报文,并将所述第二时间报文入所述时钟主设备的端口时所述时钟主设备记录的第四时间戳放入所述第二时间报文;其中,所述第二时间戳用于指示所述时钟从设备接收到所述第一时间报文的时刻,所述第三时间戳用于指示所述时钟从设备发送所述第二时间报文的时刻;When the clock master device receives the second time message carrying the second time stamp and the third time stamp sent by the clock slave device, and enters the second time message into the port of the clock master device The fourth time stamp recorded by the clock master device is placed in the second time message; wherein, the second time stamp is used to indicate the moment when the clock slave device receives the first time message, and the first Three time stamps are used to indicate the time when the clock slave device sends the second time message;所述时钟主设备复制所述第二时间报文生成第三时间报文,并向所述时钟从设备发送所述第三时间报文。The clock master device copies the second time message to generate a third time message, and sends the third time message to the clock slave device.
- 根据权利要求1所述的方法,其中,所述第一时间戳、所述第二时间戳、所述第三时间戳以及所述第四时间戳均包括秒比特、纳秒比特以及亚纳秒比特。The method of claim 1, wherein the first timestamp, the second timestamp, the third timestamp, and the fourth timestamp all include second bits, nanosecond bits, and sub-nanoseconds Bit.
- 根据权利要求1所述的方法,在所述时钟主设备向时钟从设备发送第一时间报文之前,还包括:The method according to claim 1, before the clock master device sends the first time message to the clock slave device, further comprising:所述时钟主设备发送携带端口信息的第四时间报文;The clock master device sends a fourth time message carrying port information;所述时钟主设备从接收到的携带端口信息的第四时间报文中提取所述端口信息,并根据所述端口信息,确定端口连接关系。The clock master device extracts the port information from the received fourth time message carrying the port information, and determines the port connection relationship according to the port information.
- 根据权利要求1所述的方法,还包括:通过以下方式确定所述第一时间戳:The method according to claim 1, further comprising: determining the first time stamp by:确定所述第一时间报文的帧起始定界符SFD到达所述时钟主设备的串行收发器SERDES的并行数据入口处的时间戳,给所述时间戳补偿SERDES发送端的所有延时,得到所述第一时间戳。Determining the time stamp of the frame start delimiter SFD of the first time message reaching the parallel data entry of the serial transceiver SERDES of the clock master device, and compensating for all the delay of the SERDES sender for the time stamp, Obtain the first time stamp.
- 根据权利要求1所述的方法,还包括:通过以下方式确定所述第四时间戳:The method according to claim 1, further comprising: determining the fourth time stamp by:确定所述第二时间报文的SFD到达所述时钟主设备的SERDES的并行数据出口处的时间戳,给所述时间戳补偿SERDES接收端的所有延时,得到所述第四时间戳。Determining the timestamp at which the SFD of the second time message reaches the parallel data exit of the SERDES of the clock master device, compensating the timestamp for all delays at the SERDES receiving end, and obtaining the fourth timestamp.
- 根据权利要求1至5中任一项所述的方法,其中,所述时钟主设备和所述时钟从设备属于同一个集群***。The method according to any one of claims 1 to 5, wherein the clock master device and the clock slave device belong to the same cluster system.
- 一种时间同步方法,包括:A time synchronization method, including:时钟从设备接收时钟主设备发送的携带第一时间戳的第一时间报文,并将所述第一时间报文入所述时钟从设备的端口时所述时钟从设备记录的第二时间戳放入所述第一时间报文;所述第一时间戳用于指示所述时钟主设备发送所述第一时间报文的时刻;The clock slave device receives the first time message carrying the first time stamp sent by the clock master device, and the second time stamp recorded by the clock slave device when the first time message is entered into the port of the clock slave device Put in the first time message; the first time stamp is used to indicate the time when the clock master sends the first time message;所述时钟从设备复制所述第一时间报文生成第二时间报文,向所述时钟主设备发送所述第二时间报文,并将所述第二时间报文出所述时钟从设备的端口时所述时钟从设备记录的第三时间戳放入所述第二时间报文;The clock slave device copies the first time message to generate a second time message, sends the second time message to the clock master device, and sends the second time message out of the clock slave device The third time stamp recorded by the clock slave device into the second time packet;所述时钟从设备接收所述时钟主设备发送的第三时间报文,并根据从所述第三时间报文获取的所述第一时间戳、所述第二时间戳、所述第三时间戳以及第四时间戳,计算所述时钟从设备与所述时钟主设备之间的时间偏差;其中,所述第四时间戳用于指示所述时钟主设备接收到所述第二时间报文的时刻;The clock slave device receives a third time message sent by the clock master device, and according to the first time stamp, the second time stamp, and the third time obtained from the third time message A time stamp and a fourth time stamp to calculate the time deviation between the clock slave device and the clock master device; wherein the fourth time stamp is used to indicate that the clock master device received the second time message Moment of所述时钟从设备根据所述时间偏差,调整所述时钟从设备的时间。The clock slave device adjusts the time of the clock slave device according to the time deviation.
- 根据权利要求7所述的方法,其中,所述第一时间戳、所述第二时间戳、所述第三时间戳以及所述第四时间戳均包括秒比特、纳秒比特以及亚纳秒比特。The method according to claim 7, wherein the first timestamp, the second timestamp, the third timestamp, and the fourth timestamp all include second bits, nanosecond bits, and sub-nanoseconds Bit.
- 根据权利要求7所述的方法,在所述时钟从设备从时钟主设备接收携带第一时间戳的第一时间报文之前,还包括:The method according to claim 7, before the clock slave device receives the first time message carrying the first time stamp from the clock master device, further comprising:所述时钟从设备发送携带端口信息的第四时间报文;The clock slave device sends a fourth time message carrying port information;所述时钟从设备从接收到的携带端口信息的第四时间报文中提取所述端口信息,并根据所述端口信息,确定端口连接关系。The clock slave device extracts the port information from the received fourth time message carrying the port information, and determines the port connection relationship according to the port information.
- 根据权利要求7所述的方法,还包括:通过以下方式确定所述第二时间戳:The method according to claim 7, further comprising: determining the second time stamp by:确定所述第一时间报文的帧起始定界符SFD到达所述时钟从设备的串行收发器SERDES的并行数据出口处的时间戳,给所述时间戳补偿SERDES接收端的所有延时,得到所述第二时间戳。Determine a timestamp at which the frame start delimiter SFD of the first time message reaches the parallel data exit of the serial transceiver SERDES of the clock slave device, and compensate all delays at the SERDES receiving end for the timestamp, Obtain the second time stamp.
- 根据权利要求7所述的方法,还包括:通过以下方式确定所述第三时间戳:The method according to claim 7, further comprising: determining the third time stamp by:确定所述第二时间报文的SFD到达所述时钟从设备的SERDES的并行数据入口处的时间戳,给所述时间戳补偿SERDES发送端的所有延时,得到所述第三时间戳。Determining the time stamp of the SFD of the second time message reaching the parallel data entry of the SERDES of the clock slave device, compensating the time stamp for all delays of the SERDES sender, and obtaining the third time stamp.
- 根据权利要求7至11中任一项所述的方法,其中,所述时钟从设备和所述时钟主设备属于同一个集群***。The method according to any one of claims 7 to 11, wherein the clock slave device and the clock master device belong to the same cluster system.
- 一种时间同步***,包括:时钟主设备以及时钟从设备;A time synchronization system, including: a clock master device and a clock slave device;所述时钟主设备设置为向所述时钟从设备发送第一时间报文,其中,所述第一时间报文携带所述第一时间报文出所述时钟主设备的端口时所述时钟主设备记录的第一时间戳;The clock master device is configured to send a first time message to the clock slave device, where the clock master device carries the first time message when the first time message is carried out of the port of the clock master device The first time stamp recorded by the device;所述时钟从设备设置为将所述第一时间报文入所述时钟从设备的端口时所述时钟从设备记录的第二时间戳放入所述第一时间报文,复制所述第一时间报文生成第二时间报文,向所述时钟主设备发送所述第二时间报文,并将所述第二时间报文出所述时钟从设备的端口时所述时钟从设备记录的第三时间戳放入所述第二时间报文;The clock slave device is configured to put the second time stamp recorded by the clock slave device into the first time packet when the first time message is entered into the port of the clock slave device, and copy the first time message The time message generates a second time message, sends the second time message to the clock master device, and outputs the second time message to the clock slave device when the clock slave device records Put a third time stamp into the second time message;所述时钟主设备还设置为将所述第二时间报文入所述时钟主设备的端口时所述时钟主设备记录的第四时间戳放入所述第二时间报文,复制所述第二时间报文生成第三时间报文,并向所述时钟从设备发送所述第三时间报文;The clock master device is further configured to put the fourth time stamp recorded by the clock master device into the second time message when the second time message is entered into the port of the clock master device, and copy the The second time message generates a third time message, and sends the third time message to the clock slave device;所述时钟从设备还设置为接收所述第三时间报文,根据从所述第三时间报文获取的所述第一时间戳、所述第二时间戳、所述第三时间戳以及所述第四时间戳,计算所述时钟从设备与所述时钟主设备之间的时间偏差;根据所述时间偏差,调整所述时钟从设备的时间。The clock slave device is further configured to receive the third time message, based on the first timestamp, the second timestamp, the third timestamp and the timestamp obtained from the third time message The fourth time stamp, calculate the time deviation between the clock slave device and the clock master device; adjust the time of the clock slave device according to the time deviation.
- 根据权利要求13所述的***,其中,所述时钟主设备包括:The system according to claim 13, wherein the clock master device comprises:第一时间报文处理模块,设置为控制所述时钟主设备发出所述第一时间报文,并将所述第一时间报文出所述时钟主设备的端口时所述时钟主设备记录的第一时间戳放入所述第一时间报文;A first time message processing module, configured to control the clock master device to send out the first time message, and output the first time message to the port of the clock master device when the clock master device records Put the first time stamp into the first time message;第三时间报文处理模块,设置为将所述第二时间报文入所述时钟主设备的端口时所述时钟主设备记录的第四时间戳放入所述第二时间报文,复制所述第二时间报文生成第三时间报文,并向所述时钟从设备发送所述第三时间报文。The third time message processing module is configured to put the fourth time stamp recorded by the clock master device into the second time message when the second time message enters the port of the clock master device, and copy the The second time message generates a third time message, and sends the third time message to the clock slave device.
- 根据权利要求14所述的***,其中,所述时钟主设备还包括:第一端口关系处理模块,设置为发送携带端口信息的第四时间报文;从接收到的携带端口信息的第四时间报文中提取所述端口信息,并根据所述端口信息,确定所述时钟主设备的端口连接关系。The system according to claim 14, wherein the clock master device further comprises: a first port relationship processing module configured to send a fourth time message carrying port information; from a received fourth time carrying port information Extract the port information from the message, and determine the port connection relationship of the clock master device according to the port information.
- 根据权利要求13所述的***,其中,所述时钟从设备包括:The system according to claim 13, wherein the clock slave device comprises:第二时间报文处理模块,设置为将所述第一时间报文入所述时钟从设备的端口时所述时钟从设备记录的第二时间戳放入所述第一时间报文,复制所述第一时间报文生成第二时间报文,向所述时钟主设备发送所述第二时间报文,并将所述第二时间报文出所述时钟从设备的端口时所述时钟从设备记录的第三时间戳放入所述第二时间报文;The second time message processing module is configured to put the second time stamp recorded by the clock slave device into the first time message when the first time message is entered into the port of the clock slave device, and copy the Generating a second time message from the first time message, sending the second time message to the clock master device, and outputting the second time message from the port of the clock slave device to the clock slave Put the third time stamp recorded by the device into the second time message;时间同步计算模块,设置为根据从所述第三时间报文获取的所述第一时间 戳、所述第二时间戳、所述第三时间戳以及所述第四时间戳,计算所述时钟从设备与所述时钟主设备之间的时间偏差;A time synchronization calculation module, configured to calculate the clock based on the first timestamp, the second timestamp, the third timestamp, and the fourth timestamp obtained from the third time message Time deviation between the slave device and the clock master device;时间同步调整模块,设置为根据所述时间偏差,调整所述时钟从设备的时间。The time synchronization adjustment module is set to adjust the time of the clock slave device according to the time deviation.
- 根据权利要求16所述的***,其中,所述时钟从设备还包括:The system of claim 16, wherein the clock slave device further comprises:第二端口关系处理模块,设置为发送携带端口信息的第四时间报文;从接收到的携带端口信息的第四时间报文中提取所述端口信息,并根据所述端口信息,确定所述时钟从设备的端口连接关系。The second port relationship processing module is configured to send a fourth time message carrying port information; extract the port information from the received fourth time message carrying port information, and determine the Clock slave device port connection relationship.
- 根据权利要求13所述的***,其中,所述第一时间戳、所述第二时间戳、所述第三时间戳以及所述第四时间戳均包括秒比特、纳秒比特以及亚纳秒比特。The system of claim 13, wherein the first timestamp, the second timestamp, the third timestamp, and the fourth timestamp all include second bits, nanosecond bits, and sub-nanoseconds Bit.
- 根据权利要求13至18中任一项所述的***,其中,所述时钟主设备和所述时钟从设备属于同一个集群***。The system according to any one of claims 13 to 18, wherein the clock master device and the clock slave device belong to the same cluster system.
- 一种时间主设备,包括:存储器和处理器,所述存储器设置为存储时间同步程序,所述时间同步程序被所述处理器执行时实现如权利要求1至6中任一项所述的时间同步方法。A time master device, including: a memory and a processor, the memory is configured to store a time synchronization program, the time synchronization program is executed by the processor to achieve the time according to any one of claims 1 to 6 Synchronization method.
- 一种时间从设备,包括:存储器和处理器,所述存储器设置为存储时间同步程序,所述时间同步程序被所述处理器执行时实现如权利要求7至12中任一项所述的时间同步方法。A time slave device, including: a memory and a processor, the memory is configured to store a time synchronization program, the time synchronization program is executed by the processor to achieve the time according to any one of claims 7 to 12 Synchronization method.
- 一种计算机可读介质,存储有时间同步程序,所述时间同步程序被处理器执行时实现如权利要求1至6中任一项所述的时间同步方法。A computer-readable medium storing a time synchronization program, which when executed by a processor implements the time synchronization method according to any one of claims 1 to 6.
- 一种计算机可读介质,存储有时间同步程序,所述时间同步程序被处理器执行时实现如权利要求7至12中任一项所述的时间同步方法。A computer-readable medium storing a time synchronization program, which when executed by a processor implements the time synchronization method according to any one of claims 7 to 12.
Applications Claiming Priority (2)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201811633978.6 | 2018-12-29 | ||
CN201811633978.6A CN111385048B (en) | 2018-12-29 | 2018-12-29 | Time synchronization method and system |
Publications (1)
Publication Number | Publication Date |
---|---|
WO2020135857A1 true WO2020135857A1 (en) | 2020-07-02 |
Family
ID=71128886
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
PCT/CN2019/129789 WO2020135857A1 (en) | 2018-12-29 | 2019-12-30 | Time synchronization method, system and device, and storage medium |
Country Status (2)
Country | Link |
---|---|
CN (1) | CN111385048B (en) |
WO (1) | WO2020135857A1 (en) |
Cited By (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN114221732A (en) * | 2021-12-23 | 2022-03-22 | 北京四方继保工程技术有限公司 | High-precision ping-pong synchronization method and system with synchronization quality |
CN114374629A (en) * | 2022-01-18 | 2022-04-19 | 苏州盛科科技有限公司 | Method, device and storage medium for realizing high precision support of IPFIX timestamp |
CN115276868A (en) * | 2022-07-05 | 2022-11-01 | 交控科技股份有限公司 | Method, device and system for synchronizing main and standby equipment |
CN117439691A (en) * | 2023-10-23 | 2024-01-23 | 合芯科技有限公司 | Time information synchronization system, processor chip and electronic device |
CN117728913A (en) * | 2023-12-27 | 2024-03-19 | 小米汽车科技有限公司 | Method, device, storage medium and vehicle for time synchronization |
Families Citing this family (8)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN111918380B (en) * | 2020-07-27 | 2021-08-20 | 深圳大学 | Method for synchronizing electronic equipment and reference node in wireless network and electronic equipment |
CN114079525A (en) * | 2020-08-19 | 2022-02-22 | 华为技术有限公司 | Clock synchronization method and device |
CN112235067B (en) * | 2020-09-24 | 2022-03-25 | 烽火通信科技股份有限公司 | Centralized 1588 time synchronization method and time synchronization system |
CN112187393B (en) * | 2020-09-30 | 2022-09-02 | 北京国科天迅科技有限公司 | PON bus time synchronization method and device, computer equipment and storage medium |
CN112838903B (en) * | 2020-12-31 | 2022-08-26 | 广东大普通信技术股份有限公司 | Clock synchronization method, equipment and storage medium |
CN113573403B (en) * | 2021-07-26 | 2023-11-03 | 南京濠暻通讯科技有限公司 | Slave clock synchronization system and method for 5G RRU |
CN114584247A (en) * | 2022-03-04 | 2022-06-03 | 北京小马睿行科技有限公司 | Time synchronization method, detection device and system |
CN116938379B (en) * | 2023-09-18 | 2023-12-15 | 湖北芯擎科技有限公司 | Method, device, electronic equipment and computer readable storage medium for time synchronization |
Citations (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN1996998A (en) * | 2006-12-26 | 2007-07-11 | 华为技术有限公司 | A method and device for high-bandwidth data transfer |
CN107294634A (en) * | 2017-06-13 | 2017-10-24 | 烽火通信科技股份有限公司 | The centralized approach of 1588 time synchronizeds is realized in a kind of distributed system |
US9929928B1 (en) * | 2015-12-24 | 2018-03-27 | Microsemi Solutions (U.S.), Inc. | Packet transmitter and method for timestamping packets |
CN108270504A (en) * | 2017-01-03 | 2018-07-10 | 格芯公司 | The nanosecond accuracy of high accuracy time stamp auxiliary device is utilized under the precision time protocol netted very much in second |
CN109039514A (en) * | 2018-07-19 | 2018-12-18 | 烽火通信科技股份有限公司 | A method of improving IEEE1588 timestamp precision |
Family Cites Families (7)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
ES2415506T5 (en) * | 2010-06-09 | 2021-10-21 | Abb Power Grids Switzerland Ag | Safe clock synchronization |
CN102833062B (en) * | 2012-09-25 | 2015-08-12 | 广东电网公司珠海供电局 | Intelligent substation IEEE1588 master-salve clock synchronization message setting means and system |
US9450846B1 (en) * | 2012-10-17 | 2016-09-20 | Cisco Technology, Inc. | System and method for tracking packets in a network environment |
CN103138865B (en) * | 2013-01-25 | 2015-09-16 | 杭州华三通信技术有限公司 | A kind of method for synchronizing time and device |
CN106341218A (en) * | 2015-07-06 | 2017-01-18 | 北京东土军悦科技有限公司 | Clock synchronization method and device based on windows operating system |
CN106533600B (en) * | 2016-10-14 | 2018-09-28 | 瑞斯康达科技发展股份有限公司 | A kind of clock synchronizing method and equipment |
CN109120392A (en) * | 2017-06-22 | 2019-01-01 | 中兴通讯股份有限公司 | Time translation method and device, equipment, storage medium, processor |
-
2018
- 2018-12-29 CN CN201811633978.6A patent/CN111385048B/en active Active
-
2019
- 2019-12-30 WO PCT/CN2019/129789 patent/WO2020135857A1/en active Application Filing
Patent Citations (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN1996998A (en) * | 2006-12-26 | 2007-07-11 | 华为技术有限公司 | A method and device for high-bandwidth data transfer |
US9929928B1 (en) * | 2015-12-24 | 2018-03-27 | Microsemi Solutions (U.S.), Inc. | Packet transmitter and method for timestamping packets |
CN108270504A (en) * | 2017-01-03 | 2018-07-10 | 格芯公司 | The nanosecond accuracy of high accuracy time stamp auxiliary device is utilized under the precision time protocol netted very much in second |
CN107294634A (en) * | 2017-06-13 | 2017-10-24 | 烽火通信科技股份有限公司 | The centralized approach of 1588 time synchronizeds is realized in a kind of distributed system |
CN109039514A (en) * | 2018-07-19 | 2018-12-18 | 烽火通信科技股份有限公司 | A method of improving IEEE1588 timestamp precision |
Cited By (7)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN114221732A (en) * | 2021-12-23 | 2022-03-22 | 北京四方继保工程技术有限公司 | High-precision ping-pong synchronization method and system with synchronization quality |
CN114374629A (en) * | 2022-01-18 | 2022-04-19 | 苏州盛科科技有限公司 | Method, device and storage medium for realizing high precision support of IPFIX timestamp |
CN114374629B (en) * | 2022-01-18 | 2024-07-05 | 苏州盛科科技有限公司 | Method, device and storage medium for realizing IPFIX timestamp to support high precision |
CN115276868A (en) * | 2022-07-05 | 2022-11-01 | 交控科技股份有限公司 | Method, device and system for synchronizing main and standby equipment |
CN117439691A (en) * | 2023-10-23 | 2024-01-23 | 合芯科技有限公司 | Time information synchronization system, processor chip and electronic device |
CN117439691B (en) * | 2023-10-23 | 2024-05-28 | 合芯科技有限公司 | Time information synchronization system, processor chip and electronic device |
CN117728913A (en) * | 2023-12-27 | 2024-03-19 | 小米汽车科技有限公司 | Method, device, storage medium and vehicle for time synchronization |
Also Published As
Publication number | Publication date |
---|---|
CN111385048A (en) | 2020-07-07 |
CN111385048B (en) | 2023-06-30 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
WO2020135857A1 (en) | Time synchronization method, system and device, and storage medium | |
US8879586B2 (en) | Inband timestamping | |
CN101977104B (en) | IEEE1588 based accurate clock synchronization protocol system and synchronization method thereof | |
US8964790B2 (en) | Communication apparatus | |
US9667370B2 (en) | Communication device with peer-to-peer assist to provide synchronization | |
TWI485996B (en) | Apparatus and method for enabling a passive optical network on supporting time synchronization | |
KR101290643B1 (en) | Method and system for bearing time synchronization protocol in optical transport network | |
CN102244603B (en) | Method, equipment and system for transmitting message bearing time | |
KR20130126986A (en) | Method, apparatus and system for time distribution in a telecommunications network | |
CN106162860A (en) | The method and system of a kind of time synchronized, the network equipment | |
CN101951312A (en) | E1 link-based bidirectional time-frequency synchronous transmission method and master-slave device | |
CN102299788A (en) | Method and device for controlling automatic transmission of IEEE1558 (Institute of Electrical and Electronic Engineers 1558) protocol message | |
CN102006157A (en) | Time synchronization method and system | |
CN106027193A (en) | Clock synchronization method, module, equipment and system for network timing system | |
WO2019036943A1 (en) | Packet processing method and network device | |
CN110572230A (en) | correction method and device for realizing time synchronization | |
CN108259109A (en) | The network equipment and TOD synchronous method in PTP domains | |
CN102469377A (en) | Ethernet passive optical network (EPON) system and method for realizing end-to-end transparent clock in system | |
CN106877967B (en) | IEEE1588 transparent clock residence time measurement method and its device | |
CN113424466B (en) | Method and device for clock synchronization | |
CN101902291B (en) | Method, equipment and system for precise time synchronization | |
US9442511B2 (en) | Method and a device for maintaining a synchronized local timer using a periodic signal | |
CN111181679A (en) | IEEE 1588-based high-speed streaming media bus accurate clock synchronization system | |
JP2023537348A (en) | Synchronization in distributed communication systems | |
CN106301642B (en) | A kind of clock synchronizing method and device of passive optical network |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
121 | Ep: the epo has been informed by wipo that ep was designated in this application |
Ref document number: 19904416 Country of ref document: EP Kind code of ref document: A1 |
|
NENP | Non-entry into the national phase |
Ref country code: DE |
|
32PN | Ep: public notification in the ep bulletin as address of the adressee cannot be established |
Free format text: NOTING OF LOSS OF RIGHTS PURSUANT TO RULE 112(1) EPC (EPO FORM 1205 DATED 19.08.21.) |
|
122 | Ep: pct application non-entry in european phase |
Ref document number: 19904416 Country of ref document: EP Kind code of ref document: A1 |