WO2018076651A1 - Time synchronization method, device and computer storage medium - Google Patents

Time synchronization method, device and computer storage medium Download PDF

Info

Publication number
WO2018076651A1
WO2018076651A1 PCT/CN2017/082636 CN2017082636W WO2018076651A1 WO 2018076651 A1 WO2018076651 A1 WO 2018076651A1 CN 2017082636 W CN2017082636 W CN 2017082636W WO 2018076651 A1 WO2018076651 A1 WO 2018076651A1
Authority
WO
WIPO (PCT)
Prior art keywords
time
processing unit
packet
timestamp
dwell
Prior art date
Application number
PCT/CN2017/082636
Other languages
French (fr)
Chinese (zh)
Inventor
陈宗正
李龙龙
Original Assignee
深圳市中兴微电子技术有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 深圳市中兴微电子技术有限公司 filed Critical 深圳市中兴微电子技术有限公司
Publication of WO2018076651A1 publication Critical patent/WO2018076651A1/en

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04JMULTIPLEX COMMUNICATION
    • H04J3/00Time-division multiplex systems
    • H04J3/02Details
    • H04J3/06Synchronising arrangements
    • H04J3/0635Clock or time synchronisation in a network
    • H04J3/0638Clock or time synchronisation among nodes; Internode synchronisation
    • H04J3/0658Clock or time synchronisation among packet nodes
    • H04J3/0661Clock or time synchronisation among packet nodes using timestamps
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04JMULTIPLEX COMMUNICATION
    • H04J3/00Time-division multiplex systems
    • H04J3/02Details
    • H04J3/06Synchronising arrangements
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04JMULTIPLEX COMMUNICATION
    • H04J3/00Time-division multiplex systems
    • H04J3/02Details
    • H04J3/06Synchronising arrangements
    • H04J3/0635Clock or time synchronisation in a network
    • H04J3/0682Clock or time synchronisation in a network by delay compensation, e.g. by compensation of propagation delay or variations thereof, by ranging
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L7/00Arrangements for synchronising receiver with transmitter

Definitions

  • the present invention relates to the field of flexible Ethernet, and in particular to a time synchronization method, device and computer storage medium.
  • GPS Global Positioning System
  • Embodiments of the present invention provide a time synchronization method, device, and computer storage medium, which can implement high-precision time synchronization between devices.
  • An embodiment of the present invention provides a time synchronization method, where the method is applied to a first device, where the method includes:
  • first timestamp indicates a time when the second time processing unit of the second device sends the first message
  • the compensation time is configured to the first device such that the time of the first device synchronizes the time of the second device.
  • the acquiring the first timestamp includes:
  • the first packet carries the first timestamp
  • the modified domain of the first packet carries a first camp time
  • the first camp time indicates that the first packet is in the second device Second a dwell time between the time processing unit and the second service processing unit of the second device;
  • the determining the first time includes:
  • the first message is from a first service processing unit of the first device to a time of the first time processing unit to a second dwell time, and writing the second dwell time The correction field of the second packet, obtaining the first time according to the first dwell time and the second dwell time;
  • Determining the second timestamp and the third timestamp including:
  • the second time stamp is identified by the first packet
  • Obtaining the fourth timestamp and the second time including:
  • the method includes:
  • the determining that the first message is from the first service processing unit of the first device to the first time processing unit is a second dwell time, including:
  • the determining, by the second time, the dwell time between the first time processing unit and the first service processing unit of the first device is a third dwell time, including:
  • the determining that the first packet is sent to the first service processing unit is the first time information, including:
  • the first service processing unit detects the frame header of the overhead frame, sampling the time at the frame header of the overhead frame as a first value, and sampling the frame number at the frame header of the overhead frame as a second value;
  • Sampling the frame number of the overhead frame in which the first byte of the first packet is located is a third value
  • the determining that the second packet is sent out of the first service processing unit is the fourth time information, including:
  • the time at the frame header of the sampling overhead frame is a fourth value, and the frame header of the overhead frame is sampled.
  • the frame number is the fifth value
  • the fourth time information is determined based on the fourth value, the fifth value, and the sixth value.
  • the embodiment of the present invention further provides a computer storage medium, where the computer storage medium stores computer executable instructions, and the computer executable instructions are used to execute the time synchronization method applied to the first device according to the embodiment of the present invention. .
  • An embodiment of the present invention provides a time synchronization method, where the method is applied to a second device, where the method includes:
  • the method further includes:
  • the second packet carries a third timestamp, where the third timestamp indicates the time when the first time processing unit of the first device sends the second packet, and the modified domain of the second packet carries a third dwell time, where the third dwell time indicates a dwell time between the first time processing unit and the first service processing unit of the first device;
  • a dwell time of the second packet from the second service processing unit to the second time processing unit is a fourth dwell time, and writing the fourth dwell time to the second a correction field of the message, obtaining the second time according to the third dwell time and the fourth dwell time;
  • the determining, by the first message, a dwell time between the second time processing unit of the second device and the second service processing unit of the second device is a first resident Time, including:
  • the time at the frame header of the sampling overhead frame is a seventh value
  • the frame number at the frame header of the sampling the overhead frame is an eighth value
  • the frame number of the overhead frame in which the first byte of the first packet is located is determined.
  • a ninth value determining, according to the seventh value, the eighth value, and the ninth value, that the time when the first packet is sent out to the second service processing unit is the sixth time information;
  • the determining that the second message is from the second service processing unit to the second time processing unit is a fourth dwell time, including:
  • the sending the first packet to the first device includes:
  • the embodiment of the present invention further provides a computer storage medium, where the computer storage medium stores computer executable instructions, and the computer executable instructions are used to execute the time synchronization method applied to the second device according to the embodiment of the present invention. .
  • An embodiment of the present invention provides a time synchronization device, where the device includes: a first service processing unit, a first time processing unit, and a configuration unit,
  • the first service processing unit is configured to acquire a first timestamp, where the first timestamp indicates a time when the second time processing unit of the second device sends the first message;
  • the first time processing unit is configured to determine a first time, where the first time indicates a dwell time between the second device and the first device, and is further configured to determine a second timestamp indicating a time when the first time processing unit of the first device receives the first message, and the third timestamp indicating the first time The time when the processing unit sends the second packet;
  • the first service processing unit is configured to acquire a fourth timestamp and a second time, where the fourth timestamp indicates a time when the second time processing unit receives the second message, and the second time indication a dwell time of the second message between the first device and the second device;
  • the configuration unit is configured to determine compensation according to the first timestamp, the second timestamp, the third timestamp, the fourth timestamp, the first time, and the second time Time; is further configured to configure the compensation time to the first device such that the time of the first device synchronizes the time of the second device.
  • the first service processing unit includes: a first system time stamp processing module, configured to receive at least one overhead frame sent by the second device, and extract the at least one overhead Each of the first packets of the frame is combined to obtain the first packet, and the first packet carries the first timestamp, the first packet
  • the modified domain of the file carries a first camp time, the first camp time indicating that the first packet is in the second time processing unit of the second device and the second service processing unit of the second device Residence time
  • the first time processing unit is configured to determine that a dwell time of the first packet from the first service processing unit of the first device to the first time processing unit is a second dwell time, It is further configured to write the second dwell time to a correction domain of the second message, and obtain the first time according to the first dwell time and the second dwell time.
  • the first time processing unit includes: a first time stamping module and a first message generating module,
  • the first time stamping module is configured to: when the first packet is sent to the first time processing unit, identify the second timestamp of the first packet;
  • the first packet generating module is configured to generate the second packet, and identify a third timestamp to the second packet.
  • the first service processing unit is configured to determine that a dwell time between the first time processing unit and the first service processing unit of the first device is a third dwell time, configured to write the third dwell time to a correction domain of the second message, such that the second device determines the second time according to the third dwell time And configured to insert all bytes of the second packet into a configuration reserved bit of at least one overhead frame in a byte order, and send the at least one overhead frame to the second device, where each overhead The frame is inserted into one byte of the second message.
  • the first service processing unit is configured to determine that the time when the first packet is transmitted to the first service processing unit is first time information
  • the first time processing unit is configured to determine that the time when the first packet is transmitted to the first time processing unit is second time information, and is further configured to: according to the first time information and the second time Determining that the first message is sent from the first service processing unit to the first The dwell time of the processing unit for a time is the second dwell time;
  • the first time processing unit is configured to determine that the time when the second packet is sent out by the first time processing unit is third time information
  • the first service processing unit is configured to determine that the time when the second packet is sent out of the first service processing unit is fourth time information, and is further configured to: according to the third time information and the fourth time And determining, by the information, that the dwell time of the second packet between the first time processing unit and the first service processing unit is a third dwell time.
  • the first service processing unit includes: a first system time stamp sampling module, and a first system time stamp processing module,
  • the first system timestamp sampling module is configured to: when the first service processing unit detects a frame header of the overhead frame, sample the time at the frame header of the overhead frame as a first value, and sample the overhead frame The frame number at the frame header is a second value; and the frame number of the overhead frame in which the first byte of the first packet is sampled is a third value;
  • the first system time stamp sampling module is configured to determine first time information according to the first value, the second value, and the third value.
  • the first service processing unit includes: a first system time stamp sampling module, a first system time stamp processing module,
  • the first system timestamp sampling module is configured to: the time at the frame header of the sampling overhead frame is a fourth value, and the frame number at the frame header of the sampling the overhead frame is a fifth value; and the second report is further configured to determine The frame number of the overhead frame in which the first byte of the text is located is the sixth value;
  • the first system time stamp processing module is configured to determine the fourth time information according to the fourth value, the fifth value, and the sixth value.
  • the embodiment of the present invention further provides a time synchronization device, where the device includes: a second time processing unit and a second service processing unit, where the second time processing unit includes: a second message generation module, and a second time stamp Module,
  • the second packet generating module is configured to generate a first packet
  • the second time stamping module is configured to identify a first timestamp for the first packet, where the first timestamp indicates that the second time processing unit of the second device sends the first packet time;
  • the second service processing unit is configured to determine that a dwell time between the second time processing unit of the second device and the second service processing unit of the second device is the first
  • the dwell time is written into the correction domain of the second packet, and is further configured to send the first packet to the first device.
  • the second service processing unit is configured to receive at least one overhead frame sent by the first device, and extract each byte of the second packet in the at least one overhead frame, Each of the bytes is combined to obtain the second packet, where the second packet carries a third timestamp, and the third timestamp indicates that the first time processing unit of the first device sends the The time of the second packet, the modified domain of the second packet carries a third camp time, and the third camp time indicates that the second packet is in the first time processing unit and the first device The dwell time between the first business processing units;
  • the second time processing unit is configured to determine that a dwell time of the second packet from the second service processing unit to the second time processing unit is a fourth dwell time, and is further configured to The fourth dwell time is written into the correction domain of the second packet, and is further configured to obtain the second time according to the third dwell time and the fourth dwell time;
  • the second time stamping module is configured to identify a fourth timestamp for the second message, where the fourth timestamp indicates a time when the second time processing unit receives the second message;
  • the second packet generating module is configured to generate a third packet
  • the second service processing unit is configured to send the third packet to the first device, where the third packet carries the fourth timestamp, and the modified domain of the third packet carries the The second time.
  • the second time processing unit is configured to determine that the time when the first message is sent out by the second time processing unit is fifth time information
  • the second service processing unit is configured to: the time at the frame header of the sampling overhead frame is a seventh value, and the frame number at the frame header of the sampling the overhead frame is an eighth value, and the first packet is determined.
  • the frame number of the overhead frame in which the byte is located is a ninth value, and the first message is sent out to the second service processing unit according to the seventh value, the eighth value, and the ninth value.
  • the time is the sixth time information; and is further configured to determine, according to the fifth time information and the sixth time information, that the first message is in the second time processing unit and the second service processing unit
  • the dwell time between the two is the first dwell time;
  • the second service processing unit is configured to determine that the time when the second packet is transmitted to the second service processing unit is the seventh time information
  • the second time processing unit is configured to determine that the time when the second packet is transmitted to the second time processing unit is eighth time information; and is further configured to: according to the seventh time information and the eighth time Determining, by the information, a dwell time of the second packet from the second service processing unit to the second time processing unit is a fourth dwell time;
  • the second service processing unit is configured to receive at least one overhead frame, and further configured to extract each byte of the second packet in the at least one overhead frame, and combine each of the bytes to obtain a Said the second message.
  • the embodiment of the present invention provides a time synchronization method, a device, and a computer storage medium, which acquires a first timestamp, where the first timestamp indicates a time when the second time processing unit of the second device sends the first message; Determining, by the first time, a dwell time between the second device and the first device; determining a second timestamp and a third timestamp, wherein the second timestamp indicates the first time processing unit of the first device The time when the first message is received, the third timestamp indicates the time when the first time processing unit sends the second message; the fourth timestamp is obtained, and the second timestamp indicates that the second time processing unit receives the second message.
  • Time of the text the second time indicates that the second message is a dwell time between the first device and the second device; determining a compensation time according to the first timestamp, the second timestamp, the third timestamp, the fourth timestamp, the first time, and the second time; The time is configured to the first device such that the time of the first device synchronizes the second device.
  • the time synchronization method and device provided by the embodiment of the present invention obtain timestamp and dwell time of the packet transmission in the first time synchronization device and the second time synchronization device by performing timestamp sampling on the packet transmission process, thereby obtaining
  • the compensation time is used to compensate the first time synchronization device by the compensation time to ensure that the time synchronization of the first time synchronization device synchronizes the time of the second time synchronization device, thereby effectively achieving high-precision time synchronization.
  • FIG. 1 is a schematic flowchart 1 of a time synchronization method according to an embodiment of the present invention
  • FIG. 2 is a second schematic flowchart of a time synchronization method according to an embodiment of the present invention.
  • FIG. 3 is a schematic diagram of implementing a FLEXE 1588 time synchronization device according to an embodiment of the present invention
  • FIG. 4 is a schematic structural diagram 1 of a first device according to an embodiment of the present disclosure.
  • FIG. 5 is a schematic structural diagram 2 of a first device according to an embodiment of the present disclosure.
  • FIG. 6 is a schematic structural diagram 1 of a second device according to an embodiment of the present disclosure.
  • FIG. 7 is a schematic structural diagram 2 of a second device according to an embodiment of the present invention.
  • the embodiment of the invention provides a time synchronization method. As shown in FIG. 1 , the method may include:
  • Step 101 Acquire a first timestamp, where the first timestamp indicates a time when the second time processing unit of the second device sends the first packet.
  • the time synchronization method provided by the embodiment of the present invention is applied to the first device, that is, the execution entity of the time synchronization method is the first device, and the first device can be understood as the first time synchronization device, and the first time synchronization device can be specifically the base station. Wait.
  • the first device may implement time synchronization of the FLEXE 1588, and the first device may include: a first time processing unit and a first service processing unit.
  • 1588 is a master-slave synchronization system.
  • the master clock periodically issues PTP time synchronization and time information, and receives the timestamp information sent by the master clock port from the clock port. Based on this information, the system calculates the master-slave line time delay and the master-slave time difference. The time difference is used to adjust the local time so that the device time remains at a frequency and phase consistent with the master time. 1588 can achieve both frequency synchronization and phase synchronization.
  • the first time processing unit includes: a processing CPU module, a message generation module, a 1588 time counting module, a system time counting module, a time stamping module, and a system time stamp processing module.
  • the first service processing unit includes: a CPU module, a system time counting module, a system time stamp sampling module, and a system time stamp processing module.
  • the CPU module is mainly used to configure information such as an operation mode of the first device, for example, configuring the first device as a master device or a slave device.
  • a message generation module is configured to generate and receive a PTP time synchronization message.
  • the 1588 time counting module and the system time counting module are mainly used to generate time information.
  • the counting clocks of the two are the same, that is, the starting time of the clock and the counting frequency of the clock are the same, and the difference is the 1588 time counting module.
  • the counter can be timed and the counter of the system time counting module cannot be timed.
  • Time stamping module mainly used to generate 1588 timestamp.
  • System time stamp processing module used to sample the time when the time message is sent to and from the time processing unit
  • the time stamp together with the time sent by the service processing unit, calculates the dwell time of the time message between the time processing unit and the service processing unit.
  • the CPU module is mainly used to configure information such as the working mode of the device and the FLEXE overhead position of the time packet.
  • the system time counting module is mainly used to generate system time information.
  • the counting clock of the system time counting module is the same as the system time counting module clock in the time processing unit, and the counting start time is also the same.
  • the system time stamp sampling module is mainly used for sampling the frame head time of the FLEXE overhead frame, and calculating the time of the time message at the entrance and exit of the service processing unit; then sending the time to the system time stamp processing module, and transmitting it to the time processing unit.
  • the time together calculates the dwell time of the time message between the time processing unit and the business processing unit.
  • each FLEXE overhead frame is only inserted into one byte of the time message.
  • the time at the frame header of the FLEXE overhead frame where the first byte of the time packet is located is taken as the time when the time packet enters and exits the service processing unit.
  • the delay needs to be compensated. That is, the second system time stamp processing module needs to calculate the time message at the entrance and exit of the service processing unit. time.
  • the calculation method is as follows: Since the time for transmitting a FLEXE overhead frame is basically fixed, it can be calculated that each time message is sent from the entry to the system time stamp processing module, or from the system time stamp processing module to the exit. The number of frames, automatically compensated for the number of frames, to get the time of the time message at the entrance or exit.
  • the first device receives the first packet sent by the second device, where the first packet carries the first timestamp, and the modified domain of the first packet carries a first camp time
  • the first dwell time indicates that the first message is in a second time processing unit of the second device and The dwell time between the second service processing units of the second device.
  • the receiving the first packet sent by the second device may include:
  • Receiving at least one overhead frame extracting each byte of the first packet in the at least one overhead frame, and combining each of the bytes to obtain the first packet.
  • Step 102 Determine a first time, where the first time indicates a dwell time between the second device and the first device.
  • the first device determines that the camping time of the first packet from the first service processing unit of the first device to the first time processing unit is a second camp time, where the first The second dwell time is written into the correction domain of the second packet, and the first time is obtained according to the first dwell time and the second dwell time.
  • the determining that the first message is from the first service processing unit of the first device to the first time processing unit is a second dwell time, including:
  • the determining that the first packet is sent to the first service processing unit is the first time information, including:
  • the first service processing unit detects the frame header of the overhead frame, sampling the time at the frame header of the overhead frame as a first value, and sampling the frame number at the frame header of the overhead frame as a second value;
  • Sampling the frame number of the overhead frame in which the first byte of the first packet is located is a third value
  • Step 103 Determine a second timestamp and a third timestamp, where the second timestamp indicates a time when the first time processing unit of the first device receives the first message, and the third timestamp indicates that the first time processing unit sends the The time of the second message.
  • the first device identifies the second timestamp to the first packet, and generates the second packet to the second The message identifies the third timestamp.
  • the method includes:
  • the determining, by the second time, the dwell time between the first time processing unit and the first service processing unit of the first device is a third dwell time, including:
  • the determining that the second packet is sent out of the first service processing unit Time is the fourth time information, including:
  • the time at the frame header of the sampling overhead frame is a fourth value, and the frame number at the frame header of the sampling the overhead frame is a fifth value;
  • the fourth time information is determined based on the fourth value, the fifth value, and the sixth value.
  • the sending the second packet to the second device includes:
  • Step 104 Obtain a fourth timestamp and a second time, where the fourth timestamp indicates a time when the second time processing unit receives the second message, and the second time indicates that the second message is between the first device and the second device. Dwell time.
  • the acquiring, by the first device, the fourth timestamp and the second time may include: receiving, by the first device, a third packet sent by the second device, where the third packet carries the fourth timestamp, The correction domain of the third message carries the second time.
  • Step 105 Determine a compensation time according to the first timestamp, the second timestamp, the third timestamp, the fourth timestamp, the first time, and the second time.
  • the first timestamp is set to T1
  • the second timestamp is T2
  • the third timestamp is T3
  • the fourth timestamp is T4
  • the first time is CFs
  • the second time is CFd
  • the compensation time offset can be determined.
  • Step 106 Configure the compensation time to the first device, so that the time of the first device synchronizes the time of the second device.
  • the first device can configure the compensation time to the self device, that is, the first device can compensate the compensation time by using the software, so that the time of the first device can be synchronized to the second device. On the time.
  • the time synchronization method provided by the embodiment of the present invention obtains a time stamp and a dwell time transmitted by the packet in the first time synchronization device and the second time synchronization device by performing timestamp sampling on the packet transmission process, thereby obtaining a compensation time.
  • the first time synchronization device is compensated by the compensation time to ensure that the time synchronization of the first time synchronization device synchronizes the time of the second time synchronization device, thereby effectively achieving high-precision time synchronization.
  • the embodiment of the present invention further provides a computer storage medium, where the computer storage medium stores computer executable instructions, and the computer executable instructions are used to execute the time synchronization method applied to the first device according to the embodiment of the present invention. .
  • An embodiment of the present invention provides a time synchronization method. As shown in FIG. 2, the method is applied to a second device, where the method includes:
  • Step 201 Generate a first packet, and identify a first timestamp to the first packet, where the first timestamp indicates a time when the second time processing unit of the second device sends the first packet.
  • the time synchronization method provided by the embodiment of the present invention is applied to the second device, that is, the execution entity of the time synchronization method is the second device, and the second device can be understood as the second time synchronization device, and the second time synchronization device can be specifically the base station. Wait.
  • the second device may implement time synchronization of the FLEXE 1588, and the second device may include: a second time processing unit and a second service processing unit.
  • the second time processing unit includes: a processing CPU module, a message generation module, a 1588 time counting module, a system time counting module, a time stamping module, and a system time stamp processing module.
  • the second service processing unit includes: a CPU module, a system time counting module, a system time stamp sampling module, and a system time stamp processing module.
  • the functions implemented by the respective modules in the second time processing unit and the second service processing unit are the same as those in the foregoing first device, and the embodiments are not described herein.
  • Step 202 Determine a dwell time between the second time processing unit of the second device and the second service processing unit of the second device, where the first message is a first dwell time, where The first dwell time is written to the correction domain of the second message.
  • the second device determines that a dwell time between the second time processing unit of the second device and the second service processing unit of the second device is the first dwell time, Can include:
  • the determining that the time when the first packet is sent out by the second service processing unit is the sixth time information including:
  • the time at the frame header of the sampling overhead frame is a seventh value, and the frame number at the frame header of the sampling the overhead frame is an eighth value;
  • the sixth time information is determined based on the seventh value, the eighth value, and the ninth value.
  • Step 203 Send the first packet to the first device.
  • the second device inserts all the bytes of the first packet into the configuration reserved bits of the at least one overhead frame in a byte order, and sends the at least one overhead frame to the first device, where each An overhead frame is inserted into one byte of the first message.
  • the method may further include:
  • the second packet carries a third timestamp, the third timestamp indicating that the first time processing unit of the first device sends the second packet Time, the modified domain of the second packet carries a third dwell time, the third dwell time indicating that the second packet is in the first time processing unit and the first device Residence time between business processing units;
  • a dwell time of the second packet from the second service processing unit to the second time processing unit is a fourth dwell time, and writing the fourth dwell time to the second a correction field of the message, obtaining the second time according to the third dwell time and the fourth dwell time;
  • the determining that the second message is from the second service processing unit to the second time processing unit is a fourth dwell time, including:
  • determining that the second packet is transmitted to the second service processing unit is the seventh time information
  • the time at the frame header of the sampling the overhead frame is a tenth value, and the frame number at the frame header of the sampling the overhead frame is the eleventh value.
  • the seventh time information is determined based on the tenth value, the eleventh value, and the twelfth value.
  • the receiving the second packet sent by the first device includes:
  • Receiving at least one overhead frame extracting each byte of the second packet in the at least one overhead frame, and combining each of the bytes to obtain the second packet.
  • the time synchronization method provided by the embodiment of the present invention obtains a time stamp and a dwell time transmitted by the packet in the first time synchronization device and the second time synchronization device by performing timestamp sampling on the packet transmission process, thereby obtaining a compensation time.
  • the first time synchronization device is compensated by the compensation time to ensure that the time synchronization of the first time synchronization device synchronizes the time of the second time synchronization device, thereby effectively achieving high-precision time synchronization.
  • the embodiment of the present invention further provides a computer storage medium, where the computer storage medium stores computer executable instructions, and the computer executable instructions are used to execute the time synchronization method applied to the second device according to the embodiment of the present invention. .
  • the first device is set to be the device B
  • the second device is the device A, that is, the time of the device B is synchronized with the time of the device A, and the master device and the slave device are configured by the CPU.
  • the device A is set.
  • the master device is the master device
  • the device B is set as the slave device slave.
  • the time synchronization process is as follows:
  • the message generating module of the time processing unit of the device A generates a sync message, that is, a first message, and the sync message enters a time stamping module, and the synchronization message is sent with a timestamp T1. That is, the first timestamp, T1 can be understood as the time when the sync message enters the time stamping module, and T1 is the timestamp generated by the 1588 time counter module.
  • the sync message is transmitted to the system time stamp processing module of the time processing unit, and the time stamp t1 generated by the system time counter module is marked, that is, t1 can be understood as the time when the sync message enters the system time stamp processing module, and t1 is accompanied by sync.
  • the message is sent to the service processing device.
  • the service processing device receives the sync message, and after processing, inserts all the bytes of the sync message into the configuration reserved bit of the FLEXE overhead frame in sequence, and inserts one byte of the sync message into each FLEXE overhead frame.
  • the processing process of the sync message is: the system time stamp sampling module samples the time d1 and the frame number m1 at the frame header of each FLEXE overhead frame at the exit of the service processing device, and returns the system time stamp processing module to the system time stamp processing module.
  • the module samples the frame number m2 of the FLEXE overhead frame in which the first byte of the sync packet is located, thereby calculating the time t2 of the service packet from the service packet, as follows:
  • C is the time required to deliver a FLEXE overhead frame, which is a fixed value and can be configured by the CPU.
  • the dwell time ⁇ t1 between the time processing device and the service processing device is calculated, and the calculation method is as follows:
  • the device B extracts each byte of the sync packet from the FLEXE overhead frame through the FLEXE interface and forms a complete sync packet, that is, the first packet, and calculates the time at which the sync packet is sent out at the service processing device.
  • the method for calculating the time of the sync message at the entry of the service processing device is: the frame header of the FLEXE overhead frame sampled by the system time stamp sampling module when the device B service processing unit enters the frame header of the FLEXE overhead frame.
  • the time d2 and the frame number m3 are transmitted to the system time stamp processing module, and the system time stamp processing module samples the frame number m4 of the FLEXE overhead frame in which the first byte of the sync message is located, thereby calculating the sync message on the device B.
  • the time t3 at the entrance of the business processing device is calculated as follows:
  • C is the time required to deliver a FLEXE overhead frame, which is a fixed value, which can be CPU configuration.
  • the extracted complete sync message and the calculated sync message are transmitted to the time processing device at time t3 at the entrance of the service processing device.
  • the time processing device When receiving the sync message, the time processing device samples the system time t4 when the sync message is received, and calculates the dwell time ⁇ t2 of the sync message from the service processing device entrance to the current time processing device, as shown in the following formula. :
  • the sync message is sent to the time stamping module, and the 1588 timestamp T2 is received when the sync message is received.
  • the software of device B knows that the timestamp T1 of the device A sends the sync message and the timestamp T2 of the sync message received by itself, and the correction field CFs of the sync message knows that the sync message is on the device A and the device B. The dwell time between the two devices.
  • the device A extracts each byte of the delay_req packet from the FLEXE overhead frame through the FLEXE interface and forms a complete delay_req packet, and calculates the time of the delay_req packet at the entry of the service processing device.
  • the process is the same as the process of the device B processing the sync message, except that the time stamping module of the time processing device is marked with the receiving time stamp T4 of the delay_req message.
  • the packet generation module of the time processing device in the device A generates a delay response delay_resp message, that is, a third message, and the delay_resp message carries the 1588 timestamp T4 of the delay_req message and the correction field CFd of the delay_req message.
  • Delay_resp message does not do any timestamp Rationally, it is sent directly through the overhead frame of FLEXE.
  • Device B extracts the delay_resp packet from the FLEXE overhead frame through the FLEXE interface, and also sends the software directly to device B without any timestamp processing.
  • the software of the device B obtains the time stamp T1 when the device A sends the sync message and the time stamp T2 that the device receives the sync message, and obtains the time stamp T3 when the device B sends the delay_req message and the device B receives the delay_req message.
  • the T4 is obtained, and the dwell time CFs between the two devices of the device A and the device B is obtained, and the dwell time CFd between the two devices of the device A and the device B is obtained.
  • the time difference between device A and device B is obtained, and device B can synchronize the time of device B to the time of device A by software offsetting the offset value.
  • the FLEXE1588 time synchronization can be implemented by the method provided by the embodiment of the present invention, and the time synchronization between the devices through the FLEXE interface can be realized, and the timing accuracy can be up to the nanosecond level.
  • one time processing device may also be connected to multiple service processing devices, that is, time when multiple first devices are time synchronized to the second device.
  • the counting clock of the system time counting module of the plurality of service processing devices is the same as the initial counting time, and can be delivered by the time processing device, and the timing principle is the same as described above.
  • the time synchronization device 30 includes: a first service processing unit 301, a first time processing unit 302, and a configuration unit 303, where
  • the first service processing unit 301 is configured to acquire a first timestamp, where the first timestamp indicates a time when the second time processing unit of the second device sends the first packet;
  • the first time processing unit 302 is configured to determine a first time, where the first time indicates a dwell time of the first message between the second device and the first device; Determining a second timestamp and a third timestamp, wherein the second timestamp indicates the first device Receiving, by the first time processing unit, the time of the first packet, where the third timestamp indicates a time when the first time processing unit sends the second packet;
  • the first service processing unit 301 is configured to acquire a fourth timestamp and a second time, where the fourth timestamp indicates a time when the second time processing unit receives the second message, the second time And indicating a dwell time of the second packet between the first device and the second device;
  • the configuration unit 303 is further configured to: according to the first timestamp, the second timestamp, the third timestamp, the fourth timestamp, the first time, and the second time, Determining a compensation time; further configured to configure the compensation time to the first device such that time of the first device synchronizes time of the second device.
  • the first service processing unit 301 includes: a first system time stamp processing module 3011, configured to receive the first packet sent by the second device, where the first packet carries The first timestamp, the modified domain of the first packet carries a first camp time, and the first camp time indicates that the first packet is in the second time processing unit and the second device The dwell time between the second service processing units of the second device.
  • a first system time stamp processing module 3011 configured to receive the first packet sent by the second device, where the first packet carries The first timestamp, the modified domain of the first packet carries a first camp time, and the first camp time indicates that the first packet is in the second time processing unit and the second device The dwell time between the second service processing units of the second device.
  • the first time processing unit 302 is configured to determine a dwell time of the first message from a first service processing unit of the first device to the first time processing unit. And the second dwell time is further configured to write the second dwell time into the correction domain of the second packet, and obtain the first according to the first dwell time and the second dwell time For a time.
  • the first time processing unit 302 includes: a first time stamping module 3021, and a first packet generating module 3022.
  • the first time stamping module 3021 is configured to: when the first packet is sent to the first time processing unit, identify a second timestamp for the first packet;
  • the first packet generating module 3022 is configured to generate the second packet, and identify the second packet with the third timestamp.
  • the first service processing unit 301 is configured to determine a dwell time between the first time processing unit and the first service processing unit of the first device. a third dwell time, further configured to write the third dwell time to a correction domain of the second message, such that the second device determines the second according to the third dwell time Time; configured to send the second message to the second device.
  • the first service processing unit 301 is configured to receive a third packet sent by the second device, where the third packet carries the fourth timestamp, and the third packet The correction domain carries the second time.
  • the first service processing unit 301 is configured to determine that the time when the first packet is transmitted to the first service processing unit is first time information
  • the first time processing unit 302 is configured to determine that the time when the first packet is sent to the first time processing unit is second time information, and is further configured to: according to the first time information and the second The time information determines that the dwell time of the first message from the first service processing unit to the first time processing unit is a second dwell time.
  • the first time processing unit 302 is configured to determine that the time when the second message is sent out by the first time processing unit is third time information
  • the first service processing unit 301 is configured to determine that the time when the second packet is sent out of the first service processing unit is fourth time information, and is further configured to be based on the third time information and the fourth The time information determines that the dwell time of the second message between the first time processing unit and the first service processing unit is a third dwell time.
  • the first service processing unit 301 includes: a first system time stamp sampling module 3012, and a first system time stamp processing module 3011.
  • the first system timestamp sampling module 3012 is configured to: when the first service processing unit detects the frame header of the overhead frame, sample the time at the frame header of the overhead frame as a first value, and sample the overhead.
  • the frame number at the frame header of the frame is a second value; and is further configured to sample the first message first
  • the frame number of the overhead frame in which the bytes are located is the third value;
  • the first system timestamp processing module 3011 is configured to determine the first time information according to the first value, the second value, and the third value.
  • the first service processing unit 301 is configured to receive at least one overhead frame, and is further configured to extract each byte of the first packet in the at least one overhead frame, where each of the One byte is combined to obtain the first message.
  • the first service processing unit 301 includes: a first system time stamp sampling module 3012, and a first system time stamp processing module 3011.
  • the first system timestamp sampling module 3012 is configured to: the time at the frame header of the sampling overhead frame is a fourth value, and the frame number at the frame header of the sampling the overhead frame is a fifth value; and is further configured to determine the second The frame number of the overhead frame in which the first byte of the message is located is the sixth value;
  • the first system time stamp processing module 3011 is configured to determine the fourth time information according to the fourth value, the fifth value, and the sixth value.
  • the first service processing unit 301 is configured to insert all bytes of the second packet into a configuration reserved bit of at least one overhead frame in a byte order, and is further configured to send the At least one overhead frame to the second device, wherein each overhead frame is inserted into one byte of the second message.
  • time synchronization device For a detailed description of the time synchronization device provided by the embodiment of the present invention, reference may be made to the description of the foregoing time synchronization method embodiment, and details are not described herein again.
  • the time synchronization device obtained by the embodiment of the present invention obtains the time stamp and the dwell time transmitted by the packet in the first time synchronization device and the second time synchronization device by time stamping the packet transmission process, thereby obtaining the compensation time.
  • the first time synchronization device is compensated by the compensation time to ensure that the time synchronization of the first time synchronization device synchronizes the time of the second time synchronization device, thereby effectively achieving high-precision time synchronization.
  • the embodiment of the invention provides a time synchronization device, as shown in FIG. 6, the time synchronization device
  • the device 40 includes a second time processing unit 401 and a second service processing unit 402.
  • the second time processing unit 401 includes: a second message generating module 4011 and a second time stamping module 4012.
  • the second packet generating module 4011 is configured to generate a first packet.
  • the second time stamping module 4012 is configured to identify a first timestamp for the first message, where the first timestamp indicates that the second time processing unit of the second device sends the first timestamp time;
  • the second service processing unit 401 is configured to determine that a dwell time between the second time processing unit of the second device and the second service processing unit of the second device is The first camp time is written into the correction domain of the second packet, and is configured to send the first packet to the first device.
  • the second service processing unit 402 is configured to receive a second packet sent by the first device, where the second packet carries a third timestamp, and the third timestamp indicates a time when the first time processing unit of the first device sends the second packet, where the modified domain of the second packet carries a third camp time, and the third camp time indicates the second packet a dwell time between the first time processing unit and the first service processing unit of the first device;
  • the second time processing unit 401 is configured to determine that a dwell time of the second packet from the second service processing unit to the second time processing unit is a fourth camp time, and is further configured to Writing the fourth dwell time to the correction domain of the second packet, further configured to obtain the second time according to the third dwell time and the fourth dwell time;
  • the second time stamping module 4012 is configured to identify a fourth timestamp for the second message, where the fourth timestamp indicates a time when the second time processing unit receives the second message;
  • the second packet generating module 4011 is configured to generate a third packet.
  • the second service processing unit 402 is configured to send the third packet to the first device, where the third packet carries the fourth timestamp, and the modified domain of the third packet carries the Description The second time.
  • the second time processing unit 401 is configured to determine that the time when the first packet is sent out by the second time processing unit is fifth time information
  • the second service processing unit 402 is configured to determine that the time when the first packet is sent out by the second service processing unit is sixth time information, and is further configured to be based on the fifth time information and the sixth The time information determines that the dwell time of the first message between the second time processing unit and the second service processing unit is a first dwell time.
  • the second service processing unit 402 is configured to determine that the time when the second packet is transmitted to the second service processing unit is the seventh time information
  • the second time processing unit 401 is configured to determine that the time when the second packet is transmitted to the second time processing unit is eighth time information; and is further configured to: according to the seventh time information and the eighth The time information is determined to be a fourth dwell time of the second message from the second service processing unit to the second time processing unit.
  • the second service processing unit 402 includes: a second system time stamp sampling module 4021, and a second system time stamp processing module 4022.
  • the second system time stamp sampling module 4021 is configured to: the time at the frame header of the sampling overhead frame is a seventh value, and is also used to sample the frame number at the frame header of the overhead frame as an eighth value; The frame number of the overhead frame in which the first byte of the first packet is located is the ninth value;
  • the second system time stamp processing module 4022 is configured to determine the sixth time information according to the seventh value, the eighth value, and the ninth value.
  • the second service processing unit 402 is configured to insert all bytes of the first packet into a configuration reserved bit of at least one overhead frame in a byte order, and is further configured to send the At least one overhead frame to the first device, wherein each overhead frame is inserted into one byte of the first message.
  • the second service processing unit 402 is configured to receive at least one overhead.
  • the frame is further configured to extract each byte of the second packet in the at least one overhead frame, and combine each of the bytes to obtain the second packet.
  • time synchronization device For a detailed description of the time synchronization device provided by the embodiment of the present invention, reference may be made to the description of the foregoing time synchronization method embodiment, and details are not described herein again.
  • the time synchronization device obtained by the embodiment of the present invention obtains the time stamp and the dwell time transmitted by the packet in the first time synchronization device and the second time synchronization device by time stamping the packet transmission process, thereby obtaining the compensation time.
  • the first time synchronization device is compensated by the compensation time to ensure that the time synchronization of the first time synchronization device synchronizes the time of the second time synchronization device, thereby effectively achieving high-precision time synchronization.
  • embodiments of the present invention can be provided as a method, system, or computer program product. Accordingly, the present invention can take the form of a hardware embodiment, a software embodiment, or a combination of software and hardware. Moreover, the invention can take the form of a computer program product embodied on one or more computer-usable storage media (including but not limited to disk storage and optical storage, etc.) including computer usable program code.
  • the computer program instructions can also be stored in a computer readable memory that can direct a computer or other programmable data processing device to operate in a particular manner, such that the instructions stored in the computer readable memory produce an article of manufacture comprising the instruction device.
  • the device is implemented in a flow chart A function specified in a block or blocks of a process or multiple processes and/or block diagrams.
  • These computer program instructions can also be loaded onto a computer or other programmable data processing device such that a series of operational steps are performed on a computer or other programmable device to produce computer-implemented processing for execution on a computer or other programmable device.
  • the instructions provide steps for implementing the functions specified in one or more of the flow or in a block or blocks of a flow diagram.
  • the embodiment of the present invention provides a time synchronization method, which acquires a first timestamp, where the first timestamp indicates a time when the second time processing unit of the second device sends the first message; and determines the first time, the first time indicates the first time.
  • a dwell time between the second device and the first device determining a second timestamp and a third timestamp, wherein the second timestamp indicates that the first time processing unit of the first device receives the first message Time, the third timestamp indicates the time when the first time processing unit sends the second message; the fourth timestamp and the second time are obtained, the fourth timestamp indicates the time when the second time processing unit receives the second message, and the second time
  • the time indicates a dwell time of the second message between the first device and the second device; according to the first timestamp, the second timestamp, the third timestamp, the fourth timestamp, the first time, and the second time, Determining the compensation time; configuring the compensation time to the first device such that the time of the first device synchronizes the time of the second device.
  • the timestamp and the dwell time of the packet transmitted in the first time synchronization device and the second time synchronization device are obtained, thereby obtaining a compensation time, and the compensation time is first.
  • the time synchronization device performs compensation to ensure that the time of the first time synchronization device synchronizes the time of the second time synchronization device, thereby effectively achieving high-precision time synchronization.

