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

Time synchronization method and apparatus, and computer device and storage medium Download PDF

Info

Publication number
WO2022227318A1
WO2022227318A1 PCT/CN2021/109497 CN2021109497W WO2022227318A1 WO 2022227318 A1 WO2022227318 A1 WO 2022227318A1 CN 2021109497 W CN2021109497 W CN 2021109497W WO 2022227318 A1 WO2022227318 A1 WO 2022227318A1
Authority
WO
WIPO (PCT)
Prior art keywords
time
node
stamp
synchronization
time stamp
Prior art date
Application number
PCT/CN2021/109497
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 WO2022227318A1 publication Critical patent/WO2022227318A1/en

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04JMULTIPLEX COMMUNICATION
    • H04J3/00Time-division multiplex systems
    • H04J3/02Details
    • H04J3/06Synchronising arrangements
    • H04J3/0635Clock or time synchronisation in a network
    • H04J3/0638Clock or time synchronisation among nodes; Internode synchronisation
    • H04J3/0658Clock or time synchronisation among packet nodes
    • H04J3/0661Clock or time synchronisation among packet nodes using timestamps
    • H04J3/0667Bidirectional timestamps, e.g. NTP or PTP for compensation of clock drift and for compensation of propagation delays

Definitions

  • the present application relates to the field of communication technologies, and in particular, to a time synchronization method, apparatus, computer equipment and storage medium.
  • an FC node or an FC switch is usually selected as a time synchronization server in a high-speed serial transmission bus (FC, Fiber Channel) network, and the other FC nodes are used as time synchronization clients for time synchronization.
  • the time is usually provided to the FC node by sending the time synchronization ELS frame.
  • the time synchronization ELS frame interacts multiple times between the time synchronization server and the time synchronization client, so as to calculate the deviation and link delay between the time synchronization server and the time synchronization client, so as to dynamically analyze the FC nodes. Time compensation can achieve high time synchronization accuracy, which is ns level.
  • a time synchronization method the method is applied to a first time node, comprising:
  • the primitive information includes a first timestamp
  • the first timestamp is the local time of the first time node when the primitive information is sent
  • the reply information is information generated by the second time node according to the primitive information, the reply information includes a second time stamp and a third time stamp, the second time stamp The time stamp is the local time when the second time node receives the primitive information, and the third time stamp is the local time when the second time node sends the second time stamp;
  • the synchronization time of the first time node is determined according to the first time stamp, the second time stamp, the third time stamp and the fourth time stamp.
  • the sending primitive information includes:
  • the primitive information is sent between data frames of the high-speed serial transmission bus according to a preset time interval.
  • the synchronization time of the first time node is determined according to the first time stamp, the second time stamp, the third time stamp and the fourth time stamp, include:
  • a first error between the second time node and the first time node is determined according to the first time stamp, the second time stamp, the third time stamp and the fourth time stamp ;
  • the synchronization time of the first time node is determined.
  • a time synchronization method the method is applied to a second time node, comprising:
  • the local time of the second time node is latched to obtain the target time
  • the local time is corrected to obtain the synchronization time of the second time node.
  • the obtaining of the timing result between two pulse signals to obtain the second timing result includes:
  • the local time is corrected according to the second timing result and the second error to obtain the synchronization time of the second time node, including:
  • the clock cycle of the second time node is corrected to obtain a target clock cycle
  • the local time is corrected by using the target clock period to obtain the synchronization time of the second time node.
  • a time synchronization device the device is applied to a first time node, comprising:
  • a primitive information sending module configured to send primitive information; wherein, the primitive information includes a first time stamp, and the first time stamp is the local time of the first time node when the primitive information is sent;
  • a reply information receiving module configured to receive reply information sent by a second time node; the reply information is information generated by the second time node according to the primitive information, and the reply information includes a second time stamp and a third time stamp.
  • time stamp the second time stamp is the local time when the second time node receives the primitive information
  • the third time stamp is the local time when the second time node sends the second time stamp time
  • a local time determination module configured to acquire the local time of the first time node when the reply information is received, and obtain a fourth time stamp
  • a first time synchronization module configured to determine the synchronization time of the first time node according to the first time stamp, the second time stamp, the third time stamp and the fourth time stamp.
  • a time synchronization device the device is applied to a second time node, comprising:
  • the timing result determination module is used to obtain the timing result between two pulse signals to obtain the second timing result
  • a local time latch module configured to latch the local time of the second time node to obtain the target time when the pulse signal is detected for the second time
  • a second error determination module configured to obtain the second error between the target time and the timing time
  • a second time synchronization module configured to correct the local time according to the second timing result and the second error to obtain the synchronization time of the second time node.
  • a computer device includes a memory and a processor, the memory stores a computer program, and the processor implements the method described in any one of the above embodiments when the processor executes the computer program.
  • the above-mentioned time synchronization method, device, computer equipment and storage medium by sending primitive information; wherein, the primitive information includes a first time stamp, and the first time stamp is the local time of the first time node when the primitive information is sent;
  • the third time stamp is the local time when the second time node sends the second time stamp; the local time of the first time node when the reply message is received is obtained, and the fourth time stamp is obtained; according to the first time stamp, the second time stamp
  • the timestamp, the third timestamp, and the fourth timestamp determine the synchronization time of the first time node. Therefore, the time of the first time node can be synchronized accurately and efficiently according to the primitive information exchange between the first time node and the second time node without occupying
  • FIG. 1 is an application environment diagram of a time synchronization method in an embodiment of the present application.
  • FIG. 2 is a schematic flowchart of a time synchronization method in an embodiment of the present application.
  • FIG. 3 is a schematic diagram of time synchronization sending of primitives in an embodiment of the present application.
  • FIG. 4 is a schematic diagram of primitive time synchronization in an embodiment of the present application.
  • FIG. 5 is a schematic flowchart of an implementation manner of step S400 in an embodiment of the present application.
  • FIG. 6 is a schematic flowchart of a time synchronization method in an embodiment of the present application.
  • FIG. 7 is a schematic flowchart of an implementation manner of step S400 ′ in an embodiment of the present application.
  • FIG. 8 is a schematic flowchart of a time synchronization method in a specific embodiment of the present application.
  • FIG. 9 is an internal structural diagram of a time synchronization module in an embodiment of the present application.
  • FIG. 10 is a structural block diagram of a time synchronization apparatus according to an embodiment of the present application.
  • FIG. 11 is a structural block diagram of a time synchronization apparatus according to an embodiment of the present application.
  • FIG. 12 is an internal structure diagram of a computer device in an embodiment of the application.
  • FIG. 13 is an internal structural diagram of a computer device in an embodiment of the present application.
  • the time synchronization method provided by this application can be applied to the application environment shown in FIG. 1 .
  • the first time node 102 communicates with the second time node 104 through the network.
  • the first time node 102 and the second time node 104 are FC nodes in a high-speed serial transmission bus (FC, Fiber Channel).
  • the first time node 102 may be a time synchronization client, and the second time node 104 may be a time synchronization server.
  • An initialization operation is required during time synchronization, and it is configured as the first time node or the second time node according to the design requirements.
  • the implementation method is realized through the configuration register.
  • a time synchronization method is provided, and the method is applied to the first time node 102 in FIG. 1 as an example for description, including the following steps:
  • Step S100 sending primitive information; wherein, the primitive information includes a first time stamp, and the first time stamp is the local time of the first time node when the primitive information is sent.
  • Step S200 receiving reply information sent by the second time node;
  • the reply information is information generated by the second time node according to the primitive information, the reply information includes a second time stamp and a third time stamp, and the second time stamp is the second time node The local time when the primitive information is received, and the third time stamp is the local time when the second time node sends the second time stamp.
  • Step S300 Obtain the local time of the first time node when the reply information is received, and obtain a fourth time stamp.
  • Step S400 Determine the synchronization time of the first time node according to the first time stamp, the second time stamp, the third time stamp and the fourth time stamp.
  • the primitive generally refers to a program segment composed of several instructions, which is used to realize a specific function, and the control of the computer process is usually completed by the primitive.
  • the primitive information refers to information including the local time of the first time node when the primitive is sent.
  • the first timestamp is the local time of the first time node when the primitive information is sent.
  • the second time stamp is the local time when the second time node receives the primitive information, and the third time stamp is the local time when the second time node sends the second time stamp.
  • the first time node of the time synchronization client sends the primitive information including the first time stamp to the second time node of the time synchronization server to initiate the time synchronization process. After receiving the primitive information at the second time, it generates reply information including the second time stamp and the third time stamp, and returns the reply information to the first time node. After receiving the reply information sent by the second time node, the first time node parses the reply information to obtain the corresponding second time stamp and third time stamp. Next, the first time node obtains the local time of the first time node when the reply information is received, and obtains a fourth time stamp.
  • the time of the first time node is synchronized to obtain the first time stamp.
  • the synchronization time of the time node is synchronized.
  • the first time node and the second time node directly interact through primitives, do not occupy FC frames or FC channels, and can perform time synchronization in time, so that the obtained synchronization time is also more accurate.
  • primitive information is sent; wherein the primitive information includes a first timestamp, and the first timestamp is the local time of the first time node when the primitive information is sent; and the reply information sent by the second time node is received;
  • the reply information is information generated by the second time node according to the primitive information.
  • the reply information includes a second time stamp and a third time stamp.
  • the second time stamp is the local time when the second time node receives the primitive information
  • the third time stamp The local time when the second time stamp is sent for the second time node; the local time of the first time node when the reply message is received is obtained, and the fourth time stamp is obtained; according to the first time stamp, the second time stamp, the third time stamp and the The fourth timestamp determines the synchronization time of the first time node. Therefore, the time of the first time node can be synchronized in time according to the primitive information exchange between the first time node and the second time node without occupying the FC channel.
  • step S100 including:
  • the primitive information is sent between the data frames of the high-speed serial transmission bus.
  • the preset time interval is a time synchronization period set in advance.
  • the first time node continuously sends primitive messages to the second time node according to the time interval, and the accuracy of time synchronization can be improved through multiple interactions.
  • the first time node sends primitive information to the second time node between data frames (FC frames) of the high-speed serial transmission bus according to a preset time interval.
  • Figure 3 is a schematic diagram of primitive time synchronization transmission.
  • the FC protocol stipulates that at least 6 IDLE codes should be spaced between two FC frames.
  • three time primitives SYNx and SYNy are used.
  • SYNz replaces three IDLE codes, and applies the replaced primitive information SYNx, SYNy, SYNz for data transmission, for example, the first time node sends the primitive information to the second time node, or the second time node sends the first time node.
  • Send reply message for example, the first time node sends the primitive information to the second time node, or the second time node sends the first time node.
  • FIG 4 is a schematic diagram of primitive time synchronization. As shown in Figure 4, after three IDLE codes are replaced with three time primitive information SYNx, SYNy, SYNz, the replaced primitive information SYNx, SYNy, SYNz is changed from the first The time node is sent to the second time node.
  • T11 and T21 are the time points when the primitive information is sent twice, which are two first time stamps; T12 and T22 are two second time stamps; T13 and T23 are two third time stamps stamp; T 14 and T 24 are two fourth time stamps.
  • the time interval between T11 and T21 is the preset time interval.
  • the primitive information is continuously sent to the first time node between the data frames of the high-speed serial transmission bus, the FC channel is not occupied, and the time is improved by multiple primitive interactions. Accuracy of synchronization.
  • step S400 it is a schematic flowchart of an implementable implementation manner of step S400, which specifically includes:
  • Step S411 Determine the first error between the second time node and the first time node according to the first time stamp, the second time stamp, the third time stamp and the fourth time stamp.
  • the first error offset 1 between the second time node and the first time node is determined according to formula (1), and the specific formula (1) is:
  • T1 is the first time stamp
  • T2 is the second time stamp
  • T3 is the third time stamp
  • T4 is the fourth time stamp
  • Step S412 Obtain the timing result between the first time stamp and the next first time stamp, obtain the first time stamp, and determine the first time stamp according to the first time stamp, the next first time stamp and the first time stamp. time offset.
  • the first timing result T Count1 is the timing result between the first time stamp T 11 and the next first time stamp T 21 , that is, the time starts at the first time stamp T 11 and starts at the next first time stamp T 21 End the timing, and determine the timing result at this time as the first timing result T Count1 .
  • the second time node waits to receive the first time node reply primitive T_RDY, and if it does not receive the first time node reply primitive T_RDY, it will wait until the first time node The second time node waits to receive the first time node reply primitive T_RDY. At this time, the count value T Count1 between T 11 and T 21 is recorded twice.
  • the first time stamp is the local time of the first time node when the primitive information is sent.
  • Each of the secondary transmission primitive information corresponds to a first time stamp, the first time stamp T 11 and the next first time stamp T 21 .
  • the first time offset ⁇ 1 can be determined.
  • the specific formula (2) is:
  • the first time node when the first time node sends primitive information to the second time node, it is necessary to determine the link status of the serdes interface, and when the serdes link is idle, record the local time, obtain the first timestamp, and send the first time stamp to the second time node. Two time nodes send primitive information.
  • the first time node logic calculates the time offset and link delay between the first time node logic and the second time node logic, and determines the first time offset and the second time offset according to the
  • the synchronization time of a time node can be dynamically corrected in each synchronization cycle, which ensures the high precision of time synchronization.
  • the second time node can not only adjust the deviation from the first time node, but also correct and fine-tune its own frequency according to the two timing cycles of the second time node, so as to achieve the purpose of high-precision primitive time synchronization.
  • Step S413 Determine the second time offset according to the first timestamp, the next first timestamp and the first error.
  • the second time deviation ⁇ 2 is determined, and the specific formula (3) is:
  • Step S420 Determine the synchronization time of the first time node according to the first time offset and the second time offset.
  • the synchronization time ⁇ ' of the first time node is determined according to formula (4), and the specific formula (4) is:
  • is the clock period of 8.000ns. It should be noted that the above description takes 125 MHz as the clock frequency and 8.000 ns as the clock period. In the actual synchronization process, the calculation needs to be performed with the actual clock frequency and clock period.
  • the second time node performs timing with each connected first time node in turn according to the timing cycle, which ensures the validity of time synchronization and one-to-many time synchronization.
  • the completion time is short. Both the first time node and the second time node need to send and receive primitive information once. In extreme cases, a time synchronization primitive is inserted in the gap between the longest frames of the two frames. The completion time is to receive two frames. Maximum FC frame time.
  • a time synchronization method is provided, and the method is applied to the second time node 104 in FIG. 1 as an example for description, including the following steps:
  • step S100' the timing result between two pulse signals is obtained, and the second timing result is obtained.
  • Step S200' when the pulse signal is detected for the second time, the local time of the second time node is latched to obtain the target time.
  • Step S300' acquiring the second error between the target time and the timing time.
  • Step S400' correcting the local time according to the second timing result and the second error to obtain the synchronization time of the second time node.
  • a timing result between two pulse signals is acquired, and a second timing result is obtained.
  • the pulse signal is detected for the second time
  • the local time of the second time node is latched, the target time is obtained, and the second error between the target time and the timing time is determined.
  • the local time of the second time node is corrected to obtain the synchronization time of the second time node.
  • the second timing result is obtained by acquiring the timing result between two pulse signals, and when the pulse signal is detected for the second time, the local time of the second time node is latched to obtain the target time. Obtain the second error between the target time and the timing time. According to the second timing result and the second error, the local time is corrected to obtain the synchronization time of the second time node. Therefore, the local time can be corrected according to the standard timing time, the second error between the local target time and the timing time, and the accuracy of the time synchronization of the first time node is improved.
  • step S100' including:
  • the timing is started; when the pulse signal is detected for the second time, the timing result between the two pulse signals is obtained, and the second timing result is obtained.
  • the first time node count is started. Next, continue to detect the 1PPS pulse signal, and when the rising edge of the 1PPS pulse signal is received for the second time, buffer the current counting result to obtain the second timing result T Count2 , and restart counting to provide a basis for the next cycle of detection.
  • the timing when the pulse signal is detected for the first time, the timing is started, and when the pulse signal is detected for the second time, the timing result between the two pulse signals is obtained, and the second timing result is obtained, which can be used as a follow-up basis.
  • the second timing result provides a basis for correcting the local time and improves the accuracy of the time synchronization of the first time node.
  • step S400 ′ it is a schematic flowchart of an implementable implementation manner of step S400 ′, which specifically includes:
  • Step S410' correcting the clock period of the second time node according to the second timing result and the second error to obtain the target clock period.
  • Step S420' using the target clock period to correct the local time to obtain the synchronization time of the second time node.
  • the target clock period ⁇ f is determined according to formula (5), and the specific formula (5) is:
  • offset 2 is the second error
  • 125MHz is the clock frequency
  • 8.000 is the clock period in ns. It should be noted that the above description takes 125 MHz as the clock frequency and 8.000 ns as the clock period, and in the actual synchronization process, the calculation needs to be performed with the actual clock frequency and clock period.
  • the local time is corrected by using the target clock period, and the synchronization time of the second time node can be obtained.
  • the clock cycle of the second time node is corrected to obtain the target clock cycle; the target clock cycle is used to correct the local time, which improves the synchronization time of the second time node. accuracy.
  • a time synchronization method including a master time node (second time node 104) and a slave time node (first time node 102), respectively Time synchronization with slave time nodes, including the following steps:
  • the time synchronization module initializes the operation, and configures the module as the master time node or the slave time node according to the design requirements, and the implementation method is realized by the configuration register. After initialization, determine whether the current node is the main time node. If it is the master time node, it is divided into two branches: the master time node time synchronization branch and the slave time node time synchronization branch.
  • the frequency offset correction module of the main time node is used to detect whether a 1PPS pulse signal is received. If so, the second error offset 2 between the local time (target time) and the timing time is calculated, and two The second timing result T Count2 between the secondary 1PPS pulse signals is calculated, and the frequency offset between the main time node and the 1PPS pulse signal is calculated according to formula (5) to obtain the target clock period ⁇ f . Finally, the local time of the master time node is corrected according to the target clock cycle ⁇ f , and the synchronization time of the master time node is obtained.
  • the time synchronization branch of the slave time node the action of the master time node timing the slave time node, needs to be explained in conjunction with the action of the slave time node.
  • the time synchronization module initializes the operation and determines that the current node is the slave time node, the slave time node regularly sends the TIME primitive to the link to the master time node.
  • the link status of the serdes interface is judged, and if the serdes link is idle, the local time at which the TIME primitive is sent is recorded from the time node to obtain the first timestamp T 1 .
  • the master time node After receiving the TIME primitive, the master time node records the local time of receiving the TIME primitive, and obtains a second timestamp T 2 .
  • the master time node sends the second time stamp T 2 and the current local time third time stamp T 3 to the slave time node.
  • the master time node After receiving the second time stamp T 2 and the current local time third time stamp T 3 sent by the master time node from the time node, cache the second time stamp T 2 and the current local time third time stamp T 3 , and record Receive the fourth timestamp T4 of the primary time node T2 and the current local time third timestamp T3, and record the first timestamp between the current first timestamp T11 and the next first timestamp T21 The timing result T Count1 .
  • formula (1), formula (2), formula (3) and formula (4) it is determined that the local time of the slave time node is corrected to obtain the synchronization time of the slave time node.
  • Figure 9 is the internal structure diagram of the time synchronization module.
  • a "main time node frequency offset correction module” is added. Deviation compensation, to compensate the clock deviation between the main time node and the external GPS and other timing equipment.
  • the "master-slave node deviation calculation module” and “slave node frequency deviation correction module” are added, and the "master-slave node deviation calculation module” calculates the master-slave node time deviation according to the real-time timing results, and then Compensate for slave node time.
  • the "slave node frequency deviation correction module” calculates the frequency deviation between the master and slave nodes according to the synchronization messages sent by the master node at two adjacent times, and completes the deviation correction for the frequency of the slave nodes.
  • the above-mentioned embodiment does not occupy the bandwidth of the FC channel, and can achieve high-precision time synchronization, so that one master node can simultaneously perform high-precision time synchronization on multiple slave nodes.
  • FIGS. 1-9 are shown in sequence according to the arrows, these steps are not necessarily executed in the sequence shown by the arrows. Unless explicitly stated herein, the execution of these steps is not strictly limited to the order, and these steps may be performed in other orders. Moreover, at least a part of the steps in FIGS. 1-9 may include multiple steps or multiple stages. These steps or stages are not necessarily executed and completed at the same time, but may be executed at different times. The execution of these steps or stages The order is also not necessarily sequential, but may be performed alternately or alternately with other steps or at least a portion of the steps or phases within the other steps.
  • a time synchronization apparatus including: a primitive information sending module 101, a reply information receiving module 102, a local time determination module 103 and a first time synchronization module 104, wherein:
  • the primitive information sending module 101 is used for sending primitive information; wherein, the primitive information includes a first time stamp, and the first time stamp is the local time of the first time node when the primitive information is sent;
  • the reply information receiving module 102 is configured to receive reply information sent by the second time node;
  • the reply information is information generated by the second time node according to the primitive information, and the reply information includes a second time stamp and a third time stamp, and the second time stamp is the local time when the second time node receives the primitive information, and the third time stamp is the local time when the second time node sends the second time stamp;
  • a local time determination module 103 configured to obtain the local time of the first time node when the reply message is received, and obtain a fourth time stamp;
  • the first time synchronization module 104 is configured to determine the synchronization time of the first time node according to the first time stamp, the second time stamp, the third time stamp and the fourth time stamp.
  • the primitive information sending module 101 is further configured to: send primitive information between data frames of the high-speed serial transmission bus according to a preset time interval.
  • the first time synchronization module 104 is further configured to: determine the relationship between the second time node and the first time node according to the first time stamp, the second time stamp, the third time stamp and the fourth time stamp obtain the timing result between the first timestamp and the next first timestamp, obtain the first timing result, and determine according to the first timestamp, the next first timestamp and the first timing result determine the first time offset; determine the second time offset according to the first timestamp, the next first timestamp and the first error; determine the synchronization time of the first time node according to the first time offset and the second time offset .
  • a time synchronization apparatus including: a timing result determination module 111 , a local time latch module 112 , a second error determination module 113 and a second time synchronization module 114 , wherein :
  • the timing result determination module 111 is used to obtain the timing result between two pulse signals, and obtain the second timing result;
  • the local time latch module 112 is configured to latch the local time of the second time node to obtain the target time when the pulse signal is detected for the second time;
  • the second error determination module 113 is configured to obtain the second error between the target time and the timing time;
  • the second time synchronization module 114 is configured to correct the local time according to the second timing result and the second error to obtain the synchronization time of the second time node.
  • the timing result determination module 111 is further configured to: start timing when the pulse signal is detected for the first time; acquire the timing result between the two pulse signals when the pulse signal is detected for the second time, Get the second timing result.
  • the second time synchronization module 114 is further configured to: correct the clock cycle of the second time node according to the second timing result and the second error to obtain the target clock cycle; use the target clock cycle to compare the local time Correction is made to obtain the synchronization time of the second time node.
  • Each module in the above-mentioned time synchronization apparatus may be implemented in whole or in part by software, hardware and combinations thereof.
  • the above-mentioned modules can be embedded in or independent of the processor in the computer equipment in the form of hardware, or can be stored in the memory in the computer equipment in the form of software, so that the processor calls and executes the corresponding operations of the above-mentioned various modules.
  • a computer device is provided, and the computer device may be a terminal, applied to the first time node, and its internal structure diagram may be as shown in FIG. 12 .
  • the computer equipment includes a processor, memory, a communication interface, a display screen, and an input device connected by a system bus. Among them, the processor of the computer device is used to provide computing and control capabilities.
  • the memory of the computer device includes a non-volatile storage medium, an internal memory.
  • the nonvolatile storage medium stores an operating system and a computer program.
  • the internal memory provides an environment for the execution of the operating system and computer programs in the non-volatile storage medium.
  • the communication interface of the computer device is used for wired or wireless communication with an external terminal, and the wireless communication can be realized by WIFI, operator network, NFC (Near Field Communication) or other technologies.
  • the computer program when executed by the processor, implements a time synchronization method.
  • the display screen of the computer equipment may be a liquid crystal display screen or an electronic ink display screen, and the input device of the computer equipment may be a touch layer covered on the display screen, or a button, a trackball or a touchpad set on the shell of the computer equipment , or an external keyboard, trackpad, or mouse.
  • a computer device is provided, and the computer device may be a server, applied to the second time node, and its internal structure diagram may be as shown in FIG. 13 .
  • the computer device includes a processor, memory, and a network interface connected by a system bus. Among them, the processor of the computer device is used to provide computing and control capabilities.
  • the memory of the computer device includes a non-volatile storage medium, an internal memory.
  • the nonvolatile storage medium stores an operating system, a computer program, and a database.
  • the internal memory provides an environment for the execution of the operating system and computer programs in the non-volatile storage medium.
  • the computer device's database is used to store time synchronization data.
  • the network interface of the computer device is used to communicate with an external terminal through a network connection.
  • the computer program when executed by the processor, implements a time synchronization method.
  • FIG. 12 and FIG. 13 are only block diagrams of partial structures related to the solution of the present application, and do not constitute a limitation on the computer equipment to which the solution of the present application is applied.
  • a computer device may include more or fewer components than those shown in the figures, or combine certain components, or have a different arrangement of components.
  • a computer device including a memory and a processor, a computer program is stored in the memory, and the processor implements the following steps when executing the computer program:
  • the primitive information includes a first timestamp
  • the first timestamp is the local time of the first time node when the primitive information is sent
  • the reply information is the information generated by the second time node according to the primitive information, the reply information includes the second time stamp and the third time stamp, and the second time stamp is the primitive received by the second time node The local time when the information is sent, and the third time stamp is the local time when the second time node sends the second time stamp;
  • the synchronization time of the first time node is determined according to the first time stamp, the second time stamp, the third time stamp and the fourth time stamp.
  • the processor further implements the following steps when executing the computer program: sending primitive information between data frames of the high-speed serial transmission bus according to a preset time interval.
  • the processor executes the computer program, the following steps are further implemented: according to the first time stamp, the second time stamp, the third time stamp and the fourth time stamp, determining the difference between the second time node and the first time node obtain the timing result between the first timestamp and the next first timestamp, obtain the first timing result, and determine according to the first timestamp, the next first timestamp and the first timing result determine the first time offset; determine the second time offset according to the first timestamp, the next first timestamp and the first error; determine the synchronization time of the first time node according to the first time offset and the second time offset .
  • a computer device including a memory and a processor, a computer program is stored in the memory, and the processor implements the following steps when executing the computer program:
  • the local time of the second time node is latched to obtain the target time
  • the local time is corrected to obtain the synchronization time of the second time node.
  • the processor executes the computer program, the following steps are further implemented: when the pulse signal is detected for the first time, start timing; when the pulse signal is detected for the second time, obtain the timing result between the two pulse signals , to get the second timing result.
  • the processor further implements the following steps when executing the computer program: correcting the clock cycle of the second time node according to the second timing result and the second error to obtain a target clock cycle; using the target clock cycle to compare the local time Correction is made to obtain the synchronization time of the second time node.
  • a computer-readable storage medium on which a computer program is stored, and when the computer program is executed by a processor, the following steps are implemented:
  • the primitive information includes a first timestamp
  • the first timestamp is the local time of the first time node when the primitive information is sent
  • the reply information is the information generated by the second time node according to the primitive information, the reply information includes the second time stamp and the third time stamp, and the second time stamp is the primitive received by the second time node The local time when the information is sent, and the third time stamp is the local time when the second time node sends the second time stamp;
  • the synchronization time of the first time node is determined according to the first time stamp, the second time stamp, the third time stamp and the fourth time stamp.
  • the computer program further implements the following steps when executed by the processor: sending primitive information between data frames of the high-speed serial transmission bus according to preset time intervals.
  • the following steps are further implemented: determining the second time node and the first time node according to the first time stamp, the second time stamp, the third time stamp and the fourth time stamp The first error between; obtain the timing result between the first timestamp and the next first timestamp, obtain the first timing result, and according to the first timestamp, the next first timestamp and the first timing result, Determine the first time offset; determine the second time offset according to the first timestamp, the next first timestamp and the first error; determine the synchronization of the first time node according to the first time offset and the second time offset time.
  • a computer-readable storage medium on which a computer program is stored, and when the computer program is executed by a processor, the following steps are implemented:
  • the local time of the second time node is latched to obtain the target time
  • the local time is corrected to obtain the synchronization time of the second time node.
  • the following steps are further implemented: when the pulse signal is detected for the first time, start timing; when the pulse signal is detected for the second time, obtain the timing between two pulse signals As a result, the second timing result is obtained.
  • the following steps are further implemented: correcting the clock cycle of the second time node according to the second timing result and the second error to obtain the target clock cycle; The time is corrected to obtain the synchronization time of the second time node.
  • Non-volatile memory may include read-only memory (Read-Only Memory, ROM), magnetic tape, floppy disk, flash memory, or optical memory, and the like.
  • Volatile memory may include random access memory (RAM) or external cache memory.
  • the RAM may be in various forms, such as Static Random Access Memory (SRAM) or Dynamic Random Access Memory (DRAM).

