WO2018210277A1 - Clock synchronization method and device, and computer storage medium - Google Patents

Clock synchronization method and device, and computer storage medium Download PDF

Info

Publication number
WO2018210277A1
WO2018210277A1 PCT/CN2018/087150 CN2018087150W WO2018210277A1 WO 2018210277 A1 WO2018210277 A1 WO 2018210277A1 CN 2018087150 W CN2018087150 W CN 2018087150W WO 2018210277 A1 WO2018210277 A1 WO 2018210277A1
Authority
WO
WIPO (PCT)
Prior art keywords
time
clock
code block
timestamp
counting system
Prior art date
Application number
PCT/CN2018/087150
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 WO2018210277A1 publication Critical patent/WO2018210277A1/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/0647Synchronisation among TDM nodes
    • H04J3/065Synchronisation among TDM nodes using timestamps
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04JMULTIPLEX COMMUNICATION
    • H04J3/00Time-division multiplex systems
    • H04J3/02Details
    • H04J3/06Synchronising arrangements
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L7/00Arrangements for synchronising receiver with transmitter
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L7/00Arrangements for synchronising receiver with transmitter
    • H04L7/0016Arrangements for synchronising receiver with transmitter correction of synchronization errors
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04WWIRELESS COMMUNICATION NETWORKS
    • H04W56/00Synchronisation arrangements

Definitions

  • the present invention relates to the field of communications, and in particular, to a method and apparatus for clock synchronization.
  • Multi-lane (channel) interface pcs Physical Code Sublayer
  • pma Physical Media Access
  • the implementation usually uses fifo (First Input First Output), gearbox (gearbox), etc., and the processing delay is not easy to determine. If you still use the time information packet header as the reference point and time stamp on the mac (Media Access Control) layer, the time jitter will be larger and the accuracy will be worse.
  • improving the time stamping accuracy generally adopts a method of increasing the clock frequency of the time counter. This method reduces the time error to some extent, but due to problems such as the chip process, the clock frequency inside the chip cannot be increased without limitation.
  • the internal frequency of most chips is 1G, that is, the sampling error is 1 ns (nanoseconds), the internal frequency of a few chips can reach 3G, and the sampling error is 300 ps (picoseconds).
  • One aspect of the disclosure provides a method and apparatus for clock synchronization.
  • Embodiments of the present disclosure provide the following technical solutions.
  • a method of clock synchronization comprising:
  • the synchronization end device generates a timestamp according to the time of receiving and sending the periodic code block on the predetermined channel;
  • the sync device adjusts the system clock according to the determined time offset.
  • a clock synchronization device includes: a first processor and a first memory;
  • the first memory is configured to save a first time synchronization program
  • the first processor is configured to execute the first time synchronization program to perform the following operations:
  • the system clock is adjusted based on the determined time offset.
  • a clock synchronization device includes:
  • a timestamp generating module configured to generate a timestamp according to a receiving and sending time of the periodic code block on the predetermined channel
  • the determining module is configured to receive and send a time information message with the device to be synchronized, and determine a time offset between the device and the device to be synchronized by using a timestamp of the periodic code block that matches the received and sent time information message. ;
  • Yet another aspect of the present disclosure provides a method and apparatus for clock synchronization that can solve errors caused by different clock domains in the case of multiple lane interfaces.
  • Embodiments of the present disclosure provide the following technical solutions.
  • a method of clock synchronization is applied to a device including a plurality of time counting systems, the plurality of time counting systems being divided into a master time counting system and a slave time counting system; the method comprising:
  • a clock synchronization device is applied to synchronization between a plurality of time counting systems in a device, the plurality of time counting systems being divided into a master time counting system and a slave time counting system; the device comprising: a second processor and Second memory
  • the second memory is configured to save a second time synchronization program
  • the second processor is configured to execute the second time synchronization program to perform the following operations:
  • a clock synchronization apparatus is applied to synchronization between a plurality of time counting systems in a device, the plurality of time counting systems being divided into a master time counting system and a slave time counting system; the apparatus comprising:
  • a synchronization module configured to synchronize the common number clock with a clock of the primary time counting system, and synchronize the clock of the slave time counting system with the common number clock.
  • At least one embodiment of the present disclosure records time stamps with periodic locations, effectively avoiding unfixed delays caused by fifo or the like, and improving time synchronization accuracy.
  • the time is counted by the same system clock as the parallel clock (the clock at the periodic code block), and the parallel clock and the system clock are phase-phased to compensate for the time stamp, which can improve the accuracy. .
  • At least one embodiment of the present disclosure can generate a common-counter clock by calculating a common-counter clock frequency in a case where different rate interfaces use different time counting systems, thereby synchronizing different time counting systems, thereby eliminating sampling caused by different clock domains. error.
  • FIG. 2 is a schematic flowchart diagram of a method for providing clock synchronization according to an embodiment of the present invention.
  • FIG. 3 is a block diagram of an implementation provided by Embodiment 1 of the present invention.
  • Embodiment 4 is a transceiver transmission direction data path provided by Embodiment 1 of the present invention.
  • FIG. 5 is a transceiver receiving direction data path provided by Embodiment 1 of the present invention.
  • FIG. 6a is a block diagram showing an implementation of a 100G interface portion provided by Embodiment 2 of the present invention.
  • Figure 6b is a block diagram showing the implementation of the GE interface portion of Embodiment 2 of the present invention.
  • FIG. 7 is a block diagram showing an implementation of a 100G interface portion of Embodiment 3 of the present invention.
  • FIG. 8 is a schematic structural diagram of an apparatus for providing clock synchronization according to an embodiment of the present invention.
  • FIG. 9 is a schematic structural diagram of an apparatus for providing clock synchronization according to Embodiment 7 of the present invention.
  • a method for clock synchronization in this embodiment includes steps S110-S120:
  • the synchronization end device generates a timestamp according to the time of receiving and sending the aligned code block on the predetermined channel.
  • the timestamp generated according to the receiving and sending time may include: a receiving timestamp generated according to the receiving time, and/or a transmission time stamp generated according to the transmission time;
  • the time information packet is received and sent between the synchronization end device and the synchronized end device, and the time interval of the aligned code block matched by the receiving and sending time information packet is used to determine the time between the device and the synchronized device. deviation;
  • the synchronization end device adjusts a system clock according to the determined time offset.
  • the synchronization device may refer to a device to be synchronized with the device to be synchronized, and the device to be synchronized may refer to a device whose clock is used as a reference standard for synchronization.
  • the time information packet may include a TP (Precision Timing Protocol) packet, a 1588 packet, and the like.
  • TP Precision Timing Protocol
  • the periodic code block can be, but is not limited to, an aligned code block.
  • the periodic code block that matches the receiving and sending time information packet may be, but is not limited to, the sending and receiving time of the previous periodic code block where the time information header is located.
  • the predetermined channel can be, but is not limited to, lane0.
  • the determining, by using the timestamp of the aligned code block that matches the received and sent time information packet, before determining the time offset between the device and the device to be synchronized may further include:
  • the synchronization end device performs phase discrimination on the clock used to generate the time stamp and the system clock to obtain a phase difference
  • the sync device compensates for the generated timestamp using the phase difference.
  • phase discrimination may be performed before or after the time stamp is generated; after the time stamp is generated, the phase difference obtained by phase discrimination may be immediately compensated, or may be compensated when the time offset needs to be calculated.
  • the clock (system clock) frequency of the time counting system used for time stamping is the same as the clock frequency of the interface parallel clock.
  • the phase difference is compensated to the time stamp.
  • the phase discrimination accuracy determines the accuracy of the time stamping.
  • the phase clock accuracy of the same frequency clock can be up to 1 ps, and the theoretical time stamping accuracy can reach 1 ps.
  • the method may further include:
  • determining, by using a timestamp of the periodic code block that matches the received and sent time information packet, determining a time offset from the device to be synchronized may include:
  • the T1 is the timestamp of the previous periodic code block M1 of the header of the received first time information message
  • T2 is the previous period of the message header when the first time information message arrives at the device.
  • T3 is the timestamp of the previous periodic code block M3 of the header of the transmitted second time information message;
  • T4 is the device that the second time information message arrives at the synchronized end device Time stamp of the previous periodic code block M4 of the message header;
  • step S130 may include:
  • the synchronization end device adjusts a value of a time counter in the main time counting system in the synchronization end device according to an integral multiple of a clock period in the time offset, and the remaining portion adjusts a phase of the main clock in the main time counting system .
  • step S130 may further include:
  • the synchronization end device obtains a common number according to the clock time of the time counting system of the main time counting system in the synchronous end device, and creates a common number clock with the common number as the clock frequency;
  • the main time counting system may be pre-designated or defaulted, or may be selected by the synchronizing end device from one of the plurality of time counting systems as the main time counting system according to the agreed rules, and the rest is used as the slave time counting system.
  • the synchronizing the common number clock with the clock of the main time counting system, and synchronizing the clock of the time counting system with the common number clock may include:
  • n is equal to the clock frequency of the slave clock counting system divided by the common divisor
  • the embodiment provides a method for clock synchronization, which is applied to a device including multiple time counting systems, which are divided into a main time counting system and a slave time counting system; the method is as shown in FIG. 2 Including steps S210-S220:
  • the clock frequency of the time counting system used for time stamping is related to the interface rate, and the different rate interfaces correspond to time counting systems at different clock frequencies, and each time counting system uses the common number as the clock frequency clock for synchronization.
  • the main time counting system in the plurality of time counting systems may be pre-designated or defaulted, or may be selected by the synchronizing end device from the plurality of time counting systems as the main time counting system according to the agreed rules, and the rest is taken as the slave time counting system. Time counting system.
  • step S220 may include:
  • n is equal to the clock frequency of the slave clock counting system divided by the common divisor
  • the method may further include:
  • the clock of the master count time system is adjusted based on the determined time offset.
  • the device including multiple time counting systems may be regarded as a synchronous device.
  • a clock synchronization method is used.
  • the periodic code block adopts an alignment code block AM.
  • the process of clock synchronization includes the following steps S310-S370:
  • the synchronization end device is synchronized with the frequency of the system clock of the device being synchronized. .
  • step S320 a time stamp is generated.
  • the timestamp may be generated by a time counting system corresponding to the aligned code block; wherein the time counting system corresponding to the aligned code block may include an interface parallel clock (ie, a clock corresponding to the interface parallel data) and a time counter.
  • the time counting system corresponding to the aligned code block may include an interface parallel clock (ie, a clock corresponding to the interface parallel data) and a time counter.
  • step S330 the system clock and the interface parallel clock phase detector.
  • the system time of the sync device or the sync device is generated by the system clock; and the alignment block AM is processed under the interface parallel clock.
  • the two clocks have a certain phase difference, which needs to be phased out to obtain a phase difference.
  • the generated time stamp is compensated using the phase difference.
  • Step S340 time information is transmitted.
  • the synchronization end sends a time information packet, and carries the timestamp T1 corresponding to the previous alignment code block of the packet header when the time information packet is sent, and the recording time of the timestamp T1 to the time when the alignment code block is sent to the device.
  • the delay is TC1.
  • the synchronization end parses the time information packet to obtain T1 and TC1. Recording the timestamp T2 of the previous alignment code block of the message header when the time information message arrives, and the delay TC2 between the time when the alignment code block enters the device and the recording time of the timestamp T2.
  • the synchronization end sends the time information message to the synchronized end, and records the timestamp T3 of the previous alignment code block of the message header when the time information message is sent, and the time of recording the timestamp T3 to the time when the alignment code block is sent by the device.
  • the delay is TC3, TC3 is carried to the message, and T3 is saved to the local.
  • the synchronization end receives the time information packet, parses the time information packet, and obtains TC3; records the timestamp T4 of the previous alignment code block of the packet header when the packet arrives, and the time-to-time stamp of the alignment code block entering the device.
  • the delay between the recorded moments of T4 is TC4.
  • the sync end After the synchronization end receives, pair T4 and TC34 with T3, but it is not limited to pairing by the serial number of the time information message. In this way, the sync end gets two sets of time values:
  • Step S350 time stamp processing.
  • step S340 the time deviation of the synchronization end with respect to the synchronized end is calculated. Calculated as follows:
  • the delay is the length of time required for the interface of the time information message to be synchronized and the interface of the synchronization end.
  • Offset is the time deviation of the synchronization end relative to the synchronization end. The specific values of delay and offset can be calculated by the above two formulas.
  • step S360 the main time counting system is selected.
  • the master time counting system can be based on the interface used for time synchronization.
  • the current time synchronization uses a 100G (4*25G) interface
  • the 322.265625 MHz time counting system is the main time counting system.
  • the 125 MHz time counting system is the master time counting system.
  • the master time counting system may include a master clock and a master time counter.
  • the clock frequency and clock period of the main clock that is, the clock frequency and clock period of the main time counting system, are also called the main clock frequency and the main clock period.
  • Step S370 clock adjustment.
  • the value of the main time counter is adjusted according to the integral part of the clock period in the time deviation, and the remaining part adjusts the main clock phase.
  • the time deviation S1 ⁇ T + S2, where T is the clock period of the main clock; then the value of the main time counter can be added to S1, and the main clock phase is added to S2.
  • S1 and S2 may be positive or negative.
  • slave time counting systems are synchronized with the master time system, wherein the slave time counting system can include a slave clock and a slave time counter.
  • the synchronization method is as follows:
  • the clock frequency of the main time counting system is xHz (hertz)
  • the clock period is 1/x second
  • the clock frequency of the slave time counting system is yHz
  • the clock period is 1/y second
  • the clock frequency of the master and slave time counting system The common divisor is zHz.
  • the common divisor is used as the clock frequency
  • the clock period is 1/z second.
  • the three clock frequencies have the following relationship:
  • one clock cycle of the common number clock is m main clock cycles or n slave clock cycles, that is, if the clock cycle is counted, the master clock counts m number of clocks, and the slave clock counts n times,
  • the convention number clocks are equal in time.
  • To perform time synchronization between the master and slave time counting systems first determine a common-counter clock with a common number as the clock frequency, so that the rising edge of the common-count clock is aligned with the rising edge of the master clock when the count is an integer multiple of m.
  • the rising edge when the slave clock is counted as an integer multiple of n is aligned with the rising edge of the common-numbered clock, thereby synchronizing the master and slave time counting systems.
  • the rising edge of the slave clock may be first aligned with the rising edge of the common-counter clock, and the rising edge of the clock when the master clock is counted as an integer multiple of m is aligned with the rising edge of the common-numbered clock.
  • the slave time counting system may first perform coarse synchronization with the master time counting system, and then perform fine synchronization according to the above method.
  • the alignment code block AM is used as the periodic code block as an example, and the actual application is not limited thereto.
  • Time synchronization is implemented by the 1588 protocol, that is, the time information packet is 1588.
  • the block diagram of the synchronization device is shown in Figure 3.
  • the packets received by the transceiver are bit-demultiplexed and then divided into multiple lanes.
  • Each LANe performs block synchronization and AM detection respectively.
  • timestamps are added.
  • the AM detection is performed separately, and the bit is mixed and transmitted by the transceiver.
  • the device to be synchronized can also adopt the structure shown in FIG. 3 to bypass the unnecessary modules.
  • This embodiment example includes the following steps 101 to 106.
  • the transceiver (transceiver) transceiver direction bypasses the codec, buffer (buffer), gearbox and other modules.
  • the data trend is shown in bold lines in Figures 4 and 5.
  • Polarity is reached from the TX interface via multiple selectors; equivalent to bypassing the encoding module, gearbox, pattern generator, fifo, SATA (Serial Advanced Technology Attachmen) , Serial Advanced Technology Attachment) OOB (Out of Band), PCIe (peripheral component interconnect express) Beacon (beacon) and other modules.
  • SATA Serial Advanced Technology Attachmen
  • OOB Out of Band
  • PCIe peripheral component interconnect express
  • the AM timestamp matches the 1588 packet.
  • the processing time delay of the AM timestamp to the 1588 identification is fixed. There is no jitter. Otherwise, a matching error occurs, and the probability of an error is uncertain. To solve this problem, there are two ways:
  • the interval for sending packets you can set a special AM value.
  • the timestamp is based on this special AM value.
  • the AM of the Lane0 Take the AM of the Lane0 as an example.
  • a special AM is generated every 297 AMs.
  • the AM of the Lane0 is normal.
  • the value is ⁇ 0xc1, 0x68, 0x21, BIP3. , 0x3e, 0x97, 0xde, BIP7 ⁇ , the value of the special AM reverses the BIP7 byte by bit, and the other bytes have the same value as the normal AM.
  • the clock frequency of the 100G (4*25G) interface alignment code block detection part is 322.265625MHz, and the time stamp is also used by the system 322.265625MHz time counting system.
  • the 322.265625MHz time counter is 80bit, divided into two parts: 1) high 48bit is the second part; 2) low 32bit is 322.265625MHz clock cycle count value.
  • the second part can be directly added to the second part of the message timestamp, and the clock cycle count value needs to be converted into a unit of nanoseconds, and then added to the nanosecond of the message timestamp. section.
  • the clock cycle count value cnt_cycle is converted into a value of nnt_ns in nanoseconds, which is divided into two cases:
  • cnt_cycle is n times 165
  • cnt_ns is n times 512.
  • n is an integer.
  • the integer part can be added to the timestamp and the fractional part added to the correction field.
  • Timestamp compensation is placed in the correction field, and the compensation content includes:
  • the offset calculation can implement steps S340 and S350 in the foregoing embodiment, wherein the time information message adopts a 1588 message, and the calculation result includes a fractional part.
  • Offset_cycle adjusts the value of the time counter
  • offset_decimal adjusts the clock phase
  • the device of this embodiment has both 100G and GE interfaces.
  • the time counter of the 100G interface uses a clock of 322.265625 MHz
  • the time counter of the GE interface uses a clock of 125 MHz.
  • the time information packet includes a synchronization packet and a delayyeq packet.
  • the composition of the 100G interface part in the synchronous end device is as shown in FIG. 6a, and the time count value is obtained after the AM detection and the time stamp is converted (the time stamp conversion can also be performed in the implementation example 1).
  • the composition of the GE interface section is shown in Figure 6b.
  • the device to be synchronized can also use the structure shown in Figures 6a and 6b to bypass the modules that are not needed.
  • "b" in Fig. 6a and Fig. 6b is an abbreviation for the word "bit", indicating a bit.
  • the 322.226525 MHz clock is the main clock, and the 125 MHz clock is the slave clock; the offset calculation portion in FIG. 6b can be bypassed. If the case where the 125 MHz clock is the main clock, the offset calculation portion in Fig. 6a can be bypassed, and the offset calculation portion in Fig. 6b is also connected to the time stamp extraction/recording portion of Fig. 6a.
  • the sending direction selects a lane of the 100G interface arbitrarily. For example, if you select lane0, the sending direction generates a pulse at the position where the lane0 is inserted into the AM, and records the time value corresponding to the pulse. After receiving the code block boundary in the block_sync module, the receiving direction detects the AM position of lane0 and generates a pulse. The clock is counted by the time counting clock to record the time value.
  • the device that is the master sends a sync (synchronization) message
  • the AM detection module detects the value of the time counter of the 322.265625 MHz (ie, the time count value in the figure) at the time of AM, and performs timestamp conversion. Get the standard timestamp format, recorded as T1, added to the sync message.
  • the delay TC1 of the AM detection position to the device exit position is added to the CF field of the sync message.
  • the Slave device detects the AM in the receive direction, records the time counter value at the AM time, and converts it into an ns value.
  • the 1588 message identification module identifies the sync message, records the timestamp of the corresponding AM, and is T2, extracts the TC1 in the CF, adds the local compensation TC2, records it as TC21, and extracts T1 from the message, thereby obtaining T1, T2, and TC21.
  • the AM detecting module detects that the value of the 322.265625 MHz time counter at the time of AM is converted into a standard timestamp format, the 1588 message identifying module identifies the delayreq message record T4, extracts the TC3 in the CF, and compensates the TC4 for the TC34. , reply the delayresp message to the slave device.
  • the Master device 1588 sends a packet module to reply to the delayresp message, carrying T4 and TC34.
  • the Slave device receives the delayresp message, extracts seqid, T4 and TC34, reads T3 with seqid, and stores T3, T4 and TC34 to ram (random access memory) for cpu (central processing) reading.
  • the time synchronization between the GE interfaces adopts the traditional method of adding compensation.
  • the time counter uses 125M clock, the time adjustment is also the deviation adjustment time counter value of 8 ns multiple, and the deviation of 8 ns or less adjusts the clock phase.
  • clock_common with a frequency of 1.953125MHz.
  • This clock is homologous to the 125 MHz clock and the 322.265625 MHz clock and is phase aligned with the 322.626525 MHz clock.
  • the value of m is 165
  • a signal clk_322_div is defined, initialized to 0, and the clock count of 322.265625 MHz is counted to a multiple of 165 minus 1, and clk_322_div is inverted.
  • clk_322_div lags with the rising edge of clock_common. If it is less than 3 nanoseconds, it considers clock_common to be synchronized with 322.265625MHz. Otherwise, adjust the phase of clock_common. If clock_common is still aligned with 322.265625MHz, make clk_322_div relative to clock_common. The rise lag time is less than 3 ns.
  • the two time counting systems are coarsely aligned by adjusting the counter.
  • the 203, 125M time counting system is finely aligned with the clock_common.
  • the 125M clock is aligned with clock_common.
  • the value of m is 64
  • the signal clk_125_div is defined
  • the initialization is 0.
  • the time count of 125 MHz is counted to a multiple of 64 minus 1
  • the clk_125_div is inverted.
  • the time when the clk_125_div is delayed relative to the rising edge of the clock_common is detected. If it is less than 8 nanoseconds, the 125 MHz time system is considered to be aligned with the clock_common, otherwise the count value of the 125 MHz time counting system is adjusted, so that the clk_125_div is delayed by less than 8 nanoseconds with respect to the rising edge of the clock_common.
  • This embodiment is similar to the implementation example 2.
  • the composition of the 100G interface part in the synchronous device is as shown in FIG. 7 , and is basically similar to FIG. 6 a , except that the time count value is not converted; the composition of the GE interface part is as shown in FIG. 6 b .
  • the device to be synchronized can also adopt the structure shown in FIG. 7 to bypass the unnecessary modules.
  • the 322.226525 MHz clock is the main clock, and the 125 MHz clock is the slave clock; the offset calculation portion in FIG. 6b can be bypassed. If the case where the 125 MHz clock is the main clock, the offset calculation portion in Fig. 7 can be bypassed, and the offset calculation portion in Fig. 6b is also connected to the time stamp extraction/recording portion of Fig. 7.
  • the lower 32 bits of the time stamp that is, the nanosecond portion, is changed to the count value of the 322.265625 MHz clock cycle.
  • the high 48bit is still the second part.
  • the embodiment provides a clock synchronization device, including: a first processor and a first memory;
  • the first memory is configured to save a first time synchronization program
  • the first processor is configured to execute the first time synchronization program to perform the following operations:
  • the system clock is adjusted based on the determined time offset.
  • the device of this embodiment may be disposed on the synchronization device.
  • determining the time offset between the devices that are synchronized by the time interval of the received and transmitted time information message and the matched periodic code block may include:
  • the T1 is the timestamp of the previous periodic code block M1 of the header of the received first time information message
  • T2 is the previous period of the message header when the first time information message arrives at the device.
  • T3 is the timestamp of the previous periodic code block M3 of the header of the transmitted second time information message;
  • T4 is the device that the second time information message arrives at the synchronized end device Time stamp of the previous periodic code block M4 of the message header;
  • TC1 is the time delay between the recording time of the timestamp T1 and the time when the periodic code block M1 issues the device to be synchronized;
  • TC2 is the time between the time when the periodic code block M2 enters the device and the time of recording the timestamp T2.
  • TC3 is the delay between the time of recording of the timestamp T3 and the time when the periodic code block M3 issues the device;
  • TC4 is between the time when the periodic code block M4 enters the device of the synchronized end to the time of recording of the timestamp T4 Delay.
  • the adjusting the system clock according to the determined time offset may include:
  • Adjusting the main time counting system according to the time deviation for example, but not limited to, adjusting the value of the time counter of the main time counting system in the synchronous end device according to the part of the clock period in the time interval, and adjusting the value of the time counter of the remaining time device Time counting the phase of the clock of the system;
  • the common number is obtained from the clock frequency of the time counting system, and the common law clock with the common number as the clock frequency is created;
  • the master and slave time counting system refers to the master and slave time counting system in the synchronous end device.
  • the embodiment provides a device for clock synchronization, which is applied to synchronization between multiple time counting systems in a device.
  • the plurality of time counting systems are divided into a main time counting system and a slave time counting system; the device includes: a second processor and a second memory;
  • the second memory is configured to save a second time synchronization program
  • the second processor is configured to execute the second time synchronization program to perform the following operations:
  • the device of this embodiment may be disposed on the synchronization device.
  • the obtaining the common divisor according to the clock frequency of the master and slave time counting systems may further include:
  • Adjusting a clock of the primary counting time system according to the determined time offset for example, but not limited to, adjusting a value of a time counter of the primary time counting system in the synchronous end device according to a portion that is an integer multiple of a clock period in the time offset, The remaining portion adjusts the phase of the clock of the master time counting system.
  • This embodiment provides a device for clock synchronization, as shown in FIG. 8, including:
  • the timestamp generating module 61 is configured to generate a timestamp according to the receiving and sending time of the periodic code block on the predetermined channel;
  • the determining module 62 is configured to receive and send a time information message with the device to be synchronized, and determine the time between the device and the device to be synchronized by using the timestamp of the periodic code block that matches the information of the received and sent time information. deviation;
  • the adjustment module 63 is configured to adjust the system clock based on the determined time offset.
  • the device of this embodiment may be disposed on the synchronization device.
  • the determining, by using the timestamp of the periodic code block that matches the received and sent time information packet, determining the time offset between the device and the synchronized device may include:
  • the determining module determines, according to T1, T2, T3, T4, TC1, TC2, TC3, TC4, a time offset between the device and the synchronized device;
  • the T1 is the timestamp of the previous periodic code block M1 of the header of the received first time information message
  • T2 is the previous period of the message header when the first time information message arrives at the device.
  • T3 is the timestamp of the previous periodic code block M3 of the header of the transmitted second time information message;
  • T4 is the device that the second time information message arrives at the synchronized end device Time stamp of the previous periodic code block M4 of the message header;
  • TC1 is the time delay between the recording time of the timestamp T1 and the time when the periodic code block M1 issues the device to be synchronized;
  • TC2 is the time between the time when the periodic code block M2 enters the device and the time of recording the timestamp T2.
  • TC3 is the delay between the time of recording of the timestamp T3 and the time when the periodic code block M3 issues the device;
  • TC4 is between the time when the periodic code block M4 enters the device of the synchronized end to the time of recording of the timestamp T4 Delay.
  • the adjusting module may include:
  • the adjusting module adjusts the main time counting system according to the time deviation, such as but not limited to including adjusting a value of a time counter of the main time counting system in the synchronous end device according to a part of an integral multiple of a clock period in the time offset, and remaining Partially adjusting the phase of the clock of the main time counting system; obtaining a common divisor according to the clock of the time counting system according to the main time counting system, and creating a common-counter clock with the common number as the clock frequency; Synchronizing with the clock of the master time counting system, the clock from the time counting system is synchronized with the commonsake clock.
  • the time deviation such as but not limited to including adjusting a value of a time counter of the main time counting system in the synchronous end device according to a part of an integral multiple of a clock period in the time offset, and remaining Partially adjusting the phase of the clock of the main time counting system; obtaining a common divisor according to the clock of the time counting system according to the main time counting system,
  • the master and slave time counting system refers to the master and slave time counting system in the synchronous end device.
  • the time synchronization device is disposed in the synchronization device, and may include:
  • the time information generating module includes a plurality of time counters, which are respectively operated under local clock domains of different frequencies. These clock frequencies correspond to each rate interface.
  • the timestamp generating module is configured to detect the position of the aligned code block for any one of the specified lanes, and record the timestamp of the time. Note that the send and receive direction record timestamp must use the same lane alignment block.
  • the determining module may include a message generating unit, a message parsing unit, a clock phase identifying unit, and a time stamp processing unit. among them:
  • the packet generating unit is configured to generate a packet carrying time information, and add a timestamp corresponding to the sending direction alignment code block to the time information packet.
  • the packet parsing unit is configured to parse the time information packet in the receiving direction and parse the timestamp carried by the packet.
  • the clock phase detecting unit is configured to phase-detect the parallel clock and the system clock to obtain a phase difference, and use the phase difference to compensate the generated time stamp.
  • the timestamp processing unit is configured to store a timestamp carried in the packet and a timestamp recorded in the receiving direction, and calculate a time offset.
  • the adjustment module is configured to adjust the value of the main time counter and the phase of the main clock according to the time deviation. It can also be used to synchronize the values of other time counters and the phase of the clock with the master time counting system.
  • the frequency synchronization module is configured to synchronize the clock frequency of the synchronization end device to be synchronized by the synchronization end device.
  • the embodiment provides a clock synchronization device, which is applied to synchronization between multiple time counting systems in a device.
  • the multiple time counting systems are divided into a main time counting system and a slave time counting system; as shown in FIG.
  • the device includes:
  • the creating module 71 is configured to obtain a common number according to the clock of the time counting system according to the main time counting system, and create a common number clock with the common number as a clock frequency;
  • the synchronization module 72 is configured to synchronize the common number clock with the clock of the primary time counting system, and synchronize the clock of the slave time counting system with the common number clock.
  • the device of this embodiment may be disposed on the synchronization device.
  • the device may further include:
  • a timestamp generating module configured to generate a timestamp according to a receiving and sending time of the periodic code block on the predetermined channel
  • the determining module is configured to receive and send a time information message with the device to be synchronized, and determine a time offset between the device and the device to be synchronized by using a timestamp of the periodic code block that matches the received and sent time information message. ;
  • An adjustment module configured to adjust a clock of the primary time counting system according to the determined time offset; for example, but not limited to, including a part of an integer multiple of a clock period in the time offset, and adjusting a primary time counting system in the synchronous end device The value of the time counter, the remainder of which adjusts the phase of the clock of the master time counting system.
  • the present embodiment is a storage medium for storing computer-executable instructions.
  • the computer-executable instructions may implement the time synchronization method provided by one or more embodiments of the foregoing embodiments, for example, 1 and / or the method shown in Figure 2.
  • the computer storage medium can be a non-transitory storage medium, such as a read-only storage medium, a flash memory, an optical disk, a mobile hard disk, a USB flash drive, or a magnetic tape.
  • a non-transitory storage medium such as a read-only storage medium, a flash memory, an optical disk, a mobile hard disk, a USB flash drive, or a magnetic tape.
  • the embodiment of the present disclosure provides a method for clock synchronization, which effectively avoids the unfixed delay caused by fifo and the like, improves the time synchronization precision, has positive beneficial effects, and is simple to implement, and has the characteristics that can be widely used in the industry.