Abstract

Disclosed in embodiments of the present invention are a time synchronization method, a device and a computer storage medium: acquiring a first time stamp of a second time processing unit of a second device sending a first report; determining a residence time between the second device and a first device in the first report as a first time; determining a second time stamp of a first time processing unit of the first device receiving the first report and a third time stamp of the first time processing unit sending a second report; acquiring a fourth time stamp of the second time processing unit receiving the second report, and acquiring a residence time of the second report between the first device and the second device as a second time; determining a compensation time according to the first time stamp, the second time stamp, the third time stamp, the fourth time stamp, the first time and the second time; configuring the compensation time to the first device, so as to synchronize time of the first device with time of the second device.

Description

一种时间同步方法、设备及计算机存储介质Time synchronization method, device and computer storage medium
相关申请的交叉引用Cross-reference to related applications
本申请基于申请号为201610933876.0、申请日为2016年10月31日的中国专利申请提出,并要求该中国专利申请的优先权,该中国专利申请的全部内容在此引入本申请作为参考。The present application is based on a Chinese patent application filed on Jan. 31, 2016, the filing date of
技术领域Technical field
本发明涉及灵活以太网(Flex Ethernet)领域,尤其涉及一种时间同步方法、设备及计算机存储介质。The present invention relates to the field of flexible Ethernet, and in particular to a time synchronization method, device and computer storage medium.
背景技术Background technique
随着移动通讯网络的发展,各基站之间需要保持严格的同步,以保证业务的正常运行。然而,时钟同步已经不满足各种业务的要求,高精度的时间同步成为网络的必要需求。With the development of mobile communication networks, strict synchronization needs to be maintained between base stations to ensure the normal operation of services. However, clock synchronization has not met the requirements of various services, and high-precision time synchronization has become a necessary requirement of the network.
现有已经部署的网络中,大多采用全球定位系统(GPS,Global Positioning System)作为精准的时间源,来保证网络中各个节点之间的时间同步。而大规模部署GPS会有成本和安全的问题,因此,利用承载和传送网络本身来传递时间信息,只在核心节点安装少量的GPS或其他精准系统来提供时间源,网络其他节点通过传递的时间信息来同步到主时间源上,成为传送网络的一种必要需求。FLEXE作为最新提出的一种以太网形式,未来会越来越多地使用FLEXE来传递业务,因此,实现利用FLEXE来完成网络时间同步是一个亟待解决的问题。 Most of the existing deployed networks use the Global Positioning System (GPS) as a precise time source to ensure time synchronization between nodes in the network. Large-scale deployment of GPS will have cost and security issues. Therefore, using the bearer and transport network itself to transmit time information, only a small amount of GPS or other precision system is installed at the core node to provide the time source, and the time passed by other nodes of the network. Information is synchronized to the primary time source and becomes a necessary requirement for the transport network. FLEXE is the latest Ethernet form, and FLEXE will be used more and more to deliver services in the future. Therefore, implementing FLEXE to complete network time synchronization is an urgent problem to be solved.
发明内容Summary of the invention
本发明实施例提供一种时间同步方法、设备及计算机存储介质,可以实现设备之间高精度的时间同步。Embodiments of the present invention provide a time synchronization method, device, and computer storage medium, which can implement high-precision time synchronization between devices.
本发明实施例的技术方案是这样实现的:The technical solution of the embodiment of the present invention is implemented as follows:
本发明实施例提供一种时间同步方法,所述方法应用于第一设备,所述方法包括:An embodiment of the present invention provides a time synchronization method, where the method is applied to a first device, where the method includes:
获取第一时间戳,所述第一时间戳指示第二设备的第二时间处理单元发送第一报文的时间;Obtaining a first timestamp, where the first timestamp indicates a time when the second time processing unit of the second device sends the first message;
确定第一时间,所述第一时间指示所述第一报文在所述第二设备和所述第一设备之间的驻留时间;Determining a first time, the first time indicating a dwell time of the first message between the second device and the first device;
确定第二时间戳和第三时间戳,所述第二时间戳指示所述第一设备的第一时间处理单元接收所述第一报文的时间,所述第三时间戳指示所述第一时间处理单元发送第二报文的时间;Determining a second timestamp indicating a time at which the first time processing unit of the first device receives the first message, the third timestamp indicating the first time Time when the time processing unit sends the second message;
获取第四时间戳和第二时间,所述第四时间戳指示所述第二时间处理单元接收所述第二报文的时间,所述第二时间指示所述第二报文在所述第一设备和所述第二设备之间的驻留时间;Obtaining a fourth timestamp indicating a time when the second time processing unit receives the second message, and the second time indicating that the second message is in the a dwell time between a device and the second device;
根据所述第一时间戳、所述第二时间戳、所述第三时间戳、所述第四时间戳、所述第一时间和所述第二时间,确定补偿时间;Determining a compensation time according to the first timestamp, the second timestamp, the third timestamp, the fourth timestamp, the first time, and the second time;
将所述补偿时间配置到所述第一设备,以使得所述第一设备的时间同步所述第二设备的时间。The compensation time is configured to the first device such that the time of the first device synchronizes the time of the second device.
在一实施例中,所述获取第一时间戳,包括:In an embodiment, the acquiring the first timestamp includes:
接收所述第二设备发送的至少一个开销帧,提取所述至少一个开销帧中所述第一报文的每一个字节,将所述每一个字节进行组合获得所述第一报文,所述第一报文携带所述第一时间戳,所述第一报文的修正域携带第一驻留时间,所述第一驻留时间指示所述第一报文在所述第二设备的第二 时间处理单元和所述第二设备的第二业务处理单元之间的驻留时间;Receiving at least one overhead frame sent by the second device, extracting each byte of the first packet in the at least one overhead frame, and combining each byte to obtain the first packet, The first packet carries the first timestamp, the modified domain of the first packet carries a first camp time, and the first camp time indicates that the first packet is in the second device Second a dwell time between the time processing unit and the second service processing unit of the second device;
所述确定第一时间,包括:The determining the first time includes:
确定所述第一报文从传入所述第一设备的第一业务处理单元到所述第一时间处理单元的驻留时间为第二驻留时间,将所述第二驻留时间写入所述第二报文的修正域,根据所述第一驻留时间和所述第二驻留时间获得所述第一时间;Determining that the first message is from a first service processing unit of the first device to a time of the first time processing unit to a second dwell time, and writing the second dwell time The correction field of the second packet, obtaining the first time according to the first dwell time and the second dwell time;
所述确定第二时间戳和第三时间戳,包括:Determining the second timestamp and the third timestamp, including:
当所述第一报文传入所述第一时间处理单元时,给所述第一报文标识第二时间戳;And when the first packet is sent to the first time processing unit, the second time stamp is identified by the first packet;
生成所述第二报文,给所述第二报文标识第三时间戳;Generating the second packet, and identifying, by the second packet, a third timestamp;
所述获取第四时间戳和第二时间,包括:Obtaining the fourth timestamp and the second time, including:
接收所述第二设备发送的第三报文,所述第三报文携带所述第四时间戳,所述第三报文的修正域携带所述第二时间。Receiving a third packet sent by the second device, where the third packet carries the fourth timestamp, and the modified domain of the third packet carries the second time.
在一实施例中,在所述生成第二报文,给所述第二报文标识第三时间戳之后,包括:In an embodiment, after the generating the second packet and the third packet identifying the third timestamp, the method includes:
确定所述第二报文在所述第一时间处理单元和所述第一设备的第一业务处理单元之间的驻留时间为第三驻留时间,将所述第三驻留时间写入所述第二报文的修正域,以使得所述第二设备根据所述第三驻留时间确定所述第二时间;Determining, by the second packet, a dwell time between the first time processing unit and the first service processing unit of the first device as a third dwell time, and writing the third dwell time a correction field of the second packet, so that the second device determines the second time according to the third camp time;
将所述第二报文的所有字节按照字节顺序插入到至少一个开销帧的配置保留比特中,发送所述至少一个开销帧至所述第二设备,其中,每一个开销帧插入所述第二报文的一个字节。Inserting, in byte order, all bytes of the second packet into a configuration reserved bit of at least one overhead frame, and transmitting the at least one overhead frame to the second device, where each overhead frame is inserted into the One byte of the second message.
在一实施例中,所述确定所述第一报文从传入所述第一设备的第一业务处理单元到所述第一时间处理单元的驻留时间为第二驻留时间,包括:In an embodiment, the determining that the first message is from the first service processing unit of the first device to the first time processing unit is a second dwell time, including:
确定所述第一报文传入所述第一业务处理单元的时间为第一时间信 息;Determining that the time when the first packet is transmitted to the first service processing unit is a first time letter interest;
确定所述第一报文传入所述第一时间处理单元的时间为第二时间信息;Determining, that the time when the first packet is transmitted to the first time processing unit is second time information;
根据所述第一时间信息和所述第二时间信息,确定所述第一报文从传入所述第一业务处理单元到所述第一时间处理单元的驻留时间为第二驻留时间。Determining, according to the first time information and the second time information, that a dwell time of the first packet from the first service processing unit to the first time processing unit is a second dwell time .
在一实施例中,所述确定所述第二报文在所述第一时间处理单元和所述第一设备的第一业务处理单元之间的驻留时间为第三驻留时间,包括:In an embodiment, the determining, by the second time, the dwell time between the first time processing unit and the first service processing unit of the first device is a third dwell time, including:
确定所述第二报文传出所述第一时间处理单元的时间为第三时间信息;Determining, that the time when the second packet is sent out by the first time processing unit is third time information;
确定所述第二报文传出所述第一业务处理单元的时间为第四时间信息;Determining, that the time when the second packet is sent out by the first service processing unit is fourth time information;
根据所述第三时间信息和所述第四时间信息,确定所述第二报文在所述第一时间处理单元和所述第一业务处理单元之间的驻留时间为第三驻留时间。Determining, according to the third time information and the fourth time information, a dwell time between the first time processing unit and the first service processing unit as a third dwell time .
在一实施例中,所述确定所述第一报文传入所述第一业务处理单元的时间为第一时间信息,包括:In an embodiment, the determining that the first packet is sent to the first service processing unit is the first time information, including:
当所述第一业务处理单元检测到开销帧的帧头时,采样所述开销帧的帧头处的时间为第一数值,采样所述开销帧的帧头处的帧号为第二数值;When the first service processing unit detects the frame header of the overhead frame, sampling the time at the frame header of the overhead frame as a first value, and sampling the frame number at the frame header of the overhead frame as a second value;
采样所述第一报文第一个字节所在开销帧的帧号为第三数值;Sampling the frame number of the overhead frame in which the first byte of the first packet is located is a third value;
根据所述第一数值、所述第二数值和所述第三数值,确定第一时间信息。Determining the first time information based on the first value, the second value, and the third value.
在一实施例中,所述确定所述第二报文传出所述第一业务处理单元的时间为第四时间信息,包括:In an embodiment, the determining that the second packet is sent out of the first service processing unit is the fourth time information, including:
采样开销帧的帧头处的时间为第四数值,采样所述开销帧的帧头处的 帧号为第五数值;The time at the frame header of the sampling overhead frame is a fourth value, and the frame header of the overhead frame is sampled. The frame number is the fifth value;
确定所述第二报文的第一个字节所在开销帧的帧号为第六数值;Determining, that the frame number of the overhead frame in which the first byte of the second packet is located is a sixth value;
根据所述第四数值、所述第五数值和所述第六数值,确定第四时间信息。The fourth time information is determined based on the fourth value, the fifth value, and the sixth value.
本发明实施例还提供一种计算机存储介质,所述计算机存储介质中存储有计算机可执行指令,所述计算机可执行指令用于执行本发明实施例所述的应用于第一设备的时间同步方法。The embodiment of the present invention further provides a computer storage medium, where the computer storage medium stores computer executable instructions, and the computer executable instructions are used to execute the time synchronization method applied to the first device according to the embodiment of the present invention. .
本发明实施例提供一种时间同步方法,所述方法应用于第二设备,所述方法包括:An embodiment of the present invention provides a time synchronization method, where the method is applied to a second device, where the method includes:
生成第一报文,给所述第一报文标识第一时间戳,所述第一时间戳指示所述第二设备的第二时间处理单元发送所述第一报文的时间;Generating a first packet, the first timestamp indicating a first timestamp, and the first timestamp indicating a time when the second time processing unit of the second device sends the first packet;
确定所述第一报文在所述第二设备的第二时间处理单元和所述第二设备的第二业务处理单元之间的驻留时间为第一驻留时间,将所述第一驻留时间写入所述第二报文的修正域;Determining, by the first camp, a dwell time between the second time processing unit of the second device and the second service processing unit of the second device as a first dwell time, the first station Writing a time to write the correction field of the second message;
发送所述第一报文至第一设备。Sending the first packet to the first device.
在一实施例中,所述方法还包括:In an embodiment, the method further includes:
接收所述第一设备发送的至少一个开销帧,提取所述至少一个开销帧中所述第二报文的每一个字节,将所述每一个字节进行组合获得所述第二报文,所述第二报文携带第三时间戳,所述第三时间戳指示所述第一设备的第一时间处理单元发送所述第二报文的时间,所述第二报文的修正域携带第三驻留时间,所述第三驻留时间指示所述第二报文在所述第一时间处理单元和所述第一设备的第一业务处理单元之间的驻留时间;Receiving at least one overhead frame sent by the first device, extracting each byte of the second packet in the at least one overhead frame, and combining each of the bytes to obtain the second packet, The second packet carries a third timestamp, where the third timestamp indicates the time when the first time processing unit of the first device sends the second packet, and the modified domain of the second packet carries a third dwell time, where the third dwell time indicates a dwell time between the first time processing unit and the first service processing unit of the first device;
确定所述第二报文从传入所述第二业务处理单元到所述第二时间处理单元的驻留时间为第四驻留时间,将所述第四驻留时间写入所述第二报文的修正域,根据所述第三驻留时间和所述第四驻留时间获得所述第二时间; Determining that a dwell time of the second packet from the second service processing unit to the second time processing unit is a fourth dwell time, and writing the fourth dwell time to the second a correction field of the message, obtaining the second time according to the third dwell time and the fourth dwell time;
给所述第二报文标识第四时间戳,所述第四时间戳指示所述第二时间处理单元接收所述第二报文的时间;And identifying, by the second timestamp, a fourth timestamp, where the fourth timestamp indicates a time when the second time processing unit receives the second message;
生成第三报文,发送所述第三报文至所述第一设备,所述第三报文携带所述第四时间戳,所述第三报文的修正域携带所述第二时间。Generating a third packet, and sending the third packet to the first device, where the third packet carries the fourth timestamp, and the modified domain of the third packet carries the second time.
在一实施例中,所述确定所述第一报文在所述第二设备的第二时间处理单元和所述第二设备的第二业务处理单元之间的驻留时间为第一驻留时间,包括:In an embodiment, the determining, by the first message, a dwell time between the second time processing unit of the second device and the second service processing unit of the second device is a first resident Time, including:
确定所述第一报文传出所述第二时间处理单元的时间为第五时间信息;Determining, that the time when the first packet is sent out by the second time processing unit is fifth time information;
采样开销帧的帧头处的时间为第七数值,采样所述开销帧的帧头处的帧号为第八数值,确定所述第一报文的第一个字节所在开销帧的帧号为第九数值,根据所述第七数值、所述第八数值和所述第九数值,确定所述第一报文传出所述第二业务处理单元的时间为第六时间信息;The time at the frame header of the sampling overhead frame is a seventh value, and the frame number at the frame header of the sampling the overhead frame is an eighth value, and the frame number of the overhead frame in which the first byte of the first packet is located is determined. a ninth value, determining, according to the seventh value, the eighth value, and the ninth value, that the time when the first packet is sent out to the second service processing unit is the sixth time information;
根据所述第五时间信息和所述第六时间信息,确定所述第一报文在所述第二时间处理单元和所述第二业务处理单元之间的驻留时间为第一驻留时间。Determining, according to the fifth time information and the sixth time information, a dwell time of the first packet between the second time processing unit and the second service processing unit as a first dwell time .
在一实施例中,所述确定所述第二报文从传入所述第二业务处理单元到所述第二时间处理单元的驻留时间为第四驻留时间,包括:In an embodiment, the determining that the second message is from the second service processing unit to the second time processing unit is a fourth dwell time, including:
确定所述第二报文传入所述第二业务处理单元的时间为第七时间信息;Determining, that the time when the second packet is transmitted to the second service processing unit is seventh time information;
确定所述第二报文传入所述第二时间处理单元的时间为第八时间信息;Determining that the time when the second packet is transmitted to the second time processing unit is eighth time information;
根据所述第七时间信息和所述第八时间信息,确定所述第二报文从传入所述第二业务处理单元到所述第二时间处理单元的驻留时间为第四驻留时间。 Determining, according to the seventh time information and the eighth time information, that a dwell time of the second packet from the second service processing unit to the second time processing unit is a fourth dwell time .
在一实施例中,所述发送所述第一报文至第一设备,包括:In an embodiment, the sending the first packet to the first device includes:
将所述第一报文的所有字节按照字节顺序插入到至少一个开销帧的配置保留比特中,发送所述至少一个开销帧至所述第一设备,其中,每一个开销帧插入所述第一报文的一个字节。Inserting, in byte order, all bytes of the first packet into a configuration reserved bit of at least one overhead frame, and transmitting the at least one overhead frame to the first device, where each overhead frame is inserted into the One byte of the first message.
本发明实施例还提供一种计算机存储介质,所述计算机存储介质中存储有计算机可执行指令,所述计算机可执行指令用于执行本发明实施例所述的应用于第二设备的时间同步方法。The embodiment of the present invention further provides a computer storage medium, where the computer storage medium stores computer executable instructions, and the computer executable instructions are used to execute the time synchronization method applied to the second device according to the embodiment of the present invention. .
本发明实施例提供一种时间同步设备,所述设备包括:第一业务处理单元、第一时间处理单元、配置单元,An embodiment of the present invention provides a time synchronization device, where the device includes: a first service processing unit, a first time processing unit, and a configuration unit,
所述第一业务处理单元,配置为获取第一时间戳,所述第一时间戳指示第二设备的第二时间处理单元发送第一报文的时间;The first service processing unit is configured to acquire a first timestamp, where the first timestamp indicates a time when the second time processing unit of the second device sends the first message;
所述第一时间处理单元,配置为确定第一时间,所述第一时间指示所述第一报文在所述第二设备和所述第一设备之间的驻留时间;还配置为确定第二时间戳和第三时间戳,所述第二时间戳指示所述第一设备的第一时间处理单元接收所述第一报文的时间,所述第三时间戳指示所述第一时间处理单元发送第二报文的时间;The first time processing unit is configured to determine a first time, where the first time indicates a dwell time between the second device and the first device, and is further configured to determine a second timestamp indicating a time when the first time processing unit of the first device receives the first message, and the third timestamp indicating the first time The time when the processing unit sends the second packet;
所述第一业务处理单元,配置为获取第四时间戳和第二时间,所述第四时间戳指示所述第二时间处理单元接收所述第二报文的时间,所述第二时间指示所述第二报文在所述第一设备和所述第二设备之间的驻留时间;The first service processing unit is configured to acquire a fourth timestamp and a second time, where the fourth timestamp indicates a time when the second time processing unit receives the second message, and the second time indication a dwell time of the second message between the first device and the second device;
所述配置单元,配置为根据所述第一时间戳、所述第二时间戳、所述第三时间戳、所述第四时间戳、所述第一时间和所述第二时间,确定补偿时间;还配置为将所述补偿时间配置到所述第一设备,以使得所述第一设备的时间同步所述第二设备的时间。The configuration unit is configured to determine compensation according to the first timestamp, the second timestamp, the third timestamp, the fourth timestamp, the first time, and the second time Time; is further configured to configure the compensation time to the first device such that the time of the first device synchronizes the time of the second device.
在一实施例中,所述第一业务处理单元包括:第一系统时戳处理模块,配置为接收所述第二设备发送的至少一个开销帧,提取所述至少一个开销 帧中所述第一报文的每一个字节,将所述每一个字节进行组合获得所述第一报文,所述第一报文携带所述第一时间戳,所述第一报文的修正域携带第一驻留时间,所述第一驻留时间指示所述第一报文在所述第二设备的第二时间处理单元和所述第二设备的第二业务处理单元之间的驻留时间;In an embodiment, the first service processing unit includes: a first system time stamp processing module, configured to receive at least one overhead frame sent by the second device, and extract the at least one overhead Each of the first packets of the frame is combined to obtain the first packet, and the first packet carries the first timestamp, the first packet The modified domain of the file carries a first camp time, the first camp time indicating that the first packet is in the second time processing unit of the second device and the second service processing unit of the second device Residence time
所述第一时间处理单元,配置为确定所述第一报文从传入所述第一设备的第一业务处理单元到所述第一时间处理单元的驻留时间为第二驻留时间,还配置为将所述第二驻留时间写入所述第二报文的修正域,根据所述第一驻留时间和所述第二驻留时间获得所述第一时间。The first time processing unit is configured to determine that a dwell time of the first packet from the first service processing unit of the first device to the first time processing unit is a second dwell time, It is further configured to write the second dwell time to a correction domain of the second message, and obtain the first time according to the first dwell time and the second dwell time.
所述第一时间处理单元包括:第一打时戳模块、第一报文产生模块,The first time processing unit includes: a first time stamping module and a first message generating module,
所述第一打时戳模块,配置为当所述第一报文传入所述第一时间处理单元时,给所述第一报文标识第二时间戳;The first time stamping module is configured to: when the first packet is sent to the first time processing unit, identify the second timestamp of the first packet;
所述第一报文产生模块,配置为生成所述第二报文,给所述第二报文标识第三时间戳。The first packet generating module is configured to generate the second packet, and identify a third timestamp to the second packet.
在一实施例中,所述第一业务处理单元,配置为确定所述第二报文在所述第一时间处理单元和所述第一设备的第一业务处理单元之间的驻留时间为第三驻留时间,还配置为将所述第三驻留时间写入所述第二报文的修正域,以使得所述第二设备根据所述第三驻留时间确定所述第二时间;还配置为将所述第二报文的所有字节按照字节顺序插入到至少一个开销帧的配置保留比特中,发送所述至少一个开销帧至所述第二设备,其中,每一个开销帧插入所述第二报文的一个字节。In an embodiment, the first service processing unit is configured to determine that a dwell time between the first time processing unit and the first service processing unit of the first device is a third dwell time, configured to write the third dwell time to a correction domain of the second message, such that the second device determines the second time according to the third dwell time And configured to insert all bytes of the second packet into a configuration reserved bit of at least one overhead frame in a byte order, and send the at least one overhead frame to the second device, where each overhead The frame is inserted into one byte of the second message.
在一实施例中,所述第一业务处理单元,配置为确定所述第一报文传入所述第一业务处理单元的时间为第一时间信息;In an embodiment, the first service processing unit is configured to determine that the time when the first packet is transmitted to the first service processing unit is first time information;
所述第一时间处理单元,配置为确定所述第一报文传入所述第一时间处理单元的时间为第二时间信息;还配置为根据所述第一时间信息和所述第二时间信息,确定所述第一报文从传入所述第一业务处理单元到所述第 一时间处理单元的驻留时间为第二驻留时间;The first time processing unit is configured to determine that the time when the first packet is transmitted to the first time processing unit is second time information, and is further configured to: according to the first time information and the second time Determining that the first message is sent from the first service processing unit to the first The dwell time of the processing unit for a time is the second dwell time;
所述第一时间处理单元,配置为确定所述第二报文传出所述第一时间处理单元的时间为第三时间信息;The first time processing unit is configured to determine that the time when the second packet is sent out by the first time processing unit is third time information;
所述第一业务处理单元,配置为确定所述第二报文传出所述第一业务处理单元的时间为第四时间信息;还配置为根据所述第三时间信息和所述第四时间信息,确定所述第二报文在所述第一时间处理单元和所述第一业务处理单元之间的驻留时间为第三驻留时间。The first service processing unit is configured to determine that the time when the second packet is sent out of the first service processing unit is fourth time information, and is further configured to: according to the third time information and the fourth time And determining, by the information, that the dwell time of the second packet between the first time processing unit and the first service processing unit is a third dwell time.
在一实施例中,所述第一业务处理单元包括:第一系统时戳采样模块、第一系统时戳处理模块,In an embodiment, the first service processing unit includes: a first system time stamp sampling module, and a first system time stamp processing module,
所述第一系统时戳采样模块,配置为当所述第一业务处理单元检测到开销帧的帧头时,采样所述开销帧的帧头处的时间为第一数值,采样所述开销帧的帧头处的帧号为第二数值;还配置为采样所述第一报文第一个字节所在开销帧的帧号为第三数值;The first system timestamp sampling module is configured to: when the first service processing unit detects a frame header of the overhead frame, sample the time at the frame header of the overhead frame as a first value, and sample the overhead frame The frame number at the frame header is a second value; and the frame number of the overhead frame in which the first byte of the first packet is sampled is a third value;
所述第一系统时戳采样模块,配置为根据所述第一数值、所述第二数值和所述第三数值,确定第一时间信息。The first system time stamp sampling module is configured to determine first time information according to the first value, the second value, and the third value.
在一实施例中,所述第一业务处理单元,包括:第一系统时戳采样模块、第一系统时戳处理模块,In an embodiment, the first service processing unit includes: a first system time stamp sampling module, a first system time stamp processing module,
第一系统时戳采样模块,配置为采样开销帧的帧头处的时间为第四数值,采样所述开销帧的帧头处的帧号为第五数值;还配置为确定所述第二报文的第一个字节所在开销帧的帧号为第六数值;The first system timestamp sampling module is configured to: the time at the frame header of the sampling overhead frame is a fourth value, and the frame number at the frame header of the sampling the overhead frame is a fifth value; and the second report is further configured to determine The frame number of the overhead frame in which the first byte of the text is located is the sixth value;
第一系统时戳处理模块,配置为根据所述第四数值、所述第五数值和所述第六数值,确定第四时间信息。The first system time stamp processing module is configured to determine the fourth time information according to the fourth value, the fifth value, and the sixth value.
本发明实施例还提供一种时间同步设备,所述设备包括:第二时间处理单元和第二业务处理单元,所述第二时间处理单元包括:第二报文产生模块、第二打时戳模块, The embodiment of the present invention further provides a time synchronization device, where the device includes: a second time processing unit and a second service processing unit, where the second time processing unit includes: a second message generation module, and a second time stamp Module,
所述第二报文产生模块,配置为生成第一报文;The second packet generating module is configured to generate a first packet;
所述第二打时戳模块,配置为给所述第一报文标识第一时间戳,所述第一时间戳指示所述第二设备的第二时间处理单元发送所述第一报文的时间;The second time stamping module is configured to identify a first timestamp for the first packet, where the first timestamp indicates that the second time processing unit of the second device sends the first packet time;
所述第二业务处理单元,配置为确定所述第一报文在所述第二设备的第二时间处理单元和所述第二设备的第二业务处理单元之间的驻留时间为第一驻留时间,将所述第一驻留时间写入所述第二报文的修正域;还配置为发送所述第一报文至第一设备。The second service processing unit is configured to determine that a dwell time between the second time processing unit of the second device and the second service processing unit of the second device is the first The dwell time is written into the correction domain of the second packet, and is further configured to send the first packet to the first device.
在一实施例中,所述第二业务处理单元,配置为接收所述第一设备发送的至少一个开销帧,提取所述至少一个开销帧中所述第二报文的每一个字节,将所述每一个字节进行组合获得所述第二报文,所述第二报文携带第三时间戳,所述第三时间戳指示所述第一设备的第一时间处理单元发送所述第二报文的时间,所述第二报文的修正域携带第三驻留时间,所述第三驻留时间指示所述第二报文在所述第一时间处理单元和所述第一设备的第一业务处理单元之间的驻留时间;In an embodiment, the second service processing unit is configured to receive at least one overhead frame sent by the first device, and extract each byte of the second packet in the at least one overhead frame, Each of the bytes is combined to obtain the second packet, where the second packet carries a third timestamp, and the third timestamp indicates that the first time processing unit of the first device sends the The time of the second packet, the modified domain of the second packet carries a third camp time, and the third camp time indicates that the second packet is in the first time processing unit and the first device The dwell time between the first business processing units;
所述第二时间处理单元,配置为确定所述第二报文从传入所述第二业务处理单元到所述第二时间处理单元的驻留时间为第四驻留时间,还配置为将所述第四驻留时间写入所述第二报文的修正域,还配置为根据所述第三驻留时间和所述第四驻留时间获得所述第二时间;The second time processing unit is configured to determine that a dwell time of the second packet from the second service processing unit to the second time processing unit is a fourth dwell time, and is further configured to The fourth dwell time is written into the correction domain of the second packet, and is further configured to obtain the second time according to the third dwell time and the fourth dwell time;
所述第二打时戳模块,配置为给所述第二报文标识第四时间戳,所述第四时间戳指示所述第二时间处理单元接收所述第二报文的时间;The second time stamping module is configured to identify a fourth timestamp for the second message, where the fourth timestamp indicates a time when the second time processing unit receives the second message;
所述第二报文产生模块,配置为生成第三报文;The second packet generating module is configured to generate a third packet;
所述第二业务处理单元,配置为发送所述第三报文至所述第一设备,所述第三报文携带所述第四时间戳,所述第三报文的修正域携带所述第二时间。 The second service processing unit is configured to send the third packet to the first device, where the third packet carries the fourth timestamp, and the modified domain of the third packet carries the The second time.
在一实施例中,所述第二时间处理单元,配置为确定所述第一报文传出所述第二时间处理单元的时间为第五时间信息;In an embodiment, the second time processing unit is configured to determine that the time when the first message is sent out by the second time processing unit is fifth time information;
所述第二业务处理单元,配置为采样开销帧的帧头处的时间为第七数值,采样所述开销帧的帧头处的帧号为第八数值,确定所述第一报文的第一个字节所在开销帧的帧号为第九数值,根据所述第七数值、所述第八数值和所述第九数值,确定所述第一报文传出所述第二业务处理单元的时间为第六时间信息;还配置为根据所述第五时间信息和所述第六时间信息,确定所述第一报文在所述第二时间处理单元和所述第二业务处理单元之间的驻留时间为第一驻留时间;The second service processing unit is configured to: the time at the frame header of the sampling overhead frame is a seventh value, and the frame number at the frame header of the sampling the overhead frame is an eighth value, and the first packet is determined. The frame number of the overhead frame in which the byte is located is a ninth value, and the first message is sent out to the second service processing unit according to the seventh value, the eighth value, and the ninth value. The time is the sixth time information; and is further configured to determine, according to the fifth time information and the sixth time information, that the first message is in the second time processing unit and the second service processing unit The dwell time between the two is the first dwell time;
所述第二业务处理单元,配置为确定所述第二报文传入所述第二业务处理单元的时间为第七时间信息;The second service processing unit is configured to determine that the time when the second packet is transmitted to the second service processing unit is the seventh time information;
所述第二时间处理单元,配置为确定所述第二报文传入所述第二时间处理单元的时间为第八时间信息;还配置为根据所述第七时间信息和所述第八时间信息,确定所述第二报文从传入所述第二业务处理单元到所述第二时间处理单元的驻留时间为第四驻留时间;The second time processing unit is configured to determine that the time when the second packet is transmitted to the second time processing unit is eighth time information; and is further configured to: according to the seventh time information and the eighth time Determining, by the information, a dwell time of the second packet from the second service processing unit to the second time processing unit is a fourth dwell time;
所述第二业务处理单元,配置为接收至少一个开销帧,还配置为提取所述至少一个开销帧中所述第二报文的每一个字节,将所述每一个字节进行组合获得所述第二报文。The second service processing unit is configured to receive at least one overhead frame, and further configured to extract each byte of the second packet in the at least one overhead frame, and combine each of the bytes to obtain a Said the second message.
本发明实施例提供一种时间同步方法、设备及计算机存储介质,获取第一时间戳,第一时间戳指示第二设备的第二时间处理单元发送第一报文的时间;确定第一时间,第一时间指示第一报文在第二设备和第一设备之间的驻留时间;确定第二时间戳和第三时间戳,其中,第二时间戳指示第一设备的第一时间处理单元接收第一报文的时间,第三时间戳指示第一时间处理单元发送第二报文的时间;获取第四时间戳和第二时间,第四时间戳指示第二时间处理单元接收第二报文的时间,第二时间指示第二报文在 第一设备和第二设备之间的驻留时间;根据第一时间戳、第二时间戳、第三时间戳、第四时间戳、第一时间和第二时间,确定补偿时间;将补偿时间配置到第一设备,以使得第一设备的时间同步第二设备的时间。本发明实施例提供的时间同步方法和设备,通过对报文传输过程进行时间戳采样,获得报文在第一时间同步设备和第二时间同步设备中传输的时间戳和驻留时间,从而获得补偿时间,通过该补偿时间对第一时间同步设备进行补偿,以保证第一时间同步设备的时间同步第二时间同步设备的时间,从而有效实现高精度的时间同步。The embodiment of the present invention provides a time synchronization method, a device, and a computer storage medium, which acquires a first timestamp, where the first timestamp indicates a time when the second time processing unit of the second device sends the first message; Determining, by the first time, a dwell time between the second device and the first device; determining a second timestamp and a third timestamp, wherein the second timestamp indicates the first time processing unit of the first device The time when the first message is received, the third timestamp indicates the time when the first time processing unit sends the second message; the fourth timestamp is obtained, and the second timestamp indicates that the second time processing unit receives the second message. Time of the text, the second time indicates that the second message is a dwell time between the first device and the second device; determining a compensation time according to the first timestamp, the second timestamp, the third timestamp, the fourth timestamp, the first time, and the second time; The time is configured to the first device such that the time of the first device synchronizes the second device. The time synchronization method and device provided by the embodiment of the present invention obtain timestamp and dwell time of the packet transmission in the first time synchronization device and the second time synchronization device by performing timestamp sampling on the packet transmission process, thereby obtaining The compensation time is used to compensate the first time synchronization device by the compensation time to ensure that the time synchronization of the first time synchronization device synchronizes the time of the second time synchronization device, thereby effectively achieving high-precision time synchronization.
附图说明DRAWINGS
在附图(其不一定是按比例绘制的)中,相似的附图标记可在不同的视图中描述相似的部件。具有不同字母后缀的相似附图标记可表示相似部件的不同示例。附图以示例而非限制的方式大体示出本文中所讨论的各个实施例。In the drawings, which are not necessarily to scale, the Like reference numerals with different letter suffixes may indicate different examples of similar components. The drawings generally illustrate the various embodiments discussed herein by way of example and not limitation.
图1为本发明实施例提供的时间同步方法流程示意图一;1 is a schematic flowchart 1 of a time synchronization method according to an embodiment of the present invention;
图2为本发明实施例提供的时间同步方法流程示意图二;2 is a second schematic flowchart of a time synchronization method according to an embodiment of the present invention;
图3为本发明实施例提供的实现FLEXE1588时间同步设备示意图;3 is a schematic diagram of implementing a FLEXE 1588 time synchronization device according to an embodiment of the present invention;
图4为本发明实施例提供的第一设备结构示意图一;FIG. 4 is a schematic structural diagram 1 of a first device according to an embodiment of the present disclosure;
图5为本发明实施例提供的第一设备结构示意图二;FIG. 5 is a schematic structural diagram 2 of a first device according to an embodiment of the present disclosure;
图6为本发明实施例提供的第二设备结构示意图一;FIG. 6 is a schematic structural diagram 1 of a second device according to an embodiment of the present disclosure;
图7为本发明实施例提供的第二设备结构示意图二。FIG. 7 is a schematic structural diagram 2 of a second device according to an embodiment of the present invention.
具体实施方式detailed description
下面将结合本发明实施例中的附图,对本发明实施例中的技术方案进行清楚、完整地描述。The technical solutions in the embodiments of the present invention will be clearly and completely described in the following with reference to the accompanying drawings.
本发明实施例提供一种时间同步方法,如图1所示,该方法可以包括: The embodiment of the invention provides a time synchronization method. As shown in FIG. 1 , the method may include:
步骤101、获取第一时间戳,第一时间戳指示第二设备的第二时间处理单元发送第一报文的时间。Step 101: Acquire a first timestamp, where the first timestamp indicates a time when the second time processing unit of the second device sends the first packet.
本发明实施例提供的时间同步方法应用于第一设备,即该时间同步方法的执行主体为第一设备,该第一设备可以理解为第一时间同步设备,第一时间同步设备具体可以为基站等。The time synchronization method provided by the embodiment of the present invention is applied to the first device, that is, the execution entity of the time synchronization method is the first device, and the first device can be understood as the first time synchronization device, and the first time synchronization device can be specifically the base station. Wait.
具体的,第一设备可以实现FLEXE1588的时间同步,该第一设备可以包括:第一时间处理单元和第一业务处理单元。Specifically, the first device may implement time synchronization of the FLEXE 1588, and the first device may include: a first time processing unit and a first service processing unit.
需要说明的是,1588是一种主从同步系统。在系统的同步过程中,主时钟周期性发布PTP时间同步及时间信息,从时钟端口接收主时钟端口发来的时间戳信息,系统根据此信息计算出主从线路时间延迟及主从时间差,并利用该时间差调整本地时间,从而使设备时间保持与主设备时间一致的频率和相位。1588可以同时实现频率同步和相位同步。It should be noted that 1588 is a master-slave synchronization system. During the synchronization process of the system, the master clock periodically issues PTP time synchronization and time information, and receives the timestamp information sent by the master clock port from the clock port. Based on this information, the system calculates the master-slave line time delay and the master-slave time difference. The time difference is used to adjust the local time so that the device time remains at a frequency and phase consistent with the master time. 1588 can achieve both frequency synchronization and phase synchronization.
其中,第一时间处理单元包括:处理CPU模块、报文产生模块、1588时间计数模块、系统时间计数模块、打时戳模块和系统时戳处理模块。The first time processing unit includes: a processing CPU module, a message generation module, a 1588 time counting module, a system time counting module, a time stamping module, and a system time stamp processing module.
第一业务处理单元包括:CPU模块、系统时间计数模块、系统时戳采样模块和系统时戳处理模块。The first service processing unit includes: a CPU module, a system time counting module, a system time stamp sampling module, and a system time stamp processing module.
其中,在第一时间处理单元中,CPU模块,主要用于配置该第一设备的工作模式等信息,例如,配置该第一设备为主设备,或者从设备。In the first time processing unit, the CPU module is mainly used to configure information such as an operation mode of the first device, for example, configuring the first device as a master device or a slave device.
报文产生模块,用于产生和接收PTP时间同步报文。A message generation module is configured to generate and receive a PTP time synchronization message.
1588时间计数模块和系统时间计数模块,主要用于产生时间信息,两者的计数时钟是一样的,即时钟的起始时间和时钟的计数频率是相同的,所不同的是1588时间计数模块的计数器可以被校时,而系统时间计数模块的计数器不能被校时。The 1588 time counting module and the system time counting module are mainly used to generate time information. The counting clocks of the two are the same, that is, the starting time of the clock and the counting frequency of the clock are the same, and the difference is the 1588 time counting module. The counter can be timed and the counter of the system time counting module cannot be timed.
打时戳模块,主要用于产生1588时间戳。Time stamping module, mainly used to generate 1588 timestamp.
系统时戳处理模块,用于采样时间报文出入时间处理单元时的系统时 间戳,与业务处理单元发送来的时间一起计算时间报文在时间处理单元和业务处理单元之间的驻留时间。System time stamp processing module, used to sample the time when the time message is sent to and from the time processing unit The time stamp, together with the time sent by the service processing unit, calculates the dwell time of the time message between the time processing unit and the service processing unit.
在第一业务处理单元中,CPU模块,主要用于配置本设备的工作模式、时间报文占用FLEXE开销位置等信息。In the first service processing unit, the CPU module is mainly used to configure information such as the working mode of the device and the FLEXE overhead position of the time packet.
系统时间计数模块,主要用于产生系统时间信息,该系统时间计数模块的计数时钟与时间处理单元中的系统时间计数模块时钟相同,且计数起始时间也相同。The system time counting module is mainly used to generate system time information. The counting clock of the system time counting module is the same as the system time counting module clock in the time processing unit, and the counting start time is also the same.
系统时戳采样模块,主要用于采样FLEXE开销帧的帧头时间,并计算时间报文在业务处理单元出入口处的时间;然后将此时间送往系统时戳处理模块,与时间处理单元传递过来的时间一起计算时间报文在时间处理单元和业务处理单元之间的驻留时间。The system time stamp sampling module is mainly used for sampling the frame head time of the FLEXE overhead frame, and calculating the time of the time message at the entrance and exit of the service processing unit; then sending the time to the system time stamp processing module, and transmitting it to the time processing unit. The time together calculates the dwell time of the time message between the time processing unit and the business processing unit.
在业务处理单元中,由于时间报文的所有字节是按顺序插入到连续多个FLEXE开销帧的保留bit中,且每个FLEXE开销帧只插入时间报文的一个字节。取时间报文第一个字节所在的FLEXE开销帧的帧头处的时间作为时间报文出入业务处理单元的时间。In the service processing unit, since all bytes of the time message are sequentially inserted into the reserved bits of consecutive multiple FLEXE overhead frames, and each FLEXE overhead frame is only inserted into one byte of the time message. The time at the frame header of the FLEXE overhead frame where the first byte of the time packet is located is taken as the time when the time packet enters and exits the service processing unit.
系统时戳处理模块与业务处理单元的出入口有一定的延时,为提高对时精度,需要补偿这段延时,即需要在第二系统时戳处理模块推算出时间报文在业务处理单元的出入口处的时间。There is a certain delay between the system timestamp processing module and the service processing unit's gateway. To improve the timing accuracy, the delay needs to be compensated. That is, the second system time stamp processing module needs to calculate the time message at the entrance and exit of the service processing unit. time.
推算方法如下:由于传送一个FLEXE开销帧的时间基本是固定的,因此,可以计算出每个时间报文从入口处到系统时戳处理模块,或者从系统时戳处理模块到出口处延时的帧数,自动补偿该帧数的时间,即可得到时间报文在入口或出口处的时间。The calculation method is as follows: Since the time for transmitting a FLEXE overhead frame is basically fixed, it can be calculated that each time message is sent from the entry to the system time stamp processing module, or from the system time stamp processing module to the exit. The number of frames, automatically compensated for the number of frames, to get the time of the time message at the entrance or exit.
具体的,第一设备接收所述第二设备发送的所述第一报文,所述第一报文携带所述第一时间戳,所述第一报文的修正域携带第一驻留时间,所述第一驻留时间指示所述第一报文在所述第二设备的第二时间处理单元和 所述第二设备的第二业务处理单元之间的驻留时间。Specifically, the first device receives the first packet sent by the second device, where the first packet carries the first timestamp, and the modified domain of the first packet carries a first camp time The first dwell time indicates that the first message is in a second time processing unit of the second device and The dwell time between the second service processing units of the second device.
在一实施例中,所述接收所述第二设备发送的所述第一报文,可以包括:In an embodiment, the receiving the first packet sent by the second device may include:
接收至少一个开销帧,提取所述至少一个开销帧中所述第一报文的每一个字节,将所述每一个字节进行组合获得所述第一报文。Receiving at least one overhead frame, extracting each byte of the first packet in the at least one overhead frame, and combining each of the bytes to obtain the first packet.
步骤102、确定第一时间,第一时间指示第一报文在第二设备和第一设备之间的驻留时间。Step 102: Determine a first time, where the first time indicates a dwell time between the second device and the first device.
具体的,第一设备确定所述第一报文从传入所述第一设备的第一业务处理单元到所述第一时间处理单元的驻留时间为第二驻留时间,将所述第二驻留时间写入所述第二报文的修正域,根据所述第一驻留时间和所述第二驻留时间获得所述第一时间。Specifically, the first device determines that the camping time of the first packet from the first service processing unit of the first device to the first time processing unit is a second camp time, where the first The second dwell time is written into the correction domain of the second packet, and the first time is obtained according to the first dwell time and the second dwell time.
在一实施例中,所述确定所述第一报文从传入所述第一设备的第一业务处理单元到所述第一时间处理单元的驻留时间为第二驻留时间,包括:In an embodiment, the determining that the first message is from the first service processing unit of the first device to the first time processing unit is a second dwell time, including:
确定所述第一报文传入所述第一业务处理单元的时间为第一时间信息;Determining, that the time when the first packet is sent to the first service processing unit is first time information;
确定所述第一报文传入所述第一时间处理单元的时间为第二时间信息;Determining, that the time when the first packet is transmitted to the first time processing unit is second time information;
根据所述第一时间信息和所述第二时间信息,确定所述第一报文从传入所述第一业务处理单元到所述第一时间处理单元的驻留时间为第二驻留时间。Determining, according to the first time information and the second time information, that a dwell time of the first packet from the first service processing unit to the first time processing unit is a second dwell time .
在一实施例中,所述确定所述第一报文传入所述第一业务处理单元的时间为第一时间信息,包括:In an embodiment, the determining that the first packet is sent to the first service processing unit is the first time information, including:
当所述第一业务处理单元检测到开销帧的帧头时,采样所述开销帧的帧头处的时间为第一数值,采样所述开销帧的帧头处的帧号为第二数值;When the first service processing unit detects the frame header of the overhead frame, sampling the time at the frame header of the overhead frame as a first value, and sampling the frame number at the frame header of the overhead frame as a second value;
采样所述第一报文第一个字节所在开销帧的帧号为第三数值; Sampling the frame number of the overhead frame in which the first byte of the first packet is located is a third value;
根据所述第一数值、所述第二数值和所述第三数值,确定第一时间信息。Determining the first time information based on the first value, the second value, and the third value.
步骤103、确定第二时间戳和第三时间戳,其中,第二时间戳指示第一设备的第一时间处理单元接收第一报文的时间,第三时间戳指示第一时间处理单元发送第二报文的时间。Step 103: Determine a second timestamp and a third timestamp, where the second timestamp indicates a time when the first time processing unit of the first device receives the first message, and the third timestamp indicates that the first time processing unit sends the The time of the second message.
具体的,当所述第一报文传入所述第一时间处理单元时,第一设备给所述第一报文标识第二时间戳;生成所述第二报文,给所述第二报文标识第三时间戳。Specifically, when the first packet is sent to the first time processing unit, the first device identifies the second timestamp to the first packet, and generates the second packet to the second The message identifies the third timestamp.
在一实施例中,在所述生成第二报文,给所述第二报文标识第三时间戳之后,包括:In an embodiment, after the generating the second packet and the third packet identifying the third timestamp, the method includes:
确定所述第二报文在所述第一时间处理单元和所述第一设备的第一业务处理单元之间的驻留时间为第三驻留时间,将所述第三驻留时间写入所述第二报文的修正域,以使得所述第二设备根据所述第三驻留时间确定所述第二时间;Determining, by the second packet, a dwell time between the first time processing unit and the first service processing unit of the first device as a third dwell time, and writing the third dwell time a correction field of the second packet, so that the second device determines the second time according to the third camp time;
发送所述第二报文至所述第二设备。Sending the second packet to the second device.
在一实施例中,所述确定所述第二报文在所述第一时间处理单元和所述第一设备的第一业务处理单元之间的驻留时间为第三驻留时间,包括:In an embodiment, the determining, by the second time, the dwell time between the first time processing unit and the first service processing unit of the first device is a third dwell time, including:
确定所述第二报文传出所述第一时间处理单元的时间为第三时间信息;Determining, that the time when the second packet is sent out by the first time processing unit is third time information;
确定所述第二报文传出所述第一业务处理单元的时间为第四时间信息;Determining, that the time when the second packet is sent out by the first service processing unit is fourth time information;
根据所述第三时间信息和所述第四时间信息,确定所述第二报文在所述第一时间处理单元和所述第一业务处理单元之间的驻留时间为第三驻留时间。Determining, according to the third time information and the fourth time information, a dwell time between the first time processing unit and the first service processing unit as a third dwell time .
在一实施例中,所述确定所述第二报文传出所述第一业务处理单元的 时间为第四时间信息,包括:In an embodiment, the determining that the second packet is sent out of the first service processing unit Time is the fourth time information, including:
采样开销帧的帧头处的时间为第四数值,采样所述开销帧的帧头处的帧号为第五数值;The time at the frame header of the sampling overhead frame is a fourth value, and the frame number at the frame header of the sampling the overhead frame is a fifth value;
确定所述第二报文的第一个字节所在开销帧的帧号为第六数值;Determining, that the frame number of the overhead frame in which the first byte of the second packet is located is a sixth value;
根据所述第四数值、所述第五数值和所述第六数值,确定第四时间信息。The fourth time information is determined based on the fourth value, the fifth value, and the sixth value.
在一实施例中,所述发送所述第二报文至所述第二设备,包括:In an embodiment, the sending the second packet to the second device includes:
将所述第二报文的所有字节按照字节顺序插入到至少一个开销帧的配置保留比特中,发送所述至少一个开销帧至所述第二设备,其中,每一个开销帧插入所述第二报文的一个字节。Inserting, in byte order, all bytes of the second packet into a configuration reserved bit of at least one overhead frame, and transmitting the at least one overhead frame to the second device, where each overhead frame is inserted into the One byte of the second message.
步骤104、获取第四时间戳和第二时间,第四时间戳指示第二时间处理单元接收第二报文的时间,第二时间指示第二报文在第一设备和第二设备之间的驻留时间。Step 104: Obtain a fourth timestamp and a second time, where the fourth timestamp indicates a time when the second time processing unit receives the second message, and the second time indicates that the second message is between the first device and the second device. Dwell time.
具体的,第一设备获取第四时间戳和第二时间可以包括:第一设备接收所述第二设备发送的第三报文,所述第三报文携带所述第四时间戳,所述第三报文的修正域携带所述第二时间。Specifically, the acquiring, by the first device, the fourth timestamp and the second time may include: receiving, by the first device, a third packet sent by the second device, where the third packet carries the fourth timestamp, The correction domain of the third message carries the second time.
步骤105、根据第一时间戳、第二时间戳、第三时间戳、第四时间戳、第一时间和第二时间,确定补偿时间。Step 105: Determine a compensation time according to the first timestamp, the second timestamp, the third timestamp, the fourth timestamp, the first time, and the second time.
具体的,设定第一时间戳为T1,第二时间戳为T2,第三时间戳为T3,第四时间戳为T4,第一时间为CFs,第二时间为CFd,可以确定补偿时间offset为:Specifically, the first timestamp is set to T1, the second timestamp is T2, the third timestamp is T3, the fourth timestamp is T4, the first time is CFs, and the second time is CFd, and the compensation time offset can be determined. for:
offset=((T2-T1-CFs)-(T4-T3-CFd))/2Offset=((T2-T1-CFs)-(T4-T3-CFd))/2
步骤106、将补偿时间配置到第一设备,以使得第一设备的时间同步第二设备的时间。Step 106: Configure the compensation time to the first device, so that the time of the first device synchronizes the time of the second device.
具体的,第一设备可以将补偿时间配置到自身设备,即第一设备可以通过软件补偿该补偿时间,从而,可以将第一设备的时间同步到第二设备 的时间上。Specifically, the first device can configure the compensation time to the self device, that is, the first device can compensate the compensation time by using the software, so that the time of the first device can be synchronized to the second device. On the time.
本发明实施例提供的时间同步方法,通过对报文传输过程进行时间戳采样,获得报文在第一时间同步设备和第二时间同步设备中传输的时间戳和驻留时间,从而获得补偿时间,通过该补偿时间对第一时间同步设备进行补偿,以保证第一时间同步设备的时间同步第二时间同步设备的时间,从而有效实现高精度的时间同步。The time synchronization method provided by the embodiment of the present invention obtains a time stamp and a dwell time transmitted by the packet in the first time synchronization device and the second time synchronization device by performing timestamp sampling on the packet transmission process, thereby obtaining a compensation time. The first time synchronization device is compensated by the compensation time to ensure that the time synchronization of the first time synchronization device synchronizes the time of the second time synchronization device, thereby effectively achieving high-precision time synchronization.
本发明实施例还提供一种计算机存储介质,所述计算机存储介质中存储有计算机可执行指令,所述计算机可执行指令用于执行本发明实施例所述的应用于第一设备的时间同步方法。The embodiment of the present invention further provides a computer storage medium, where the computer storage medium stores computer executable instructions, and the computer executable instructions are used to execute the time synchronization method applied to the first device according to the embodiment of the present invention. .
本发明实施例提供一种时间同步方法,如图2所示,所述方法应用于第二设备,所述方法包括:An embodiment of the present invention provides a time synchronization method. As shown in FIG. 2, the method is applied to a second device, where the method includes:
步骤201、生成第一报文,给所述第一报文标识第一时间戳,所述第一时间戳指示所述第二设备的第二时间处理单元发送所述第一报文的时间。Step 201: Generate a first packet, and identify a first timestamp to the first packet, where the first timestamp indicates a time when the second time processing unit of the second device sends the first packet.
本发明实施例提供的时间同步方法应用于第二设备,即该时间同步方法的执行主体为第二设备,该第二设备可以理解为第二时间同步设备,第二时间同步设备具体可以为基站等。The time synchronization method provided by the embodiment of the present invention is applied to the second device, that is, the execution entity of the time synchronization method is the second device, and the second device can be understood as the second time synchronization device, and the second time synchronization device can be specifically the base station. Wait.
具体的,第二设备可以实现FLEXE1588的时间同步,该第二设备可以包括:第二时间处理单元和第二业务处理单元。Specifically, the second device may implement time synchronization of the FLEXE 1588, and the second device may include: a second time processing unit and a second service processing unit.
其中,第二时间处理单元包括:处理CPU模块、报文产生模块、1588时间计数模块、系统时间计数模块、打时戳模块和系统时戳处理模块。第二业务处理单元包括:CPU模块、系统时间计数模块、系统时戳采样模块和系统时戳处理模块。The second time processing unit includes: a processing CPU module, a message generation module, a 1588 time counting module, a system time counting module, a time stamping module, and a system time stamp processing module. The second service processing unit includes: a CPU module, a system time counting module, a system time stamp sampling module, and a system time stamp processing module.
具体的,第二时间处理单元和第二业务处理单元中的各个模块实现的功能与上述第一设备中各个模块实现的功能相同,可参考上述实施例,本发明实施例在此不再赘述。 Specifically, the functions implemented by the respective modules in the second time processing unit and the second service processing unit are the same as those in the foregoing first device, and the embodiments are not described herein.
步骤202、确定所述第一报文在所述第二设备的第二时间处理单元和所述第二设备的第二业务处理单元之间的驻留时间为第一驻留时间,将所述第一驻留时间写入所述第二报文的修正域。Step 202: Determine a dwell time between the second time processing unit of the second device and the second service processing unit of the second device, where the first message is a first dwell time, where The first dwell time is written to the correction domain of the second message.
具体的,第二设备确定所述第一报文在所述第二设备的第二时间处理单元和所述第二设备的第二业务处理单元之间的驻留时间为第一驻留时间,可以包括:Specifically, the second device determines that a dwell time between the second time processing unit of the second device and the second service processing unit of the second device is the first dwell time, Can include:
确定所述第一报文传出所述第二时间处理单元的时间为第五时间信息;Determining, that the time when the first packet is sent out by the second time processing unit is fifth time information;
确定所述第一报文传出所述第二业务处理单元的时间为第六时间信息;Determining, that the time when the first packet is sent out by the second service processing unit is sixth time information;
根据所述第五时间信息和所述第六时间信息,确定所述第一报文在所述第二时间处理单元和所述第二业务处理单元之间的驻留时间为第一驻留时间。Determining, according to the fifth time information and the sixth time information, a dwell time of the first packet between the second time processing unit and the second service processing unit as a first dwell time .
在一实施例中,所述确定所述第一报文传出所述第二业务处理单元的时间为第六时间信息,包括:In an embodiment, the determining that the time when the first packet is sent out by the second service processing unit is the sixth time information, including:
采样开销帧的帧头处的时间为第七数值,采样所述开销帧的帧头处的帧号为第八数值;The time at the frame header of the sampling overhead frame is a seventh value, and the frame number at the frame header of the sampling the overhead frame is an eighth value;
确定所述第一报文的第一个字节所在开销帧的帧号为第九数值;Determining, that the frame number of the overhead frame in which the first byte of the first packet is located is a ninth value;
根据所述第七数值、所述第八数值和所述第九数值,确定第六时间信息。The sixth time information is determined based on the seventh value, the eighth value, and the ninth value.
步骤203、发送所述第一报文至第一设备。Step 203: Send the first packet to the first device.
具体的,第二设备将所述第一报文的所有字节按照字节顺序插入到至少一个开销帧的配置保留比特中,发送所述至少一个开销帧至所述第一设备,其中,每一个开销帧插入所述第一报文的一个字节。Specifically, the second device inserts all the bytes of the first packet into the configuration reserved bits of the at least one overhead frame in a byte order, and sends the at least one overhead frame to the first device, where each An overhead frame is inserted into one byte of the first message.
在一实施例中,所述方法还可以包括: In an embodiment, the method may further include:
接收所述第一设备发送的第二报文,所述第二报文携带第三时间戳,所述第三时间戳指示所述第一设备的第一时间处理单元发送所述第二报文的时间,所述第二报文的修正域携带第三驻留时间,所述第三驻留时间指示所述第二报文在所述第一时间处理单元和所述第一设备的第一业务处理单元之间的驻留时间;Receiving a second packet sent by the first device, where the second packet carries a third timestamp, the third timestamp indicating that the first time processing unit of the first device sends the second packet Time, the modified domain of the second packet carries a third dwell time, the third dwell time indicating that the second packet is in the first time processing unit and the first device Residence time between business processing units;
确定所述第二报文从传入所述第二业务处理单元到所述第二时间处理单元的驻留时间为第四驻留时间,将所述第四驻留时间写入所述第二报文的修正域,根据所述第三驻留时间和所述第四驻留时间获得所述第二时间;Determining that a dwell time of the second packet from the second service processing unit to the second time processing unit is a fourth dwell time, and writing the fourth dwell time to the second a correction field of the message, obtaining the second time according to the third dwell time and the fourth dwell time;
给所述第二报文标识第四时间戳,所述第四时间戳指示所述第二时间处理单元接收所述第二报文的时间;And identifying, by the second timestamp, a fourth timestamp, where the fourth timestamp indicates a time when the second time processing unit receives the second message;
生成第三报文,发送所述第三报文至所述第一设备,所述第三报文携带所述第四时间戳,所述第三报文的修正域携带所述第二时间。Generating a third packet, and sending the third packet to the first device, where the third packet carries the fourth timestamp, and the modified domain of the third packet carries the second time.
在一实施例中,所述确定所述第二报文从传入所述第二业务处理单元到所述第二时间处理单元的驻留时间为第四驻留时间,包括:In an embodiment, the determining that the second message is from the second service processing unit to the second time processing unit is a fourth dwell time, including:
确定所述第二报文传入所述第二业务处理单元的时间为第七时间信息;Determining, that the time when the second packet is transmitted to the second service processing unit is seventh time information;
确定所述第二报文传入所述第二时间处理单元的时间为第八时间信息;Determining that the time when the second packet is transmitted to the second time processing unit is eighth time information;
根据所述第七时间信息和所述第八时间信息,确定所述第二报文从传入所述第二业务处理单元到所述第二时间处理单元的驻留时间为第四驻留时间。Determining, according to the seventh time information and the eighth time information, that a dwell time of the second packet from the second service processing unit to the second time processing unit is a fourth dwell time .
在一实施例中,确定所述第二报文传入所述第二业务处理单元的时间为第七时间信息;In an embodiment, determining that the second packet is transmitted to the second service processing unit is the seventh time information;
当所述第二业务处理单元检测到开销帧的帧头时,采样所述开销帧的帧头处的时间为第十数值,采样所述开销帧的帧头处的帧号为第十一数值; When the second service processing unit detects the frame header of the overhead frame, the time at the frame header of the sampling the overhead frame is a tenth value, and the frame number at the frame header of the sampling the overhead frame is the eleventh value. ;
采样所述第二报文第一个字节所在开销帧的帧号为第十二数值;Sampling the frame number of the overhead frame in which the first byte of the second packet is located is the twelfth value;
根据所述第十数值、所述第十一数值和所述第十二数值,确定第七时间信息。The seventh time information is determined based on the tenth value, the eleventh value, and the twelfth value.
在一实施例中,所述接收所述第一设备发送的第二报文,包括:In an embodiment, the receiving the second packet sent by the first device includes:
接收至少一个开销帧,提取所述至少一个开销帧中所述第二报文的每一个字节,将所述每一个字节进行组合获得所述第二报文。Receiving at least one overhead frame, extracting each byte of the second packet in the at least one overhead frame, and combining each of the bytes to obtain the second packet.
本发明实施例提供的时间同步方法,通过对报文传输过程进行时间戳采样,获得报文在第一时间同步设备和第二时间同步设备中传输的时间戳和驻留时间,从而获得补偿时间,通过该补偿时间对第一时间同步设备进行补偿,以保证第一时间同步设备的时间同步第二时间同步设备的时间,从而有效实现高精度的时间同步。The time synchronization method provided by the embodiment of the present invention obtains a time stamp and a dwell time transmitted by the packet in the first time synchronization device and the second time synchronization device by performing timestamp sampling on the packet transmission process, thereby obtaining a compensation time. The first time synchronization device is compensated by the compensation time to ensure that the time synchronization of the first time synchronization device synchronizes the time of the second time synchronization device, thereby effectively achieving high-precision time synchronization.
本发明实施例还提供一种计算机存储介质,所述计算机存储介质中存储有计算机可执行指令,所述计算机可执行指令用于执行本发明实施例所述的应用于第二设备的时间同步方法。The embodiment of the present invention further provides a computer storage medium, where the computer storage medium stores computer executable instructions, and the computer executable instructions are used to execute the time synchronization method applied to the second device according to the embodiment of the present invention. .
示例性的,设定第一设备为设备B,第二设备为设备A,即要实现设备B的时间与设备A的时间同步,通过CPU配置主设备、从设备,具体的,将设备A设定为主设备Master,将设备B设定为从设备Slave,时间同步过程如下所述:Exemplarily, the first device is set to be the device B, and the second device is the device A, that is, the time of the device B is synchronized with the time of the device A, and the master device and the slave device are configured by the CPU. Specifically, the device A is set. The master device is the master device, and the device B is set as the slave device slave. The time synchronization process is as follows:
示例性的,如图3所示,设备A的时间处理单元的报文产生模块产生sync报文,即第一报文,该sync报文进入打时戳模块,打上sync报文发送时间戳T1,即第一时间戳,T1可以理解为sync报文进入打时戳模块的时间,T1是由1588时间计数器模块产生的时间戳。Exemplarily, as shown in FIG. 3, the message generating module of the time processing unit of the device A generates a sync message, that is, a first message, and the sync message enters a time stamping module, and the synchronization message is sent with a timestamp T1. That is, the first timestamp, T1 can be understood as the time when the sync message enters the time stamping module, and T1 is the timestamp generated by the 1588 time counter module.
然后,sync报文传输到时间处理单元的系统时戳处理模块,打上由系统时间计数器模块产生的时间戳t1,即,t1可以理解为sync报文进入系统时戳处理模块的时间,t1随同sync报文送往业务处理装置。 Then, the sync message is transmitted to the system time stamp processing module of the time processing unit, and the time stamp t1 generated by the system time counter module is marked, that is, t1 can be understood as the time when the sync message enters the system time stamp processing module, and t1 is accompanied by sync. The message is sent to the service processing device.
业务处理装置收到sync报文,经处理后将sync报文的所有字节按顺序插入到FLEXE开销帧的配置保留bit中,每一FLEXE开销帧插入sync报文的一个字节,The service processing device receives the sync message, and after processing, inserts all the bytes of the sync message into the configuration reserved bit of the FLEXE overhead frame in sequence, and inserts one byte of the sync message into each FLEXE overhead frame.
其中,sync报文处理过程为:系统时戳采样模块采样业务处理装置出口处每个FLEXE开销帧的帧头处的时间d1和帧号m1,回传到系统时戳处理模块,系统时戳处理模块采样sync报文第一个字节所在FLEXE开销帧的帧号m2,由此计算出sync报文出业务处理装置的时间t2,具体如下式:The processing process of the sync message is: the system time stamp sampling module samples the time d1 and the frame number m1 at the frame header of each FLEXE overhead frame at the exit of the service processing device, and returns the system time stamp processing module to the system time stamp processing module. The module samples the frame number m2 of the FLEXE overhead frame in which the first byte of the sync packet is located, thereby calculating the time t2 of the service packet from the service packet, as follows:
t2=d1+(m2-m1)*CT2=d1+(m2-m1)*C
其中,C为传递一个FLEXE开销帧所需要的时间,为一固定值,可由CPU配置。Where C is the time required to deliver a FLEXE overhead frame, which is a fixed value and can be configured by the CPU.
得到t2后,计算出时间报文在时间处理装置和业务处理装置之间的驻留时间Δt1,计算方法为如下式:After obtaining t2, the dwell time Δt1 between the time processing device and the service processing device is calculated, and the calculation method is as follows:
Δt1=t2-t1Δt1=t2-t1
并将该驻留时间Δt1写入sync报文的修正域,即sync报文的修正域变为CF2=CF1+Δt1And the resident time Δt1 is written into the correction domain of the sync message, that is, the correction field of the sync message is changed to CF2=CF1+Δt1
设备B通过FLEXE接口从FLEXE开销帧中提取出sync报文的每一个字节并组成完整的sync报文,即第一报文,同时计算出sync报文在业务处理装置入口出的时间。The device B extracts each byte of the sync packet from the FLEXE overhead frame through the FLEXE interface and forms a complete sync packet, that is, the first packet, and calculates the time at which the sync packet is sent out at the service processing device.
计算sync报文在业务处理装置入口出的时间的方法为:在设备B业务处理单元入口出定到FLEXE开销帧的帧头的时候,将系统时戳采样模块采样到的FLEXE开销帧的帧头处的时间d2和帧号m3传送到系统时戳处理模块,系统时戳处理模块采样sync报文第一个字节所在FLEXE开销帧的帧号m4,由此可以计算出sync报文在设备B的业务处理装置入口处的时间t3,具体计算如下式所示:The method for calculating the time of the sync message at the entry of the service processing device is: the frame header of the FLEXE overhead frame sampled by the system time stamp sampling module when the device B service processing unit enters the frame header of the FLEXE overhead frame. The time d2 and the frame number m3 are transmitted to the system time stamp processing module, and the system time stamp processing module samples the frame number m4 of the FLEXE overhead frame in which the first byte of the sync message is located, thereby calculating the sync message on the device B. The time t3 at the entrance of the business processing device is calculated as follows:
t3=d2-(m3-m4)*CT3=d2-(m3-m4)*C
其中,C为传递一个FLEXE开销帧所需要的时间,为一固定值,可由 CPU配置。Where C is the time required to deliver a FLEXE overhead frame, which is a fixed value, which can be CPU configuration.
将提取到的完整的sync报文和计算出的sync报文在业务处理装置入口处的时间t3一并传送给时间处理装置。The extracted complete sync message and the calculated sync message are transmitted to the time processing device at time t3 at the entrance of the service processing device.
时间处理装置收到sync报文时,采样出收到sync报文时的系统时间t4,计算出sync报文从业务处理装置入口处到当前时间处理装置的驻留时间Δt2,具体如下式所示:When receiving the sync message, the time processing device samples the system time t4 when the sync message is received, and calculates the dwell time Δt2 of the sync message from the service processing device entrance to the current time processing device, as shown in the following formula. :
Δt2=t4-t3Δt2=t4-t3
计算得到Δt2后,将该驻留时间写入sync报文的修正域,即sync报文的修正域变为:CFs=CF2+Δt2。After calculating Δt2, the resident time is written into the correction domain of the sync message, that is, the correction field of the sync message becomes: CFs=CF2+Δt2.
随后sync报文送往打时戳模块,打上接收到sync报文时的1588时间戳T2。至此设备B的软件知道了设备A发送sync报文的时戳T1和自身接收到sync报文的时戳T2,并且由sync报文的修正域CFs知道了sync报文在设备A和设备B的两种装置之间的驻留时间。Then, the sync message is sent to the time stamping module, and the 1588 timestamp T2 is received when the sync message is received. At this point, the software of device B knows that the timestamp T1 of the device A sends the sync message and the timestamp T2 of the sync message received by itself, and the correction field CFs of the sync message knows that the sync message is on the device A and the device B. The dwell time between the two devices.
设备B中时间处理装置的报文产生模块产生延迟请求delay_req报文,即第二报文,delay_req报文的处理过程与设备A处理sync报文的过程相同,所不同的是设备B记录的是delay_req报文发出的时戳T3,同时delay_req报文的修正域变为CF4=CF3+Δt3。The packet generation module of the time processing device in the device B generates a delay request delay_req message, that is, the second message, and the processing process of the delay_req message is the same as the process of processing the sync message by the device A, except that the device B records the The timestamp T3 sent by the delay_req message, and the correction field of the delay_req message becomes CF4=CF3+Δt3.
设备A通过FLEXE接口从FLEXE开销帧中提取出delay_req报文的每一个字节并组成完整的delay_req报文,同时计算出delay_req报文在业务处理装置入口出的时间。该过程与设备B处理sync报文的过程相同,所不同的是在时间处理装置的打时戳模块打上的是delay_req报文的接收时戳T4。同时得到delay_req报文的修正域CFd=CF4+Δt4。The device A extracts each byte of the delay_req packet from the FLEXE overhead frame through the FLEXE interface and forms a complete delay_req packet, and calculates the time of the delay_req packet at the entry of the service processing device. The process is the same as the process of the device B processing the sync message, except that the time stamping module of the time processing device is marked with the receiving time stamp T4 of the delay_req message. At the same time, the correction field CFd=CF4+Δt4 of the delay_req message is obtained.
设备A中时间处理装置的报文产生模块产生延时响应delay_resp报文,即第三报文,delay_resp报文携带设备A接收到delay_req报文的1588时间戳T4和delay_req报文的修正域CFd。delay_resp报文不做任何时间戳的处 理,直接通过FLEXE的开销帧发送出去。The packet generation module of the time processing device in the device A generates a delay response delay_resp message, that is, a third message, and the delay_resp message carries the 1588 timestamp T4 of the delay_req message and the correction field CFd of the delay_req message. Delay_resp message does not do any timestamp Rationally, it is sent directly through the overhead frame of FLEXE.
设备B通过FLEXE接口从FLEXE开销帧中提取出delay_resp报文,同样不做任何时间戳的处理,直接送往设备B的软件。Device B extracts the delay_resp packet from the FLEXE overhead frame through the FLEXE interface, and also sends the software directly to device B without any timestamp processing.
设备B的软件获得到了设备A发送sync报文的时戳T1和自身接收到sync报文的时戳T2,获得到了设备B发送delay_req报文的时戳T3和设备B接收到delay_req报文的时戳T4,获得到了sync报文在设备A和设备B的两种装置之间的驻留时间CFs,获得到了delay_req报文在设备A和设备B的两种装置之间的驻留时间CFd,可通过公式The software of the device B obtains the time stamp T1 when the device A sends the sync message and the time stamp T2 that the device receives the sync message, and obtains the time stamp T3 when the device B sends the delay_req message and the device B receives the delay_req message. The T4 is obtained, and the dwell time CFs between the two devices of the device A and the device B is obtained, and the dwell time CFd between the two devices of the device A and the device B is obtained. Through formula
offset=((T2-T1-CFs)-(T4-T3-CFd))/2Offset=((T2-T1-CFs)-(T4-T3-CFd))/2
得出设备A和设备B之间的时间差,设备B通过软件补偿该offset值,即可将设备B的时间同步到设备A的时间上。The time difference between device A and device B is obtained, and device B can synchronize the time of device B to the time of device A by software offsetting the offset value.
通过本发明实施例提供的方法可以实现FLEXE1588时间同步,可实现设备之间通过FLEXE接口的时间同步,并且对时精度可高达纳秒级别。The FLEXE1588 time synchronization can be implemented by the method provided by the embodiment of the present invention, and the time synchronization between the devices through the FLEXE interface can be realized, and the timing accuracy can be up to the nanosecond level.
需要说明的是,以上是本发明其中一种实施方式,实际上,一个设备中,一个时间处理装置也可以连接多个业务处理装置,即多个第一设备时间同步到第二设备的时间上,多个业务处理装置的系统时间计数模块的计数时钟和计数初始时间相同,可以通过时间处理装置下发,对时原理同上所述。It should be noted that the above is one embodiment of the present invention. In fact, in one device, one time processing device may also be connected to multiple service processing devices, that is, time when multiple first devices are time synchronized to the second device. The counting clock of the system time counting module of the plurality of service processing devices is the same as the initial counting time, and can be delivered by the time processing device, and the timing principle is the same as described above.
本发明实施例提供一种时间同步设备,如图4所示,时间同步设备30包括:第一业务处理单元301、第一时间处理单元302、配置单元303,其中,The embodiment of the present invention provides a time synchronization device. As shown in FIG. 4, the time synchronization device 30 includes: a first service processing unit 301, a first time processing unit 302, and a configuration unit 303, where
所述第一业务处理单元301,配置为获取第一时间戳,所述第一时间戳指示第二设备的第二时间处理单元发送第一报文的时间;The first service processing unit 301 is configured to acquire a first timestamp, where the first timestamp indicates a time when the second time processing unit of the second device sends the first packet;
所述第一时间处理单元302,配置为确定第一时间,所述第一时间指示所述第一报文在所述第二设备和所述第一设备之间的驻留时间;还用于确定第二时间戳和第三时间戳,其中,所述第二时间戳指示所述第一设备的 第一时间处理单元接收所述第一报文的时间,所述第三时间戳指示所述第一时间处理单元发送第二报文的时间;The first time processing unit 302 is configured to determine a first time, where the first time indicates a dwell time of the first message between the second device and the first device; Determining a second timestamp and a third timestamp, wherein the second timestamp indicates the first device Receiving, by the first time processing unit, the time of the first packet, where the third timestamp indicates a time when the first time processing unit sends the second packet;
所述第一业务处理单元301,配置为获取第四时间戳和第二时间,所述第四时间戳指示所述第二时间处理单元接收所述第二报文的时间,所述第二时间指示所述第二报文在所述第一设备和所述第二设备之间的驻留时间;The first service processing unit 301 is configured to acquire a fourth timestamp and a second time, where the fourth timestamp indicates a time when the second time processing unit receives the second message, the second time And indicating a dwell time of the second packet between the first device and the second device;
所述配置单元303,还配置为根据所述第一时间戳、所述第二时间戳、所述第三时间戳、所述第四时间戳、所述第一时间和所述第二时间,确定补偿时间;还配置为将所述补偿时间配置到所述第一设备,以使得所述第一设备的时间同步所述第二设备的时间。The configuration unit 303 is further configured to: according to the first timestamp, the second timestamp, the third timestamp, the fourth timestamp, the first time, and the second time, Determining a compensation time; further configured to configure the compensation time to the first device such that time of the first device synchronizes time of the second device.
在一实施例中,所述第一业务处理单元301包括:第一系统时戳处理模块3011,配置为接收所述第二设备发送的所述第一报文,所述第一报文携带所述第一时间戳,所述第一报文的修正域携带第一驻留时间,所述第一驻留时间指示所述第一报文在所述第二设备的第二时间处理单元和所述第二设备的第二业务处理单元之间的驻留时间。In an embodiment, the first service processing unit 301 includes: a first system time stamp processing module 3011, configured to receive the first packet sent by the second device, where the first packet carries The first timestamp, the modified domain of the first packet carries a first camp time, and the first camp time indicates that the first packet is in the second time processing unit and the second device The dwell time between the second service processing units of the second device.
在一实施例中,所述第一时间处理单元302,配置为确定所述第一报文从传入所述第一设备的第一业务处理单元到所述第一时间处理单元的驻留时间为第二驻留时间,还配置为将所述第二驻留时间写入所述第二报文的修正域,根据所述第一驻留时间和所述第二驻留时间获得所述第一时间。In an embodiment, the first time processing unit 302 is configured to determine a dwell time of the first message from a first service processing unit of the first device to the first time processing unit. And the second dwell time is further configured to write the second dwell time into the correction domain of the second packet, and obtain the first according to the first dwell time and the second dwell time For a time.
在一实施例中,如图5所示,所述第一时间处理单元302包括:第一打时戳模块3021、第一报文产生模块3022,In an embodiment, as shown in FIG. 5, the first time processing unit 302 includes: a first time stamping module 3021, and a first packet generating module 3022.
所述第一打时戳模块3021,配置为当所述第一报文传入所述第一时间处理单元时,给所述第一报文标识第二时间戳;The first time stamping module 3021 is configured to: when the first packet is sent to the first time processing unit, identify a second timestamp for the first packet;
所述第一报文产生模块3022,配置为生成所述第二报文,给所述第二报文标识第三时间戳。 The first packet generating module 3022 is configured to generate the second packet, and identify the second packet with the third timestamp.
在一实施例中,所述第一业务处理单元301,配置为确定所述第二报文在所述第一时间处理单元和所述第一设备的第一业务处理单元之间的驻留时间为第三驻留时间,还配置为将所述第三驻留时间写入所述第二报文的修正域,以使得所述第二设备根据所述第三驻留时间确定所述第二时间;还配置为发送所述第二报文至所述第二设备。In an embodiment, the first service processing unit 301 is configured to determine a dwell time between the first time processing unit and the first service processing unit of the first device. a third dwell time, further configured to write the third dwell time to a correction domain of the second message, such that the second device determines the second according to the third dwell time Time; configured to send the second message to the second device.
在一实施例中,所述第一业务处理单元301,配置为接收所述第二设备发送的第三报文,所述第三报文携带所述第四时间戳,所述第三报文的修正域携带所述第二时间。In an embodiment, the first service processing unit 301 is configured to receive a third packet sent by the second device, where the third packet carries the fourth timestamp, and the third packet The correction domain carries the second time.
在一实施例中,所述第一业务处理单元301,配置为确定所述第一报文传入所述第一业务处理单元的时间为第一时间信息;In an embodiment, the first service processing unit 301 is configured to determine that the time when the first packet is transmitted to the first service processing unit is first time information;
所述第一时间处理单元302,用于确定所述第一报文传入所述第一时间处理单元的时间为第二时间信息;还配置为根据所述第一时间信息和所述第二时间信息,确定所述第一报文从传入所述第一业务处理单元到所述第一时间处理单元的驻留时间为第二驻留时间。The first time processing unit 302 is configured to determine that the time when the first packet is sent to the first time processing unit is second time information, and is further configured to: according to the first time information and the second The time information determines that the dwell time of the first message from the first service processing unit to the first time processing unit is a second dwell time.
在一实施例中,所述第一时间处理单元302,配置为确定所述第二报文传出所述第一时间处理单元的时间为第三时间信息;In an embodiment, the first time processing unit 302 is configured to determine that the time when the second message is sent out by the first time processing unit is third time information;
所述第一业务处理单元301,配置为确定所述第二报文传出所述第一业务处理单元的时间为第四时间信息;还配置为根据所述第三时间信息和所述第四时间信息,确定所述第二报文在所述第一时间处理单元和所述第一业务处理单元之间的驻留时间为第三驻留时间。The first service processing unit 301 is configured to determine that the time when the second packet is sent out of the first service processing unit is fourth time information, and is further configured to be based on the third time information and the fourth The time information determines that the dwell time of the second message between the first time processing unit and the first service processing unit is a third dwell time.
在一实施例中,如图5所示,所述第一业务处理单元301包括:第一系统时戳采样模块3012、第一系统时戳处理模块3011,In an embodiment, as shown in FIG. 5, the first service processing unit 301 includes: a first system time stamp sampling module 3012, and a first system time stamp processing module 3011.
所述第一系统时戳采样模块3012,配置为当所述第一业务处理单元检测到开销帧的帧头时,采样所述开销帧的帧头处的时间为第一数值,采样所述开销帧的帧头处的帧号为第二数值;还配置为采样所述第一报文第一 个字节所在开销帧的帧号为第三数值;The first system timestamp sampling module 3012 is configured to: when the first service processing unit detects the frame header of the overhead frame, sample the time at the frame header of the overhead frame as a first value, and sample the overhead. The frame number at the frame header of the frame is a second value; and is further configured to sample the first message first The frame number of the overhead frame in which the bytes are located is the third value;
所述第一系统时戳处理模块3011,配置为根据所述第一数值、所述第二数值和所述第三数值,确定第一时间信息。The first system timestamp processing module 3011 is configured to determine the first time information according to the first value, the second value, and the third value.
在一实施例中,所述第一业务处理单元301,配置为接收至少一个开销帧,还用于提取所述至少一个开销帧中所述第一报文的每一个字节,将所述每一个字节进行组合获得所述第一报文。In an embodiment, the first service processing unit 301 is configured to receive at least one overhead frame, and is further configured to extract each byte of the first packet in the at least one overhead frame, where each of the One byte is combined to obtain the first message.
在一实施例中,如图5所示,所述第一业务处理单元301,包括:第一系统时戳采样模块3012、第一系统时戳处理模块3011,In an embodiment, as shown in FIG. 5, the first service processing unit 301 includes: a first system time stamp sampling module 3012, and a first system time stamp processing module 3011.
第一系统时戳采样模块3012,配置为采样开销帧的帧头处的时间为第四数值,采样所述开销帧的帧头处的帧号为第五数值;还配置为确定所述第二报文的第一个字节所在开销帧的帧号为第六数值;The first system timestamp sampling module 3012 is configured to: the time at the frame header of the sampling overhead frame is a fourth value, and the frame number at the frame header of the sampling the overhead frame is a fifth value; and is further configured to determine the second The frame number of the overhead frame in which the first byte of the message is located is the sixth value;
第一系统时戳处理模块3011,配置为根据所述第四数值、所述第五数值和所述第六数值,确定第四时间信息。The first system time stamp processing module 3011 is configured to determine the fourth time information according to the fourth value, the fifth value, and the sixth value.
在一实施例中,所述第一业务处理单元301,配置为将所述第二报文的所有字节按照字节顺序插入到至少一个开销帧的配置保留比特中,还配置为发送所述至少一个开销帧至所述第二设备,其中,每一个开销帧插入所述第二报文的一个字节。In an embodiment, the first service processing unit 301 is configured to insert all bytes of the second packet into a configuration reserved bit of at least one overhead frame in a byte order, and is further configured to send the At least one overhead frame to the second device, wherein each overhead frame is inserted into one byte of the second message.
具体的,本发明实施例提供的时间同步设备的理解可以参考上述的时间同步方法实施例的说明,本发明实施例在此不再赘述。For a detailed description of the time synchronization device provided by the embodiment of the present invention, reference may be made to the description of the foregoing time synchronization method embodiment, and details are not described herein again.
本发明实施例提供的时间同步设备,通过对报文传输过程进行时间戳采样,获得报文在第一时间同步设备和第二时间同步设备中传输的时间戳和驻留时间,从而获得补偿时间,通过该补偿时间对第一时间同步设备进行补偿,以保证第一时间同步设备的时间同步第二时间同步设备的时间,从而有效实现高精度的时间同步。The time synchronization device provided by the embodiment of the present invention obtains the time stamp and the dwell time transmitted by the packet in the first time synchronization device and the second time synchronization device by time stamping the packet transmission process, thereby obtaining the compensation time. The first time synchronization device is compensated by the compensation time to ensure that the time synchronization of the first time synchronization device synchronizes the time of the second time synchronization device, thereby effectively achieving high-precision time synchronization.
本发明实施例提供一种时间同步设备,如图6所示,所述时间同步设 备40包括:第二时间处理单元401和第二业务处理单元402,所述第二时间处理单元401包括:第二报文产生模块4011、第二打时戳模块4012,其中,The embodiment of the invention provides a time synchronization device, as shown in FIG. 6, the time synchronization device The device 40 includes a second time processing unit 401 and a second service processing unit 402. The second time processing unit 401 includes: a second message generating module 4011 and a second time stamping module 4012.
所述第二报文产生模块4011,配置为生成第一报文;The second packet generating module 4011 is configured to generate a first packet.
所述第二打时戳模块4012,配置为给所述第一报文标识第一时间戳,所述第一时间戳指示所述第二设备的第二时间处理单元发送所述第一报文的时间;The second time stamping module 4012 is configured to identify a first timestamp for the first message, where the first timestamp indicates that the second time processing unit of the second device sends the first timestamp time;
所述第二业务处理单元401,配置为确定所述第一报文在所述第二设备的第二时间处理单元和所述第二设备的第二业务处理单元之间的驻留时间为第一驻留时间,将所述第一驻留时间写入所述第二报文的修正域;还配置为发送所述第一报文至第一设备。The second service processing unit 401 is configured to determine that a dwell time between the second time processing unit of the second device and the second service processing unit of the second device is The first camp time is written into the correction domain of the second packet, and is configured to send the first packet to the first device.
在一实施例中,所述第二业务处理单元402,配置为接收所述第一设备发送的第二报文,所述第二报文携带第三时间戳,所述第三时间戳指示所述第一设备的第一时间处理单元发送所述第二报文的时间,所述第二报文的修正域携带第三驻留时间,所述第三驻留时间指示所述第二报文在所述第一时间处理单元和所述第一设备的第一业务处理单元之间的驻留时间;In an embodiment, the second service processing unit 402 is configured to receive a second packet sent by the first device, where the second packet carries a third timestamp, and the third timestamp indicates a time when the first time processing unit of the first device sends the second packet, where the modified domain of the second packet carries a third camp time, and the third camp time indicates the second packet a dwell time between the first time processing unit and the first service processing unit of the first device;
所述第二时间处理单元401,配置为确定所述第二报文从传入所述第二业务处理单元到所述第二时间处理单元的驻留时间为第四驻留时间,还配置为将所述第四驻留时间写入所述第二报文的修正域,还配置为根据所述第三驻留时间和所述第四驻留时间获得所述第二时间;The second time processing unit 401 is configured to determine that a dwell time of the second packet from the second service processing unit to the second time processing unit is a fourth camp time, and is further configured to Writing the fourth dwell time to the correction domain of the second packet, further configured to obtain the second time according to the third dwell time and the fourth dwell time;
所述第二打时戳模块4012,配置为给所述第二报文标识第四时间戳,所述第四时间戳指示所述第二时间处理单元接收所述第二报文的时间;The second time stamping module 4012 is configured to identify a fourth timestamp for the second message, where the fourth timestamp indicates a time when the second time processing unit receives the second message;
所述第二报文产生模块4011,配置为生成第三报文;The second packet generating module 4011 is configured to generate a third packet.
所述第二业务处理单元402,配置为发送所述第三报文至所述第一设备,所述第三报文携带所述第四时间戳,所述第三报文的修正域携带所述 第二时间。The second service processing unit 402 is configured to send the third packet to the first device, where the third packet carries the fourth timestamp, and the modified domain of the third packet carries the Description The second time.
在一实施例中,所述第二时间处理单元401,配置为确定所述第一报文传出所述第二时间处理单元的时间为第五时间信息;In an embodiment, the second time processing unit 401 is configured to determine that the time when the first packet is sent out by the second time processing unit is fifth time information;
所述第二业务处理单元402,配置为确定所述第一报文传出所述第二业务处理单元的时间为第六时间信息;还配置为根据所述第五时间信息和所述第六时间信息,确定所述第一报文在所述第二时间处理单元和所述第二业务处理单元之间的驻留时间为第一驻留时间。The second service processing unit 402 is configured to determine that the time when the first packet is sent out by the second service processing unit is sixth time information, and is further configured to be based on the fifth time information and the sixth The time information determines that the dwell time of the first message between the second time processing unit and the second service processing unit is a first dwell time.
在一实施例中,所述第二业务处理单元402,配置为确定所述第二报文传入所述第二业务处理单元的时间为第七时间信息;In an embodiment, the second service processing unit 402 is configured to determine that the time when the second packet is transmitted to the second service processing unit is the seventh time information;
所述第二时间处理单元401,配置为确定所述第二报文传入所述第二时间处理单元的时间为第八时间信息;还配置为根据所述第七时间信息和所述第八时间信息,确定所述第二报文从传入所述第二业务处理单元到所述第二时间处理单元的驻留时间为第四驻留时间。The second time processing unit 401 is configured to determine that the time when the second packet is transmitted to the second time processing unit is eighth time information; and is further configured to: according to the seventh time information and the eighth The time information is determined to be a fourth dwell time of the second message from the second service processing unit to the second time processing unit.
在一实施例中,如图7所示,所述第二业务处理单元402包括:第二系统时戳采样模块4021、第二系统时戳处理模块4022,In an embodiment, as shown in FIG. 7, the second service processing unit 402 includes: a second system time stamp sampling module 4021, and a second system time stamp processing module 4022.
第二系统时戳采样模块4021,配置为采样开销帧的帧头处的时间为第七数值,还用于采样所述开销帧的帧头处的帧号为第八数值;还配置为确定所述第一报文的第一个字节所在开销帧的帧号为第九数值;The second system time stamp sampling module 4021 is configured to: the time at the frame header of the sampling overhead frame is a seventh value, and is also used to sample the frame number at the frame header of the overhead frame as an eighth value; The frame number of the overhead frame in which the first byte of the first packet is located is the ninth value;
第二系统时戳处理模块4022,配置为根据所述第七数值、所述第八数值和所述第九数值,确定第六时间信息。The second system time stamp processing module 4022 is configured to determine the sixth time information according to the seventh value, the eighth value, and the ninth value.
在一实施例中,所述第二业务处理单元402,配置为将所述第一报文的所有字节按照字节顺序插入到至少一个开销帧的配置保留比特中,还配置为发送所述至少一个开销帧至所述第一设备,其中,每一个开销帧插入所述第一报文的一个字节。In an embodiment, the second service processing unit 402 is configured to insert all bytes of the first packet into a configuration reserved bit of at least one overhead frame in a byte order, and is further configured to send the At least one overhead frame to the first device, wherein each overhead frame is inserted into one byte of the first message.
在一实施例中,所述第二业务处理单元402,配置为接收至少一个开销 帧,还用于提取所述至少一个开销帧中所述第二报文的每一个字节,将所述每一个字节进行组合获得所述第二报文。In an embodiment, the second service processing unit 402 is configured to receive at least one overhead. The frame is further configured to extract each byte of the second packet in the at least one overhead frame, and combine each of the bytes to obtain the second packet.
具体的,本发明实施例提供的时间同步设备的理解可以参考上述的时间同步方法实施例的说明,本发明实施例在此不再赘述。For a detailed description of the time synchronization device provided by the embodiment of the present invention, reference may be made to the description of the foregoing time synchronization method embodiment, and details are not described herein again.
本发明实施例提供的时间同步设备,通过对报文传输过程进行时间戳采样,获得报文在第一时间同步设备和第二时间同步设备中传输的时间戳和驻留时间,从而获得补偿时间,通过该补偿时间对第一时间同步设备进行补偿,以保证第一时间同步设备的时间同步第二时间同步设备的时间,从而有效实现高精度的时间同步。The time synchronization device provided by the embodiment of the present invention obtains the time stamp and the dwell time transmitted by the packet in the first time synchronization device and the second time synchronization device by time stamping the packet transmission process, thereby obtaining the compensation time. The first time synchronization device is compensated by the compensation time to ensure that the time synchronization of the first time synchronization device synchronizes the time of the second time synchronization device, thereby effectively achieving high-precision time synchronization.
本领域内的技术人员应明白,本发明的实施例可提供为方法、系统、或计算机程序产品。因此,本发明可采用硬件实施例、软件实施例、或结合软件和硬件方面的实施例的形式。而且,本发明可采用在一个或多个其中包含有计算机可用程序代码的计算机可用存储介质(包括但不限于磁盘存储器和光学存储器等)上实施的计算机程序产品的形式。Those skilled in the art will appreciate that embodiments of the present invention can be provided as a method, system, or computer program product. Accordingly, the present invention can take the form of a hardware embodiment, a software embodiment, or a combination of software and hardware. Moreover, the invention can take the form of a computer program product embodied on one or more computer-usable storage media (including but not limited to disk storage and optical storage, etc.) including computer usable program code.
本发明是参照根据本发明实施例的方法、设备(系统)、和计算机程序产品的流程图和/或方框图来描述的。应理解可由计算机程序指令实现流程图和/或方框图中的每一流程和/或方框、以及流程图和/或方框图中的流程和/或方框的结合。可提供这些计算机程序指令到通用计算机、专用计算机、嵌入式处理机或其他可编程数据处理设备的处理器以产生一个机器,使得通过计算机或其他可编程数据处理设备的处理器执行的指令产生用于实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能的装置。The present invention has been described with reference to flowchart illustrations and/or block diagrams of methods, apparatus (system), and computer program products according to embodiments of the invention. It will be understood that each flow and/or block of the flowchart illustrations and/or FIG. These computer program instructions can be provided to a processor of a general purpose computer, special purpose computer, embedded processor, or other programmable data processing device to produce a machine for the execution of instructions for execution by a processor of a computer or other programmable data processing device. Means for implementing the functions specified in one or more of the flow or in a block or blocks of the flow chart.
这些计算机程序指令也可存储在能引导计算机或其他可编程数据处理设备以特定方式工作的计算机可读存储器中,使得存储在该计算机可读存储器中的指令产生包括指令装置的制造品,该指令装置实现在流程图一个 流程或多个流程和/或方框图一个方框或多个方框中指定的功能。The computer program instructions can also be stored in a computer readable memory that can direct a computer or other programmable data processing device to operate in a particular manner, such that the instructions stored in the computer readable memory produce an article of manufacture comprising the instruction device. The device is implemented in a flow chart A function specified in a block or blocks of a process or multiple processes and/or block diagrams.
这些计算机程序指令也可装载到计算机或其他可编程数据处理设备上,使得在计算机或其他可编程设备上执行一系列操作步骤以产生计算机实现的处理,从而在计算机或其他可编程设备上执行的指令提供用于实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能的步骤。These computer program instructions can also be loaded onto a computer or other programmable data processing device such that a series of operational steps are performed on a computer or other programmable device to produce computer-implemented processing for execution on a computer or other programmable device. The instructions provide steps for implementing the functions specified in one or more of the flow or in a block or blocks of a flow diagram.
以上所述,仅为本发明的较佳实施例而已,并非用于限定本发明的保护范围。The above is only the preferred embodiment of the present invention and is not intended to limit the scope of the present invention.
工业实用性Industrial applicability
本发明实施例提供一种时间同步方法,获取第一时间戳,第一时间戳指示第二设备的第二时间处理单元发送第一报文的时间;确定第一时间,第一时间指示第一报文在第二设备和第一设备之间的驻留时间;确定第二时间戳和第三时间戳,其中,第二时间戳指示第一设备的第一时间处理单元接收第一报文的时间,第三时间戳指示第一时间处理单元发送第二报文的时间;获取第四时间戳和第二时间,第四时间戳指示第二时间处理单元接收第二报文的时间,第二时间指示第二报文在第一设备和第二设备之间的驻留时间;根据第一时间戳、第二时间戳、第三时间戳、第四时间戳、第一时间和第二时间,确定补偿时间;将补偿时间配置到第一设备,以使得第一设备的时间同步第二设备的时间。如此,通过对报文传输过程进行时间戳采样,获得报文在第一时间同步设备和第二时间同步设备中传输的时间戳和驻留时间,从而获得补偿时间,通过该补偿时间对第一时间同步设备进行补偿,以保证第一时间同步设备的时间同步第二时间同步设备的时间,从而有效实现高精度的时间同步。 The embodiment of the present invention provides a time synchronization method, which acquires a first timestamp, where the first timestamp indicates a time when the second time processing unit of the second device sends the first message; and determines the first time, the first time indicates the first time. a dwell time between the second device and the first device; determining a second timestamp and a third timestamp, wherein the second timestamp indicates that the first time processing unit of the first device receives the first message Time, the third timestamp indicates the time when the first time processing unit sends the second message; the fourth timestamp and the second time are obtained, the fourth timestamp indicates the time when the second time processing unit receives the second message, and the second time The time indicates a dwell time of the second message between the first device and the second device; according to the first timestamp, the second timestamp, the third timestamp, the fourth timestamp, the first time, and the second time, Determining the compensation time; configuring the compensation time to the first device such that the time of the first device synchronizes the time of the second device. In this manner, by performing timestamp sampling on the packet transmission process, the timestamp and the dwell time of the packet transmitted in the first time synchronization device and the second time synchronization device are obtained, thereby obtaining a compensation time, and the compensation time is first. The time synchronization device performs compensation to ensure that the time of the first time synchronization device synchronizes the time of the second time synchronization device, thereby effectively achieving high-precision time synchronization.