Landscapes

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

Abstract

The present application relates to a time synchronization method and apparatus, and a computer device and a storage medium. The method comprises: sending primitive information, wherein the primitive information comprises a first timestamp, and the first timestamp is the local time of a first time node when the primitive information is sent; receiving reply information, which is sent by a second time node, wherein the reply information comprises a second timestamp and a third timestamp, the second timestamp is the local time when the second time node receives the primitive information, and the third timestamp is the local time when the second time node sends the second timestamp; acquiring the local time of the first time node when the reply information is received, so as to obtain a fourth timestamp; and determining a synchronization time of the first time node according to the first timestamp, the second timestamp, the third timestamp and the fourth timestamp. Therefore, according to primitive information exchange between a first time node and a second time node, the time of the first time node can be synchronized in a timely, accurate and efficient manner.

Description

时间同步方法、装置、计算机设备和存储介质Time synchronization method, apparatus, computer equipment and storage medium
相关申请Related applications
本申请要求2021年04月30日申请的,申请号为202110485780.3,名称为“时间同步方法、装置、计算机设备和存储介质”的中国专利申请的优先权,在此将其全文引入作为参考。This application claims the priority of the Chinese patent application filed on April 30, 2021, the application number is 202110485780.3, and the title is "Time Synchronization Method, Apparatus, Computer Equipment and Storage Medium", which is hereby incorporated by reference in its entirety.
技术领域technical field
本申请涉及通信技术领域,特别是涉及一种时间同步方法、装置、计算机设备和存储介质。The present application relates to the field of communication technologies, and in particular, to a time synchronization method, apparatus, computer equipment and storage medium.
背景技术Background technique
随着通信技术的发展,出现了对光纤交换机进行时间同步的技术。传统技术中,通常是在高速串行传输总线(FC,Fiber Channel)网络中选择一个FC节点或者FC交换机作为时间同步服务器,其余FC节点作为时间同步客户端进行时间同步。传统方式中,为获得高精度的同步时间,通常是通过发送时间同步ELS帧向FC节点进行授时。具体为,时间同步ELS帧在时间同步服务器与时间同步客户端之间进行多次交互,从而计算出时间同步服务器与时间同步客户端之间的偏差和链路延迟,从而动态的对FC节点进行时间补偿,能够达到很高的时间同步精度,为ns级。With the development of communication technology, a technology for time synchronization of optical fiber switches has appeared. In the traditional technology, an FC node or an FC switch is usually selected as a time synchronization server in a high-speed serial transmission bus (FC, Fiber Channel) network, and the other FC nodes are used as time synchronization clients for time synchronization. In the traditional way, in order to obtain high-precision synchronization time, the time is usually provided to the FC node by sending the time synchronization ELS frame. Specifically, the time synchronization ELS frame interacts multiple times between the time synchronization server and the time synchronization client, so as to calculate the deviation and link delay between the time synchronization server and the time synchronization client, so as to dynamically analyze the FC nodes. Time compensation can achieve high time synchronization accuracy, which is ns level.
然而,由于ELS帧时间同步方式需要占用FC总线带宽,在FC帧交换占用FC通道期间,ELS帧同步方式无法发起,短期内会造成服务器与客户端二者之间的时间偏差增大。因此,如何准确高效地实现时间同步,是一项亟待解决的问题。However, since the ELS frame time synchronization method needs to occupy the FC bus bandwidth, when the FC frame exchange occupies the FC channel, the ELS frame synchronization method cannot be initiated, which will increase the time deviation between the server and the client in the short term. Therefore, how to achieve time synchronization accurately and efficiently is an urgent problem to be solved.
发明内容SUMMARY OF THE INVENTION
基于此,有必要针对上述技术问题,提供一种能够准确高效地实现时间同步的时间同步方法、装置、计算机设备和存储介质。Based on this, it is necessary to provide a time synchronization method, device, computer equipment and storage medium that can accurately and efficiently realize time synchronization in view of the above technical problems.
一种时间同步方法,所述方法应用于第一时间节点,包括:A time synchronization method, the method is applied to a first time node, comprising:
发送原语信息;其中,所述原语信息包括第一时间戳,所述第一时间戳为发送所述原语信息时所述第一时间节点的本地时间;Sending primitive information; wherein, the primitive information includes a first timestamp, and the first timestamp is the local time of the first time node when the primitive information is sent;
接收第二时间节点发送的回复信息;所述回复信息为所述第二时间节点根据所述原语 信息生成的信息,所述回复信息包括第二时间戳和第三时间戳,所述第二时间戳为所述第二时间节点接收所述原语信息时的本地时间,所述第三时间戳为所述第二时间节点发送所述第二时间戳时的本地时间;Receive reply information sent by a second time node; the reply information is information generated by the second time node according to the primitive information, the reply information includes a second time stamp and a third time stamp, the second time stamp The time stamp is the local time when the second time node receives the primitive information, and the third time stamp is the local time when the second time node sends the second time stamp;
获取接收所述回复信息时所述第一时间节点的本地时间,得到第四时间戳;obtaining the local time of the first time node when receiving the reply information, and obtaining a fourth timestamp;
根据所述第一时间戳、所述第二时间戳、所述第三时间戳和所述第四时间戳,确定出所述第一时间节点的同步时间。The synchronization time of the first time node is determined according to the first time stamp, the second time stamp, the third time stamp and the fourth time stamp.
在其中一个实施例中,所述发送原语信息,包括:In one embodiment, the sending primitive information includes:
按照预设的时间间隔,在高速串行传输总线的数据帧之间发送所述原语信息。The primitive information is sent between data frames of the high-speed serial transmission bus according to a preset time interval.
在其中一个实施例中,所述根据所述第一时间戳、所述第二时间戳、所述第三时间戳和所述第四时间戳,确定出所述第一时间节点的同步时间,包括:In one embodiment, the synchronization time of the first time node is determined according to the first time stamp, the second time stamp, the third time stamp and the fourth time stamp, include:
根据所述第一时间戳、所述第二时间戳、所述第三时间戳和所述第四时间戳,确定出所述第二时间节点和所述第一时间节点之间的第一误差;A first error between the second time node and the first time node is determined according to the first time stamp, the second time stamp, the third time stamp and the fourth time stamp ;
获取所述第一时间戳与下一第一时间戳之间的计时结果,得到第一计时结果,并根据所述第一时间戳、所述下一第一时间戳和所述第一计时结果,确定出第一时间偏差;Obtain the timing result between the first timestamp and the next first timestamp, obtain the first timing result, and obtain the first timing result according to the first timestamp, the next first timestamp and the first timing result , determine the first time deviation;
根据所述第一时间戳、所述下一第一时间戳和所述第一误差,确定出第二时间偏差;determining a second time offset according to the first time stamp, the next first time stamp and the first error;
根据所述第一时间偏差和所述第二时间偏差,确定出所述第一时间节点的同步时间。According to the first time offset and the second time offset, the synchronization time of the first time node is determined.
一种时间同步方法,所述方法应用于第二时间节点,包括:A time synchronization method, the method is applied to a second time node, comprising:
获取两次脉冲信号之间的计时结果,得到第二计时结果;Obtain the timing result between two pulse signals, and obtain the second timing result;
在第二次检测到脉冲信号时,锁存所述第二时间节点的本地时间,得到目标时间;When the pulse signal is detected for the second time, the local time of the second time node is latched to obtain the target time;
获取所述目标时间与授时时间之间的第二误差;obtaining the second error between the target time and the timing time;
根据所述第二计时结果和所述第二误差,对所述本地时间进行修正,得到所述第二时间节点的同步时间。According to the second timing result and the second error, the local time is corrected to obtain the synchronization time of the second time node.
在其中一个实施例中,所述获取两次脉冲信号之间的计时结果,得到第二计时结果,包括:In one embodiment, the obtaining of the timing result between two pulse signals to obtain the second timing result includes:
在第一次检测到脉冲信号时,开始计时;When the pulse signal is detected for the first time, start timing;
在第二次检测到脉冲信号时,获取两次脉冲信号之间的计时结果,得到所述第二计时结果。When the pulse signal is detected for the second time, the timing result between the two pulse signals is obtained, and the second timing result is obtained.
在其中一个实施例中,所述根据所述第二计时结果和所述第二误差,对所述本地时间进行修正,得到所述第二时间节点的同步时间,包括:In one embodiment, the local time is corrected according to the second timing result and the second error to obtain the synchronization time of the second time node, including:
根据所述第二计时结果和所述第二误差,对所述第二时间节点的时钟周期进行修正,得到目标时钟周期;According to the second timing result and the second error, the clock cycle of the second time node is corrected to obtain a target clock cycle;
采用所述目标时钟周期对所述本地时间进行修正,得到所述第二时间节点的同步时间。The local time is corrected by using the target clock period to obtain the synchronization time of the second time node.
一种时间同步装置,所述装置应用于第一时间节点,包括:A time synchronization device, the device is applied to a first time node, comprising:
原语信息发送模块,用于发送原语信息;其中,所述原语信息包括第一时间戳,所述第一时间戳为发送所述原语信息时所述第一时间节点的本地时间;a primitive information sending module, configured to send primitive information; wherein, the primitive information includes a first time stamp, and the first time stamp is the local time of the first time node when the primitive information is sent;
回复信息接收模块,用于接收第二时间节点发送的回复信息;所述回复信息为所述第二时间节点根据所述原语信息生成的信息,所述回复信息包括第二时间戳和第三时间戳,所述第二时间戳为所述第二时间节点接收所述原语信息时的本地时间,所述第三时间戳为所述第二时间节点发送所述第二时间戳时的本地时间;A reply information receiving module, configured to receive reply information sent by a second time node; the reply information is information generated by the second time node according to the primitive information, and the reply information includes a second time stamp and a third time stamp. time stamp, the second time stamp is the local time when the second time node receives the primitive information, and the third time stamp is the local time when the second time node sends the second time stamp time;
本地时间确定模块,用于获取接收所述回复信息时所述第一时间节点的本地时间,得到第四时间戳;a local time determination module, configured to acquire the local time of the first time node when the reply information is received, and obtain a fourth time stamp;
第一时间同步模块,用于根据所述第一时间戳、所述第二时间戳、所述第三时间戳和所述第四时间戳,确定出所述第一时间节点的同步时间。A first time synchronization module, configured to determine the synchronization time of the first time node according to the first time stamp, the second time stamp, the third time stamp and the fourth time stamp.
一种时间同步装置,所述装置应用于第二时间节点,包括:A time synchronization device, the device is applied to a second time node, comprising:
计时结果确定模块,用于获取两次脉冲信号之间的计时结果,得到第二计时结果;The timing result determination module is used to obtain the timing result between two pulse signals to obtain the second timing result;
本地时间锁存模块,用于在第二次检测到脉冲信号时,锁存所述第二时间节点的本地时间,得到目标时间;a local time latch module, configured to latch the local time of the second time node to obtain the target time when the pulse signal is detected for the second time;
第二误差确定模块,用于获取所述目标时间与授时时间之间的第二误差;a second error determination module, configured to obtain the second error between the target time and the timing time;
第二时间同步模块,用于根据所述第二计时结果和所述第二误差,对所述本地时间进行修正,得到所述第二时间节点的同步时间。A second time synchronization module, configured to correct the local time according to the second timing result and the second error to obtain the synchronization time of the second time node.
一种计算机设备,包括存储器和处理器,所述存储器存储有计算机程序,所述处理器执行所述计算机程序时实现上述任一项实施例所述的方法。A computer device includes a memory and a processor, the memory stores a computer program, and the processor implements the method described in any one of the above embodiments when the processor executes the computer program.
一种计算机可读存储介质,其上存储有计算机程序,所述计算机程序被处理器执行时实现上述任一项实施例所述的方法。A computer-readable storage medium on which a computer program is stored, and when the computer program is executed by a processor, implements the method described in any one of the foregoing embodiments.
上述时间同步方法、装置、计算机设备和存储介质,通过发送原语信息;其中,原语信息包括第一时间戳,第一时间戳为发送原语信息时第一时间节点的本地时间;接收第二时间节点发送的回复信息;回复信息为第二时间节点根据原语信息生成的信息,回复信息包括第二时间戳和第三时间戳,第二时间戳为第二时间节点接收原语信息时的本地时间,第三时间戳为第二时间节点发送第二时间戳时的本地时间;获取接收回复信息时第一时间节点的本地时间,得到第四时间戳;根据第一时间戳、第二时间戳、第三时间戳和第四时间戳,确定出第一时间节点的同步时间。从而无需占用FC通道,根据第一时间节点与第 二时间节点之间的原语信息交互,能及而又准确高效地对第一时间节点的时间进行同步。The above-mentioned time synchronization method, device, computer equipment and storage medium, by sending primitive information; wherein, the primitive information includes a first time stamp, and the first time stamp is the local time of the first time node when the primitive information is sent; The reply information sent by the second time node; the reply information is the information generated by the second time node according to the primitive information, the reply information includes the second time stamp and the third time stamp, and the second time stamp is when the second time node receives the primitive information The third time stamp is the local time when the second time node sends the second time stamp; the local time of the first time node when the reply message is received is obtained, and the fourth time stamp is obtained; according to the first time stamp, the second time stamp The timestamp, the third timestamp, and the fourth timestamp determine the synchronization time of the first time node. Therefore, the time of the first time node can be synchronized accurately and efficiently according to the primitive information exchange between the first time node and the second time node without occupying the FC channel.
附图说明Description of drawings
图1为本申请一个实施例中时间同步方法的应用环境图。FIG. 1 is an application environment diagram of a time synchronization method in an embodiment of the present application.
图2为本申请一个实施例中时间同步方法的流程示意图。FIG. 2 is a schematic flowchart of a time synchronization method in an embodiment of the present application.
图3为本申请一个实施例中原语时间同步发送示意图。FIG. 3 is a schematic diagram of time synchronization sending of primitives in an embodiment of the present application.
图4为本申请一个实施例中原语时间同步示意图。FIG. 4 is a schematic diagram of primitive time synchronization in an embodiment of the present application.
图5为本申请一个实施例中步骤S400的一种可实施方式的流程示意图。FIG. 5 is a schematic flowchart of an implementation manner of step S400 in an embodiment of the present application.
图6为本申请一个实施例中时间同步方法的流程示意图。FIG. 6 is a schematic flowchart of a time synchronization method in an embodiment of the present application.
图7为本申请一个实施例中步骤S400'的一种可实施方式的流程示意图。FIG. 7 is a schematic flowchart of an implementation manner of step S400 ′ in an embodiment of the present application.
图8为本申请一个具体实施例中时间同步方法的流程示意图。FIG. 8 is a schematic flowchart of a time synchronization method in a specific embodiment of the present application.
图9为本申请一个实施例中时间同步模块内部结构图。FIG. 9 is an internal structural diagram of a time synchronization module in an embodiment of the present application.
图10为本申请一个实施例中时间同步装置的结构框图。FIG. 10 is a structural block diagram of a time synchronization apparatus according to an embodiment of the present application.
图11为本申请一个实施例中时间同步装置的结构框图。FIG. 11 is a structural block diagram of a time synchronization apparatus according to an embodiment of the present application.
图12为本申请一个实施例中计算机设备的内部结构图。FIG. 12 is an internal structure diagram of a computer device in an embodiment of the application.
图13为本申请一个实施例中计算机设备的内部结构图。FIG. 13 is an internal structural diagram of a computer device in an embodiment of the present application.
具体实施方式Detailed ways
为了使本申请的目的、技术方案及优点更加清楚明白,以下结合附图及实施例,对本申请进行进一步详细说明。应当理解,此处描述的具体实施例仅仅用以解释本申请,并不用于限定本申请。In order to make the purpose, technical solutions and advantages of the present application more clearly understood, the present application will be described in further detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application, but not to limit the present application.
本申请提供的时间同步方法,可以应用于如图1所示的应用环境中。其中,第一时间节点102通过网络与第二时间节点104进行通信。第一时间节点102和第二时间节点104为高速串行传输总线(FC,Fiber Channel)中的FC节点。其中,第一时间节点102可以为时间同步客户端,第二时间节点104可以为时间同步服务器。时间同步时需要初始化操作,根据设计需求配置为第一时间节点或者第二时间节点,实现方式通过配置寄存器实现。The time synchronization method provided by this application can be applied to the application environment shown in FIG. 1 . The first time node 102 communicates with the second time node 104 through the network. The first time node 102 and the second time node 104 are FC nodes in a high-speed serial transmission bus (FC, Fiber Channel). The first time node 102 may be a time synchronization client, and the second time node 104 may be a time synchronization server. An initialization operation is required during time synchronization, and it is configured as the first time node or the second time node according to the design requirements. The implementation method is realized through the configuration register.
在一个实施例中,如图2所示,提供了一种时间同步方法,以该方法应用于图1中的第一时间节点102为例进行说明,包括以下步骤:In one embodiment, as shown in FIG. 2 , a time synchronization method is provided, and the method is applied to the first time node 102 in FIG. 1 as an example for description, including the following steps:
步骤S100,发送原语信息;其中,原语信息包括第一时间戳,第一时间戳为发送原语信息时第一时间节点的本地时间。Step S100, sending primitive information; wherein, the primitive information includes a first time stamp, and the first time stamp is the local time of the first time node when the primitive information is sent.
步骤S200,接收第二时间节点发送的回复信息;回复信息为第二时间节点根据原语信 息生成的信息,回复信息包括第二时间戳和第三时间戳,第二时间戳为第二时间节点接收原语信息时的本地时间,第三时间戳为第二时间节点发送第二时间戳时的本地时间。Step S200, receiving reply information sent by the second time node; the reply information is information generated by the second time node according to the primitive information, the reply information includes a second time stamp and a third time stamp, and the second time stamp is the second time node The local time when the primitive information is received, and the third time stamp is the local time when the second time node sends the second time stamp.
步骤S300,获取接收回复信息时第一时间节点的本地时间,得到第四时间戳。Step S300: Obtain the local time of the first time node when the reply information is received, and obtain a fourth time stamp.
步骤S400,根据第一时间戳、第二时间戳、第三时间戳和第四时间戳,确定出第一时间节点的同步时间。Step S400: Determine the synchronization time of the first time node according to the first time stamp, the second time stamp, the third time stamp and the fourth time stamp.
其中,原语一般是指由若干条指令组成的程序段,用来实现某个特定功能,,计算机进程的控制通常由原语完成。原语信息是指包括发送原语时第一时间节点的本地时间的信息。第一时间戳为发送原语信息时第一时间节点的本地时间。第二时间戳为第二时间节点接收原语信息时的本地时间,第三时间戳为第二时间节点发送第二时间戳时的本地时间。Among them, the primitive generally refers to a program segment composed of several instructions, which is used to realize a specific function, and the control of the computer process is usually completed by the primitive. The primitive information refers to information including the local time of the first time node when the primitive is sent. The first timestamp is the local time of the first time node when the primitive information is sent. The second time stamp is the local time when the second time node receives the primitive information, and the third time stamp is the local time when the second time node sends the second time stamp.
具体地,时间同步客户端第一时间节点向时间同步服务器第二时间节点发送包括第一时间戳的原语信息,发起时间同步流程。第二时间接收到原语信息后,生成包括第二时间戳和第三时间戳的回复信息,并将该回复信息返回至第一时间节点。第一时间节点接收到第二时间节点发送的回复信息后,解析回复信息,得到对应的第二时间戳和第三时间戳。接着,第一时间节点获取接收回复信息时第一时间节点的本地时间,得到第四时间戳。最后,根据第一时间节点与第二时间节点交互过程中得到的第一时间戳、第二时间戳、第三时间戳和第四时间戳,对第一时间节点的时间进行同步,得到第一时间节点的同步时间。Specifically, the first time node of the time synchronization client sends the primitive information including the first time stamp to the second time node of the time synchronization server to initiate the time synchronization process. After receiving the primitive information at the second time, it generates reply information including the second time stamp and the third time stamp, and returns the reply information to the first time node. After receiving the reply information sent by the second time node, the first time node parses the reply information to obtain the corresponding second time stamp and third time stamp. Next, the first time node obtains the local time of the first time node when the reply information is received, and obtains a fourth time stamp. Finally, according to the first time stamp, the second time stamp, the third time stamp and the fourth time stamp obtained during the interaction between the first time node and the second time node, the time of the first time node is synchronized to obtain the first time stamp. The synchronization time of the time node.
其中,第一时间节点与第二时间节点直接通过原语进行交互,不占用FC帧或FC通道,能及时进行时间同步,从而得到的同步时间也更为精确。Among them, the first time node and the second time node directly interact through primitives, do not occupy FC frames or FC channels, and can perform time synchronization in time, so that the obtained synchronization time is also more accurate.
上述时间同步方法,通过发送原语信息;其中,原语信息包括第一时间戳,第一时间戳为发送原语信息时第一时间节点的本地时间;接收第二时间节点发送的回复信息;回复信息为第二时间节点根据原语信息生成的信息,回复信息包括第二时间戳和第三时间戳,第二时间戳为第二时间节点接收原语信息时的本地时间,第三时间戳为第二时间节点发送第二时间戳时的本地时间;获取接收回复信息时第一时间节点的本地时间,得到第四时间戳;根据第一时间戳、第二时间戳、第三时间戳和第四时间戳,确定出第一时间节点的同步时间。从而无需占用FC通道,便能根据第一时间节点与第二时间节点之间的原语信息交互,能及时而又对第一时间节点的时间进行同步。In the above method for time synchronization, primitive information is sent; wherein the primitive information includes a first timestamp, and the first timestamp is the local time of the first time node when the primitive information is sent; and the reply information sent by the second time node is received; The reply information is information generated by the second time node according to the primitive information. The reply information includes a second time stamp and a third time stamp. The second time stamp is the local time when the second time node receives the primitive information, and the third time stamp The local time when the second time stamp is sent for the second time node; the local time of the first time node when the reply message is received is obtained, and the fourth time stamp is obtained; according to the first time stamp, the second time stamp, the third time stamp and the The fourth timestamp determines the synchronization time of the first time node. Therefore, the time of the first time node can be synchronized in time according to the primitive information exchange between the first time node and the second time node without occupying the FC channel.
在一个实施例中,为步骤S100的一种可实施方式,包括:In one embodiment, it is a possible implementation manner of step S100, including:
按照预设的时间间隔,在高速串行传输总线的数据帧之间发送原语信息。According to the preset time interval, the primitive information is sent between the data frames of the high-speed serial transmission bus.
其中,预设的时间间隔为提前设定的时间同步周期。第一时间节点按照该时间间隔,不断地向第二时间节点发送原语消息,通过多次交互,可以提高时间同步的精度。The preset time interval is a time synchronization period set in advance. The first time node continuously sends primitive messages to the second time node according to the time interval, and the accuracy of time synchronization can be improved through multiple interactions.
具体地,第一时间节点按照预设的时间间隔,在高速串行传输总线的数据帧(FC帧) 之间,向第二时间节点发送原语信息。图3为原语时间同步发送示意图,如图3所示,FC协议规定两个FC帧之间至少需要间隔6个IDLE码,在两个FC帧间隙,用三个时间原语信息SYNx、SYNy、SYNz替换三个IDLE码,应用替换后的原语信息SYNx、SYNy、SYNz进行数据的传输,例如第一时间节点向第二时间节点发送原语信息,或第二时间节点向第一时间节点发送回复信息。图4为原语时间同步示意图,如图4所示,在用三个时间原语信息SYNx、SYNy、SYNz替换三个IDLE码后,将替换后的原语信息SYNx、SYNy、SYNz从第一时间节点发送至第二时间节点。其中,T 11和T 21是两次发送原语信息的时间点,为两个第一时间戳;T 12和T 22为两个第二时间戳;T 13和T 23为两个第三时间戳;T 14和T 24为两个第四时间戳。T 11和T 21之间的时间间隔即为预设的时间间隔。 Specifically, the first time node sends primitive information to the second time node between data frames (FC frames) of the high-speed serial transmission bus according to a preset time interval. Figure 3 is a schematic diagram of primitive time synchronization transmission. As shown in Figure 3, the FC protocol stipulates that at least 6 IDLE codes should be spaced between two FC frames. In the gap between two FC frames, three time primitives SYNx and SYNy are used. , SYNz replaces three IDLE codes, and applies the replaced primitive information SYNx, SYNy, SYNz for data transmission, for example, the first time node sends the primitive information to the second time node, or the second time node sends the first time node. Send reply message. Figure 4 is a schematic diagram of primitive time synchronization. As shown in Figure 4, after three IDLE codes are replaced with three time primitive information SYNx, SYNy, SYNz, the replaced primitive information SYNx, SYNy, SYNz is changed from the first The time node is sent to the second time node. Among them, T11 and T21 are the time points when the primitive information is sent twice, which are two first time stamps; T12 and T22 are two second time stamps; T13 and T23 are two third time stamps stamp; T 14 and T 24 are two fourth time stamps. The time interval between T11 and T21 is the preset time interval.
上述实施例中,按照预设的时间间隔,在高速串行传输总线的数据帧之间不断地向第一时间节点发送原语信息,不占用FC通道,通过多次原语交互,提高了时间同步的精度。In the above embodiment, according to the preset time interval, the primitive information is continuously sent to the first time node between the data frames of the high-speed serial transmission bus, the FC channel is not occupied, and the time is improved by multiple primitive interactions. Accuracy of synchronization.
在一个实施例中,如图5所示,为步骤S400的一种可实施方式的流程示意图,具体包括:In one embodiment, as shown in FIG. 5 , it is a schematic flowchart of an implementable implementation manner of step S400, which specifically includes:
步骤S411,根据第一时间戳、第二时间戳、第三时间戳和第四时间戳,确定出第二时间节点和第一时间节点之间的第一误差。Step S411: Determine the first error between the second time node and the first time node according to the first time stamp, the second time stamp, the third time stamp and the fourth time stamp.
具体地,根据公式(1)确定出第二时间节点和第一时间节点之间的第一误差offset 1,具体公式(1)为: Specifically, the first error offset 1 between the second time node and the first time node is determined according to formula (1), and the specific formula (1) is:
Figure PCTCN2021109497-appb-000001
Figure PCTCN2021109497-appb-000001
其中,T 1为第一时间戳,T 2为第二时间戳,T 3为第三时间戳,T 4为第四时间戳。 Wherein, T1 is the first time stamp, T2 is the second time stamp, T3 is the third time stamp, and T4 is the fourth time stamp.
步骤S412,获取第一时间戳与下一第一时间戳之间的计时结果,得到第一计时结果,并根据第一时间戳、下一第一时间戳和第一计时结果,确定出第一时间偏差。Step S412: Obtain the timing result between the first time stamp and the next first time stamp, obtain the first time stamp, and determine the first time stamp according to the first time stamp, the next first time stamp and the first time stamp. time offset.
其中,第一计时结果T Count1为第一时间戳T 11和下一第一时间戳T 21之间的的计时结果,即在第一时间戳T 11开始计时,并在下一第一时间戳T 21结束计时,并将此时的计时结果确定为第一计时结果T Count1。在一些实施例中,在第一时间节点接收到回复信息后,第二时间节点等待接收第一时间节点回复原语T_RDY,若没有接收到第一节点回复原语T_RDY,则一直等待,直到第二时间节点等待接收第一时间节点回复原语T_RDY。此时,记录两次T 11和T 21之间的计数值T Count1Wherein, the first timing result T Count1 is the timing result between the first time stamp T 11 and the next first time stamp T 21 , that is, the time starts at the first time stamp T 11 and starts at the next first time stamp T 21 End the timing, and determine the timing result at this time as the first timing result T Count1 . In some embodiments, after the first time node receives the reply information, the second time node waits to receive the first time node reply primitive T_RDY, and if it does not receive the first time node reply primitive T_RDY, it will wait until the first time node The second time node waits to receive the first time node reply primitive T_RDY. At this time, the count value T Count1 between T 11 and T 21 is recorded twice.
具体地,由于第一时间节点向第二时间节点发送原语信息是按照预设的时间间隔不断地发送的,第一时间戳是发送原语信息时第一时间节点的本地时间,因此,每次发送原语 信息均对应一个第一时间戳,第一时间戳T 11和下一第一时间戳T 21。根据公式(2),通过第一时间戳T 11、下一第一时间戳T 21和第一计时结果T Count1,可以确定出第一时间偏差δ 1。具体公式(2)为: Specifically, since the primitive information sent by the first time node to the second time node is continuously sent according to preset time intervals, the first time stamp is the local time of the first time node when the primitive information is sent. Each of the secondary transmission primitive information corresponds to a first time stamp, the first time stamp T 11 and the next first time stamp T 21 . According to formula (2), through the first time stamp T 11 , the next first time stamp T 21 and the first timing result T Count1 , the first time offset δ 1 can be determined. The specific formula (2) is:
Figure PCTCN2021109497-appb-000002
Figure PCTCN2021109497-appb-000002
在一些实施例中,在第一时间节点向第二时间节点发送原语信息时,需要判断serdes接口链路状态,在serdes链路空闲时,记录本地时间,得到第一时间戳,并向第二时间节点发送原语信息。In some embodiments, when the first time node sends primitive information to the second time node, it is necessary to determine the link status of the serdes interface, and when the serdes link is idle, record the local time, obtain the first timestamp, and send the first time stamp to the second time node. Two time nodes send primitive information.
需要说明的是,经过多次原语交互,第一时间节点逻辑计算出与第二时间节点逻辑之间的时间偏差和链路延迟,并根据第一时间偏差和第二时间偏差,确定出第一时间节点的同步时间,可以在每一个同步周期内进行动态修正,保证了时间同步的高精度。第二时间节点不仅能够调整与第一时间节点之间的偏差,还能够根据第二时间节点的两次授时周期,对自身的频率进行校正与微调,达到高精度原语时间同步的目的。It should be noted that after multiple primitive interactions, the first time node logic calculates the time offset and link delay between the first time node logic and the second time node logic, and determines the first time offset and the second time offset according to the The synchronization time of a time node can be dynamically corrected in each synchronization cycle, which ensures the high precision of time synchronization. The second time node can not only adjust the deviation from the first time node, but also correct and fine-tune its own frequency according to the two timing cycles of the second time node, so as to achieve the purpose of high-precision primitive time synchronization.
步骤S413,根据第一时间戳、下一第一时间戳和第一误差,确定出第二时间偏差。Step S413: Determine the second time offset according to the first timestamp, the next first timestamp and the first error.
具体地,根据公式(3)所示的主从节点偏差计算模块,确定出第二时间偏差δ 2,具体公式(3)为: Specifically, according to the master-slave node deviation calculation module shown in formula (3), the second time deviation δ 2 is determined, and the specific formula (3) is:
Figure PCTCN2021109497-appb-000003
Figure PCTCN2021109497-appb-000003
步骤S420,根据第一时间偏差和第二时间偏差,确定出第一时间节点的同步时间。Step S420: Determine the synchronization time of the first time node according to the first time offset and the second time offset.
具体地,根据公式(4)确定出第一时间节点的同步时间δ′,具体公式(4)为:Specifically, the synchronization time δ' of the first time node is determined according to formula (4), and the specific formula (4) is:
δ'=δ+δ 12      (4) δ'=δ+δ 12 (4)
其中,当时钟频率为125MHz时,δ为时钟周期8.000ns。需要说明的是上述以125MHz为时钟频率、8.000ns为时钟周期进行的说明,实际同步过程中,需要以实际的时钟频率和时钟周期进行计算。Among them, when the clock frequency is 125MHz, δ is the clock period of 8.000ns. It should be noted that the above description takes 125 MHz as the clock frequency and 8.000 ns as the clock period. In the actual synchronization process, the calculation needs to be performed with the actual clock frequency and clock period.
上述实施例中,通过第一时间戳、第二时间戳、第三时间戳和第四时间戳,能够进一步确定出第二时间节点和第一时间节点之间的第一误差、第一时间偏差和第二时间偏差,需要说明的是,第二时间节点依据授时周期,依次与每一个连接的第一时间节点进行授时, 保证了时间同步的有效性一对多时间同步。完成授时时间短,第一时间节点和第二时间及节点均需要发送和接收一次原语信息,极端情况下在两帧最长帧之间间隙插入时间同步原语,完成授时时间为接收两帧最长FC帧时间。In the above embodiment, through the first time stamp, the second time stamp, the third time stamp and the fourth time stamp, the first error and the first time deviation between the second time node and the first time node can be further determined. Compared with the second time deviation, it should be noted that the second time node performs timing with each connected first time node in turn according to the timing cycle, which ensures the validity of time synchronization and one-to-many time synchronization. The completion time is short. Both the first time node and the second time node need to send and receive primitive information once. In extreme cases, a time synchronization primitive is inserted in the gap between the longest frames of the two frames. The completion time is to receive two frames. Maximum FC frame time.
在一个实施例中,如图6所示,提供了一种时间同步方法,以该方法应用于图1中的第二时间节点104为例进行说明,包括以下步骤:In one embodiment, as shown in FIG. 6 , a time synchronization method is provided, and the method is applied to the second time node 104 in FIG. 1 as an example for description, including the following steps:
步骤S100',获取两次脉冲信号之间的计时结果,得到第二计时结果。In step S100', the timing result between two pulse signals is obtained, and the second timing result is obtained.
步骤S200',在第二次检测到脉冲信号时,锁存第二时间节点的本地时间,得到目标时间。Step S200', when the pulse signal is detected for the second time, the local time of the second time node is latched to obtain the target time.
步骤S300',获取目标时间与授时时间之间的第二误差。Step S300', acquiring the second error between the target time and the timing time.
步骤S400',根据第二计时结果和第二误差,对本地时间进行修正,得到第二时间节点的同步时间。Step S400', correcting the local time according to the second timing result and the second error to obtain the synchronization time of the second time node.
具体地,在第二时间节点,获取两次脉冲信号之间的计时结果,得到第二计时结果。并在第二次检测到脉冲信号时,锁存第二时间节点的本地时间,得到目标时间,确定目标时间与授时时间之间的第二误差。按照第二计时结果和第二误差,对第二时间节点的本地时间进行修正,得到第二时间节点的同步时间。Specifically, at the second time node, a timing result between two pulse signals is acquired, and a second timing result is obtained. And when the pulse signal is detected for the second time, the local time of the second time node is latched, the target time is obtained, and the second error between the target time and the timing time is determined. According to the second timing result and the second error, the local time of the second time node is corrected to obtain the synchronization time of the second time node.
上述时间同步方法,通过获取两次脉冲信号之间的计时结果,得到第二计时结果,并在第二次检测到脉冲信号时,锁存第二时间节点的本地时间,得到目标时间。获取目标时间与授时时间之间的第二误差。根据第二计时结果和第二误差,对本地时间进行修正,得到第二时间节点的同步时间。从而能够根据标准授时时间、本地目标时间与授时时间之间的第二误差,对本地时间进行修正,提升了第一时间节点时间同步的准确性。In the above time synchronization method, the second timing result is obtained by acquiring the timing result between two pulse signals, and when the pulse signal is detected for the second time, the local time of the second time node is latched to obtain the target time. Obtain the second error between the target time and the timing time. According to the second timing result and the second error, the local time is corrected to obtain the synchronization time of the second time node. Therefore, the local time can be corrected according to the standard timing time, the second error between the local target time and the timing time, and the accuracy of the time synchronization of the first time node is improved.
在一个实施例中,为步骤S100'的一种可实施方式,包括:In one embodiment, it is a possible implementation manner of step S100', including:
在第一次检测到脉冲信号时,开始计时;在第二次检测到脉冲信号时,获取两次脉冲信号之间的计时结果,得到第二计时结果。When the pulse signal is detected for the first time, the timing is started; when the pulse signal is detected for the second time, the timing result between the two pulse signals is obtained, and the second timing result is obtained.
具体地,在第二时间节点第一次接收到1PPS脉冲信号的上升沿时,启动第一时间节点计计时。接着,继续检测1PPS脉冲信号,在第二次接收到1PPS脉冲信号的上升沿时,缓存本次计数结果,得到第二计时结果T Count2,并重新开始计数,为下一周期的检测提供基础。 Specifically, when the second time node receives the rising edge of the 1PPS pulse signal for the first time, the first time node count is started. Next, continue to detect the 1PPS pulse signal, and when the rising edge of the 1PPS pulse signal is received for the second time, buffer the current counting result to obtain the second timing result T Count2 , and restart counting to provide a basis for the next cycle of detection.
上述实施例中,在第一次检测到脉冲信号时,开始计时,并在第二次检测到脉冲信号时,获取两次脉冲信号之间的计时结果,得到第二计时结果,能够为后续根据第二计时结果对本地时间进行修正提供基础,提高第一时间节点时间同步的准确性。In the above-mentioned embodiment, when the pulse signal is detected for the first time, the timing is started, and when the pulse signal is detected for the second time, the timing result between the two pulse signals is obtained, and the second timing result is obtained, which can be used as a follow-up basis. The second timing result provides a basis for correcting the local time and improves the accuracy of the time synchronization of the first time node.
在一个实施例中,如图7所示,为步骤S400'的一种可实施方式的流程示意图,具体包括:In one embodiment, as shown in FIG. 7 , it is a schematic flowchart of an implementable implementation manner of step S400 ′, which specifically includes:
步骤S410',根据第二计时结果和第二误差,对第二时间节点的时钟周期进行修正,得到目标时钟周期。Step S410', correcting the clock period of the second time node according to the second timing result and the second error to obtain the target clock period.
步骤S420',采用目标时钟周期对本地时间进行修正,得到第二时间节点的同步时间。Step S420', using the target clock period to correct the local time to obtain the synchronization time of the second time node.
具体地,根据公式(5)确定出目标时钟周期δ f,具体公式(5)为: Specifically, the target clock period δ f is determined according to formula (5), and the specific formula (5) is:
Figure PCTCN2021109497-appb-000004
Figure PCTCN2021109497-appb-000004
其中,offset 2为第二误差,125MHz为时钟频率,8.000为以ns为单位的时钟周期。需要说明的是上述以125MHz为时钟频率、8.000ns为时钟周期进行说明,实际同步过程中,需要以实际的时钟频率和时钟周期进行计算。 Among them, offset 2 is the second error, 125MHz is the clock frequency, and 8.000 is the clock period in ns. It should be noted that the above description takes 125 MHz as the clock frequency and 8.000 ns as the clock period, and in the actual synchronization process, the calculation needs to be performed with the actual clock frequency and clock period.
在得到目标时钟周期,采用目标时钟周期对本地时间进行修正,可以得到第二时间节点的同步时间。After the target clock period is obtained, the local time is corrected by using the target clock period, and the synchronization time of the second time node can be obtained.
上述实施例中,根据第二计时结果和第二误差,对第二时间节点的时钟周期进行修正,得到目标时钟周期;采用目标时钟周期对本地时间进行修正,提高了第二时间节点的同步时间的精度。In the above embodiment, according to the second timing result and the second error, the clock cycle of the second time node is corrected to obtain the target clock cycle; the target clock cycle is used to correct the local time, which improves the synchronization time of the second time node. accuracy.
在一个具体的实施例中,如图8所示,提供了一种时间同步方法,包括主时间节点(第二时间节点104)和从时间节点(第一时间节点102),分别对主时间节点和从时间节点进行时间同步,包括以下步骤:In a specific embodiment, as shown in FIG. 8, a time synchronization method is provided, including a master time node (second time node 104) and a slave time node (first time node 102), respectively Time synchronization with slave time nodes, including the following steps:
如图8所示,时间同步模块初始化操作,根据设计需求将该模块配置为主时间节点或者从时间节点,实现方式通过配置寄存器实现。初始化后,判断当前节点是否为主时间节点。若为主时间节点,则分为两个分支:主时间节点时间同步分支和从时间节点时间同步分支。As shown in Figure 8, the time synchronization module initializes the operation, and configures the module as the master time node or the slave time node according to the design requirements, and the implementation method is realized by the configuration register. After initialization, determine whether the current node is the main time node. If it is the master time node, it is divided into two branches: the master time node time synchronization branch and the slave time node time synchronization branch.
在主时间节点时间同步分支,通过主时间节点频偏修正模块,检测是否接收到1PPS脉冲信号,若是,则计算本地时间(目标时间)与授时时间之间的第二误差offset 2,同时计算两次1PPS脉冲信号之间的第二计时结果T Count2,并根据公式(5)计算主时间节点和1PPS脉冲信号之间的频偏,得到目标时钟周期δ f。最后,根据目标时钟周期δ f对主时间节点的本地时间进行修正,得到主时间节点同步时间。 In the time synchronization branch of the main time node, the frequency offset correction module of the main time node is used to detect whether a 1PPS pulse signal is received. If so, the second error offset 2 between the local time (target time) and the timing time is calculated, and two The second timing result T Count2 between the secondary 1PPS pulse signals is calculated, and the frequency offset between the main time node and the 1PPS pulse signal is calculated according to formula (5) to obtain the target clock period δ f . Finally, the local time of the master time node is corrected according to the target clock cycle δf , and the synchronization time of the master time node is obtained.
从时间节点时间同步分支,为主时间节点对从时间节点进行授时的动作,需要结合从 时间节点的动作加以说明。当时间同步模块初始化操作后,判断当前节点为从时间节点时,从时间节点定时向主时间节点发送TIME原语到链路。接着,判断serdes接口链路状态,若serdes链路空闲,则从时间节点记录发送TIME原语的本地时间,得到第一时间戳T 1。主时间节点接收到TIME原语后,记录接收TIME原语的本地时间,得到第二时间戳T 2。接着,主时间节点向从时间节点发送第二时间戳T 2和当前的本地时间第三时间戳T 3。从时间节点接收到主时间节点发送的第二时间戳T 2和当前的本地时间第三时间戳T 3后,缓存第二时间戳T 2和当前的本地时间第三时间戳T 3,并记录接收到主时间节点的T 2和当前的本地时间第三时间戳T 3的第四时间戳T 4,以及记录当前第一时间戳T 11与下一第一时间戳T 21之间的第一计时结果T Count1。最后,根据公式(1)、公式(2)、公式(3)和公式(4),确定出对从时间节点的本地时间进行修正,得到从时间节点同步时间。 The time synchronization branch of the slave time node, the action of the master time node timing the slave time node, needs to be explained in conjunction with the action of the slave time node. After the time synchronization module initializes the operation and determines that the current node is the slave time node, the slave time node regularly sends the TIME primitive to the link to the master time node. Next, the link status of the serdes interface is judged, and if the serdes link is idle, the local time at which the TIME primitive is sent is recorded from the time node to obtain the first timestamp T 1 . After receiving the TIME primitive, the master time node records the local time of receiving the TIME primitive, and obtains a second timestamp T 2 . Next, the master time node sends the second time stamp T 2 and the current local time third time stamp T 3 to the slave time node. After receiving the second time stamp T 2 and the current local time third time stamp T 3 sent by the master time node from the time node, cache the second time stamp T 2 and the current local time third time stamp T 3 , and record Receive the fourth timestamp T4 of the primary time node T2 and the current local time third timestamp T3, and record the first timestamp between the current first timestamp T11 and the next first timestamp T21 The timing result T Count1 . Finally, according to formula (1), formula (2), formula (3) and formula (4), it is determined that the local time of the slave time node is corrected to obtain the synchronization time of the slave time node.
图9为时间同步模块内部结构图,如图9所示,当节点配置为主时间节点时,增加了“主时间节点频偏修正模块”,该模块能够根据外界输入的两次1PPS信号进行时间偏差补偿,补偿主时间节点与外界GPS等授时设备的时钟偏差。当节点配置为从时间节点时,增加了“主从节点偏差计算模块”、“从节点频偏修正模块”,“主从节点偏差计算模块”根据实时授时结果计算出主从节点时间偏差,然后对从节点时间进行补偿。“从节点频偏修正模块”根据主节点发送的两次相邻时间的同步消息,计算主从节点之间的频率偏差,对从节点频率完成偏差校正。Figure 9 is the internal structure diagram of the time synchronization module. As shown in Figure 9, when the node is configured as the main time node, a "main time node frequency offset correction module" is added. Deviation compensation, to compensate the clock deviation between the main time node and the external GPS and other timing equipment. When the node is configured as a slave time node, the "master-slave node deviation calculation module" and "slave node frequency deviation correction module" are added, and the "master-slave node deviation calculation module" calculates the master-slave node time deviation according to the real-time timing results, and then Compensate for slave node time. The "slave node frequency deviation correction module" calculates the frequency deviation between the master and slave nodes according to the synchronization messages sent by the master node at two adjacent times, and completes the deviation correction for the frequency of the slave nodes.
上述实施例,既不占用FC通道带宽,又能够实现高精度时间同步,实现了一个主节点同时对多个从节点进行高精度时间同步。The above-mentioned embodiment does not occupy the bandwidth of the FC channel, and can achieve high-precision time synchronization, so that one master node can simultaneously perform high-precision time synchronization on multiple slave nodes.
应该理解的是,虽然图1-9的流程图中的各个步骤按照箭头的指示依次显示,但是这些步骤并不是必然按照箭头指示的顺序依次执行。除非本文中有明确的说明,这些步骤的执行并没有严格的顺序限制,这些步骤可以以其它的顺序执行。而且,图1-9中的至少一部分步骤可以包括多个步骤或者多个阶段,这些步骤或者阶段并不必然是在同一时刻执行完成,而是可以在不同的时刻执行,这些步骤或者阶段的执行顺序也不必然是依次进行,而是可以与其它步骤或者其它步骤中的步骤或者阶段的至少一部分轮流或者交替地执行。It should be understood that although the steps in the flowcharts of FIGS. 1-9 are shown in sequence according to the arrows, these steps are not necessarily executed in the sequence shown by the arrows. Unless explicitly stated herein, the execution of these steps is not strictly limited to the order, and these steps may be performed in other orders. Moreover, at least a part of the steps in FIGS. 1-9 may include multiple steps or multiple stages. These steps or stages are not necessarily executed and completed at the same time, but may be executed at different times. The execution of these steps or stages The order is also not necessarily sequential, but may be performed alternately or alternately with other steps or at least a portion of the steps or phases within the other steps.
在一个实施例中,如图10所示,提供了一种时间同步装置,包括:原语信息发送模块101、回复信息接收模块102、本地时间确定模块103和第一时间同步模块104,其中:In one embodiment, as shown in FIG. 10, a time synchronization apparatus is provided, including: a primitive information sending module 101, a reply information receiving module 102, a local time determination module 103 and a first time synchronization module 104, wherein:
原语信息发送模块101,用于发送原语信息;其中,原语信息包括第一时间戳,第一时间戳为发送原语信息时第一时间节点的本地时间;The primitive information sending module 101 is used for sending primitive information; wherein, the primitive information includes a first time stamp, and the first time stamp is the local time of the first time node when the primitive information is sent;
回复信息接收模块102,用于接收第二时间节点发送的回复信息;回复信息为第二时间节点根据原语信息生成的信息,回复信息包括第二时间戳和第三时间戳,第二时间戳为 第二时间节点接收原语信息时的本地时间,第三时间戳为第二时间节点发送第二时间戳时的本地时间;The reply information receiving module 102 is configured to receive reply information sent by the second time node; the reply information is information generated by the second time node according to the primitive information, and the reply information includes a second time stamp and a third time stamp, and the second time stamp is the local time when the second time node receives the primitive information, and the third time stamp is the local time when the second time node sends the second time stamp;
本地时间确定模块103,用于获取接收回复信息时第一时间节点的本地时间,得到第四时间戳;a local time determination module 103, configured to obtain the local time of the first time node when the reply message is received, and obtain a fourth time stamp;
第一时间同步模块104,用于根据第一时间戳、第二时间戳、第三时间戳和第四时间戳,确定出第一时间节点的同步时间。The first time synchronization module 104 is configured to determine the synchronization time of the first time node according to the first time stamp, the second time stamp, the third time stamp and the fourth time stamp.
在其中一个实施例中,原语信息发送模块101还用于:按照预设的时间间隔,在高速串行传输总线的数据帧之间发送原语信息。In one embodiment, the primitive information sending module 101 is further configured to: send primitive information between data frames of the high-speed serial transmission bus according to a preset time interval.
在其中一个实施例中,第一时间同步模块104还用于:根据第一时间戳、第二时间戳、第三时间戳和第四时间戳,确定出第二时间节点和第一时间节点之间的第一误差;获取第一时间戳与下一第一时间戳之间的计时结果,得到第一计时结果,并根据第一时间戳、下一第一时间戳和第一计时结果,确定出第一时间偏差;根据第一时间戳、下一第一时间戳和第一误差,确定出第二时间偏差;根据第一时间偏差和第二时间偏差,确定出第一时间节点的同步时间。In one embodiment, the first time synchronization module 104 is further configured to: determine the relationship between the second time node and the first time node according to the first time stamp, the second time stamp, the third time stamp and the fourth time stamp obtain the timing result between the first timestamp and the next first timestamp, obtain the first timing result, and determine according to the first timestamp, the next first timestamp and the first timing result determine the first time offset; determine the second time offset according to the first timestamp, the next first timestamp and the first error; determine the synchronization time of the first time node according to the first time offset and the second time offset .
在一个实施例中,如图11所示,提供了一种时间同步装置,包括:计时结果确定模块111、本地时间锁存模块112、第二误差确定模块113和第二时间同步模块114,其中:In one embodiment, as shown in FIG. 11 , a time synchronization apparatus is provided, including: a timing result determination module 111 , a local time latch module 112 , a second error determination module 113 and a second time synchronization module 114 , wherein :
计时结果确定模块111,用于获取两次脉冲信号之间的计时结果,得到第二计时结果;The timing result determination module 111 is used to obtain the timing result between two pulse signals, and obtain the second timing result;
本地时间锁存模块112,用于在第二次检测到脉冲信号时,锁存第二时间节点的本地时间,得到目标时间;The local time latch module 112 is configured to latch the local time of the second time node to obtain the target time when the pulse signal is detected for the second time;
第二误差确定模块113,用于获取目标时间与授时时间之间的第二误差;The second error determination module 113 is configured to obtain the second error between the target time and the timing time;
第二时间同步模块114,用于根据第二计时结果和第二误差,对本地时间进行修正,得到第二时间节点的同步时间。The second time synchronization module 114 is configured to correct the local time according to the second timing result and the second error to obtain the synchronization time of the second time node.
在其中一个实施例中,计时结果确定模块111还用于:在第一次检测到脉冲信号时,开始计时;在第二次检测到脉冲信号时,获取两次脉冲信号之间的计时结果,得到第二计时结果。In one embodiment, the timing result determination module 111 is further configured to: start timing when the pulse signal is detected for the first time; acquire the timing result between the two pulse signals when the pulse signal is detected for the second time, Get the second timing result.
在其中一个实施例中,第二时间同步模块114还用于:根据第二计时结果和第二误差,对第二时间节点的时钟周期进行修正,得到目标时钟周期;采用目标时钟周期对本地时间进行修正,得到第二时间节点的同步时间。In one embodiment, the second time synchronization module 114 is further configured to: correct the clock cycle of the second time node according to the second timing result and the second error to obtain the target clock cycle; use the target clock cycle to compare the local time Correction is made to obtain the synchronization time of the second time node.
关于时间同步装置的具体限定可以参见上文中对于时间同步方法的限定,在此不再赘述。上述时间同步装置中的各个模块可全部或部分通过软件、硬件及其组合来实现。上述各模块可以硬件形式内嵌于或独立于计算机设备中的处理器中,也可以以软件形式 存储于计算机设备中的存储器中,以便于处理器调用执行以上各个模块对应的操作。For the specific limitation of the time synchronization apparatus, reference may be made to the limitation of the time synchronization method above, which will not be repeated here. Each module in the above-mentioned time synchronization apparatus may be implemented in whole or in part by software, hardware and combinations thereof. The above-mentioned modules can be embedded in or independent of the processor in the computer equipment in the form of hardware, or can be stored in the memory in the computer equipment in the form of software, so that the processor calls and executes the corresponding operations of the above-mentioned various modules.
在一个实施例中,提供了一种计算机设备,该计算机设备可以是终端,应用于第一时间节点,其内部结构图可以如图12所示。该计算机设备包括通过系统总线连接的处理器、存储器、通信接口、显示屏和输入装置。其中,该计算机设备的处理器用于提供计算和控制能力。该计算机设备的存储器包括非易失性存储介质、内存储器。该非易失性存储介质存储有操作系统和计算机程序。该内存储器为非易失性存储介质中的操作系统和计算机程序的运行提供环境。该计算机设备的通信接口用于与外部的终端进行有线或无线方式的通信,无线方式可通过WIFI、运营商网络、NFC(近场通信)或其他技术实现。该计算机程序被处理器执行时以实现一种时间同步方法。该计算机设备的显示屏可以是液晶显示屏或者电子墨水显示屏,该计算机设备的输入装置可以是显示屏上覆盖的触摸层,也可以是计算机设备外壳上设置的按键、轨迹球或触控板,还可以是外接的键盘、触控板或鼠标等。In one embodiment, a computer device is provided, and the computer device may be a terminal, applied to the first time node, and its internal structure diagram may be as shown in FIG. 12 . The computer equipment includes a processor, memory, a communication interface, a display screen, and an input device connected by a system bus. Among them, the processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium, an internal memory. The nonvolatile storage medium stores an operating system and a computer program. The internal memory provides an environment for the execution of the operating system and computer programs in the non-volatile storage medium. The communication interface of the computer device is used for wired or wireless communication with an external terminal, and the wireless communication can be realized by WIFI, operator network, NFC (Near Field Communication) or other technologies. The computer program, when executed by the processor, implements a time synchronization method. The display screen of the computer equipment may be a liquid crystal display screen or an electronic ink display screen, and the input device of the computer equipment may be a touch layer covered on the display screen, or a button, a trackball or a touchpad set on the shell of the computer equipment , or an external keyboard, trackpad, or mouse.
在一个实施例中,提供了一种计算机设备,该计算机设备可以是服务器,应用于第二时间节点,其内部结构图可以如图13所示。该计算机设备包括通过系统总线连接的处理器、存储器和网络接口。其中,该计算机设备的处理器用于提供计算和控制能力。该计算机设备的存储器包括非易失性存储介质、内存储器。该非易失性存储介质存储有操作系统、计算机程序和数据库。该内存储器为非易失性存储介质中的操作系统和计算机程序的运行提供环境。该计算机设备的数据库用于存储时间同步数据。该计算机设备的网络接口用于与外部的终端通过网络连接通信。该计算机程序被处理器执行时以实现一种时间同步方法。In one embodiment, a computer device is provided, and the computer device may be a server, applied to the second time node, and its internal structure diagram may be as shown in FIG. 13 . The computer device includes a processor, memory, and a network interface connected by a system bus. Among them, the processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium, an internal memory. The nonvolatile storage medium stores an operating system, a computer program, and a database. The internal memory provides an environment for the execution of the operating system and computer programs in the non-volatile storage medium. The computer device's database is used to store time synchronization data. The network interface of the computer device is used to communicate with an external terminal through a network connection. The computer program, when executed by the processor, implements a time synchronization method.
本领域技术人员可以理解,图12、图13中示出的结构,仅仅是与本申请方案相关的部分结构的框图,并不构成对本申请方案所应用于其上的计算机设备的限定,具体的计算机设备可以包括比图中所示更多或更少的部件,或者组合某些部件,或者具有不同的部件布置。Those skilled in the art can understand that the structures shown in FIG. 12 and FIG. 13 are only block diagrams of partial structures related to the solution of the present application, and do not constitute a limitation on the computer equipment to which the solution of the present application is applied. A computer device may include more or fewer components than those shown in the figures, or combine certain components, or have a different arrangement of components.
在一个实施例中,提供了一种计算机设备,包括存储器和处理器,存储器中存储有计算机程序,该处理器执行计算机程序时实现以下步骤:In one embodiment, a computer device is provided, including a memory and a processor, a computer program is stored in the memory, and the processor implements the following steps when executing the computer program:
发送原语信息;其中,原语信息包括第一时间戳,第一时间戳为发送原语信息时第一时间节点的本地时间;Sending primitive information; wherein, the primitive information includes a first timestamp, and the first timestamp is the local time of the first time node when the primitive information is sent;
接收第二时间节点发送的回复信息;回复信息为第二时间节点根据原语信息生成的信息,回复信息包括第二时间戳和第三时间戳,第二时间戳为第二时间节点接收原语信息时的本地时间,第三时间戳为第二时间节点发送第二时间戳时的本地时间;Receive the reply information sent by the second time node; the reply information is the information generated by the second time node according to the primitive information, the reply information includes the second time stamp and the third time stamp, and the second time stamp is the primitive received by the second time node The local time when the information is sent, and the third time stamp is the local time when the second time node sends the second time stamp;
获取接收回复信息时第一时间节点的本地时间,得到第四时间戳;Obtain the local time of the first time node when the reply message is received, and obtain the fourth timestamp;
根据第一时间戳、第二时间戳、第三时间戳和第四时间戳,确定出第一时间节点的同步时间。The synchronization time of the first time node is determined according to the first time stamp, the second time stamp, the third time stamp and the fourth time stamp.
在一个实施例中,处理器执行计算机程序时还实现以下步骤:按照预设的时间间隔,在高速串行传输总线的数据帧之间发送原语信息。In one embodiment, the processor further implements the following steps when executing the computer program: sending primitive information between data frames of the high-speed serial transmission bus according to a preset time interval.
在一个实施例中,处理器执行计算机程序时还实现以下步骤:根据第一时间戳、第二时间戳、第三时间戳和第四时间戳,确定出第二时间节点和第一时间节点之间的第一误差;获取第一时间戳与下一第一时间戳之间的计时结果,得到第一计时结果,并根据第一时间戳、下一第一时间戳和第一计时结果,确定出第一时间偏差;根据第一时间戳、下一第一时间戳和第一误差,确定出第二时间偏差;根据第一时间偏差和第二时间偏差,确定出第一时间节点的同步时间。In one embodiment, when the processor executes the computer program, the following steps are further implemented: according to the first time stamp, the second time stamp, the third time stamp and the fourth time stamp, determining the difference between the second time node and the first time node obtain the timing result between the first timestamp and the next first timestamp, obtain the first timing result, and determine according to the first timestamp, the next first timestamp and the first timing result determine the first time offset; determine the second time offset according to the first timestamp, the next first timestamp and the first error; determine the synchronization time of the first time node according to the first time offset and the second time offset .
在一个实施例中,提供了一种计算机设备,包括存储器和处理器,存储器中存储有计算机程序,该处理器执行计算机程序时实现以下步骤:In one embodiment, a computer device is provided, including a memory and a processor, a computer program is stored in the memory, and the processor implements the following steps when executing the computer program:
获取两次脉冲信号之间的计时结果,得到第二计时结果;Obtain the timing result between two pulse signals, and obtain the second timing result;
在第二次检测到脉冲信号时,锁存第二时间节点的本地时间,得到目标时间;When the pulse signal is detected for the second time, the local time of the second time node is latched to obtain the target time;
获取目标时间与授时时间之间的第二误差;Obtain the second error between the target time and the timing time;
根据第二计时结果和第二误差,对本地时间进行修正,得到第二时间节点的同步时间。According to the second timing result and the second error, the local time is corrected to obtain the synchronization time of the second time node.
在一个实施例中,处理器执行计算机程序时还实现以下步骤:在第一次检测到脉冲信号时,开始计时;在第二次检测到脉冲信号时,获取两次脉冲信号之间的计时结果,得到第二计时结果。In one embodiment, when the processor executes the computer program, the following steps are further implemented: when the pulse signal is detected for the first time, start timing; when the pulse signal is detected for the second time, obtain the timing result between the two pulse signals , to get the second timing result.
在一个实施例中,处理器执行计算机程序时还实现以下步骤:根据第二计时结果和第二误差,对第二时间节点的时钟周期进行修正,得到目标时钟周期;采用目标时钟周期对本地时间进行修正,得到第二时间节点的同步时间。In one embodiment, the processor further implements the following steps when executing the computer program: correcting the clock cycle of the second time node according to the second timing result and the second error to obtain a target clock cycle; using the target clock cycle to compare the local time Correction is made to obtain the synchronization time of the second time node.
在一个实施例中,提供了一种计算机可读存储介质,其上存储有计算机程序,计算机程序被处理器执行时实现以下步骤:In one embodiment, a computer-readable storage medium is provided on which a computer program is stored, and when the computer program is executed by a processor, the following steps are implemented:
发送原语信息;其中,原语信息包括第一时间戳,第一时间戳为发送原语信息时第一时间节点的本地时间;Sending primitive information; wherein, the primitive information includes a first timestamp, and the first timestamp is the local time of the first time node when the primitive information is sent;
接收第二时间节点发送的回复信息;回复信息为第二时间节点根据原语信息生成的信息,回复信息包括第二时间戳和第三时间戳,第二时间戳为第二时间节点接收原语信息时的本地时间,第三时间戳为第二时间节点发送第二时间戳时的本地时间;Receive the reply information sent by the second time node; the reply information is the information generated by the second time node according to the primitive information, the reply information includes the second time stamp and the third time stamp, and the second time stamp is the primitive received by the second time node The local time when the information is sent, and the third time stamp is the local time when the second time node sends the second time stamp;
获取接收回复信息时第一时间节点的本地时间,得到第四时间戳;Obtain the local time of the first time node when the reply message is received, and obtain the fourth timestamp;
根据第一时间戳、第二时间戳、第三时间戳和第四时间戳,确定出第一时间节点的同 步时间。The synchronization time of the first time node is determined according to the first time stamp, the second time stamp, the third time stamp and the fourth time stamp.
在一个实施例中,计算机程序被处理器执行时还实现以下步骤:按照预设的时间间隔,在高速串行传输总线的数据帧之间发送原语信息。In one embodiment, the computer program further implements the following steps when executed by the processor: sending primitive information between data frames of the high-speed serial transmission bus according to preset time intervals.
在一个实施例中,计算机程序被处理器执行时还实现以下步骤:根据第一时间戳、第二时间戳、第三时间戳和第四时间戳,确定出第二时间节点和第一时间节点之间的第一误差;获取第一时间戳与下一第一时间戳之间的计时结果,得到第一计时结果,并根据第一时间戳、下一第一时间戳和第一计时结果,确定出第一时间偏差;根据第一时间戳、下一第一时间戳和第一误差,确定出第二时间偏差;根据第一时间偏差和第二时间偏差,确定出第一时间节点的同步时间。In one embodiment, when the computer program is executed by the processor, the following steps are further implemented: determining the second time node and the first time node according to the first time stamp, the second time stamp, the third time stamp and the fourth time stamp The first error between; obtain the timing result between the first timestamp and the next first timestamp, obtain the first timing result, and according to the first timestamp, the next first timestamp and the first timing result, Determine the first time offset; determine the second time offset according to the first timestamp, the next first timestamp and the first error; determine the synchronization of the first time node according to the first time offset and the second time offset time.
在一个实施例中,提供了一种计算机可读存储介质,其上存储有计算机程序,计算机程序被处理器执行时实现以下步骤:In one embodiment, a computer-readable storage medium is provided on which a computer program is stored, and when the computer program is executed by a processor, the following steps are implemented:
获取两次脉冲信号之间的计时结果,得到第二计时结果;Obtain the timing result between two pulse signals, and obtain the second timing result;
在第二次检测到脉冲信号时,锁存第二时间节点的本地时间,得到目标时间;When the pulse signal is detected for the second time, the local time of the second time node is latched to obtain the target time;
获取目标时间与授时时间之间的第二误差;Obtain the second error between the target time and the timing time;
根据第二计时结果和第二误差,对本地时间进行修正,得到第二时间节点的同步时间。According to the second timing result and the second error, the local time is corrected to obtain the synchronization time of the second time node.
在一个实施例中,计算机程序被处理器执行时还实现以下步骤:在第一次检测到脉冲信号时,开始计时;在第二次检测到脉冲信号时,获取两次脉冲信号之间的计时结果,得到第二计时结果。In one embodiment, when the computer program is executed by the processor, the following steps are further implemented: when the pulse signal is detected for the first time, start timing; when the pulse signal is detected for the second time, obtain the timing between two pulse signals As a result, the second timing result is obtained.
在一个实施例中,计算机程序被处理器执行时还实现以下步骤:根据第二计时结果和第二误差,对第二时间节点的时钟周期进行修正,得到目标时钟周期;采用目标时钟周期对本地时间进行修正,得到第二时间节点的同步时间。In one embodiment, when the computer program is executed by the processor, the following steps are further implemented: correcting the clock cycle of the second time node according to the second timing result and the second error to obtain the target clock cycle; The time is corrected to obtain the synchronization time of the second time node.
本领域普通技术人员可以理解实现上述实施例方法中的全部或部分流程,是可以通过计算机程序来指令相关的硬件来完成,所述的计算机程序可存储于一非易失性计算机可读取存储介质中,该计算机程序在执行时,可包括如上述各方法的实施例的流程。其中,本申请所提供的各实施例中所使用的对存储器、存储、数据库或其它介质的任何引用,均可包括非易失性和易失性存储器中的至少一种。非易失性存储器可包括只读存储器(Read-Only Memory,ROM)、磁带、软盘、闪存或光存储器等。易失性存储器可包括随机存取存储器(Random Access Memory,RAM)或外部高速缓冲存储器。作为说明而非局限,RAM可以是多种形式,比如静态随机存取存储器(Static Random Access Memory,SRAM)或动态随机存取存储器(Dynamic Random Access Memory,DRAM)等。Those of ordinary skill in the art can understand that all or part of the processes in the methods of the above embodiments can be implemented by instructing relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage In the medium, when the computer program is executed, it may include the processes of the above-mentioned method embodiments. Wherein, any reference to memory, storage, database or other media used in the various embodiments provided in this application may include at least one of non-volatile and volatile memory. Non-volatile memory may include read-only memory (Read-Only Memory, ROM), magnetic tape, floppy disk, flash memory, or optical memory, and the like. Volatile memory may include random access memory (RAM) or external cache memory. By way of illustration and not limitation, the RAM may be in various forms, such as Static Random Access Memory (SRAM) or Dynamic Random Access Memory (DRAM).
以上实施例的各技术特征可以进行任意的组合,为使描述简洁,未对上述实施例中的 各个技术特征所有可能的组合都进行描述,然而,只要这些技术特征的组合不存在矛盾,都应当认为是本说明书记载的范围。The technical features of the above embodiments can be combined arbitrarily. In order to make the description simple, all possible combinations of the technical features in the above embodiments are not described. However, as long as there is no contradiction in the combination of these technical features It is considered to be the range described in this specification.
以上所述实施例仅表达了本申请的几种实施方式,其描述较为具体和详细,但并不能因此而理解为对发明专利范围的限制。应当指出的是,对于本领域的普通技术人员来说,在不脱离本申请构思的前提下,还可以做出若干变形和改进,这些都属于本申请的保护范围。因此,本申请专利的保护范围应以所附权利要求为准。The above-mentioned embodiments only represent several embodiments of the present application, and the descriptions thereof are specific and detailed, but should not be construed as a limitation on the scope of the invention patent. It should be noted that, for those skilled in the art, without departing from the concept of the present application, several modifications and improvements can be made, which all belong to the protection scope of the present application. Therefore, the scope of protection of the patent of the present application shall be subject to the appended claims.