Landscapes

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

Abstract

Disclosed are a clock synchronization method and device. The clock synchronization method comprises: a synchronizing end device generates a time stamp according to a receiving time and a transmitting time of a periodic code block over a predetermined channel; the synchronizing end device transmits a time information message to and receives a time information message from a synchronized end device, and determines a time difference with the synchronized end device according to time stamps of periodic code blocks matching the transmitting and receiving of time information messages; and the synchronizing end device adjusts the system clock according to the determined time difference. Embodiments of the present invention further provide a computer storage medium.

Description

时钟同步的方法和装置、计算机存储介质Method and device for clock synchronization, computer storage medium
相关申请的交叉引用Cross-reference to related applications
本公开基于申请号为201710344469.0、申请日为2017年05月16日的中国专利申请提出,并要求该中国专利申请的优先权,该中国专利申请的全部内容在此引入本公开作为参考。The present disclosure is based on a Chinese patent application filed on Jan. 16, 2017, the entire disclosure of which is hereby incorporated by reference.
技术领域Technical field
本发明涉及通信领域,尤其涉及一种时钟同步的方法和装置。The present invention relates to the field of communications, and in particular, to a method and apparatus for clock synchronization.
背景技术Background technique
多lane(通道)接口pcs(Physical Code Sublayer,物理编码子层)和pma(Physical Media Access,物理介质接入层)部分因有码块的分发合并,数据位宽的转换以及时钟域的转换等,实现时通常会用到fifo(First Input First Output,先入先出)、gearbox(变速箱)等,处理延时不易确定。若仍以时间信息报文头为基准点,在mac(Media Access Control,介质接入控制)层打时间戳,时间抖动会比较大,准度也会比较差。Multi-lane (channel) interface pcs (Physical Code Sublayer) and pma (Physical Media Access) are partially distributed due to code blocks, data bit width conversion, and clock domain conversion. The implementation usually uses fifo (First Input First Output), gearbox (gearbox), etc., and the processing delay is not easy to determine. If you still use the time information packet header as the reference point and time stamp on the mac (Media Access Control) layer, the time jitter will be larger and the accuracy will be worse.
目前,提高打时间戳精度一般采用提高时间计数器的时钟频率的方法,这种方法一定程度上减小了时间误差,但是因芯片工艺等问题,芯片内部的时钟频率不能无限制的提高。大部分芯片内部的频率为1G,即采样误差为1ns(纳秒),少数芯片内部频率可以达到3G,采样误差为300ps(皮秒)。At present, improving the time stamping accuracy generally adopts a method of increasing the clock frequency of the time counter. This method reduces the time error to some extent, but due to problems such as the chip process, the clock frequency inside the chip cannot be increased without limitation. The internal frequency of most chips is 1G, that is, the sampling error is 1 ns (nanoseconds), the internal frequency of a few chips can reach 3G, and the sampling error is 300 ps (picoseconds).
发明内容Summary of the invention
本公开的一个方面提供一种时钟同步的方法和装置。One aspect of the disclosure provides a method and apparatus for clock synchronization.
本公开实施例提供如下技术方案。Embodiments of the present disclosure provide the following technical solutions.
一种时钟同步的方法,包括:A method of clock synchronization, comprising:
同步端设备根据预定通道上周期性码块的收、发时刻生成时间戳;The synchronization end device generates a timestamp according to the time of receiving and sending the periodic code block on the predetermined channel;
所述同步端设备与被同步端设备之间收、发时间信息报文,通过与收、发时间信息报文匹配的周期性码块的时间戳,确定与被同步端设备之间的时间偏差;And receiving, by the synchronization end device, the time information packet between the device and the device to be synchronized, and determining the time deviation between the device and the device to be synchronized by using the time stamp of the periodic code block that matches the information of the received and sent time information packet ;
所述同步端设备根据所确定的时间偏差调整系统时钟。The sync device adjusts the system clock according to the determined time offset.
一种时钟同步的装置,包括:第一处理器和第一存储器;A clock synchronization device includes: a first processor and a first memory;
所述第一存储器配置为保存第一时间同步程序;The first memory is configured to save a first time synchronization program;
所述第一处理器配置为执行所述第一时间同步程序,以进行如下操作:The first processor is configured to execute the first time synchronization program to perform the following operations:
根据预定通道上周期性码块的收、发时刻生成时间戳;Generating a timestamp according to the time of receiving and sending the periodic code block on the predetermined channel;
与被同步端设备之间收、发时间信息报文,通过与收、发时间信息报文匹配的周期性码块的时间戳,确定与被同步端设备之间的时间偏差;And receiving and transmitting a time information packet with the device to be synchronized, and determining a time offset between the device and the device to be synchronized by using a timestamp of the periodic code block that matches the received and sent time information message;
根据所确定的时间偏差调整系统时钟。The system clock is adjusted based on the determined time offset.
一种时钟同步的装置,包括:A clock synchronization device includes:
时间戳生成模块,配置为根据预定通道上周期性码块的收、发时刻生成时间戳;a timestamp generating module, configured to generate a timestamp according to a receiving and sending time of the periodic code block on the predetermined channel;
确定模块,配置为与被同步端设备之间收、发时间信息报文,通过与收、发时间信息报文匹配的周期性码块的时间戳,确定与被同步端设备之间的时间偏差;The determining module is configured to receive and send a time information message with the device to be synchronized, and determine a time offset between the device and the device to be synchronized by using a timestamp of the periodic code block that matches the received and sent time information message. ;
调整模块,配置为根据所确定的时间偏差调整系统时钟。The adjustment module is configured to adjust the system clock based on the determined time offset.
本公开的又一个方面提供一种时钟同步的方法和装置,可以解决多lane接口的情况下不同时钟域带来的误差。Yet another aspect of the present disclosure provides a method and apparatus for clock synchronization that can solve errors caused by different clock domains in the case of multiple lane interfaces.
本公开实施例提供如下技术方案。Embodiments of the present disclosure provide the following technical solutions.
一种时钟同步的方法,应用于包括多个时间计数系统的设备,所述多个时间计数系统分为主时间计数系统和从时间计数系统;所述方法包括:A method of clock synchronization is applied to a device including a plurality of time counting systems, the plurality of time counting systems being divided into a master time counting system and a slave time counting system; the method comprising:
根据所述主时间计数系统、从时间计数系统的时钟频率得到公约数,创建以所述公约数作为时钟频率的公约数时钟;Obtaining a common divisor according to the clock of the time counting system according to the main time counting system, and creating a common-counter clock with the common number as a clock frequency;
将所述公约数时钟与所述主时间计数系统的时钟进行同步,将所述从时间计数系统的时钟与所述公约数时钟进行同步。Synchronizing the commons clock with the clock of the primary time counting system, and synchronizing the clock from the time counting system with the common number clock.
一种时钟同步的装置,应用于设备中多个时间计数系统之间的同步,所述多个时间计数系统分为主时间计数系统和从时间计数系统;所述装置包括:第二处理器和第二存储器;A clock synchronization device is applied to synchronization between a plurality of time counting systems in a device, the plurality of time counting systems being divided into a master time counting system and a slave time counting system; the device comprising: a second processor and Second memory
所述第二存储器配置为保存第二时间同步程序;The second memory is configured to save a second time synchronization program;
所述第二处理器配置为执行所述第二时间同步程序,以进行如下操作:The second processor is configured to execute the second time synchronization program to perform the following operations:
根据所述主时间计数系统、从时间计数系统的时钟频率得到公约数,创建以所述公约数作为时钟频率的公约数时钟;Obtaining a common divisor according to the clock of the time counting system according to the main time counting system, and creating a common-counter clock with the common number as a clock frequency;
将所述公约数时钟与所述主时间计数系统的时钟进行同步,将所述从时间计数系统的时钟与所述公约数时钟进行同步。Synchronizing the commons clock with the clock of the primary time counting system, and synchronizing the clock from the time counting system with the common number clock.
一种时钟同步的装置,应用于设备中多个时间计数系统之间的同步,所述多个时间计数系统分为主时间计数系统和从时间计数系统;所述装置包括:A clock synchronization apparatus is applied to synchronization between a plurality of time counting systems in a device, the plurality of time counting systems being divided into a master time counting system and a slave time counting system; the apparatus comprising:
创建模块,配置为根据所述主时间计数系统、从时间计数系统的时钟频率得到公约数,创建以所述公约数作为时钟频率的公约数时钟;Creating a module, configured to obtain a common number according to the clock of the time counting system according to the main time counting system, and create a common-counter clock with the common number as a clock frequency;
同步模块,配置为将所述公约数时钟与所述主时间计数系统的时钟进行同步,将所述从时间计数系统的时钟与所述公约数时钟进行同步。And a synchronization module configured to synchronize the common number clock with a clock of the primary time counting system, and synchronize the clock of the slave time counting system with the common number clock.
本公开的至少一个实施例用周期性的位置记录时间戳,有效地避免了fifo等引起的不固定时延,提高时间同步精度。该实施例的可选方案中,用与并行时钟(周期性码块处的时钟)频率相同的系统时钟进行时间计数,并对并行时钟和系统时钟进行鉴相,补偿到时间戳,可以提高精度。At least one embodiment of the present disclosure records time stamps with periodic locations, effectively avoiding unfixed delays caused by fifo or the like, and improving time synchronization accuracy. In an alternative of this embodiment, the time is counted by the same system clock as the parallel clock (the clock at the periodic code block), and the parallel clock and the system clock are phase-phased to compensate for the time stamp, which can improve the accuracy. .
本公开至少一个实施例在不同速率接口用不同的时间计数系统的情况下,通过计算公约数时钟频率来创建公约数时钟,从而对不同时间计数系统进行同步,可以消除不同时钟域采样带来的误差。At least one embodiment of the present disclosure can generate a common-counter clock by calculating a common-counter clock frequency in a case where different rate interfaces use different time counting systems, thereby synchronizing different time counting systems, thereby eliminating sampling caused by different clock domains. error.
本公开的其它特征和优点将在随后的说明书中阐述,并且,部分地从 说明书中变得显而易见,或者通过实施本公开而了解。本公开的目的和其他优点可通过在说明书、权利要求书以及附图中所特别指出的结构来实现和获得。Other features and advantages of the present disclosure will be set forth in the description which follows. The objectives and other advantages of the present disclosure can be realized and obtained by the structure particularly pointed out in the appended claims.
附图说明DRAWINGS
附图用来提供对本公开技术方案的进一步理解,并且构成说明书的一部分,与本公开的实施例起用于解释本公开的技术方案,并不构成对本公开技术方案的限制。The drawings are intended to provide a further understanding of the embodiments of the present disclosure, and are intended to be illustrative of the embodiments of the present disclosure.
图1是本发明实施例提供时钟同步的方法的流程示意图。1 is a schematic flow chart of a method for providing clock synchronization according to an embodiment of the present invention.
图2是本发明实施例提供时钟同步的方法的流程示意图。FIG. 2 is a schematic flowchart diagram of a method for providing clock synchronization according to an embodiment of the present invention.
图3是本发明实施方式1提供的实现框图。FIG. 3 is a block diagram of an implementation provided by Embodiment 1 of the present invention.
图4是本发明实施示例1提供的收发器发送方向数据通路。4 is a transceiver transmission direction data path provided by Embodiment 1 of the present invention.
图5是本发明实施示例1提供的收发器接收方向数据通路。FIG. 5 is a transceiver receiving direction data path provided by Embodiment 1 of the present invention.
图6a是本发明实施示例2提供的100G接口部分的实现框图;6a is a block diagram showing an implementation of a 100G interface portion provided by Embodiment 2 of the present invention;
图6b是本发明实施示例2的GE接口部分的实现框图。Figure 6b is a block diagram showing the implementation of the GE interface portion of Embodiment 2 of the present invention.
图7是本发明实施示例3的100G接口部分的实现框图。7 is a block diagram showing an implementation of a 100G interface portion of Embodiment 3 of the present invention.
图8是本发明实施例提供时钟同步的装置的结构示意图;FIG. 8 is a schematic structural diagram of an apparatus for providing clock synchronization according to an embodiment of the present invention; FIG.
图9是本发明实施例七=提供时钟同步的装置的结构示意图。FIG. 9 is a schematic structural diagram of an apparatus for providing clock synchronization according to Embodiment 7 of the present invention.
具体实施方式detailed description
为使本公开的目的、技术方案和优点更加清楚明白,下文中将结合附图对本公开的实施例进行详细说明。需要说明的是,在不冲突的情况下,本公开中的实施例及实施例中的特征可以相互任意组合。The embodiments of the present disclosure will be described in detail below with reference to the accompanying drawings. It should be noted that the embodiments in the present disclosure and the features in the embodiments may be arbitrarily combined with each other without conflict.
在附图的流程图示出的步骤可以在诸如一组计算机可执行指令的计算 机系统中执行。并且,虽然在流程图中示出了逻辑顺序,但是在某些情况下,可以以不同于此处的顺序执行所示出或描述的步骤。The steps illustrated in the flowchart of the figures may be executed in a computer system such as a set of computer executable instructions. Also, although logical sequences are shown in the flowcharts, in some cases the steps shown or described may be performed in a different order than the ones described herein.
本实施例一种时钟同步的方法,如图1所示,包括步骤S110~S120:A method for clock synchronization in this embodiment, as shown in FIG. 1, includes steps S110-S120:
S110、同步端设备根据预定通道上对齐码块的收、发时刻生成时间戳;此处的根据收、发时刻生成的时间戳,可包括:根据接收时刻生成的接收时间戳、和/或,根据发送时刻生成的发送时间戳;S110. The synchronization end device generates a timestamp according to the time of receiving and sending the aligned code block on the predetermined channel. The timestamp generated according to the receiving and sending time may include: a receiving timestamp generated according to the receiving time, and/or a transmission time stamp generated according to the transmission time;
S120、所述同步端设备与被同步端设备之间收、发时间信息报文,通过与收、发时间信息报文匹配的对齐码块的时间戳,确定与被同步端设备之间的时间偏差;S120. The time information packet is received and sent between the synchronization end device and the synchronized end device, and the time interval of the aligned code block matched by the receiving and sending time information packet is used to determine the time between the device and the synchronized device. deviation;
S130、所述同步端设备根据所确定的时间偏差调整系统时钟。S130. The synchronization end device adjusts a system clock according to the determined time offset.
其中,同步端设备可以是指要和被同步端设备进行同步的设备,被同步端设备可以是指时钟作为同步的参照标准的设备。The synchronization device may refer to a device to be synchronized with the device to be synchronized, and the device to be synchronized may refer to a device whose clock is used as a reference standard for synchronization.
其中,所述时间信息报文可以包括ptp(Precision Timing Protocol,精确时间协议)报文、1588报文等。The time information packet may include a TP (Precision Timing Protocol) packet, a 1588 packet, and the like.
其中,周期性码块可以但不限于是对齐码块。The periodic code block can be, but is not limited to, an aligned code block.
其中,所述与收、发时间信息报文匹配的周期性码块可以但不限于是时间信息报文头所在位置的前一个周期性码块的收发时刻。The periodic code block that matches the receiving and sending time information packet may be, but is not limited to, the sending and receiving time of the previous periodic code block where the time information header is located.
其中,预定通道可以但不限于是lane0。Wherein, the predetermined channel can be, but is not limited to, lane0.
可选地,所述通过与收、发时间信息报文匹配的对齐码块的时间戳,确定与被同步端设备之间的时间偏差前还可以包括:Optionally, the determining, by using the timestamp of the aligned code block that matches the received and sent time information packet, before determining the time offset between the device and the device to be synchronized, may further include:
所述同步端设备对生成时间戳所用的时钟与系统时钟进行鉴相,得到相位差;The synchronization end device performs phase discrimination on the clock used to generate the time stamp and the system clock to obtain a phase difference;
所述同步端设备使用所述相位差对所生成的时间戳进行补偿。The sync device compensates for the generated timestamp using the phase difference.
本可选方案中,鉴相可以在生成时间戳之前或之后进行;在生成时间戳后,可以立即使用鉴相得到的相位差进行补偿,也可以在需要计算时间偏差时再进行补偿。In this alternative, the phase discrimination may be performed before or after the time stamp is generated; after the time stamp is generated, the phase difference obtained by phase discrimination may be immediately compensated, or may be compensated when the time offset needs to be calculated.
本可选方案中,考虑到打时间戳所用的时间计数系统的时钟(系统时钟)频率与接口并行时钟的时钟频率相同,对两个时钟鉴相,鉴相得到相位差补偿到时间戳。In this alternative, the clock (system clock) frequency of the time counting system used for time stamping is the same as the clock frequency of the interface parallel clock. For phase discrimination of the two clocks, the phase difference is compensated to the time stamp.
鉴相精度决定了打时间戳的精度,比如同频时钟鉴相精度最高可达1ps,则理论上打时间戳精度可以达到1ps。The phase discrimination accuracy determines the accuracy of the time stamping. For example, the phase clock accuracy of the same frequency clock can be up to 1 ps, and the theoretical time stamping accuracy can reach 1 ps.
可选地,所述步骤S110前还可以包括:Optionally, before the step S110, the method may further include:
将所述同步端设备的系统时钟和被同步端设备的系统时钟进行频率同步。Synchronizing the system clock of the sync device with the system clock of the device being synced.
可选地,所述通过与收、发时间信息报文匹配的周期性码块的时间戳,确定与被同步端设备之间的时间偏差可以包括:Optionally, determining, by using a timestamp of the periodic code block that matches the received and sent time information packet, determining a time offset from the device to be synchronized may include:
根据T1、T2、T3、T4、TC1、TC2、TC3、TC4确定和所述被同步端设备之间的时间偏差;Determining the time deviation between the synchronized device and the device according to T1, T2, T3, T4, TC1, TC2, TC3, TC4;
其中,T1是所接收的第一时间信息报文在发送时报文头的前一个周期性码块M1的时间戳;T2是所述第一时间信息报文到达本设备时报文头的前一个周期性码块M2的时间戳;T3是所发送的第二时间信息报文的报文头的前一个周期性码块M3的时间戳;T4是所述第二时间信息报文到达被同步端设备时,报文头的前一个周期性码块M4的时间戳;The T1 is the timestamp of the previous periodic code block M1 of the header of the received first time information message, and T2 is the previous period of the message header when the first time information message arrives at the device. The timestamp of the code block M2; T3 is the timestamp of the previous periodic code block M3 of the header of the transmitted second time information message; T4 is the device that the second time information message arrives at the synchronized end device Time stamp of the previous periodic code block M4 of the message header;
TC1是时间戳T1的记录时刻到周期性码块M1发出被同步端设备的时刻之间的时延;TC2是周期性码块M2进入本设备的时刻到时间戳T2的记录时刻之间的时延;TC3是时间戳T3的记录时刻到周期性码块M3发出本设备的时刻之间的时延;TC4是周期性码块M4进入被同步端设备的时刻到时间戳T4的记录时刻之间的时延。TC1 is the time delay between the recording time of the timestamp T1 and the time when the periodic code block M1 issues the device to be synchronized; TC2 is the time between the time when the periodic code block M2 enters the device and the time of recording the timestamp T2. TC3 is the delay between the time of recording of the timestamp T3 and the time when the periodic code block M3 issues the device; TC4 is between the time when the periodic code block M4 enters the device of the synchronized end to the time of recording of the timestamp T4 Delay.
可选地,所述步骤S130可以包括:Optionally, the step S130 may include:
所述同步端设备根据所述时间偏差中时钟周期的整数倍的部分,调整所述同步端设备中主时间计数系统中时间计数器的值,余下部分调整所述主时间计数系统中主时钟的相位。The synchronization end device adjusts a value of a time counter in the main time counting system in the synchronization end device according to an integral multiple of a clock period in the time offset, and the remaining portion adjusts a phase of the main clock in the main time counting system .
可选地,所述步骤S130还可以包括:Optionally, the step S130 may further include:
所述同步端设备根据所述同步端设备中主时间计数系统、从时间计数 系统的时钟频率得到公约数,创建以所述公约数作为时钟频率的公约数时钟;The synchronization end device obtains a common number according to the clock time of the time counting system of the main time counting system in the synchronous end device, and creates a common number clock with the common number as the clock frequency;
所述同步端设备将所述公约数时钟与所述主时间计数系统的时钟进行同步,将所述从时间计数系统的时钟与所述公约数时钟进行同步。The synchronization end device synchronizes the common number clock with the clock of the main time counting system, and synchronizes the clock of the slave time counting system with the common number clock.
本可选方案中,主时间计数系统可以预先指定或默认,也可以根据约定规则由同步端设备自行从多个时间计数系统中选择一个作为主时间计数系统,其余作为从时间计数系统。In this alternative, the main time counting system may be pre-designated or defaulted, or may be selected by the synchronizing end device from one of the plurality of time counting systems as the main time counting system according to the agreed rules, and the rest is used as the slave time counting system.
可选地,所述将所述公约数时钟与主时间计数系统的时钟进行同步,将从时间计数系统的时钟与所述公约数时钟进行同步可以包括:Optionally, the synchronizing the common number clock with the clock of the main time counting system, and synchronizing the clock of the time counting system with the common number clock may include:
使所述公约数时钟的上升沿对齐计数为m的整数倍时的主时间计数系统的时钟的上升沿,使从时间计数系统的时钟计数为n的整数倍时的上升沿与所述公约数时钟的上升沿对齐;a rising edge of the clock of the main time counting system when the rising edge of the common number clock is aligned to an integer multiple of m, so that the rising edge of the clock counting from the time counting system is an integer multiple of n and the common divisor Align the rising edge of the clock;
其中,m等于所述主时钟计数系统的时钟频率除以所述公约数;n等于所述从时钟计数系统的时钟频率除以所述公约数。Where m is equal to the clock frequency of the master clock counting system divided by the common divisor; n is equal to the clock frequency of the slave clock counting system divided by the common divisor.
本实施例提供一种时钟同步的方法,应用于包括多个时间计数系统的设备,所述多个时间计数系统分为主时间计数系统和从时间计数系统;所述方法如图2所示,包括步骤S210~S220:The embodiment provides a method for clock synchronization, which is applied to a device including multiple time counting systems, which are divided into a main time counting system and a slave time counting system; the method is as shown in FIG. 2 Including steps S210-S220:
S210、根据所述主时间计数系统、从时间计数系统的时钟频率得到公约数,创建以所述公约数作为时钟频率的公约数时钟;S210. Obtain a common divisor according to the clock of the time counting system according to the main time counting system, and create a common-counter clock with the common number as a clock frequency;
S220、将所述公约数时钟与所述主时间计数系统的时钟进行同步,将所述从时间计数系统的时钟与所述公约数时钟进行同步。S220. Synchronize the common number clock with the clock of the main time counting system, and synchronize the clock of the slave time counting system with the common number clock.
本实施例中,打时间戳所用时间计数系统的时钟频率与接口速率相关,不同速率接口对应不同的时钟频率下的时间计数系统,各时间计数系统用以公约数作为时钟频率的时钟进行同步。In this embodiment, the clock frequency of the time counting system used for time stamping is related to the interface rate, and the different rate interfaces correspond to time counting systems at different clock frequencies, and each time counting system uses the common number as the clock frequency clock for synchronization.
本实施例中,还可以先对从时间计数系统可以先和主时间计数系统进行计数值粗同步后,再按上述方法进行细同步。In this embodiment, the slave time counting system may first perform coarse synchronization with the master time counting system, and then perform fine synchronization according to the above method.
本实施例中,多个时间计数系统中的主时间计数系统可以预先指定或 默认,也可以根据约定规则由同步端设备自行从多个时间计数系统中选择一个作为主时间计数系统,其余作为从时间计数系统。In this embodiment, the main time counting system in the plurality of time counting systems may be pre-designated or defaulted, or may be selected by the synchronizing end device from the plurality of time counting systems as the main time counting system according to the agreed rules, and the rest is taken as the slave time counting system. Time counting system.
可选地,步骤S220可以包括:Optionally, step S220 may include:
使所述公约数时钟的上升沿对齐计数为m的整数倍时的主时间计数系统的时钟的上升沿,使从时间计数系统的时钟计数为n的整数倍时的上升沿与所述公约数时钟的上升沿对齐;a rising edge of the clock of the main time counting system when the rising edge of the common number clock is aligned to an integer multiple of m, so that the rising edge of the clock counting from the time counting system is an integer multiple of n and the common divisor Align the rising edge of the clock;
其中,m等于所述主时钟计数系统的时钟频率除以所述公约数;n等于所述从时钟计数系统的时钟频率除以所述公约数。Where m is equal to the clock frequency of the master clock counting system divided by the common divisor; n is equal to the clock frequency of the slave clock counting system divided by the common divisor.
可选地,所述步骤S210前还可以包括:Optionally, before the step S210, the method may further include:
根据预定通道上周期性码块的收、发时刻生成时间戳;Generating a timestamp according to the time of receiving and sending the periodic code block on the predetermined channel;
与被同步端设备之间收、发时间信息报文,通过与收、发时间信息报文匹配的周期性码块的时间戳,确定与被同步端设备之间的时间偏差;And receiving and transmitting a time information packet with the device to be synchronized, and determining a time offset between the device and the device to be synchronized by using a timestamp of the periodic code block that matches the received and sent time information message;
根据所确定的时间偏差调整所述主计数时间系统的时钟。The clock of the master count time system is adjusted based on the determined time offset.
本可选方案中,所述包括多个时间计数系统的设备可以视为同步端设备。In this alternative, the device including multiple time counting systems may be regarded as a synchronous device.
本可选方案的其它实施细节可参见前述实施例。Further implementation details of this alternative can be found in the previous embodiments.
本实施例一种时钟同步的方法,本实施例中,周期性码块采用对齐码块AM,时钟同步的过程包括以下步骤S310~S370:In this embodiment, a clock synchronization method is used. In this embodiment, the periodic code block adopts an alignment code block AM. The process of clock synchronization includes the following steps S310-S370:
步骤S310,频率同步。Step S310, frequency synchronization.
将同步端设备和被同步端设备的系统时钟的频率进行同步。。The synchronization end device is synchronized with the frequency of the system clock of the device being synchronized. .
步骤S320,时间戳生成。In step S320, a time stamp is generated.
检测收发方向指定lane的对齐码块AM,记录其发送或到达的时间,生成时间戳。Detects the alignment code block AM of the specified lane in the sending and receiving direction, records the time of sending or arriving, and generates a timestamp.
时间戳可以由对齐码块对应的时间计数系统生成;其中,对齐码块对应的时间计数系统可以包括接口并行时钟(即接口并行数据对应的时钟)和时间计数器。The timestamp may be generated by a time counting system corresponding to the aligned code block; wherein the time counting system corresponding to the aligned code block may include an interface parallel clock (ie, a clock corresponding to the interface parallel data) and a time counter.
步骤S330,系统时钟与接口并行时钟鉴相。In step S330, the system clock and the interface parallel clock phase detector.
同步端设备或被同步端设备的系统时间由系统时钟产生;而对齐码块AM在接口并行时钟下处理。两个时钟有一定的相位差,需对其鉴相,得到相位差。The system time of the sync device or the sync device is generated by the system clock; and the alignment block AM is processed under the interface parallel clock. The two clocks have a certain phase difference, which needs to be phased out to obtain a phase difference.
使用所述相位差对所生成的时间戳进行补偿。The generated time stamp is compensated using the phase difference.
步骤S340,时间信息传送。Step S340, time information is transmitted.
首先,被同步端发送时间信息报文,携带时间信息报文发送时报文头的前一个对齐码块对应的时间戳T1,和时间戳T1的记录时刻到该对齐码块发出设备的时刻之间的时延TC1。同步端接收到此时间信息报文后,解析该时间信息报文,得到T1和TC1。记录时间信息报文到达时报文头的前一个对齐码块的时间戳T2,和该对齐码块进入设备的时刻到时间戳T2的记录时刻之间的时延TC2。First, the synchronization end sends a time information packet, and carries the timestamp T1 corresponding to the previous alignment code block of the packet header when the time information packet is sent, and the recording time of the timestamp T1 to the time when the alignment code block is sent to the device. The delay is TC1. After receiving the time information packet, the synchronization end parses the time information packet to obtain T1 and TC1. Recording the timestamp T2 of the previous alignment code block of the message header when the time information message arrives, and the delay TC2 between the time when the alignment code block enters the device and the recording time of the timestamp T2.
同步端发送时间信息报文给被同步端,记录时间信息报文发送时报文头的前一个对齐码块的时间戳T3,和时间戳T3的记录时刻到该对齐码块发出设备的时刻之间的时延TC3,TC3携带到报文,T3保存到本地。被同步端接收到时间信息报文,解析该时间信息报文,得到TC3;记录报文到达时报文头的前一个对齐码块的时间戳T4,和该对齐码块进入设备的时刻到时间戳T4的记录时刻之间的时延TC4。The synchronization end sends the time information message to the synchronized end, and records the timestamp T3 of the previous alignment code block of the message header when the time information message is sent, and the time of recording the timestamp T3 to the time when the alignment code block is sent by the device. The delay is TC3, TC3 is carried to the message, and T3 is saved to the local. The synchronization end receives the time information packet, parses the time information packet, and obtains TC3; records the timestamp T4 of the previous alignment code block of the packet header when the packet arrives, and the time-to-time stamp of the alignment code block entering the device. The delay between the recorded moments of T4 is TC4.
被同步端将T4和TC34(=TC3+TC4)携带到时间信息报文中,发给同步端。The T4 and TC34 (=TC3+TC4) are carried in the time information message by the synchronization end and sent to the synchronization end.
同步端收到后,将T4和TC34与T3配对,可以但不限于通过时间信息报文的序列号进行配对。这样,同步端得到两组时间值:After the synchronization end receives, pair T4 and TC34 with T3, but it is not limited to pairing by the serial number of the time information message. In this way, the sync end gets two sets of time values:
1)T1、T2、TC21(=TC1+TC2);1) T1, T2, TC21 (= TC1 + TC2);
2)T3、T4、TC34;2) T3, T4, TC34;
其中,TC1、TC2、TC3、TC4的值要固定或者变化值可知,比如可以通过实验或测试得到。步骤S350,时间戳处理。Among them, the values of TC1, TC2, TC3, and TC4 should be fixed or changed, for example, can be obtained through experiments or tests. Step S350, time stamp processing.
根据步骤S340得到的两组时间值,计算同步端相对于被同步端的时间偏差。计算公式如下:According to the two sets of time values obtained in step S340, the time deviation of the synchronization end with respect to the synchronized end is calculated. Calculated as follows:
T1+delay+offset+TC21=T2T1+delay+offset+TC21=T2
T3+delay-offset+TC 34=T4T3+delay-offset+TC 34=T4
其中,delay是时间信息报文被同步端的接口和同步端的接口所需的时间长度,offset是同步端相对被同步端的时间偏差,由以上两式可计算出delay和offset的具体值。The delay is the length of time required for the interface of the time information message to be synchronized and the interface of the synchronization end. Offset is the time deviation of the synchronization end relative to the synchronization end. The specific values of delay and offset can be calculated by the above two formulas.
步骤S360,选择主时间计数系统。In step S360, the main time counting system is selected.
主时间计数系统可以根据时间同步所用的接口来定。The master time counting system can be based on the interface used for time synchronization.
例如,当前时间同步用的100G(4*25G)接口,那322.265625MHz的时间计数系统就为主时间计数系统。若当前时间同步用GE的接口,则125MHz的时间计数系统就为主时间计数系统。For example, the current time synchronization uses a 100G (4*25G) interface, and the 322.265625 MHz time counting system is the main time counting system. If the current time synchronization uses the GE interface, the 125 MHz time counting system is the master time counting system.
其中,主时间计数系统可以包括主时钟和主时间计数器。主时钟的时钟频率、时钟周期即主时间计数系统的时钟频率、时钟周期,也称为主时钟频率、主时钟周期。The master time counting system may include a master clock and a master time counter. The clock frequency and clock period of the main clock, that is, the clock frequency and clock period of the main time counting system, are also called the main clock frequency and the main clock period.
步骤S370,时钟调整。Step S370, clock adjustment.
根据所述时间偏差中时钟周期的整数倍的部分,调整主时间计数器的值,余下部分调整主时钟相位。The value of the main time counter is adjusted according to the integral part of the clock period in the time deviation, and the remaining part adjusts the main clock phase.
比如时间偏差=S1×T+S2,其中T是主时钟的时钟周期;则可以将主时间计数器的值加上S1,将主时钟相位加上S2。For example, the time deviation = S1 × T + S2, where T is the clock period of the main clock; then the value of the main time counter can be added to S1, and the main clock phase is added to S2.
S1、S2可以为正数,也可能为负数。S1 and S2 may be positive or negative.
对其他时间计数系统(也称从时间计数系统)与主时间系统进行同步,其中,从时间计数系统可以包括从时钟和从时间计数器。从时钟的时钟频率、时钟周期即从时间计数系统的时钟频率、时钟周期,也称为从时钟频率、从时钟周期。Other time counting systems (also known as slave time counting systems) are synchronized with the master time system, wherein the slave time counting system can include a slave clock and a slave time counter. The clock frequency of the slave clock, the clock cycle, that is, the clock frequency of the system, and the clock cycle, also called the slave clock frequency, the slave clock cycle.
同步方法如下:The synchronization method is as follows:
假设主时间计数系统的时钟频率为xHz(赫兹),时钟周期为1/x秒,从时间计数系统的时钟频率为yHz,时钟周期为1/y秒,主、从时间计数系统的时钟频率的公约数为zHz,以该公约数作为时钟频率时,时钟周期为1/z秒,三个时钟频率有以下关系:Assume that the clock frequency of the main time counting system is xHz (hertz), the clock period is 1/x second, the clock frequency of the slave time counting system is yHz, the clock period is 1/y second, and the clock frequency of the master and slave time counting system The common divisor is zHz. When the common divisor is used as the clock frequency, the clock period is 1/z second. The three clock frequencies have the following relationship:
Figure PCTCN2018087150-appb-000001
Figure PCTCN2018087150-appb-000001
Figure PCTCN2018087150-appb-000002
Figure PCTCN2018087150-appb-000002
由以上两式可得:Available from the above two formulas:
Figure PCTCN2018087150-appb-000003
Figure PCTCN2018087150-appb-000003
Figure PCTCN2018087150-appb-000004
Figure PCTCN2018087150-appb-000004
即公约数时钟的一个时钟周期为m个主时钟周期或n个从时钟周期,也即若对时钟周期进行计数,主时钟计m个数的时钟、与从时钟计n个数的时间、与公约数时钟计一个数的时间相等。That is, one clock cycle of the common number clock is m main clock cycles or n slave clock cycles, that is, if the clock cycle is counted, the master clock counts m number of clocks, and the slave clock counts n times, The convention number clocks are equal in time.
主、从时间计数系统若要进行时间同步,首先确定一个以公约数作为时钟频率的公约数时钟,使该公约数时钟的上升沿对齐计数为m的整数倍时的主时钟的上升沿,之后使从时钟计数为n的整数倍时的上升沿与所述公约数时钟的上升沿对齐,从而使主、从时间计数系统达到同步。这里也可以先使公约数时钟的上升沿对齐计数为n的整数倍时的从时钟的上升沿,之后使主时钟计数为m的整数倍时的上升沿与所述公约数时钟的上升沿对齐,来使主、从时间计数系统达到同步。To perform time synchronization between the master and slave time counting systems, first determine a common-counter clock with a common number as the clock frequency, so that the rising edge of the common-count clock is aligned with the rising edge of the master clock when the count is an integer multiple of m. The rising edge when the slave clock is counted as an integer multiple of n is aligned with the rising edge of the common-numbered clock, thereby synchronizing the master and slave time counting systems. Here, the rising edge of the slave clock may be first aligned with the rising edge of the common-counter clock, and the rising edge of the clock when the master clock is counted as an integer multiple of m is aligned with the rising edge of the common-numbered clock. To synchronize the master and slave time counting systems.
其中,从时间计数系统可以先和主时间计数系统进行计数值粗同步后,再按上述方法进行细同步。The slave time counting system may first perform coarse synchronization with the master time counting system, and then perform fine synchronization according to the above method.
下面用3个实施示例说明上述实施例。以下实施示例中以对齐码块AM作为所述周期性码块为例进行说明,实际应用时不限于此。The above embodiment will be described below using three embodiment examples. In the following embodiment, the alignment code block AM is used as the periodic code block as an example, and the actual application is not limited thereto.
实施示例1Implementation example 1
本实施示例以100G(4*25G)接口为例来阐述。时间同步用1588协议来实现,即时间信息报文为1588报文。同步端设备的实现框图如图3所示,收发器接收的报文进行比特解混合后分为多个lane,各lane分别进行块同步和AM检测;要发送报文时添加时间戳,各lane分别进行AM检测,进行比特混合后由收发器发送。对接收的报文进行1588报文识别,提取和记录AM检测(收、发方向)得到的时间戳,并通过时钟鉴相的结果进行补 偿;通过收、发1588报文和匹配的AM的时间戳,进行offset计算,根据计算得到的offset调整322.265625MHz时间计数器和时钟。This embodiment example is illustrated by taking a 100G (4*25G) interface as an example. Time synchronization is implemented by the 1588 protocol, that is, the time information packet is 1588. The block diagram of the synchronization device is shown in Figure 3. The packets received by the transceiver are bit-demultiplexed and then divided into multiple lanes. Each LANe performs block synchronization and AM detection respectively. When sending packets, timestamps are added. The AM detection is performed separately, and the bit is mixed and transmitted by the transceiver. Performs 1588 packet identification on the received packet, extracts and records the timestamp obtained by the AM detection (receiving and transmitting direction), and compensates by the result of the clock phase-detection; and receives and sends the 1588 packet and the matched AM time. Poke, perform offset calculation, adjust the 322.265625MHz time counter and clock according to the calculated offset.
被同步端设备也可以采用图3所示的结构,旁路其中不需要的模块。The device to be synchronized can also adopt the structure shown in FIG. 3 to bypass the unnecessary modules.
本实施示例包括以下步骤101~106。This embodiment example includes the following steps 101 to 106.
101、数据收发。101, data transmission and reception.
transceiver(收发器)收发方向均把编解码、buffer(缓冲)、gearbox等模块bypass(旁路)掉。数据走向如图4和图5中加粗的线条所示。The transceiver (transceiver) transceiver direction bypasses the codec, buffer (buffer), gearbox and other modules. The data trend is shown in bold lines in Figures 4 and 5.
在发端,从TX interface(发送接口)经多个选择器后达到Polarity(极性);相当于旁路掉了编码模块、gearbox、模式产生器(Pattern Generator)、fifo、SATA(Serial Advanced Technology Attachmen,串行高级技术附加装置)OOB(Out of Band,带外)、PCIe(peripheral component interconnect express,外围器件互联)Beacon(信标)等模块。At the origin, Polarity is reached from the TX interface via multiple selectors; equivalent to bypassing the encoding module, gearbox, pattern generator, fifo, SATA (Serial Advanced Technology Attachmen) , Serial Advanced Technology Attachment) OOB (Out of Band), PCIe (peripheral component interconnect express) Beacon (beacon) and other modules.
在收端,从SIPO(串行进并行出)到Polarity,经过多个选择器后到达RX interface(接收接口);相当于旁路掉了解码、Buffer、gearbox、Comma Detect and Align(字符检测和对齐)等模块。At the receiving end, from the SIPO (serial in parallel) to Polarity, after passing through multiple selectors to reach the RX interface (receive interface); equivalent to bypassing decoding, Buffer, gearbox, Comma Detect and Align (character detection and Align) and other modules.
102、时间戳生成102, timestamp generation
本实施示例中,1588的时间戳以100G接口任意一个lane的对齐码块AM的收发时刻为准。比如可以是1588报文头所在位置的前一个AM的收发时刻。In this implementation example, the timestamp of 1588 is based on the sending and receiving time of the aligned code block AM of any one of the 100G interfaces. For example, it can be the sending and receiving time of the previous AM where the 1588 packet header is located.
由于AM时间戳与1588报文匹配需要AM打时间戳到1588识别的处理时延固定,不能有一点抖动,否则会出现匹配错误的情况,且出现错误的概率不定。为解决这个问题,有两种方法:The AM timestamp matches the 1588 packet. The processing time delay of the AM timestamp to the 1588 identification is fixed. There is no jitter. Otherwise, a matching error occurs, and the probability of an error is uncertain. To solve this problem, there are two ways:
方法一:method one:
根据报文的发送间隔,可以设置特殊的AM值,打时间戳以这个特殊的AM值为准。According to the interval for sending packets, you can set a special AM value. The timestamp is based on this special AM value.
以选取lane0的AM为例,当报文发包速率为16个/秒时,则每隔297个AM,生成一个特殊的AM,lane0的AM正常情况下,值为{0xc1,0x68,0x21,BIP3,0x3e,0x97,0xde,BIP7},特殊的AM的值将BIP7字节 按位取反,其他字节的值与正常AM相同。Take the AM of the Lane0 as an example. When the packet sending rate is 16/s, a special AM is generated every 297 AMs. The AM of the Lane0 is normal. The value is {0xc1, 0x68, 0x21, BIP3. , 0x3e, 0x97, 0xde, BIP7}, the value of the special AM reverses the BIP7 byte by bit, and the other bytes have the same value as the normal AM.
方法二:Method Two:
控制时间信息报文头与AM之间的时间间隔,当间隔超过门限时间时,等待下一个AM再发包。Controls the time interval between the time information packet header and the AM. When the interval exceeds the threshold time, it waits for the next AM to resend the packet.
103、时间戳转化103, timestamp conversion
100G(4*25G)接口对齐码块检测部分的时钟频率为322.265625MHz,时间戳也用系统322.265625MHz的时间计数系统。322.265625MHz的时间计数器为80bit,分两部分:1)高48bit为秒部分;2)低32bit为322.265625MHz时钟周期计数值。将时间戳添加到报文中时,秒部分可以直接加到报文时间戳的秒部分,而时钟周期计数值则需转成单位为纳秒的数值,再添加到报文时间戳的纳秒部分。时钟周期计数值cnt_cycle转换成单位为纳秒的数值cnt_ns,分两种情况:The clock frequency of the 100G (4*25G) interface alignment code block detection part is 322.265625MHz, and the time stamp is also used by the system 322.265625MHz time counting system. The 322.265625MHz time counter is 80bit, divided into two parts: 1) high 48bit is the second part; 2) low 32bit is 322.265625MHz clock cycle count value. When a timestamp is added to a message, the second part can be directly added to the second part of the message timestamp, and the clock cycle count value needs to be converted into a unit of nanoseconds, and then added to the nanosecond of the message timestamp. section. The clock cycle count value cnt_cycle is converted into a value of nnt_ns in nanoseconds, which is divided into two cases:
(1)cnt_cycle为165的n倍时,cnt_ns为512的n倍。其中,n为整数。(1) When cnt_cycle is n times 165, cnt_ns is n times 512. Where n is an integer.
(2)cnt_cycle为其他数值时,用一个除法器,用cnt_cycle除以165,商的处理方式与(1)相同,得到cnt_ns_1;余数部分记为remainder,322.265625M的时钟周期为3.1030303…纳秒,是个无限循环小数,无法得到准确的值,取7位小数,remainder每加1,cnt_ns_2就加3.1030303,当remainder为164时,转换精度为仍为亚ps级。Cnt_cycle对应的cnt_ns即为cnt_ns_1加cnt_ns_2。(2) When cnt_cycle is another value, use a divider, divide cnt_cycle by 165, and the quotient processing method is the same as (1), and get the cnt_ns_1; the remainder is recorded as the remainder, and the clock period of 322.265625M is 3.1030303... nanoseconds. Is an infinite loop decimal, can not get the exact value, take 7 decimal places, each add 1 for reminder, add 3.1030303 for cnt_ns_2, when the remainder is 164, the conversion accuracy is still sub-ps level. The cnt_ns corresponding to Cnt_cycle is cnt_ns_1 plus cnt_ns_2.
当cnt_cycle有小数时,可将整数部分添加到时间戳,小数部分添加到correction域。When cnt_cycle has a decimal, the integer part can be added to the timestamp and the fractional part added to the correction field.
104、时间戳补偿104, time stamp compensation
时间戳补偿均放到correction(修正)域中,补偿内容包括:Timestamp compensation is placed in the correction field, and the compensation content includes:
(1)收方向恢复时钟和系统时钟的鉴相值,直接加到correction域。(1) The phase detection value of the recovery clock and the system clock is directly added to the correction domain.
(2)时间戳转化的小数部分cnt_cycle_decimal。收方向将0-cnt_cycle_decimal加到correction域,发送方向直接将cnt_cycle_decimal加到correction域。(2) The fractional part of the timestamp conversion cnt_cycle_decimal. In the receiving direction, 0-cnt_cycle_decimal is added to the correction field, and the sending direction directly adds cnt_cycle_decimal to the correction field.
(3)lane0的特殊AM的第一个bit在16bit数据的第p个bit的补偿;p为正整数。(3) The first bit of the special AM of lane0 is compensated for the p-th bit of the 16-bit data; p is a positive integer.
(4)接收方向lane0的数据在bit_demux后不在第一路的补偿。(4) The data in the receiving direction lane0 is not compensated in the first way after bit_demux.
105、时间偏差offset计算105, time deviation offset calculation
offset计算可以实现前述实施例中的步骤S340和S350,其中时间信息报文采用1588报文,计算结果包含小数部分。The offset calculation can implement steps S340 and S350 in the foregoing embodiment, wherein the time information message adopts a 1588 message, and the calculation result includes a fractional part.
106、时间计数器和时钟相位调整。106, time counter and clock phase adjustment.
offset的单位为纳秒,要调整322.265625MHz时钟的计数,需转换为其时钟周期的个数offset_cycle和剩余部分offset_decimal。offset_cycle调整时间计数器的值,offset_decimal调整时钟相位。The unit of offset is nanosecond. To adjust the count of 322.265625MHz clock, it needs to be converted to the number of clock cycles offset_cycle and the remaining part offset_decimal. Offset_cycle adjusts the value of the time counter, offset_decimal adjusts the clock phase.
实施示例2Implementation example 2
本实施示例的装置有100G和GE两种接口。100G接口的时间计数器用322.265625MHz时钟,GE接口的时间计数器用125MHz时钟,时间信息报文包括同步报文、delayreq报文。本实施示例中,同步端设备中,100G接口部分的组成如图6a所示,AM检测后得到时间计数值并进行时间戳转化(实施示例1中也可以进行时间戳转化)。GE接口部分的组成如图6b所示。被同步端设备也可以采用图6a、图6b所示的结构,旁路其中不需要的模块。图6a及图6b中的“b”为因为单词“bit”的缩写,表示比特。The device of this embodiment has both 100G and GE interfaces. The time counter of the 100G interface uses a clock of 322.265625 MHz, and the time counter of the GE interface uses a clock of 125 MHz. The time information packet includes a synchronization packet and a delayyeq packet. In this embodiment, the composition of the 100G interface part in the synchronous end device is as shown in FIG. 6a, and the time count value is obtained after the AM detection and the time stamp is converted (the time stamp conversion can also be performed in the implementation example 1). The composition of the GE interface section is shown in Figure 6b. The device to be synchronized can also use the structure shown in Figures 6a and 6b to bypass the modules that are not needed. "b" in Fig. 6a and Fig. 6b is an abbreviation for the word "bit", indicating a bit.
本实施示例中,以322.265625MHz时钟为主时钟,125MHz时钟为从时钟;图6b中的offset计算部分可以旁路。如果以125MHz时钟为主时钟的情况,则图6a中的offset计算部分可以旁路,图6b中的offset计算部分也连接到图6a的时间戳提取/记录部分。In this embodiment, the 322.226525 MHz clock is the main clock, and the 125 MHz clock is the slave clock; the offset calculation portion in FIG. 6b can be bypassed. If the case where the 125 MHz clock is the main clock, the offset calculation portion in Fig. 6a can be bypassed, and the offset calculation portion in Fig. 6b is also connected to the time stamp extraction/recording portion of Fig. 6a.
100G接口之间时间同步时,采用实施示例1类似的方法,调整322.265625MHz的时间系统。不同之处在于时间戳位置:When the time is synchronized between the 100G interfaces, a similar method to the first embodiment is used to adjust the time system of 322.265625 MHz. The difference is in the timestamp location:
首先任意选取100G接口的一个lane,例如还是选取lane0,则发送方向在lane0插入AM的位置生成一个脉冲,并记录脉冲对应的时间值。接收方向在block_sync模块找到码块边界后,检测lane0的AM位置,并生成脉 冲,用时间计数时钟来釆这个脉冲,记录时间值。First, select a lane of the 100G interface arbitrarily. For example, if you select lane0, the sending direction generates a pulse at the position where the lane0 is inserted into the AM, and records the time value corresponding to the pulse. After receiving the code block boundary in the block_sync module, the receiving direction detects the AM position of lane0 and generates a pulse. The clock is counted by the time counting clock to record the time value.
以1588E2E同步方式为例,Take the 1588E2E synchronization method as an example.
作为Master的装置(即被同步端设备)1588发包模块发送sync(同步)报文,AM检测模块检测到AM时刻的322.265625MHz时间计数器的值(即图中的时间计数值)进行时间戳转化,得到标准时间戳格式,记为T1,添加到sync报文。同时,将AM检测位置到装置出口位置的延时TC1添加到sync报文的CF字段。The device that is the master (that is, the device that is being synchronized) sends a sync (synchronization) message, and the AM detection module detects the value of the time counter of the 322.265625 MHz (ie, the time count value in the figure) at the time of AM, and performs timestamp conversion. Get the standard timestamp format, recorded as T1, added to the sync message. At the same time, the delay TC1 of the AM detection position to the device exit position is added to the CF field of the sync message.
Slave的装置(即同步端设备)接收方向检测到AM,记录AM时刻的时间计数器值并转化成ns值。1588报文识别模块识别出sync报文,记录对应AM的时间戳,为T2,提取CF中的TC1,加本地补偿TC2,记为TC21,从报文中提取T1,从而得到T1、T2和TC21。The Slave device (ie, the sync device) detects the AM in the receive direction, records the time counter value at the AM time, and converts it into an ns value. The 1588 message identification module identifies the sync message, records the timestamp of the corresponding AM, and is T2, extracts the TC1 in the CF, adds the local compensation TC2, records it as TC21, and extracts T1 from the message, thereby obtaining T1, T2, and TC21. .
delayreq报文:Delayreq message:
Slave装置的1588发送模块发送delayreq报文,AM检测模块检测到AM时刻的322.265625MHz时间计数器的值(即图中的时间计数值)进行时间戳转化,得到标准时间戳格式,记为T3,并以序列号seqid为地址存储,将AM检测位置到装置出口位置的延时TC3添加到delayreq报文的CF字段。The 1588 sending module of the Slave device sends a delayeq message, and the AM detecting module detects the value of the 322.265625 MHz time counter at the time of AM (that is, the time count value in the figure) to perform timestamp conversion, and obtains a standard timestamp format, which is recorded as T3, and The serial number seqid is stored as an address, and the delay TC3 of the AM detection location to the device exit location is added to the CF field of the delayeqe message.
Master装置接收方向,AM检测模块检测到AM时刻的322.265625MHz时间计数器的值转化为标准时间戳格式,1588报文识别模块识别出delayreq报文记录T4,提取CF中的TC3,并补偿TC4得TC34,回复delayresp报文给Slave装置。The receiving direction of the master device, the AM detecting module detects that the value of the 322.265625 MHz time counter at the time of AM is converted into a standard timestamp format, the 1588 message identifying module identifies the delayreq message record T4, extracts the TC3 in the CF, and compensates the TC4 for the TC34. , reply the delayresp message to the slave device.
Master装置1588发包模块回复delayresp报文,携带T4和TC34。The Master device 1588 sends a packet module to reply to the delayresp message, carrying T4 and TC34.
Slave装置接收到delayresp报文,提取seqid、T4和TC34,以seqid读取T3,得T3、T4和TC34存储到ram(随机存取存储器)供cpu(中央处理器)读。The Slave device receives the delayresp message, extracts seqid, T4 and TC34, reads T3 with seqid, and stores T3, T4 and TC34 to ram (random access memory) for cpu (central processing) reading.
GE接口之间的时间同步,采用传统方式加补偿的方法,时间计数器用125M时钟,时间调整也是8ns倍数的偏差调整时间计数器值,8ns以下的偏差调整时钟相位。The time synchronization between the GE interfaces adopts the traditional method of adding compensation. The time counter uses 125M clock, the time adjustment is also the deviation adjustment time counter value of 8 ns multiple, and the deviation of 8 ns or less adjusts the clock phase.
本实施示例有两个时间计数系统,两个系统之间需要保持同步,在倒换或向下游装置发布时间时,才能准确。以125M时间系统同步322.265625M时间系统为例,来描述两个时间系统同步的方法,如下:This embodiment has two time counting systems, and the two systems need to be synchronized, and can be accurate when switching or publishing time to downstream devices. Take the 125M time system synchronization 322.265625M time system as an example to describe the two time system synchronization methods, as follows:
首先,生成一个公约数频率的时钟clock_common,频率为1.953125MHz。这个时钟与125MHz时钟和322.265625MHz时钟同源,并且与322.265625MHz的时钟相位对齐。First, generate a common clock frequency clock_common with a frequency of 1.953125MHz. This clock is homologous to the 125 MHz clock and the 322.265625 MHz clock and is phase aligned with the 322.626525 MHz clock.
201、clock_common与322.265625MHz时间系统对齐。201, clock_common and 322.265625MHz time system alignment.
由前述实施例的步骤S360中的式(1),得m的值为165,定义一个信号clk_322_div,初始化为0,322.265625MHz时钟计数到165的倍数减1时,clk_322_div翻转。From the equation (1) in the step S360 of the foregoing embodiment, the value of m is 165, a signal clk_322_div is defined, initialized to 0, and the clock count of 322.265625 MHz is counted to a multiple of 165 minus 1, and clk_322_div is inverted.
检测clk_322_div相对于clock_common上升沿滞后的时间,若小于3纳秒,则认为clock_common与322.265625MHz的时间同步,否则调整clock_common的相位,在clock_common仍与322.265625MHz相位对齐的情况下,使clk_322_div相对于clock_common上升沿滞后的时间小于3ns。Detecting the time that clk_322_div lags with the rising edge of clock_common. If it is less than 3 nanoseconds, it considers clock_common to be synchronized with 322.265625MHz. Otherwise, adjust the phase of clock_common. If clock_common is still aligned with 322.265625MHz, make clk_322_div relative to clock_common. The rise lag time is less than 3 ns.
202、125M时间计数系统与322.265625MHz时间计数系统粗对齐202, 125M time counting system and 322.265625MHz time counting system coarse alignment
通过调整计数器使两个时间计数系统粗对齐。The two time counting systems are coarsely aligned by adjusting the counter.
203、125M时间计数系统与clock_common细对齐。The 203, 125M time counting system is finely aligned with the clock_common.
首先125M的时钟与clock_common对齐。First, the 125M clock is aligned with clock_common.
由前述实施例的步骤S360中的式(2),得m的值为64,定义信号clk_125_div,初始化为0,125MHz的时间计数到64的倍数减1时,clk_125_div翻转。From the equation (2) in the step S360 of the foregoing embodiment, the value of m is 64, the signal clk_125_div is defined, and the initialization is 0. When the time count of 125 MHz is counted to a multiple of 64 minus 1, the clk_125_div is inverted.
检测clk_125_div相对于clock_common上升沿滞后的时间,若小于8纳秒,认为125MHz时间系统与clock_common对齐,否则调整125MHz时间计数系统的计数值,使clk_125_div相对于clock_common上升沿滞后的时间小于8纳秒。The time when the clk_125_div is delayed relative to the rising edge of the clock_common is detected. If it is less than 8 nanoseconds, the 125 MHz time system is considered to be aligned with the clock_common, otherwise the count value of the 125 MHz time counting system is adjusted, so that the clk_125_div is delayed by less than 8 nanoseconds with respect to the rising edge of the clock_common.
实施示例3Implementation example 3
本实施示例与实施示例2类似,同步端设备中的100G接口部分的组成如图7所示,和图6a基本类似,不同之处是不转化时间计数值;GE接口部分的组成如图6b所示。被同步端设备也可以采用图7所示的结构,旁路其中不需要的模块。This embodiment is similar to the implementation example 2. The composition of the 100G interface part in the synchronous device is as shown in FIG. 7 , and is basically similar to FIG. 6 a , except that the time count value is not converted; the composition of the GE interface part is as shown in FIG. 6 b . Show. The device to be synchronized can also adopt the structure shown in FIG. 7 to bypass the unnecessary modules.
本实施示例中,以322.265625MHz时钟为主时钟,125MHz时钟为从时钟;图6b中的offset计算部分可以旁路。如果以125MHz时钟为主时钟的情况,则图7中的offset计算部分可以旁路,图6b中的offset计算部分也连接到图7的时间戳提取/记录部分。In this embodiment, the 322.226525 MHz clock is the main clock, and the 125 MHz clock is the slave clock; the offset calculation portion in FIG. 6b can be bypassed. If the case where the 125 MHz clock is the main clock, the offset calculation portion in Fig. 7 can be bypassed, and the offset calculation portion in Fig. 6b is also connected to the time stamp extraction/recording portion of Fig. 7.
由于实施示例2中,100G接口同步时,时间戳转化损失了一部分精度,而且实现复杂,本实施示例不再进行时间计数值到纳秒的转化。Due to the implementation example 2, when the 100G interface is synchronized, the timestamp conversion loses a part of the precision, and the implementation is complicated. This embodiment does not perform the conversion of the time count value to the nanosecond.
100G接口时间同步时,时间戳的低32bit,即纳秒部分,改为322.265625MHz时钟周期的计数值。高48bit仍为秒部分。When the 100G interface is time synchronized, the lower 32 bits of the time stamp, that is, the nanosecond portion, is changed to the count value of the 322.265625 MHz clock cycle. The high 48bit is still the second part.
本实施例提供一种时钟同步的装置,包括:第一处理器和第一存储器;The embodiment provides a clock synchronization device, including: a first processor and a first memory;
所述第一存储器配置为保存第一时间同步程序;The first memory is configured to save a first time synchronization program;
所述第一处理器配置为执行所述第一时间同步程序,以进行如下操作:The first processor is configured to execute the first time synchronization program to perform the following operations:
根据预定通道上周期性码块的收、发时刻生成时间戳;Generating a timestamp according to the time of receiving and sending the periodic code block on the predetermined channel;
与被同步端设备之间收、发时间信息报文,通过与收、发时间信息报文匹配的周期性码块的时间戳,确定与被同步端设备之间的时间偏差;And receiving and transmitting a time information packet with the device to be synchronized, and determining a time offset between the device and the device to be synchronized by using a timestamp of the periodic code block that matches the received and sent time information message;
根据所确定的时间偏差调整系统时钟。The system clock is adjusted based on the determined time offset.
本实施例的装置可以设置于同步端设备上。The device of this embodiment may be disposed on the synchronization device.
可选地,所述通过与收、发时间信息报文与匹配的周期性码块的时间戳,确定被同步端设备之间的时间偏差可以包括:Optionally, determining the time offset between the devices that are synchronized by the time interval of the received and transmitted time information message and the matched periodic code block may include:
根据T1、T2、T3、T4、TC1、TC2、TC3、TC4确定和所述被同步端设备之间的时间偏差;Determining the time deviation between the synchronized device and the device according to T1, T2, T3, T4, TC1, TC2, TC3, TC4;
其中,T1是所接收的第一时间信息报文在发送时报文头的前一个周期性码块M1的时间戳;T2是所述第一时间信息报文到达本设备时报文头的 前一个周期性码块M2的时间戳;T3是所发送的第二时间信息报文的报文头的前一个周期性码块M3的时间戳;T4是所述第二时间信息报文到达被同步端设备时,报文头的前一个周期性码块M4的时间戳;The T1 is the timestamp of the previous periodic code block M1 of the header of the received first time information message, and T2 is the previous period of the message header when the first time information message arrives at the device. The timestamp of the code block M2; T3 is the timestamp of the previous periodic code block M3 of the header of the transmitted second time information message; T4 is the device that the second time information message arrives at the synchronized end device Time stamp of the previous periodic code block M4 of the message header;
TC1是时间戳T1的记录时刻到周期性码块M1发出被同步端设备的时刻之间的时延;TC2是周期性码块M2进入本设备的时刻到时间戳T2的记录时刻之间的时延;TC3是时间戳T3的记录时刻到周期性码块M3发出本设备的时刻之间的时延;TC4是周期性码块M4进入被同步端设备的时刻到时间戳T4的记录时刻之间的时延。TC1 is the time delay between the recording time of the timestamp T1 and the time when the periodic code block M1 issues the device to be synchronized; TC2 is the time between the time when the periodic code block M2 enters the device and the time of recording the timestamp T2. TC3 is the delay between the time of recording of the timestamp T3 and the time when the periodic code block M3 issues the device; TC4 is between the time when the periodic code block M4 enters the device of the synchronized end to the time of recording of the timestamp T4 Delay.
可选地,所述根据所确定的时间偏差调整系统时钟可以包括:Optionally, the adjusting the system clock according to the determined time offset may include:
根据所述时间偏差调整主时间计数系统;比如但不限于根据所述时间偏差中时钟周期的整数倍的部分,调整同步端设备中主时间计数系统的时间计数器的值,余下部分调整所述主时间计数系统的时钟的相位;Adjusting the main time counting system according to the time deviation; for example, but not limited to, adjusting the value of the time counter of the main time counting system in the synchronous end device according to the part of the clock period in the time interval, and adjusting the value of the time counter of the remaining time device Time counting the phase of the clock of the system;
根据主时间计数系统、从时间计数系统的时钟频率得到公约数,创建以所述公约数作为时钟频率的公约数时钟;According to the main time counting system, the common number is obtained from the clock frequency of the time counting system, and the common law clock with the common number as the clock frequency is created;
将所述公约数时钟与所述主时间计数系统的时钟进行同步,将所述从时间计数系统的时钟与所述公约数时钟进行同步。Synchronizing the commons clock with the clock of the primary time counting system, and synchronizing the clock from the time counting system with the common number clock.
当本实施例的装置设置于同步端设备上时,所述主、从时间计数系统是指同步端设备中的主、从时间计数系统。When the apparatus of this embodiment is disposed on the synchronous end device, the master and slave time counting system refers to the master and slave time counting system in the synchronous end device.
其它实施细节可参见前述实施例。Further implementation details can be found in the previous embodiments.
本实施例提供一种时钟同步的装置,应用于设备中多个时间计数系统之间的同步,所述多个时间计数系统分为主时间计数系统和从时间计数系统;所述装置包括:第二处理器和第二存储器;The embodiment provides a device for clock synchronization, which is applied to synchronization between multiple time counting systems in a device. The plurality of time counting systems are divided into a main time counting system and a slave time counting system; the device includes: a second processor and a second memory;
所述第二存储器配置为保存第二时间同步程序;The second memory is configured to save a second time synchronization program;
所述第二处理器配置为执行所述第二时间同步程序,以进行如下操作:The second processor is configured to execute the second time synchronization program to perform the following operations:
根据所述主时间计数系统、从时间计数系统的时钟频率得到公约数,创建以所述公约数作为时钟频率的公约数时钟;Obtaining a common divisor according to the clock of the time counting system according to the main time counting system, and creating a common-counter clock with the common number as a clock frequency;
将所述公约数时钟与所述主时间计数系统的时钟进行同步,将所述从 时间计数系统的时钟与所述公约数时钟进行同步。Synchronizing the commons clock with the clock of the master time counting system to synchronize the clock of the slave time counting system with the commonsake clock.
本实施例的装置可以设置于同步端设备上。The device of this embodiment may be disposed on the synchronization device.
可选地,所述根据主、从时间计数系统的时钟频率得到公约数前还可以包括:Optionally, the obtaining the common divisor according to the clock frequency of the master and slave time counting systems may further include:
根据预定通道上周期性码块的收、发时刻生成时间戳;Generating a timestamp according to the time of receiving and sending the periodic code block on the predetermined channel;
与被同步端设备之间收、发时间信息报文,通过与收、发时间信息报文匹配的周期性码块的时间戳,确定与被同步端设备之间的时间偏差;And receiving and transmitting a time information packet with the device to be synchronized, and determining a time offset between the device and the device to be synchronized by using a timestamp of the periodic code block that matches the received and sent time information message;
根据所确定的时间偏差调整所述主计数时间系统的时钟;比如但不限于包括根据所述时间偏差中时钟周期的整数倍的部分,调整同步端设备中主时间计数系统的时间计数器的值,余下部分调整所述主时间计数系统的时钟的相位。Adjusting a clock of the primary counting time system according to the determined time offset; for example, but not limited to, adjusting a value of a time counter of the primary time counting system in the synchronous end device according to a portion that is an integer multiple of a clock period in the time offset, The remaining portion adjusts the phase of the clock of the master time counting system.
其它实施细节可实现前述实施例。Other embodiments may implement the foregoing embodiments.
本实施例提供一种时钟同步的装置,如图8所示,包括:This embodiment provides a device for clock synchronization, as shown in FIG. 8, including:
时间戳生成模块61,配置为于根据预定通道上周期性码块的收、发时刻生成时间戳;The timestamp generating module 61 is configured to generate a timestamp according to the receiving and sending time of the periodic code block on the predetermined channel;
确定模块62,配置为与被同步端设备之间收、发时间信息报文,通过与收、发时间信息报文匹配的周期性码块的时间戳,确定与被同步端设备之间的时间偏差;The determining module 62 is configured to receive and send a time information message with the device to be synchronized, and determine the time between the device and the device to be synchronized by using the timestamp of the periodic code block that matches the information of the received and sent time information. deviation;
调整模块63,配置为根据所确定的时间偏差调整系统时钟。The adjustment module 63 is configured to adjust the system clock based on the determined time offset.
本实施例的装置可以设置于同步端设备上。The device of this embodiment may be disposed on the synchronization device.
可选地,所述确定模块通过与收、发时间信息报文匹配的周期性码块的时间戳,确定与被同步端设备之间的时间偏差可以包括:Optionally, the determining, by using the timestamp of the periodic code block that matches the received and sent time information packet, determining the time offset between the device and the synchronized device may include:
所述确定模块根据T1、T2、T3、T4、TC1、TC2、TC3、TC4确定和所述被同步端设备之间的时间偏差;The determining module determines, according to T1, T2, T3, T4, TC1, TC2, TC3, TC4, a time offset between the device and the synchronized device;
其中,T1是所接收的第一时间信息报文在发送时报文头的前一个周期性码块M1的时间戳;T2是所述第一时间信息报文到达本设备时报文头的 前一个周期性码块M2的时间戳;T3是所发送的第二时间信息报文的报文头的前一个周期性码块M3的时间戳;T4是所述第二时间信息报文到达被同步端设备时,报文头的前一个周期性码块M4的时间戳;The T1 is the timestamp of the previous periodic code block M1 of the header of the received first time information message, and T2 is the previous period of the message header when the first time information message arrives at the device. The timestamp of the code block M2; T3 is the timestamp of the previous periodic code block M3 of the header of the transmitted second time information message; T4 is the device that the second time information message arrives at the synchronized end device Time stamp of the previous periodic code block M4 of the message header;
TC1是时间戳T1的记录时刻到周期性码块M1发出被同步端设备的时刻之间的时延;TC2是周期性码块M2进入本设备的时刻到时间戳T2的记录时刻之间的时延;TC3是时间戳T3的记录时刻到周期性码块M3发出本设备的时刻之间的时延;TC4是周期性码块M4进入被同步端设备的时刻到时间戳T4的记录时刻之间的时延。TC1 is the time delay between the recording time of the timestamp T1 and the time when the periodic code block M1 issues the device to be synchronized; TC2 is the time between the time when the periodic code block M2 enters the device and the time of recording the timestamp T2. TC3 is the delay between the time of recording of the timestamp T3 and the time when the periodic code block M3 issues the device; TC4 is between the time when the periodic code block M4 enters the device of the synchronized end to the time of recording of the timestamp T4 Delay.
可选地,所述调整模块根据所确定的时间偏差调整系统时钟可以包括:Optionally, the adjusting module, according to the determined time offset, adjusting the system clock, may include:
所述调整模块根据所述时间偏差调整主时间计数系统,比如但不限于包括根据所述时间偏差中时钟周期的整数倍的部分,调整同步端设备中主时间计数系统的时间计数器的值,余下部分调整所述主时间计数系统的时钟的相位;根据主时间计数系统、从时间计数系统的时钟频率得到公约数,创建以所述公约数作为时钟频率的公约数时钟;将所述公约数时钟与所述主时间计数系统的时钟进行同步,将所述从时间计数系统的时钟与所述公约数时钟进行同步。The adjusting module adjusts the main time counting system according to the time deviation, such as but not limited to including adjusting a value of a time counter of the main time counting system in the synchronous end device according to a part of an integral multiple of a clock period in the time offset, and remaining Partially adjusting the phase of the clock of the main time counting system; obtaining a common divisor according to the clock of the time counting system according to the main time counting system, and creating a common-counter clock with the common number as the clock frequency; Synchronizing with the clock of the master time counting system, the clock from the time counting system is synchronized with the commonsake clock.
当本实施例的装置设置于同步端设备上时,所述主、从时间计数系统是指同步端设备中的主、从时间计数系统。When the apparatus of this embodiment is disposed on the synchronous end device, the master and slave time counting system refers to the master and slave time counting system in the synchronous end device.
其它实施细节可参见前述实施例。Further implementation details can be found in the previous embodiments.
本实施例的一个例子中,时间同步装置设置于同步端设备中,可以包括:In an example of the embodiment, the time synchronization device is disposed in the synchronization device, and may include:
时间信息生成模块,包括多个时间计数器,分别工作在不同频率的本地时钟域下。这些时钟频率与各速率接口对应。The time information generating module includes a plurality of time counters, which are respectively operated under local clock domains of different frequencies. These clock frequencies correspond to each rate interface.
时间戳生成模块,配置为对指定的任意一个lane,检测其对齐码块的位置,记录此时刻的时间戳。注意收发方向记录时间戳必须用同一个lane的对齐码块。The timestamp generating module is configured to detect the position of the aligned code block for any one of the specified lanes, and record the timestamp of the time. Note that the send and receive direction record timestamp must use the same lane alignment block.
确定模块,可以包括报文生成单元、报文解析单元、时钟鉴相单元及时间戳处理单元。其中:The determining module may include a message generating unit, a message parsing unit, a clock phase identifying unit, and a time stamp processing unit. among them:
报文生成单元配置为于生成携带时间信息的报文,将发送方向对齐码块对应的时间戳添加到时间信息报文中。The packet generating unit is configured to generate a packet carrying time information, and add a timestamp corresponding to the sending direction alignment code block to the time information packet.
报文解析单元配置为在接收方向,解析时间信息报文,将其携带的时间戳解析出来。The packet parsing unit is configured to parse the time information packet in the receiving direction and parse the timestamp carried by the packet.
时钟鉴相单元,配置为对并行时钟和系统时钟进行鉴相,得到相位差,使用所述相位差对所生成的时间戳进行补偿。The clock phase detecting unit is configured to phase-detect the parallel clock and the system clock to obtain a phase difference, and use the phase difference to compensate the generated time stamp.
时间戳处理单元,配置为存储报文携带的时间戳和接收方向记录的时间戳,计算时间偏差。The timestamp processing unit is configured to store a timestamp carried in the packet and a timestamp recorded in the receiving direction, and calculate a time offset.
调整模块,用于根据时间偏差,调整主时间计数器的值及主时钟的相位。还可以用于将其他时间计数器的值及时钟的相位与主时间计数系统同步。The adjustment module is configured to adjust the value of the main time counter and the phase of the main clock according to the time deviation. It can also be used to synchronize the values of other time counters and the phase of the clock with the master time counting system.
频率同步模块,配置为同步所述同步端设备同步被同步端的时钟频率。The frequency synchronization module is configured to synchronize the clock frequency of the synchronization end device to be synchronized by the synchronization end device.
本实施例提供一种时钟同步的装置,应用于设备中多个时间计数系统之间的同步,所述多个时间计数系统分为主时间计数系统和从时间计数系统;如图9所示,所述装置包括:The embodiment provides a clock synchronization device, which is applied to synchronization between multiple time counting systems in a device. The multiple time counting systems are divided into a main time counting system and a slave time counting system; as shown in FIG. The device includes:
创建模块71,配置为根据所述主时间计数系统、从时间计数系统的时钟频率得到公约数,创建以所述公约数作为时钟频率的公约数时钟;The creating module 71 is configured to obtain a common number according to the clock of the time counting system according to the main time counting system, and create a common number clock with the common number as a clock frequency;
同步模块72,配置为将所述公约数时钟与所述主时间计数系统的时钟进行同步,将所述从时间计数系统的时钟与所述公约数时钟进行同步。The synchronization module 72 is configured to synchronize the common number clock with the clock of the primary time counting system, and synchronize the clock of the slave time counting system with the common number clock.
本实施例的装置可以设置于同步端设备上。The device of this embodiment may be disposed on the synchronization device.
可选地,所述的装置还可以包括:Optionally, the device may further include:
时间戳生成模块,配置为根据预定通道上周期性码块的收、发时刻生成时间戳;a timestamp generating module, configured to generate a timestamp according to a receiving and sending time of the periodic code block on the predetermined channel;
确定模块,配置为与被同步端设备之间收、发时间信息报文,通过与收、发时间信息报文匹配的周期性码块的时间戳,确定与被同步端设备之间的时间偏差;The determining module is configured to receive and send a time information message with the device to be synchronized, and determine a time offset between the device and the device to be synchronized by using a timestamp of the periodic code block that matches the received and sent time information message. ;
调整模块,配置为根据所确定的时间偏差调整所述主时间计数系统的时钟;比如但不限于包括根据所述时间偏差中时钟周期的整数倍的部分,调整同步端设备中主时间计数系统的时间计数器的值,余下部分调整所述主时间计数系统的时钟的相位。An adjustment module configured to adjust a clock of the primary time counting system according to the determined time offset; for example, but not limited to, including a part of an integer multiple of a clock period in the time offset, and adjusting a primary time counting system in the synchronous end device The value of the time counter, the remainder of which adjusts the phase of the clock of the master time counting system.
其它实施细节可实现前述实施例。Other embodiments may implement the foregoing embodiments.
本实施例一种存储介质,用于存储计算机可执行指令;所述计算机可执行指令在执行时可以实现前述实施例一个或多个实施例提供的所述的时间同步方法,例如,可以实现图1和/或图2所示的方法。The present embodiment is a storage medium for storing computer-executable instructions. The computer-executable instructions may implement the time synchronization method provided by one or more embodiments of the foregoing embodiments, for example, 1 and / or the method shown in Figure 2.
所述计算机存储介质可为非瞬间存储介质,例如,只读存储介质、闪存、光盘、移动硬盘、U盘或磁带等。虽然本公开所揭露的实施方式如上,但所述的内容仅为便于理解本公开而采用的实施方式,并非用以限定本公开。任何本公开所属领域内的技术人员,在不脱离本公开所揭露的精神和范围的前提下,可以在实施的形式及细节上进行任何的修改与变化,但本公开的专利保护范围,仍须以所附的权利要求书所界定的范围为准。The computer storage medium can be a non-transitory storage medium, such as a read-only storage medium, a flash memory, an optical disk, a mobile hard disk, a USB flash drive, or a magnetic tape. The embodiments disclosed in the present disclosure are as described above, but are merely used to facilitate the understanding of the present disclosure, and are not intended to limit the present disclosure. Any modification or variation in the form and details of the implementation may be made by those skilled in the art without departing from the spirit and scope of the disclosure. The scope defined by the appended claims shall prevail.
工业实用性Industrial applicability
本公开实施例提供时钟同步的方法,有效地避免了fifo等引起的不固定时延,提高时间同步精度,具有积极的有益效果;且实现简便,具有可在工业广泛使用的特点。The embodiment of the present disclosure provides a method for clock synchronization, which effectively avoids the unfixed delay caused by fifo and the like, improves the time synchronization precision, has positive beneficial effects, and is simple to implement, and has the characteristics that can be widely used in the industry.