Claims (23)

  1. 一种时间同步方法,所述方法应用于第一设备,所述方法包括:A time synchronization method, the method being applied to a first device, the method comprising:
    获取第一时间戳,所述第一时间戳指示第二设备的第二时间处理单元发送第一报文的时间;Obtaining a first timestamp, where the first timestamp indicates a time when the second time processing unit of the second device sends the first message;
    确定第一时间,所述第一时间指示所述第一报文在所述第二设备和所述第一设备之间的驻留时间;Determining a first time, the first time indicating a dwell time of the first message between the second device and the first device;
    确定第二时间戳和第三时间戳,所述第二时间戳指示所述第一设备的第一时间处理单元接收所述第一报文的时间,所述第三时间戳指示所述第一时间处理单元发送第二报文的时间;Determining a second timestamp indicating a time at which the first time processing unit of the first device receives the first message, the third timestamp indicating the first time Time when the time processing unit sends the second message;
    获取第四时间戳和第二时间,所述第四时间戳指示所述第二时间处理单元接收所述第二报文的时间,所述第二时间指示所述第二报文在所述第一设备和所述第二设备之间的驻留时间;Obtaining a fourth timestamp indicating a time when the second time processing unit receives the second message, and the second time indicating that the second message is in the a dwell time between a device and the second device;
    根据所述第一时间戳、所述第二时间戳、所述第三时间戳、所述第四时间戳、所述第一时间和所述第二时间,确定补偿时间;Determining a compensation time according to the first timestamp, the second timestamp, the third timestamp, the fourth timestamp, the first time, and the second time;
    将所述补偿时间配置到所述第一设备,以使得所述第一设备的时间同步所述第二设备的时间。The compensation time is configured to the first device such that the time of the first device synchronizes the time of the second device.
  2. 根据权利要求1所述的方法,其中,所述获取第一时间戳,包括:The method of claim 1, wherein the obtaining the first timestamp comprises:
    接收所述第二设备发送的至少一个开销帧,提取所述至少一个开销帧中所述第一报文的每一个字节,将所述每一个字节进行组合获得所述第一报文,所述第一报文携带所述第一时间戳,所述第一报文的修正域携带第一驻留时间,所述第一驻留时间指示所述第一报文在所述第二设备的第二时间处理单元和所述第二设备的第二业务处理单元之间的驻留时间;Receiving at least one overhead frame sent by the second device, extracting each byte of the first packet in the at least one overhead frame, and combining each byte to obtain the first packet, The first packet carries the first timestamp, the modified domain of the first packet carries a first camp time, and the first camp time indicates that the first packet is in the second device a dwell time between the second time processing unit and the second service processing unit of the second device;
    所述确定第一时间,包括:The determining the first time includes:
    确定所述第一报文从传入所述第一设备的第一业务处理单元到所述第一时间处理单元的驻留时间为第二驻留时间,将所述第二驻留时间写入所 述第二报文的修正域,根据所述第一驻留时间和所述第二驻留时间获得所述第一时间;Determining that the first message is from a first service processing unit of the first device to a time of the first time processing unit to a second dwell time, and writing the second dwell time Place Determining a correction field of the second packet, obtaining the first time according to the first dwell time and the second dwell time;
    所述确定第二时间戳和第三时间戳,包括:Determining the second timestamp and the third timestamp, including:
    当所述第一报文传入所述第一时间处理单元时,给所述第一报文标识第二时间戳;And when the first packet is sent to the first time processing unit, the second time stamp is identified by the first packet;
    生成所述第二报文,给所述第二报文标识第三时间戳;Generating the second packet, and identifying, by the second packet, a third timestamp;
    所述获取第四时间戳和第二时间,包括:Obtaining the fourth timestamp and the second time, including:
    接收所述第二设备发送的第三报文,所述第三报文携带所述第四时间戳,所述第三报文的修正域携带所述第二时间。Receiving a third packet sent by the second device, where the third packet carries the fourth timestamp, and the modified domain of the third packet carries the second time.
  3. 根据权利要求2所述的方法,其中,在所述生成第二报文,给所述第二报文标识第三时间戳之后,包括:The method according to claim 2, wherein after the generating the second packet and the third packet identifying the third timestamp, the method comprises:
    确定所述第二报文在所述第一时间处理单元和所述第一设备的第一业务处理单元之间的驻留时间为第三驻留时间,将所述第三驻留时间写入所述第二报文的修正域,以使得所述第二设备根据所述第三驻留时间确定所述第二时间;Determining, by the second packet, a dwell time between the first time processing unit and the first service processing unit of the first device as a third dwell time, and writing the third dwell time a correction field of the second packet, so that the second device determines the second time according to the third camp time;
    将所述第二报文的所有字节按照字节顺序插入到至少一个开销帧的配置保留比特中,发送所述至少一个开销帧至所述第二设备,其中,每一个开销帧插入所述第二报文的一个字节。Inserting, in byte order, all bytes of the second packet into a configuration reserved bit of at least one overhead frame, and transmitting the at least one overhead frame to the second device, where each overhead frame is inserted into the One byte of the second message.
  4. 根据权利要求2所述的方法,其中,所述确定所述第一报文从传入所述第一设备的第一业务处理单元到所述第一时间处理单元的驻留时间为第二驻留时间,包括:The method according to claim 2, wherein the determining that the first message is from the first service processing unit of the first device to the first time processing unit is a second station Time to stay, including:
    确定所述第一报文传入所述第一业务处理单元的时间为第一时间信息;Determining, that the time when the first packet is sent to the first service processing unit is first time information;
    确定所述第一报文传入所述第一时间处理单元的时间为第二时间信息; Determining, that the time when the first packet is transmitted to the first time processing unit is second time information;
    根据所述第一时间信息和所述第二时间信息,确定所述第一报文从传入所述第一业务处理单元到所述第一时间处理单元的驻留时间为第二驻留时间。Determining, according to the first time information and the second time information, that a dwell time of the first packet from the first service processing unit to the first time processing unit is a second dwell time .
  5. 根据权利要求3所述的方法,其中,所述确定所述第二报文在所述第一时间处理单元和所述第一设备的第一业务处理单元之间的驻留时间为第三驻留时间,包括:The method according to claim 3, wherein said determining a dwell time of said second message between said first time processing unit and said first service processing unit of said first device is a third station Time to stay, including:
    确定所述第二报文传出所述第一时间处理单元的时间为第三时间信息;Determining, that the time when the second packet is sent out by the first time processing unit is third time information;
    确定所述第二报文传出所述第一业务处理单元的时间为第四时间信息;Determining, that the time when the second packet is sent out by the first service processing unit is fourth time information;
    根据所述第三时间信息和所述第四时间信息,确定所述第二报文在所述第一时间处理单元和所述第一业务处理单元之间的驻留时间为第三驻留时间。Determining, according to the third time information and the fourth time information, a dwell time between the first time processing unit and the first service processing unit as a third dwell time .
  6. 根据权利要求4所述的方法,其中,所述确定所述第一报文传入所述第一业务处理单元的时间为第一时间信息,包括:The method of claim 4, wherein the determining that the first message is transmitted to the first service processing unit is the first time information, including:
    当所述第一业务处理单元检测到开销帧的帧头时,采样所述开销帧的帧头处的时间为第一数值,采样所述开销帧的帧头处的帧号为第二数值;When the first service processing unit detects the frame header of the overhead frame, sampling the time at the frame header of the overhead frame as a first value, and sampling the frame number at the frame header of the overhead frame as a second value;
    采样所述第一报文第一个字节所在开销帧的帧号为第三数值;Sampling the frame number of the overhead frame in which the first byte of the first packet is located is a third value;
    根据所述第一数值、所述第二数值和所述第三数值,确定第一时间信息。Determining the first time information based on the first value, the second value, and the third value.
  7. 根据权利要求5所述的方法,其中,所述确定所述第二报文传出所述第一业务处理单元的时间为第四时间信息,包括:The method of claim 5, wherein the determining that the second packet is sent out of the first service processing unit is the fourth time information, including:
    采样开销帧的帧头处的时间为第四数值,采样所述开销帧的帧头处的帧号为第五数值;The time at the frame header of the sampling overhead frame is a fourth value, and the frame number at the frame header of the sampling the overhead frame is a fifth value;
    确定所述第二报文的第一个字节所在开销帧的帧号为第六数值; Determining, that the frame number of the overhead frame in which the first byte of the second packet is located is a sixth value;
    根据所述第四数值、所述第五数值和所述第六数值,确定第四时间信息。The fourth time information is determined based on the fourth value, the fifth value, and the sixth value.
  8. 一种时间同步方法,所述方法应用于第二设备,所述方法包括:A time synchronization method, the method being applied to a second device, the method comprising:
    生成第一报文,给所述第一报文标识第一时间戳,所述第一时间戳指示所述第二设备的第二时间处理单元发送所述第一报文的时间;Generating a first packet, the first timestamp indicating a first timestamp, and the first timestamp indicating a time when the second time processing unit of the second device sends the first packet;
    确定所述第一报文在所述第二设备的第二时间处理单元和所述第二设备的第二业务处理单元之间的驻留时间为第一驻留时间,将所述第一驻留时间写入所述第二报文的修正域;Determining, by the first camp, a dwell time between the second time processing unit of the second device and the second service processing unit of the second device as a first dwell time, the first station Writing a time to write the correction field of the second message;
    发送所述第一报文至第一设备。Sending the first packet to the first device.
  9. 根据权利要8所述的方法,其中,所述方法还包括:The method of claim 8 wherein the method further comprises:
    接收所述第一设备发送的至少一个开销帧,提取所述至少一个开销帧中所述第二报文的每一个字节,将所述每一个字节进行组合获得所述第二报文,所述第二报文携带第三时间戳,所述第三时间戳指示所述第一设备的第一时间处理单元发送所述第二报文的时间,所述第二报文的修正域携带第三驻留时间,所述第三驻留时间指示所述第二报文在所述第一时间处理单元和所述第一设备的第一业务处理单元之间的驻留时间;Receiving at least one overhead frame sent by the first device, extracting each byte of the second packet in the at least one overhead frame, and combining each of the bytes to obtain the second packet, The second packet carries a third timestamp, where the third timestamp indicates the time when the first time processing unit of the first device sends the second packet, and the modified domain of the second packet carries a third dwell time, where the third dwell time indicates a dwell time between the first time processing unit and the first service processing unit of the first device;
    确定所述第二报文从传入所述第二业务处理单元到所述第二时间处理单元的驻留时间为第四驻留时间,将所述第四驻留时间写入所述第二报文的修正域,根据所述第三驻留时间和所述第四驻留时间获得所述第二时间;Determining that a dwell time of the second packet from the second service processing unit to the second time processing unit is a fourth dwell time, and writing the fourth dwell time to the second a correction field of the message, obtaining the second time according to the third dwell time and the fourth dwell time;
    给所述第二报文标识第四时间戳,所述第四时间戳指示所述第二时间处理单元接收所述第二报文的时间;And identifying, by the second timestamp, a fourth timestamp, where the fourth timestamp indicates a time when the second time processing unit receives the second message;
    生成第三报文,发送所述第三报文至所述第一设备,所述第三报文携带所述第四时间戳,所述第三报文的修正域携带所述第二时间。Generating a third packet, and sending the third packet to the first device, where the third packet carries the fourth timestamp, and the modified domain of the third packet carries the second time.
  10. 根据权利要求8所述的方法,其中,所述确定所述第一报文在所述第二设备的第二时间处理单元和所述第二设备的第二业务处理单元之间 的驻留时间为第一驻留时间,包括:The method of claim 8, wherein the determining the first message is between a second time processing unit of the second device and a second service processing unit of the second device The dwell time is the first dwell time and includes:
    确定所述第一报文传出所述第二时间处理单元的时间为第五时间信息;Determining, that the time when the first packet is sent out by the second time processing unit is fifth time information;
    采样开销帧的帧头处的时间为第七数值,采样所述开销帧的帧头处的帧号为第八数值,确定所述第一报文的第一个字节所在开销帧的帧号为第九数值,根据所述第七数值、所述第八数值和所述第九数值,确定所述第一报文传出所述第二业务处理单元的时间为第六时间信息;The time at the frame header of the sampling overhead frame is a seventh value, and the frame number at the frame header of the sampling the overhead frame is an eighth value, and the frame number of the overhead frame in which the first byte of the first packet is located is determined. a ninth value, determining, according to the seventh value, the eighth value, and the ninth value, that the time when the first packet is sent out to the second service processing unit is the sixth time information;
    根据所述第五时间信息和所述第六时间信息,确定所述第一报文在所述第二时间处理单元和所述第二业务处理单元之间的驻留时间为第一驻留时间。Determining, according to the fifth time information and the sixth time information, a dwell time of the first packet between the second time processing unit and the second service processing unit as a first dwell time .
  11. 根据权利要求9所述的方法,其中,所述确定所述第二报文从传入所述第二业务处理单元到所述第二时间处理单元的驻留时间为第四驻留时间,包括:The method according to claim 9, wherein said determining a dwell time of said second message from said second service processing unit to said second time processing unit is a fourth dwell time, including :
    确定所述第二报文传入所述第二业务处理单元的时间为第七时间信息;Determining, that the time when the second packet is transmitted to the second service processing unit is seventh time information;
    确定所述第二报文传入所述第二时间处理单元的时间为第八时间信息;Determining that the time when the second packet is transmitted to the second time processing unit is eighth time information;
    根据所述第七时间信息和所述第八时间信息,确定所述第二报文从传入所述第二业务处理单元到所述第二时间处理单元的驻留时间为第四驻留时间。Determining, according to the seventh time information and the eighth time information, that a dwell time of the second packet from the second service processing unit to the second time processing unit is a fourth dwell time .
  12. 根据权利要求8所述的方法,其中,所述发送所述第一报文至第一设备,包括:The method of claim 8, wherein the sending the first message to the first device comprises:
    将所述第一报文的所有字节按照字节顺序插入到至少一个开销帧的配置保留比特中,发送所述至少一个开销帧至所述第一设备,其中,每一个开销帧插入所述第一报文的一个字节。 Inserting, in byte order, all bytes of the first packet into a configuration reserved bit of at least one overhead frame, and transmitting the at least one overhead frame to the first device, where each overhead frame is inserted into the One byte of the first message.
  13. 一种时间同步设备,所述设备包括:第一业务处理单元、第一时间处理单元、配置单元,A time synchronization device, the device includes: a first service processing unit, a first time processing unit, and a configuration unit,
    所述第一业务处理单元,配置为获取第一时间戳,所述第一时间戳指示第二设备的第二时间处理单元发送第一报文的时间;The first service processing unit is configured to acquire a first timestamp, where the first timestamp indicates a time when the second time processing unit of the second device sends the first message;
    所述第一时间处理单元,配置为确定第一时间,所述第一时间指示所述第一报文在所述第二设备和所述第一设备之间的驻留时间;还配置为确定第二时间戳和第三时间戳,所述第二时间戳指示所述第一设备的第一时间处理单元接收所述第一报文的时间,所述第三时间戳指示所述第一时间处理单元发送第二报文的时间;The first time processing unit is configured to determine a first time, where the first time indicates a dwell time between the second device and the first device, and is further configured to determine a second timestamp indicating a time when the first time processing unit of the first device receives the first message, and the third timestamp indicating the first time The time when the processing unit sends the second packet;
    所述第一业务处理单元,配置为获取第四时间戳和第二时间,所述第四时间戳指示所述第二时间处理单元接收所述第二报文的时间,所述第二时间指示所述第二报文在所述第一设备和所述第二设备之间的驻留时间;The first service processing unit is configured to acquire a fourth timestamp and a second time, where the fourth timestamp indicates a time when the second time processing unit receives the second message, and the second time indication a dwell time of the second message between the first device and the second device;
    所述配置单元,配置为根据所述第一时间戳、所述第二时间戳、所述第三时间戳、所述第四时间戳、所述第一时间和所述第二时间,确定补偿时间;还配置为将所述补偿时间配置到所述第一设备,以使得所述第一设备的时间同步所述第二设备的时间。The configuration unit is configured to determine compensation according to the first timestamp, the second timestamp, the third timestamp, the fourth timestamp, the first time, and the second time Time; is further configured to configure the compensation time to the first device such that the time of the first device synchronizes the time of the second device.
  14. 根据权利要求13所述的设备,其中,所述第一业务处理单元包括:The device of claim 13, wherein the first service processing unit comprises:
    第一系统时戳处理模块,配置为接收所述第二设备发送的至少一个开销帧,提取所述至少一个开销帧中所述第一报文的每一个字节,将所述每一个字节进行组合获得所述第一报文,所述第一报文携带所述第一时间戳,所述第一报文的修正域携带第一驻留时间,所述第一驻留时间指示所述第一报文在所述第二设备的第二时间处理单元和所述第二设备的第二业务处理单元之间的驻留时间;The first system time stamp processing module is configured to receive at least one overhead frame sent by the second device, and extract each byte of the first packet in the at least one overhead frame, where each byte is Combining to obtain the first packet, the first packet carries the first timestamp, the modified domain of the first packet carries a first camp time, and the first camp time indicates the a dwell time between the second time processing unit of the second device and the second service processing unit of the second device;
    所述第一时间处理单元,配置为确定所述第一报文从传入所述第一设备的第一业务处理单元到所述第一时间处理单元的驻留时间为第二驻留时 间,还配置为将所述第二驻留时间写入所述第二报文的修正域,根据所述第一驻留时间和所述第二驻留时间获得所述第一时间。The first time processing unit is configured to determine that the dwell time of the first message from the first service processing unit of the first device to the first time processing unit is the second dwell time And configured to write the second dwell time into the correction domain of the second packet, and obtain the first time according to the first dwell time and the second dwell time.
    所述第一时间处理单元包括:第一打时戳模块、第一报文产生模块,The first time processing unit includes: a first time stamping module and a first message generating module,
    所述第一打时戳模块,配置为当所述第一报文传入所述第一时间处理单元时,给所述第一报文标识第二时间戳;The first time stamping module is configured to: when the first packet is sent to the first time processing unit, identify the second timestamp of the first packet;
    所述第一报文产生模块,配置为生成所述第二报文,给所述第二报文标识第三时间戳。The first packet generating module is configured to generate the second packet, and identify a third timestamp to the second packet.
  15. 根据权利要求14所述的设备,其中,所述第一业务处理单元,配置为确定所述第二报文在所述第一时间处理单元和所述第一设备的第一业务处理单元之间的驻留时间为第三驻留时间;还配置为将所述第三驻留时间写入所述第二报文的修正域,以使得所述第二设备根据所述第三驻留时间确定所述第二时间;还配置为将所述第二报文的所有字节按照字节顺序插入到至少一个开销帧的配置保留比特中,发送所述至少一个开销帧至所述第二设备,其中,每一个开销帧插入所述第二报文的一个字节。The device according to claim 14, wherein the first service processing unit is configured to determine that the second message is between the first time processing unit and a first service processing unit of the first device The dwell time is a third dwell time; further configured to write the third dwell time to the correction domain of the second message to cause the second device to determine according to the third dwell time The second time is further configured to insert all bytes of the second packet into a configuration reserved bit of at least one overhead frame in a byte order, and send the at least one overhead frame to the second device, Each of the overhead frames is inserted into one byte of the second message.
  16. 根据权利要求15所述的设备,其中,The apparatus according to claim 15, wherein
    所述第一业务处理单元,配置为确定所述第一报文传入所述第一业务处理单元的时间为第一时间信息;The first service processing unit is configured to determine that the time when the first packet is sent to the first service processing unit is first time information;
    所述第一时间处理单元,配置为确定所述第一报文传入所述第一时间处理单元的时间为第二时间信息;还配置为根据所述第一时间信息和所述第二时间信息,确定所述第一报文从传入所述第一业务处理单元到所述第一时间处理单元的驻留时间为第二驻留时间;The first time processing unit is configured to determine that the time when the first packet is transmitted to the first time processing unit is second time information, and is further configured to: according to the first time information and the second time Determining, by the information, that the camping time of the first packet from the first service processing unit to the first time processing unit is a second camp time;
    所述第一时间处理单元,配置为确定所述第二报文传出所述第一时间处理单元的时间为第三时间信息;The first time processing unit is configured to determine that the time when the second packet is sent out by the first time processing unit is third time information;
    所述第一业务处理单元,配置为确定所述第二报文传出所述第一业务处理单元的时间为第四时间信息;还配置为根据所述第三时间信息和所述 第四时间信息,确定所述第二报文在所述第一时间处理单元和所述第一业务处理单元之间的驻留时间为第三驻留时间。The first service processing unit is configured to determine that the time when the second packet is sent out of the first service processing unit is fourth time information, and is further configured to: according to the third time information and the And determining, by the fourth time information, a dwell time of the second packet between the first time processing unit and the first service processing unit as a third dwell time.
  17. 根据权利要求15所述的设备,其中,所述第一业务处理单元包括:第一系统时戳采样模块、第一系统时戳处理模块,The device according to claim 15, wherein the first service processing unit comprises: a first system time stamp sampling module, a first system time stamp processing module,
    所述第一系统时戳采样模块,配置为当所述第一业务处理单元检测到开销帧的帧头时,采样所述开销帧的帧头处的时间为第一数值,采样所述开销帧的帧头处的帧号为第二数值;还配置为采样所述第一报文第一个字节所在开销帧的帧号为第三数值;The first system timestamp sampling module is configured to: when the first service processing unit detects a frame header of the overhead frame, sample the time at the frame header of the overhead frame as a first value, and sample the overhead frame The frame number at the frame header is a second value; and the frame number of the overhead frame in which the first byte of the first packet is sampled is a third value;
    所述第一系统时戳采样模块,配置为根据所述第一数值、所述第二数值和所述第三数值,确定第一时间信息。The first system time stamp sampling module is configured to determine first time information according to the first value, the second value, and the third value.
  18. 根据权利要求16所述的设备,其中,所述第一业务处理单元,包括:第一系统时戳采样模块、第一系统时戳处理模块,The device according to claim 16, wherein the first service processing unit comprises: a first system time stamp sampling module, a first system time stamp processing module,
    第一系统时戳采样模块,配置为采样开销帧的帧头处的时间为第四数值,采样所述开销帧的帧头处的帧号为第五数值;还配置为确定所述第二报文的第一个字节所在开销帧的帧号为第六数值;The first system timestamp sampling module is configured to: the time at the frame header of the sampling overhead frame is a fourth value, and the frame number at the frame header of the sampling the overhead frame is a fifth value; and the second report is further configured to determine The frame number of the overhead frame in which the first byte of the text is located is the sixth value;
    第一系统时戳处理模块,配置为根据所述第四数值、所述第五数值和所述第六数值,确定第四时间信息。The first system time stamp processing module is configured to determine the fourth time information according to the fourth value, the fifth value, and the sixth value.
  19. 一种时间同步设备,所述设备包括:第二时间处理单元和第二业务处理单元,所述第二时间处理单元包括:第二报文产生模块、第二打时戳模块,A time synchronization device, the device includes: a second time processing unit and a second service processing unit, where the second time processing unit includes: a second message generation module, and a second time stamping module,
    所述第二报文产生模块,配置为生成第一报文;The second packet generating module is configured to generate a first packet;
    所述第二打时戳模块,配置为给所述第一报文标识第一时间戳,所述第一时间戳指示所述第二设备的第二时间处理单元发送所述第一报文的时间;The second time stamping module is configured to identify a first timestamp for the first packet, where the first timestamp indicates that the second time processing unit of the second device sends the first packet time;
    所述第二业务处理单元,配置为确定所述第一报文在所述第二设备的 第二时间处理单元和所述第二设备的第二业务处理单元之间的驻留时间为第一驻留时间,将所述第一驻留时间写入所述第二报文的修正域;还配置为发送所述第一报文至第一设备。The second service processing unit is configured to determine that the first packet is in the second device The dwell time between the second time processing unit and the second service processing unit of the second device is a first dwell time, and the first dwell time is written into the correction domain of the second message; It is further configured to send the first message to the first device.
  20. 根据权利要求19所述的设备,其中,The apparatus according to claim 19, wherein
    所述第二业务处理单元,配置为接收所述第一设备发送的至少一个开销帧,提取所述至少一个开销帧中所述第二报文的每一个字节,将所述每一个字节进行组合获得所述第二报文,所述第二报文携带第三时间戳,所述第三时间戳指示所述第一设备的第一时间处理单元发送所述第二报文的时间,所述第二报文的修正域携带第三驻留时间,所述第三驻留时间指示所述第二报文在所述第一时间处理单元和所述第一设备的第一业务处理单元之间的驻留时间;The second service processing unit is configured to receive at least one overhead frame sent by the first device, and extract each byte of the second packet in the at least one overhead frame, where each byte is Combining to obtain the second packet, where the second packet carries a third timestamp, where the third timestamp indicates a time when the first time processing unit of the first device sends the second packet, The modified domain of the second packet carries a third camp time, and the third camp time indicates that the second packet is in the first time processing unit and the first service processing unit of the first device Residence time between;
    所述第二时间处理单元,配置为确定所述第二报文从传入所述第二业务处理单元到所述第二时间处理单元的驻留时间为第四驻留时间,还配置为将所述第四驻留时间写入所述第二报文的修正域,还配置为根据所述第三驻留时间和所述第四驻留时间获得所述第二时间;The second time processing unit is configured to determine that a dwell time of the second packet from the second service processing unit to the second time processing unit is a fourth dwell time, and is further configured to The fourth dwell time is written into the correction domain of the second packet, and is further configured to obtain the second time according to the third dwell time and the fourth dwell time;
    所述第二打时戳模块,配置为给所述第二报文标识第四时间戳,所述第四时间戳指示所述第二时间处理单元接收所述第二报文的时间;The second time stamping module is configured to identify a fourth timestamp for the second message, where the fourth timestamp indicates a time when the second time processing unit receives the second message;
    所述第二报文产生模块,配置为生成第三报文;The second packet generating module is configured to generate a third packet;
    所述第二业务处理单元,配置为发送所述第三报文至所述第一设备,所述第三报文携带所述第四时间戳,所述第三报文的修正域携带所述第二时间。The second service processing unit is configured to send the third packet to the first device, where the third packet carries the fourth timestamp, and the modified domain of the third packet carries the The second time.
  21. 根据权利要求20所述的设备,其中,The apparatus according to claim 20, wherein
    所述第二时间处理单元,配置为确定所述第一报文传出所述第二时间处理单元的时间为第五时间信息;The second time processing unit is configured to determine that the time when the first packet is sent out by the second time processing unit is fifth time information;
    所述第二业务处理单元,配置为采样开销帧的帧头处的时间为第七数 值,采样所述开销帧的帧头处的帧号为第八数值,确定所述第一报文的第一个字节所在开销帧的帧号为第九数值,根据所述第七数值、所述第八数值和所述第九数值,确定所述第一报文传出所述第二业务处理单元的时间为第六时间信息;还配置为根据所述第五时间信息和所述第六时间信息,确定所述第一报文在所述第二时间处理单元和所述第二业务处理单元之间的驻留时间为第一驻留时间;The second service processing unit is configured to count the time at the frame header of the overhead frame as the seventh number a value, the frame number at the frame header of the sampling of the overhead frame is an eighth value, and the frame number of the overhead frame in which the first byte of the first packet is located is determined to be a ninth value, according to the seventh value, Determining, by the eighth value and the ninth value, a time when the first packet is sent out by the second service processing unit is a sixth time information; and further configured to, according to the fifth time information, the Determining, by the six-time information, a dwell time of the first packet between the second time processing unit and the second service processing unit as a first dwell time;
    所述第二业务处理单元,配置为确定所述第二报文传入所述第二业务处理单元的时间为第七时间信息;The second service processing unit is configured to determine that the time when the second packet is transmitted to the second service processing unit is the seventh time information;
    所述第二时间处理单元,配置为确定所述第二报文传入所述第二时间处理单元的时间为第八时间信息;还配置为根据所述第七时间信息和所述第八时间信息,确定所述第二报文从传入所述第二业务处理单元到所述第二时间处理单元的驻留时间为第四驻留时间;The second time processing unit is configured to determine that the time when the second packet is transmitted to the second time processing unit is eighth time information; and is further configured to: according to the seventh time information and the eighth time Determining, by the information, a dwell time of the second packet from the second service processing unit to the second time processing unit is a fourth dwell time;
    所述第二业务处理单元,配置为接收至少一个开销帧,还配置为提取所述至少一个开销帧中所述第二报文的每一个字节,将所述每一个字节进行组合获得所述第二报文。The second service processing unit is configured to receive at least one overhead frame, and further configured to extract each byte of the second packet in the at least one overhead frame, and combine each of the bytes to obtain a Said the second message.
  22. 一种计算机存储介质,所述计算机存储介质中存储有可执行指令,所述可执行指令用于执行权利要求1至7任一项所述的时间同步方法。A computer storage medium having stored therein executable instructions for performing the time synchronization method of any one of claims 1 to 7.
  23. 一种计算机存储介质,所述计算机存储介质中存储有可执行指令,所述可执行指令用于执行权利要求8至12任一项所述的时间同步方法。 A computer storage medium having stored therein executable instructions for performing the time synchronization method of any one of claims 8 to 12.