Claims (10)

  1. 一种时间同步方法,所述方法应用于第一时间节点,包括:A time synchronization method, the method is applied to a first time node, comprising:
    发送原语信息;其中,所述原语信息包括第一时间戳,所述第一时间戳为发送所述原语信息时所述第一时间节点的本地时间;Sending primitive information; wherein, the primitive information includes a first timestamp, and the first timestamp is the local time of the first time node when the primitive information is sent;
    接收第二时间节点发送的回复信息;所述回复信息为所述第二时间节点根据所述原语信息生成的信息,所述回复信息包括第二时间戳和第三时间戳,所述第二时间戳为所述第二时间节点接收所述原语信息时的本地时间,所述第三时间戳为所述第二时间节点发送所述第二时间戳时的本地时间;Receive reply information sent by a second time node; the reply information is information generated by the second time node according to the primitive information, the reply information includes a second time stamp and a third time stamp, the second time stamp The time stamp is the local time when the second time node receives the primitive information, and the third time stamp is the local time when the second time node sends the second time stamp;
    获取接收所述回复信息时所述第一时间节点的本地时间,得到第四时间戳;obtaining the local time of the first time node when receiving the reply information, and obtaining a fourth timestamp;
    根据所述第一时间戳、所述第二时间戳、所述第三时间戳和所述第四时间戳,确定出所述第一时间节点的同步时间。The synchronization time of the first time node is determined according to the first time stamp, the second time stamp, the third time stamp and the fourth time stamp.
  2. 根据权利要求1所述的方法,其中,所述发送原语信息,包括:The method of claim 1, wherein the sending primitive information comprises:
    按照预设的时间间隔,在高速串行传输总线的数据帧之间发送所述原语信息。The primitive information is sent between data frames of the high-speed serial transmission bus according to a preset time interval.
  3. 根据权利要求2所述的方法,其中,所述根据所述第一时间戳、所述第二时间戳、所述第三时间戳和所述第四时间戳,确定出所述第一时间节点的同步时间,包括:The method according to claim 2, wherein the first time node is determined according to the first time stamp, the second time stamp, the third time stamp and the fourth time stamp synchronization time, including:
    根据所述第一时间戳、所述第二时间戳、所述第三时间戳和所述第四时间戳,确定出所述第二时间节点和所述第一时间节点之间的第一误差;A first error between the second time node and the first time node is determined according to the first time stamp, the second time stamp, the third time stamp and the fourth time stamp ;
    获取所述第一时间戳与下一第一时间戳之间的计时结果,得到第一计时结果,并根据所述第一时间戳、所述下一第一时间戳和所述第一计时结果,确定出第一时间偏差;Obtain the timing result between the first timestamp and the next first timestamp, obtain the first timing result, and obtain the first timing result according to the first timestamp, the next first timestamp and the first timing result , determine the first time deviation;
    根据所述第一时间戳、所述下一第一时间戳和所述第一误差,确定出第二时间偏差;determining a second time offset according to the first time stamp, the next first time stamp and the first error;
    根据所述第一时间偏差和所述第二时间偏差,确定出所述第一时间节点的同步时间。According to the first time offset and the second time offset, the synchronization time of the first time node is determined.
  4. 一种时间同步方法,所述方法应用于第二时间节点,包括:A time synchronization method, the method is applied to a second time node, comprising:
    获取两次脉冲信号之间的计时结果,得到第二计时结果;Obtain the timing result between two pulse signals, and obtain the second timing result;
    在第二次检测到脉冲信号时,锁存所述第二时间节点的本地时间,得到目标时间;When the pulse signal is detected for the second time, the local time of the second time node is latched to obtain the target time;
    获取所述目标时间与授时时间之间的第二误差;obtaining the second error between the target time and the timing time;
    根据所述第二计时结果和所述第二误差,对所述本地时间进行修正,得到所述第二时间节点的同步时间。According to the second timing result and the second error, the local time is corrected to obtain the synchronization time of the second time node.
  5. 根据权利要求4所述的方法,其中,所述获取两次脉冲信号之间的计时结果,得到第二计时结果,包括:The method according to claim 4, wherein the obtaining a timing result between two pulse signals to obtain a second timing result comprises:
    在第一次检测到脉冲信号时,开始计时;When the pulse signal is detected for the first time, start timing;
    在第二次检测到脉冲信号时,获取两次脉冲信号之间的计时结果,得到所述第二计时结果。When the pulse signal is detected for the second time, the timing result between the two pulse signals is obtained, and the second timing result is obtained.
  6. 根据权利要求4所述的方法,其中,所述根据所述第二计时结果和所述第二误差,对所述本地时间进行修正,得到所述第二时间节点的同步时间,包括:The method according to claim 4, wherein, according to the second timing result and the second error, modifying the local time to obtain the synchronization time of the second time node, comprising:
    根据所述第二计时结果和所述第二误差,对所述第二时间节点的时钟周期进行修正,得到目标时钟周期;According to the second timing result and the second error, the clock cycle of the second time node is corrected to obtain a target clock cycle;
    采用所述目标时钟周期对所述本地时间进行修正,得到所述第二时间节点的同步时间。The local time is corrected by using the target clock period to obtain the synchronization time of the second time node.
  7. 一种时间同步装置,所述装置应用于第一时间节点,包括:A time synchronization device, the device is applied to a first time node, comprising:
    原语信息发送模块,用于发送原语信息;其中,所述原语信息包括第一时间戳,所述第一时间戳为发送所述原语信息时所述第一时间节点的本地时间;a primitive information sending module, configured to send primitive information; wherein, the primitive information includes a first time stamp, and the first time stamp is the local time of the first time node when the primitive information is sent;
    回复信息接收模块,用于接收第二时间节点发送的回复信息;所述回复信息为所述第二时间节点根据所述原语信息生成的信息,所述回复信息包括第二时间戳和第三时间戳,所述第二时间戳为所述第二时间节点接收所述原语信息时的本地时间,所述第三时间戳为所述第二时间节点发送所述第二时间戳时的本地时间;A reply information receiving module, configured to receive reply information sent by a second time node; the reply information is information generated by the second time node according to the primitive information, and the reply information includes a second time stamp and a third time stamp. time stamp, the second time stamp is the local time when the second time node receives the primitive information, and the third time stamp is the local time when the second time node sends the second time stamp time;
    本地时间确定模块,用于获取接收所述回复信息时所述第一时间节点的本地时间,得到第四时间戳;a local time determination module, configured to acquire the local time of the first time node when the reply information is received, and obtain a fourth time stamp;
    第一时间同步模块,用于根据所述第一时间戳、所述第二时间戳、所述第三时间戳和所述第四时间戳,确定出所述第一时间节点的同步时间。A first time synchronization module, configured to determine the synchronization time of the first time node according to the first time stamp, the second time stamp, the third time stamp and the fourth time stamp.
  8. 一种时间同步装置,所述装置应用于第二时间节点,包括:A time synchronization device, the device is applied to a second time node, comprising:
    计时结果确定模块,用于获取两次脉冲信号之间的计时结果,得到第二计时结果;The timing result determination module is used to obtain the timing result between two pulse signals to obtain the second timing result;
    本地时间锁存模块,用于在第二次检测到脉冲信号时,锁存所述第二时间节点的本地时间,得到目标时间;a local time latch module, configured to latch the local time of the second time node to obtain the target time when the pulse signal is detected for the second time;
    第二误差确定模块,用于获取所述目标时间与授时时间之间的第二误差;a second error determination module, configured to obtain the second error between the target time and the timing time;
    第二时间同步模块,用于根据所述第二计时结果和所述第二误差,对所述本地时间进行修正,得到所述第二时间节点的同步时间。A second time synchronization module, configured to correct the local time according to the second timing result and the second error to obtain the synchronization time of the second time node.
  9. 一种计算机设备,包括存储器和处理器,所述存储器存储有计算机程序,其中,所述处理器执行所述计算机程序时实现权利要求1至3中任一项所述的方法的步骤,或实现权利要求4至6中任一项所述的方法的步骤。A computer device, comprising a memory and a processor, wherein the memory stores a computer program, wherein the processor implements the steps of the method according to any one of claims 1 to 3 when the processor executes the computer program, or realizes The steps of the method of any one of claims 4 to 6.
  10. 一种计算机可读存储介质,其上存储有计算机程序,其中,所述计算机程序被处 理器执行时实现权利要求1至3中任一项所述的方法的步骤,或实现权利要求4至6中任一项所述的方法的步骤。A computer-readable storage medium on which a computer program is stored, wherein the computer program, when executed by a processor, implements the steps of the method of any one of claims 1 to 3, or implements claims 4 to 6 The steps of any one of the methods.