Claims (19)

  1. 一种时钟同步的方法,包括:A method of clock synchronization, comprising:
    同步端设备根据预定通道上周期性码块的收、发时刻生成时间戳;The synchronization end device generates a timestamp according to the time of receiving and sending the periodic code block on the predetermined channel;
    所述同步端设备与被同步端设备之间收、发时间信息报文,通过与收、发时间信息报文匹配的周期性码块的时间戳,确定与被同步端设备之间的时间偏差;And receiving, by the synchronization end device, the time information packet between the device and the device to be synchronized, and determining the time deviation between the device and the device to be synchronized by using the time stamp of the periodic code block that matches the information of the received and sent time information packet ;
    所述同步端设备根据所确定的时间偏差调整系统时钟。The sync device adjusts the system clock according to the determined time offset.
  2. 如权利要求1所述的方法,所述通过与收、发时间信息报文匹配的周期性码块的时间戳,确定与被同步端设备之间的时间偏差前还包括:The method of claim 1, wherein the determining, by the timestamp of the periodic code block that matches the received and transmitted time information message, before determining the time offset from the device being synchronized, further comprises:
    所述同步端设备对接口并行时钟与系统时钟进行鉴相,得到相位差;The synchronization end device performs phase discrimination on the interface parallel clock and the system clock to obtain a phase difference;
    使用所述相位差对所生成的时间戳进行补偿。The generated time stamp is compensated using the phase difference.
  3. 如权利要求1所述的方法,其中,所述与通过收、发时间信息报文匹配的周期性码块的时间戳,确定与被同步端设备之间的时间偏差包括:The method of claim 1, wherein the determining a time offset from the device being synchronized by the time stamp of the periodic code block that matches the received and transmitted time information message comprises:
    根据T1、T2、T3、T4、TC1、TC2、TC3、TC4确定和所述被同步端设备之间的时间偏差;Determining the time deviation between the synchronized device and the device according to T1, T2, T3, T4, TC1, TC2, TC3, TC4;
    其中,T1是所接收的第一时间信息报文在发送时报文头的前一个周期性码块M1的时间戳;T2是所述第一时间信息报文到达本设备时报文头的前一个周期性码块M2的时间戳;T3是所发送的第二时间信息报文的报文头的前一个周期性码块M3的时间戳;T4是所述第二时间信息报文到达被同步端设备时,报文头的前一个周期性码块M4的时间戳;The T1 is the timestamp of the previous periodic code block M1 of the header of the received first time information message, and T2 is the previous period of the message header when the first time information message arrives at the device. The timestamp of the code block M2; T3 is the timestamp of the previous periodic code block M3 of the header of the transmitted second time information message; T4 is the device that the second time information message arrives at the synchronized end device Time stamp of the previous periodic code block M4 of the message header;
    TC1是时间戳T1的记录时刻到周期性码块M1发出被同步端设备的时刻之间的时延;TC2是周期性码块M2进入本设备的时刻到时间戳T2的记录时刻之间的时延;TC3是时间戳T3的记录时刻到周期性码块M3发出本设备的时刻之间的时延;TC4是周期性码块M4进入被同步端设备的时刻到时间戳T4的记录时刻之间的时延。TC1 is the time delay between the recording time of the timestamp T1 and the time when the periodic code block M1 issues the device to be synchronized; TC2 is the time between the time when the periodic code block M2 enters the device and the time of recording the timestamp T2. TC3 is the delay between the time of recording of the timestamp T3 and the time when the periodic code block M3 issues the device; TC4 is between the time when the periodic code block M4 enters the device of the synchronized end to the time of recording of the timestamp T4 Delay.
  4. 如权利要求1所述的方法,其中,所述同步端设备根据所确定的时 间偏差调整系统时钟包括:The method of claim 1 wherein said synchronizing device adjusts a system clock based on said determined time offset comprises:
    所述同步端设备根据所述时间偏差中时钟周期的整数倍的部分,调整所述同步端设备中主时间计数系统中时间计数器的值,余下部分调整所述主时间计数系统中主时钟的相位。The synchronization end device adjusts a value of a time counter in the main time counting system in the synchronization end device according to an integral multiple of a clock period in the time offset, and the remaining portion adjusts a phase of the main clock in the main time counting system .
  5. 如权利要求4所述的方法,其中,所述同步端设备根据所确定的时间偏差调整系统时钟还包括:The method of claim 4, wherein the adjusting the device to adjust the system clock according to the determined time offset further comprises:
    所述同步端设备根据同步端设备中主时间计数系统、从时间计数系统的时钟频率得到公约数,创建以所述公约数作为时钟频率的公约数时钟;The synchronization end device obtains a common number according to the clock time of the time counting system according to the main time counting system in the synchronous end device, and creates a common number clock with the common number as the clock frequency;
    所述同步端设备将所述公约数时钟与所述主时间计数系统的时钟进行同步,将所述从时间计数系统的时钟与所述公约数时钟进行同步。The synchronization end device synchronizes the common number clock with the clock of the main time counting system, and synchronizes the clock of the slave time counting system with the common number clock.
  6. 一种时钟同步的方法,应用于包括多个时间计数系统的设备,所述多个时间计数系统分为主时间计数系统和从时间计数系统;所述方法包括:A method of clock synchronization is applied to a device including a plurality of time counting systems, the plurality of time counting systems being divided into a master time counting system and a slave time counting system; the method comprising:
    根据所述主时间计数系统、从时间计数系统的时钟频率得到公约数,创建以所述公约数作为时钟频率的公约数时钟;Obtaining a common divisor according to the clock of the time counting system according to the main time counting system, and creating a common-counter clock with the common number as a clock frequency;
    将所述公约数时钟与所述主时间计数系统的时钟进行同步,将所述从时间计数系统的时钟与所述公约数时钟进行同步。Synchronizing the commons clock with the clock of the primary time counting system, and synchronizing the clock from the time counting system with the common number clock.
  7. 如权利要求6所述的方法,其中,所述将所述公约数时钟与主时间计数系统的时钟进行同步,将从时间计数系统的时钟与所述公约数时钟进行同步包括:The method of claim 6 wherein said synchronizing said commons-counter clock with a clock of a master time counting system, synchronizing a clock of said time counting system with said common-numbered clock comprises:
    使所述公约数时钟的上升沿对齐计数为m的整数倍时的主时间计数系统的时钟的上升沿,使从时间计数系统的时钟计数为n的整数倍时的上升沿与所述公约数时钟的上升沿对齐;a rising edge of the clock of the main time counting system when the rising edge of the common number clock is aligned to an integer multiple of m, so that the rising edge of the clock counting from the time counting system is an integer multiple of n and the common divisor Align the rising edge of the clock;
    其中,m等于所述主时钟计数系统的时钟频率除以所述公约数;n等于所述从时钟计数系统的时钟频率除以所述公约数。Where m is equal to the clock frequency of the master clock counting system divided by the common divisor; n is equal to the clock frequency of the slave clock counting system divided by the common divisor.
  8. 如权利要求6所述的方法,其中,所述根据主时间计数系统、从时间计数系统的时钟频率得到公约数前还包括:The method of claim 6 wherein said prior to obtaining a common divisor from the clock frequency of the time counting system based on the primary time counting system further comprises:
    根据预定通道上周期性码块的收、发时刻生成时间戳;Generating a timestamp according to the time of receiving and sending the periodic code block on the predetermined channel;
    与被同步端设备之间收、发时间信息报文,通过与收、发时间信息报 文匹配的周期性码块的时间戳,确定与被同步端设备之间的时间偏差;And receiving and transmitting a time information message with the device to be synchronized, and determining a time offset between the device and the device to be synchronized by using a time stamp of the periodic code block that matches the time information message of the receiving and transmitting time;
    根据所确定的时间偏差调整所述主计数时间系统的时钟。The clock of the master count time system is adjusted based on the determined time offset.
  9. 一种时钟同步的装置,包括:第一处理器和第一存储器;A clock synchronization device includes: a first processor and a first memory;
    所述第一存储器配置为保存第一时间同步程序;The first memory is configured to save a first time synchronization program;
    所述第一处理器配置为执行所述第一时间同步程序,以进行如下操作:The first processor is configured to execute the first time synchronization program to perform the following operations:
    根据预定通道上周期性码块的收、发时刻生成时间戳;Generating a timestamp according to the time of receiving and sending the periodic code block on the predetermined channel;
    与被同步端设备之间收、发时间信息报文,通过与收、发时间信息报文匹配的周期性码块的时间戳,确定与被同步端设备之间的时间偏差;And receiving and transmitting a time information packet with the device to be synchronized, and determining a time offset between the device and the device to be synchronized by using a timestamp of the periodic code block that matches the received and sent time information message;
    根据所确定的时间偏差调整系统时钟。The system clock is adjusted based on the determined time offset.
  10. 如权利要求9所述的装置,其中,所述通过与收、发时间信息报文匹配的周期性码块的时间戳,确定与被同步端设备之间的时间偏差包括:The apparatus of claim 9, wherein the determining, by the timestamp of the periodic code block that matches the received and transmitted time information message, determining a time offset from the device being synchronized includes:
    根据T1、T2、T3、T4、TC1、TC2、TC3、TC4确定和所述被同步端设备之间的时间偏差;Determining the time deviation between the synchronized device and the device according to T1, T2, T3, T4, TC1, TC2, TC3, TC4;
    其中,T1是所接收的第一时间信息报文在发送时报文头的前一个周期性码块M1的时间戳;T2是所述第一时间信息报文到达本设备时报文头的前一个周期性码块M2的时间戳;T3是所发送的第二时间信息报文的报文头的前一个周期性码块M3的时间戳;T4是所述第二时间信息报文到达被同步端设备时,报文头的前一个周期性码块M4的时间戳;The T1 is the timestamp of the previous periodic code block M1 of the header of the received first time information message, and T2 is the previous period of the message header when the first time information message arrives at the device. The timestamp of the code block M2; T3 is the timestamp of the previous periodic code block M3 of the header of the transmitted second time information message; T4 is the device that the second time information message arrives at the synchronized end device Time stamp of the previous periodic code block M4 of the message header;
    TC1是时间戳T1的记录时刻到周期性码块M1发出被同步端设备的时刻之间的时延;TC2是周期性码块M2进入本设备的时刻到时间戳T2的记录时刻之间的时延;TC3是时间戳T3的记录时刻到周期性码块M3发出本设备的时刻之间的时延;TC4是周期性码块M4进入被同步端设备的时刻到时间戳T4的记录时刻之间的时延。TC1 is the time delay between the recording time of the timestamp T1 and the time when the periodic code block M1 issues the device to be synchronized; TC2 is the time between the time when the periodic code block M2 enters the device and the time of recording the timestamp T2. TC3 is the delay between the time of recording of the timestamp T3 and the time when the periodic code block M3 issues the device; TC4 is between the time when the periodic code block M4 enters the device of the synchronized end to the time of recording of the timestamp T4 Delay.
  11. 如权利要求9所述的装置,其中,所述根据所确定的时间偏差调整系统时钟包括:The apparatus of claim 9 wherein said adjusting said system clock based on said determined time offset comprises:
    根据所述时间偏差调整主时间计数系统;Adjusting the main time counting system according to the time deviation;
    根据主时间计数系统、从时间计数系统的时钟频率得到公约数,创建 以所述公约数作为时钟频率的公约数时钟;According to the main time counting system, the common number is obtained from the clock frequency of the time counting system, and a common-counter clock with the common number as the clock frequency is created;
    将所述公约数时钟与所述主时间计数系统的时钟进行同步,将所述从时间计数系统的时钟与所述公约数时钟进行同步。Synchronizing the commons clock with the clock of the primary time counting system, and synchronizing the clock from the time counting system with the common number clock.
  12. 一种时钟同步的装置,应用于设备中多个时间计数系统之间的同步,所述多个时间计数系统分为主时间计数系统和从时间计数系统;所述装置包括:第二处理器和第二存储器;A clock synchronization device is applied to synchronization between a plurality of time counting systems in a device, the plurality of time counting systems being divided into a master time counting system and a slave time counting system; the device comprising: a second processor and Second memory
    其中:among them:
    所述第二存储器配置为保存第二时间同步程序;The second memory is configured to save a second time synchronization program;
    所述第二处理器配置为执行所述第二时间同步程序,以进行如下操作:The second processor is configured to execute the second time synchronization program to perform the following operations:
    根据所述主时间计数系统、从时间计数系统的时钟频率得到公约数,创建以所述公约数作为时钟频率的公约数时钟;Obtaining a common divisor according to the clock of the time counting system according to the main time counting system, and creating a common-counter clock with the common number as a clock frequency;
    将所述公约数时钟与所述主时间计数系统的时钟进行同步,将所述从时间计数系统的时钟与所述公约数时钟进行同步。Synchronizing the commons clock with the clock of the primary time counting system, and synchronizing the clock from the time counting system with the common number clock.
  13. 如权利要求12所述的装置,其中,所述根据主、从时间计数系统的时钟频率得到公约数前还包括:The apparatus of claim 12, wherein said obtaining a common divisor based on a clock frequency of the master and slave time counting systems further comprises:
    根据预定通道上周期性码块的收、发时刻生成时间戳;Generating a timestamp according to the time of receiving and sending the periodic code block on the predetermined channel;
    与被同步端设备之间收、发时间信息报文,通过与收、发时间信息报文匹配的周期性码块的时间戳,确定与被同步端设备之间的时间偏差;And receiving and transmitting a time information packet with the device to be synchronized, and determining a time offset between the device and the device to be synchronized by using a timestamp of the periodic code block that matches the received and sent time information message;
    根据所确定的时间偏差调整所述主计数时间系统的时钟。The clock of the master count time system is adjusted based on the determined time offset.
  14. 一种时钟同步的装置,包括:A clock synchronization device includes:
    时间戳生成模块,配置为根据预定通道上周期性码块的收、发时刻生成时间戳;a timestamp generating module, configured to generate a timestamp according to a receiving and sending time of the periodic code block on the predetermined channel;
    确定模块,配置为与被同步端设备之间收、发时间信息报文,通过与收、发时间信息报文匹配的周期性码块的时间戳,确定与被同步端设备之间的时间偏差;The determining module is configured to receive and send a time information message with the device to be synchronized, and determine a time offset between the device and the device to be synchronized by using a timestamp of the periodic code block that matches the received and sent time information message. ;
    调整模块,配置为根据所确定的时间偏差调整系统时钟。The adjustment module is configured to adjust the system clock based on the determined time offset.
  15. 如权利要求14所述的装置,其中,所述确定模块通过与收、发时 间信息报文匹配的周期性码块的时间戳,确定与被同步端设备之间的时间偏差包括:The apparatus of claim 14, wherein the determining module determines the time offset from the device being synchronized by the time stamp of the periodic code block that matches the incoming and outgoing time information message, including:
    所述确定模块根据T1、T2、T3、T4、TC1、TC2、TC3、TC4确定和所述被同步端设备之间的时间偏差;The determining module determines, according to T1, T2, T3, T4, TC1, TC2, TC3, TC4, a time offset between the device and the synchronized device;
    其中,T1是所接收的第一时间信息报文在发送时报文头的前一个周期性码块M1的时间戳;T2是所述第一时间信息报文到达本设备时报文头的前一个周期性码块M2的时间戳;T3是所发送的第二时间信息报文的报文头的前一个周期性码块M3的时间戳;T4是所述第二时间信息报文到达被同步端设备时,报文头的前一个周期性码块M4的时间戳;The T1 is the timestamp of the previous periodic code block M1 of the header of the received first time information message, and T2 is the previous period of the message header when the first time information message arrives at the device. The timestamp of the code block M2; T3 is the timestamp of the previous periodic code block M3 of the header of the transmitted second time information message; T4 is the device that the second time information message arrives at the synchronized end device Time stamp of the previous periodic code block M4 of the message header;
    TC1是时间戳T1的记录时刻到周期性码块M1发出被同步端设备的时刻之间的时延;TC2是周期性码块M2进入本设备的时刻到时间戳T2的记录时刻之间的时延;TC3是时间戳T3的记录时刻到周期性码块M3发出本设备的时刻之间的时延;TC4是周期性码块M4进入被同步端设备的时刻到时间戳T4的记录时刻之间的时延。TC1 is the time delay between the recording time of the timestamp T1 and the time when the periodic code block M1 issues the device to be synchronized; TC2 is the time between the time when the periodic code block M2 enters the device and the time of recording the timestamp T2. TC3 is the delay between the time of recording of the timestamp T3 and the time when the periodic code block M3 issues the device; TC4 is between the time when the periodic code block M4 enters the device of the synchronized end to the time of recording of the timestamp T4 Delay.
  16. 如权利要求14所述的装置,其中,所述调整模块根据所确定的时间偏差调整系统时钟包括:The apparatus of claim 14, wherein the adjusting module adjusts the system clock according to the determined time offset comprises:
    所述调整模块根据所述时间偏差调整主时间计数系统;根据所述主时间计数系统、从时间计数系统的时钟频率得到公约数,创建以所述公约数作为时钟频率的公约数时钟;将所述公约数时钟与所述主时间计数系统的时钟进行同步,将从时间计数系统的时钟与所述公约数时钟进行同步。The adjusting module adjusts the main time counting system according to the time deviation; according to the main time counting system, obtains a common number from the clock frequency of the time counting system, and creates a common-counter clock with the common number as a clock frequency; The convention number clock is synchronized with the clock of the master time counting system to synchronize the clock of the time counting system with the common number clock.
  17. 一种时钟同步的装置,应用于设备中多个时间计数系统之间的同步,所述多个时间计数系统分为主时间计数系统和从时间计数系统;其中,所述装置包括:A clock synchronization apparatus is applied to synchronization between a plurality of time counting systems in a device, the plurality of time counting systems being divided into a master time counting system and a slave time counting system; wherein the apparatus comprises:
    创建模块,配置为根据所述主时间计数系统、从时间计数系统的时钟频率得到公约数,创建以所述公约数作为时钟频率的公约数时钟;Creating a module, configured to obtain a common number according to the clock of the time counting system according to the main time counting system, and create a common-counter clock with the common number as a clock frequency;
    同步模块,配置为将所述公约数时钟与所述主时间计数系统的时钟进行同步,将所述从时间计数系统的时钟与所述公约数时钟进行同步。And a synchronization module configured to synchronize the common number clock with a clock of the primary time counting system, and synchronize the clock of the slave time counting system with the common number clock.
  18. 如权利要求17所述的装置,其中,还包括:The apparatus of claim 17 further comprising:
    时间戳生成模块,配置为根据预定通道上周期性码块的收、发时刻生成时间戳;a timestamp generating module, configured to generate a timestamp according to a receiving and sending time of the periodic code block on the predetermined channel;
    确定模块,配置为与被同步端设备之间收、发时间信息报文,通过与收、发时间信息报文匹配的周期性码块的时间戳,确定与被同步端设备之间的时间偏差;The determining module is configured to receive and send a time information message with the device to be synchronized, and determine a time offset between the device and the device to be synchronized by using a timestamp of the periodic code block that matches the received and sent time information message. ;
    调整模块,配置为根据所确定的时间偏差调整所述主计数时间系统的时钟。An adjustment module configured to adjust a clock of the primary count time system based on the determined time offset.
  19. 一种计算机存储介质,所述计算机存储介质存储有计算机可执行指令;所述计算机可执行指令被执行后,能够实现权利要求1至5或6至8任一项提供的方法。A computer storage medium storing computer executable instructions; the computer executable instructions being executable to implement the method of any one of claims 1 to 5 or 6 to 8.