PCT/CN2017/082636 2016-10-31 2017-04-28 Time synchronization method, device and computer storage medium WO2018076651A1 (en)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201610933876.0 2016-10-31
CN201610933876.0A CN108023656A (en) 2016-10-31 2016-10-31 A kind of method for synchronizing time and equipment

Publications (1)

Publication Number Publication Date
WO2018076651A1 true WO2018076651A1 (en) 2018-05-03

Family

ID=62024645

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2017/082636 WO2018076651A1 (en) 2016-10-31 2017-04-28 Time synchronization method, device and computer storage medium

Country Status (2)

Country Link
CN (1) CN108023656A (en)
WO (1) WO2018076651A1 (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114245411A (en) * 2021-11-08 2022-03-25 深圳震有科技股份有限公司 Method and device for testing message delay time, terminal equipment and storage medium

Families Citing this family (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112583477B (en) * 2019-09-27 2023-08-04 深圳市中兴微电子技术有限公司 Delay measurement method, delay measurement system and storage medium
CN110645995B (en) * 2019-09-29 2021-07-13 百度在线网络技术(北京)有限公司 Map navigation simulation method and device
CN114745774B (en) * 2022-03-16 2023-05-12 烽火通信科技股份有限公司 Centralized time synchronization method, device, equipment and readable storage medium

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101827098A (en) * 2010-03-31 2010-09-08 中兴通讯股份有限公司 Processing method and device for time synchronization
CN101951312A (en) * 2010-09-15 2011-01-19 电信科学技术第五研究所 E1 link-based bidirectional time-frequency synchronous transmission method and master-slave device
US20120275501A1 (en) * 2011-04-27 2012-11-01 Sergiu Rotenstein Pluggable synchronization clocks, networks, systems and methods related thereto
CN103138865A (en) * 2013-01-25 2013-06-05 杭州华三通信技术有限公司 Time synchronization method and time synchronization device

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101827098A (en) * 2010-03-31 2010-09-08 中兴通讯股份有限公司 Processing method and device for time synchronization
CN101951312A (en) * 2010-09-15 2011-01-19 电信科学技术第五研究所 E1 link-based bidirectional time-frequency synchronous transmission method and master-slave device
US20120275501A1 (en) * 2011-04-27 2012-11-01 Sergiu Rotenstein Pluggable synchronization clocks, networks, systems and methods related thereto
CN103138865A (en) * 2013-01-25 2013-06-05 杭州华三通信技术有限公司 Time synchronization method and time synchronization device

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114245411A (en) * 2021-11-08 2022-03-25 深圳震有科技股份有限公司 Method and device for testing message delay time, terminal equipment and storage medium

Also Published As

Publication number Publication date
CN108023656A (en) 2018-05-11

Similar Documents

Publication Publication Date Title
WO2018076651A1 (en) Time synchronization method, device and computer storage medium
KR101506138B1 (en) Method, apparatus and system for time distribution in a telecommunications network
CN101455014B (en) Methods and devices for sending transmission-time or reception-time information for a transmitted or received message
CN106357362B (en) A kind of method for synchronizing time, device and PTP system
CN102104476B (en) Clock synchronization device and method
CN102013931B (en) Time synchronization method and system, salve timing device and main timing device
US9491106B2 (en) Non-intrusive method for synchronizing master and slave clocks of a packet-switched network, and associated synchronization devices
CN105262555B (en) Time synchronization method, programmable logic device, single board and network element
US11522627B2 (en) TSN enabled controller
US9854548B2 (en) Method for constructing a distributed boundary clock over a dedicated communication channel
CN110120846B (en) Clock synchronization method and system
WO2018006686A1 (en) Method, apparatus and device for optimizing time synchronization between communication network devices
CN102082653B (en) Method, system and device for clock synchronization
EP2448168A1 (en) Method and system for bearing time synchronization protocol in optical transport network
DE60234349D1 (en) SYSTEM AND METHOD FOR SYNCHRONIZING TELECOMMUNICALLY ASSOCIATED CLOCKS IN A PASSIVE OPTICAL ACCESS NETWORK BASED ON ETHERNET
CN111385048A (en) Time synchronization method and system
WO2012065334A1 (en) Method, device and system for realizing time synchronization in time division multiplexing network
US20220007321A1 (en) Network Entities and Methods for a Wireless Network System for Determining Time Information
WO2017032113A1 (en) Method and apparatus for measuring time synchronization deviation
CN107809295B (en) A kind of cross-platform time synchronism apparatus and method
CN110572230A (en) correction method and device for realizing time synchronization
CN103546273B (en) Frequency synchronism device and method based on PTP frames
WO2017177751A1 (en) Time synchronization method and apparatus
CN103259640A (en) Method and device for synchronizing time
CN107786293A (en) Method for synchronizing time, clock equipment, from clockwork and clock synchronization system

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: 17864737

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 17864737

Country of ref document: EP

Kind code of ref document: A1