PCT/CN2021/109497 2021-04-30 2021-07-30 Time synchronization method and apparatus, and computer device and storage medium WO2022227318A1 (en)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN202110485780.3 2021-04-30
CN202110485780.3A CN113259039A (en) 2021-04-30 2021-04-30 Time synchronization method and device, computer equipment and storage medium

Publications (1)

Publication Number Publication Date
WO2022227318A1 true WO2022227318A1 (en) 2022-11-03

Family

ID=77223794

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2021/109497 WO2022227318A1 (en) 2021-04-30 2021-07-30 Time synchronization method and apparatus, and computer device and storage medium

Country Status (2)

Country Link
CN (1) CN113259039A (en)
WO (1) WO2022227318A1 (en)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113934672B (en) * 2021-12-14 2022-03-01 北京国科天迅科技有限公司 Network equipment management method, system, device, computer equipment and storage medium

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101800612A (en) * 2010-01-08 2010-08-11 北京交通大学 MAC (Media Access Control) layer synchronizing method improved based on IEEE 802.16d
CN102013931A (en) * 2009-09-08 2011-04-13 中兴通讯股份有限公司 Time synchronization method and system, salve timing device and main timing device
US20150281001A1 (en) * 2014-03-25 2015-10-01 Emulex Corporation System and method for managing storage transactions in a network interface
CN106992830A (en) * 2017-04-05 2017-07-28 中国科学院空间应用工程与技术中心 A kind of clock synchronizing method in the networks of FC AE 1553
CN108471337A (en) * 2018-04-04 2018-08-31 电子科技大学 A method of realizing time synchronization in FC networks
CN109525347A (en) * 2017-09-19 2019-03-26 比亚迪股份有限公司 Method for synchronizing time and device

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102013931A (en) * 2009-09-08 2011-04-13 中兴通讯股份有限公司 Time synchronization method and system, salve timing device and main timing device
CN101800612A (en) * 2010-01-08 2010-08-11 北京交通大学 MAC (Media Access Control) layer synchronizing method improved based on IEEE 802.16d
US20150281001A1 (en) * 2014-03-25 2015-10-01 Emulex Corporation System and method for managing storage transactions in a network interface
CN106992830A (en) * 2017-04-05 2017-07-28 中国科学院空间应用工程与技术中心 A kind of clock synchronizing method in the networks of FC AE 1553
CN109525347A (en) * 2017-09-19 2019-03-26 比亚迪股份有限公司 Method for synchronizing time and device
CN108471337A (en) * 2018-04-04 2018-08-31 电子科技大学 A method of realizing time synchronization in FC networks

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
ZHOU YA: "The Research and Realization of Clock Synchronization System in Fiber Channel Network Switch", CHINA MASTER’S THESES FULL-TEXT DATABASE, no. 4, 15 April 2018 (2018-04-15), XP055980797 *