PCT/CN2018/087150 2017-05-16 2018-05-16 Clock synchronization method and device, and computer storage medium WO2018210277A1 (en)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201710344469.0 2017-05-16
CN201710344469.0A CN108880723B (en) 2017-05-16 2017-05-16 Clock synchronization method and device

Publications (1)

Publication Number Publication Date
WO2018210277A1 true WO2018210277A1 (en) 2018-11-22

Family

ID=64273503

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2018/087150 WO2018210277A1 (en) 2017-05-16 2018-05-16 Clock synchronization method and device, and computer storage medium

Country Status (2)

Country Link
CN (1) CN108880723B (en)
WO (1) WO2018210277A1 (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111385050A (en) * 2018-12-29 2020-07-07 华为技术有限公司 Clock synchronization method, device and storage medium
EP4064589A4 (en) * 2019-11-19 2023-01-11 Sanechips Technology Co., Ltd. Ethernet time synchronization method and apparatus

Families Citing this family (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110224775B (en) * 2018-03-01 2021-10-29 中兴通讯股份有限公司 Method, device and equipment for determining time information
WO2020132834A1 (en) * 2018-12-24 2020-07-02 华为技术有限公司 Method and device for stamping processing
US10824188B2 (en) * 2019-01-14 2020-11-03 Groq, Inc. Multichip timing synchronization circuits and methods
CN111124997B (en) * 2019-12-25 2021-07-23 海光信息技术股份有限公司 Data sending method, data receiving method, data sending device, data receiving device, processor chip and server
CN112104435B (en) * 2020-08-28 2022-08-30 新华三技术有限公司 Clock delay compensation method, logic device and network equipment
CN112235067B (en) * 2020-09-24 2022-03-25 烽火通信科技股份有限公司 Centralized 1588 time synchronization method and time synchronization system
CN113098650B (en) * 2021-03-29 2023-07-25 大连市共进科技有限公司 Time deviation measuring method, apparatus, communication device and readable storage medium
CN114142957B (en) * 2021-11-06 2024-04-26 中国电子科技集团公司第五十四研究所 Remote time-frequency equipment testing method

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1262590A (en) * 1999-01-26 2000-08-09 西门子公司 Device for synchronizing at least one discrete assembly with central assembly
CN101217328A (en) * 2007-12-29 2008-07-09 杭州华三通信技术有限公司 Time synchronization method, system and device
WO2010145284A1 (en) * 2009-06-18 2010-12-23 中兴通讯股份有限公司 Method and system for synchronization
CN105099650A (en) * 2015-08-27 2015-11-25 京信通信系统(中国)有限公司 Synchronization client and synchronization method and system thereof
CN105682216A (en) * 2016-03-23 2016-06-15 中国矿业大学 Time synchronization method suitable for wireless sensor network under complex environment

Family Cites Families (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US9167058B2 (en) * 2013-03-18 2015-10-20 Xilinx, Inc. Timestamp correction in a multi-lane communication link with skew
CN103634096B (en) * 2013-11-27 2016-09-28 华为技术有限公司 A kind of clock synchronizing method and device
US9602271B2 (en) * 2015-06-01 2017-03-21 Globalfoundries Inc. Sub-nanosecond distributed clock synchronization using alignment marker in ethernet IEEE 1588 protocol
CN106341207A (en) * 2015-07-06 2017-01-18 华为技术有限公司 Coding block data flow sending and receiving method, device and system

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1262590A (en) * 1999-01-26 2000-08-09 西门子公司 Device for synchronizing at least one discrete assembly with central assembly
CN101217328A (en) * 2007-12-29 2008-07-09 杭州华三通信技术有限公司 Time synchronization method, system and device
WO2010145284A1 (en) * 2009-06-18 2010-12-23 中兴通讯股份有限公司 Method and system for synchronization
CN105099650A (en) * 2015-08-27 2015-11-25 京信通信系统(中国)有限公司 Synchronization client and synchronization method and system thereof
CN105682216A (en) * 2016-03-23 2016-06-15 中国矿业大学 Time synchronization method suitable for wireless sensor network under complex environment

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111385050A (en) * 2018-12-29 2020-07-07 华为技术有限公司 Clock synchronization method, device and storage medium
CN111385050B (en) * 2018-12-29 2022-11-08 华为技术有限公司 Clock synchronization method, device and storage medium
US11811501B2 (en) 2018-12-29 2023-11-07 Huawei Technologies Co., Ltd. Clock synchronization method and apparatus, and storage medium
EP4064589A4 (en) * 2019-11-19 2023-01-11 Sanechips Technology Co., Ltd. Ethernet time synchronization method and apparatus

Also Published As

Publication number Publication date
CN108880723A (en) 2018-11-23
CN108880723B (en) 2020-12-11

Similar Documents

Publication Publication Date Title
WO2018210277A1 (en) Clock synchronization method and device, and computer storage medium
US20200267669A1 (en) Methods and apparatus for synchronization of media playback within a wireless network
US10104148B2 (en) Nanosecond accuracy under precision time protocol for ethernet by using high accuracy timestamp assist device
US10673565B2 (en) Confirming data accuracy in a distributed control system
WO2014173267A1 (en) Timestamp generating method, device and system
CN110520815B (en) Method and system for accurate time stamping
US7328359B2 (en) Technique to create link determinism
CN108650051B (en) The clock synchronization apparatus and method of general devices at full hardware single step 1588
US20200127752A1 (en) Time synchronization device and time synchronization method
US10038450B1 (en) Circuits for and methods of transmitting data in an integrated circuit
CN113533815B (en) Multi-channel sampling synchronization method based on time stamps
WO2012151808A1 (en) Method and system for improving synchronization precision based on precision time protocol
US20220360350A1 (en) Method and apparatus for acquiring timestamp of data stream, storage medium, and electronic apparatus
WO2021238724A1 (en) Method and apparatus for transmitting timestamp information, and device and storage medium
CN102624382A (en) Clock synchronization method, device and radio frequency chip circuit with same device
WO2020098409A1 (en) Time synchronization method and device, and storage medium
WO2023109147A1 (en) Timestamp pulse synchronization method and apparatus, and electronic device and storage medium
CN111092713B (en) Clock synchronization device and clock synchronization method
CN101719858B (en) Synchronous processing method of bit timing of control area network (CAN) controller
US8675798B1 (en) Systems, circuits, and methods for phase inversion
US8054927B2 (en) Synchronous circuit and method for receiving data
CN101867431A (en) Network clock synchronization method
WO2016134632A1 (en) Data processing system
CN102332975A (en) Method and device for self-adaptively sampling interface
WO2020062225A1 (en) Mac device and time point estimation method

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

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

Country of ref document: EP

Kind code of ref document: A1