Also Published As

Publication number Publication date
CN113259039A (en) 2021-08-13

Similar Documents

Publication Publication Date Title
EP2378718B1 (en) Method, node and system for controlling version in distributed system
US10958367B2 (en) Network apparatus and clock synchronization method
JP6192995B2 (en) COMMUNICATION DEVICE, COMMUNICATION SYSTEM, COMMUNICATION METHOD, AND COMPUTER PROGRAM
CN109392074B (en) Clock calibration method and device
US11606155B2 (en) Method for exchanging time synchronization packet and network apparatus
WO2021136149A1 (en) Clock synchronization method and apparatus, computer device, and storage medium
KR20150143801A (en) Timestamp generating method, device and system
US20220248353A1 (en) Synchronization method and device
US11811501B2 (en) Clock synchronization method and apparatus, and storage medium
US20160098326A1 (en) Method and apparatus for enabling temporal alignment of debug information
WO2020135198A1 (en) Clock synchronization method and device, and storage medium
WO2022227318A1 (en) Time synchronization method and apparatus, and computer device and storage medium
WO2019169820A1 (en) High-precision time synchronization method
CN115080495A (en) Time synchronization method and system for standard peripheral extension interface equipment
CN113411157B (en) Method, slave clock device, master clock device and system for clock synchronization
CN115567143A (en) High precision time synchronization method, apparatus, system and medium for data acquisition system
CN115694704A (en) Time synchronization method, device, equipment and storage medium
CN111614428B (en) Method and device for improving synchronization precision among multiple clocks
CN108401287B (en) Networking method and device
CN111638749A (en) Simulation system synchronization method, simulation device and system
US20180270005A1 (en) Wireless communications device, computer readable medium storing program, and method
CN111414372A (en) Data synchronization method, device, system, equipment and storage medium
CN112019288B (en) Time synchronization method, service single board and network equipment
US20230275679A1 (en) Method and apparatus for synchronizing signals of signal measuring devices
US20220271853A1 (en) Synchronization of clock domains on a data network

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 21938784

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE