Clock synchronization method, device, electronic device and storage medium

By obtaining multiple compensation times of time messages and configuring the local clock of the slave clock, the problem of low synchronization accuracy of master and slave clocks in the prior art is solved, and a higher clock synchronization accuracy is achieved.

CN115276869BActive Publication Date: 2025-03-04CHINA TELECOM CORP LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202210877974.2
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-07-25
Publication Date
2025-03-04
Estimated Expiration
2042-07-25

AI Technical Summary

Technical Problem

The existing clock synchronization devices have different accuracy when measuring the time difference, resulting in inaccurate synchronization of master and slave clocks.

Method used

By obtaining multiple compensation times of time messages, a compensation time set is obtained, and the local clock of the slave clock is configured based on this set to realize clock synchronization of the master and slave clock.

Benefits of technology

Improve the accuracy of master-slave clock synchronization and reduce errors caused by manufacturing process deviations.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115276869B_ABST
    Figure CN115276869B_ABST
Patent Text Reader

Abstract

The present disclosure provides a clock synchronization method, device, electronic device and storage medium, wherein the clock synchronization method comprises: obtaining a compensation time set by acquiring multiple compensation times of a time message, wherein the compensation time is the difference between a first moment and a second moment, the first moment is the moment when a time message sent by a master clock is received, and the second moment is the moment when the time message is forwarded to a slave clock and the slave clock starts to process the time message, and based on the compensation time set, configuring the local clock of the slave clock to synchronize the slave clock with the master clock. The present disclosure configures the local clock of the slave clock according to the calculation results of the multiple compensation times of the time message, thereby improving the accuracy of the master-slave clock synchronization.
Need to check novelty before this filing date? Find Prior Art

Description

Background Art

[0002] The data transmission of the information transmission system needs to be synchronized with the clock to ensure that the data transmission rate is consistent in the upstream and downstream of the data transmission to avoid data loss. In the clock synchronization system, the master clock sends a time message to the slave clock, and the slave clock adjusts the local clock according to the time message to synchronize the master and slave clocks.

[0003] Existing clock synchronization devices need to provide a time difference for the time message to correct the actual reception time of the time message from the clock and improve the clock synchronization accuracy. However, when the actual manufacturing process cannot guarantee complete accuracy, the time difference measured by the clock synchronization device has different measurement accuracy between the same devices, causing the time difference to deviate from the actual value and resulting in inaccurate clock synchronization.

[0004] Based on this, how to improve the accuracy of master-slave clock synchronization has become a technical problem that needs to be solved urgently.

[0005] It should be noted that the information disclosed in the above background technology section is only used to enhance the understanding of the background of the present disclosure, and therefore may include information that does not constitute the prior art known to ordinary technicians in the field. Summary of the invention

[0006] The present disclosure provides a clock synchronization method, device, electronic device and storage medium, which at least to a certain extent overcome the problem of low master-slave clock synchronization accuracy in the related art.

[0007] Other features and advantages of the present disclosure will become apparent from the following detailed description, or may be learned in part by the practice of the present disclosure.

[0008] According to one aspect of the present disclosure, a clock synchronization method is provided, including: acquiring multiple compensation times of a time message to obtain a compensation time set, wherein the compensation time is the difference between a first moment and a second moment, the first moment being the moment when the time message sent by a master clock is received, and the second moment being the moment when the time message is forwarded to a slave clock and the slave clock starts to process the time message; based on the compensation time set, configuring the local clock of the slave clock to synchronize the slave clock with the master clock.

[0009] In one embodiment of the present disclosure, multiple compensation times of a time message are obtained to obtain a compensation time set, including: receiving a time message sent by a master clock, and determining the time when the time message is received; copying the time message to obtain multiple copies of the time message, and sending the multiple copies of the time message to the slave clock through different paths, respectively, and determining the time when the slave clock starts to process each copied time message; obtaining multiple compensation times of the time message according to the time when the time message is received and the time when the slave clock starts to process each copied time message; and writing the multiple compensation times of the time message into the correction domain CF field of the corresponding time message.

[0010] In one embodiment of the present disclosure, after acquiring multiple compensation times of the time message to obtain a compensation time set, the method further includes: screening the compensation time in the compensation time set that meets a preset range value.

[0011] In one embodiment of the present disclosure, configuring the local clock of the slave clock based on the compensation time set includes: calculating a weighted compensation time according to the compensation time set; and configuring the local clock of the slave clock based on the weighted compensation time.

[0012] In one embodiment of the present disclosure, calculating the weighted compensation time according to the compensation time set includes: calculating the compensation time weight according to the compensation time set; and calculating the weighted compensation time according to the compensation time set and the compensation time weight.

[0013] In one embodiment of the present disclosure, the compensation time weight is calculated according to the compensation time set, including: calculating the sum of the reciprocals of all compensation times in the compensation time set; calculating the compensation time weight according to the sum of the reciprocals of all compensation times in the compensation time set and the compensation time set.

[0014] In one embodiment of the present disclosure, a weighted compensation time is calculated based on the compensation time set and the compensation time weight, including: calculating the sum of the products of all compensation times in the compensation time set and the compensation time weight to obtain the weighted compensation time.

[0015] According to another aspect of the present disclosure, a clock synchronization device is provided, including: a set acquisition module, used to acquire multiple compensation times of a time message to obtain a compensation time set, wherein the compensation time is the difference between a first moment and a second moment, the first moment is the moment when the time message sent by the master clock is received, and the second moment is the moment when the time message is forwarded to the slave clock and the slave clock starts to process the time message; a clock configuration module, used to configure the local clock of the slave clock based on the compensation time set to synchronize the slave clock with the clock of the master clock.

[0016] In one embodiment of the present disclosure, the above-mentioned set acquisition module is also used to receive a time message sent by the master clock, determine the time when the time message is received; copy the time message to obtain multiple copies of the time message, send the multiple copies of the time message to the slave clock through different paths, and determine the time when the slave clock starts to process each copied time message; obtain multiple compensation times of the time message according to the time when the time message is received and the time when the slave clock starts to process each copied time message; write the multiple compensation times of the time message into the correction domain CF field of the corresponding time message.

[0017] In one embodiment of the present disclosure, the above-mentioned device further includes a deviation value screening module, and the deviation value screening module is used to screen the compensation time in the compensation time set that meets the preset range value.

[0018] In one embodiment of the present disclosure, the clock configuration module is further used to calculate a weighted compensation time according to the compensation time set; and configure the local clock of the slave clock based on the weighted compensation time.

[0019] In one embodiment of the present disclosure, the clock configuration module is further used to calculate the compensation time weight according to the compensation time set; and to calculate the weighted compensation time according to the compensation time set and the compensation time weight.

[0020] In one embodiment of the present disclosure, the clock configuration module is also used to calculate the sum of the reciprocals of all compensation times in the compensation time set; and calculate the compensation time weight based on the sum of the reciprocals of all compensation times in the compensation time set and the compensation time set.

[0021] In one embodiment of the present disclosure, the clock configuration module is further used to calculate the sum of the products of all compensation times in the compensation time set and the compensation time weights to obtain the weighted compensation time.

[0022] According to another aspect of the present disclosure, there is provided an electronic device, comprising: a processor; and a memory for storing executable instructions of the processor; wherein the processor is configured to perform the above-mentioned clock synchronization method by executing the executable instructions.

[0023] According to another aspect of the present disclosure, 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 above-mentioned clock synchronization method is implemented.

[0024] The embodiments of the present disclosure provide a clock synchronization method, device, electronic device and storage medium, wherein the clock synchronization method comprises: obtaining a compensation time set by acquiring multiple compensation times of a time message, wherein the compensation time is the difference between a first moment and a second moment, the first moment is the moment when a time message sent by a master clock is received, and the second moment is the moment when the time message is forwarded to a slave clock and the slave clock starts to process the time message, and based on the compensation time set, configuring the local clock of the slave clock to synchronize the slave clock with the master clock. The present disclosure configures the local clock of the slave clock according to the calculation results of the multiple compensation times of the time message, thereby improving the accuracy of the master-slave clock synchronization.

[0025] Furthermore, the present disclosure sets a preset range value and filters the compensation time in the compensation time set that meets the preset range value according to the preset range value, so as to remove invalid compensation time in the compensation time set and improve the reliability of data.

[0026] It is to be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the present disclosure. BRIEF DESCRIPTION OF THE DRAWINGS

[0027] The accompanying drawings herein are incorporated into the specification and constitute a part of the specification, illustrate embodiments consistent with the present disclosure, and together with the specification are used to explain the principles of the present disclosure. Obviously, the accompanying drawings described below are only some embodiments of the present disclosure, and for ordinary technicians in this field, other accompanying drawings can be obtained based on these accompanying drawings without creative work.

[0028] Figure 1 A schematic diagram of a clock synchronization system in an embodiment of the present disclosure is shown;

[0029] Figure 2 A flow chart of a clock synchronization method in an embodiment of the present disclosure is shown;

[0030] Figure 3 Another clock synchronization method flow chart in the embodiment of the present disclosure is shown;

[0031] Figure 4A schematic diagram of a clock synchronization method in an embodiment of the present disclosure is shown;

[0032] Figure 5 Another clock synchronization method flow chart in the embodiment of the present disclosure is shown;

[0033] Figure 6 Another clock synchronization method flow chart in the embodiment of the present disclosure is shown;

[0034] Figure 7 A schematic diagram of a clock synchronization device in an embodiment of the present disclosure is shown; and

[0035] Figure 8 A structural block diagram of an electronic device in an embodiment of the present disclosure is shown. DETAILED DESCRIPTION

[0036] Example embodiments will now be described more fully with reference to the accompanying drawings. However, example embodiments can be implemented in a variety of forms and should not be construed as limited to the examples set forth herein; rather, these embodiments are provided so that the disclosure will be more comprehensive and complete and to fully convey the concepts of the example embodiments to those skilled in the art. The described features, structures, or characteristics may be combined in any suitable manner in one or more embodiments.

[0037] In addition, the accompanying drawings are only schematic illustrations of the present disclosure and are not necessarily drawn to scale. The same reference numerals in the figures represent the same or similar parts, and their repeated description will be omitted. Some of the block diagrams shown in the accompanying drawings are functional entities and do not necessarily correspond to physically or logically independent entities. These functional entities can be implemented in software form, or implemented in one or more hardware modules or integrated circuits, or implemented in different networks and / or processor devices and / or microcontroller devices.

[0038] As mentioned in the above background technology, the existing clock synchronization device needs to provide a time difference value for the time message to correct the actual reception time of the time message from the clock and improve the clock synchronization accuracy. However, when the actual manufacturing process cannot guarantee complete accuracy, the time difference value measured by the clock synchronization device has different measurement accuracy between the same devices, so that the time difference value deviates from the actual value and causes inaccurate clock synchronization.

[0039] Based on this, the present disclosure provides a clock synchronization method, device, electronic device and storage medium, which improves the accuracy of master-slave clock synchronization by configuring the local clock of the slave clock according to multiple compensation times of the time message.

[0040] For ease of understanding, several terms involved in the present disclosure are explained below:

[0041] The PTP (Precise Time Protocol) protocol is a protocol for time and frequency synchronization of standard Ethernet terminal devices, also known as IEEE 1588, or 1588 for short. In the PTP clock synchronization system (i.e., PTP domain), there is one and only one synchronization clock, and all terminal devices in the PTP domain are synchronized with the clock. Among them, the node that publishes the synchronization clock in the PTP domain is the master node, and the node that receives the synchronization clock is the slave node. The master node and the slave node can use the 1588 clock synchronization algorithm to achieve clock synchronization by exchanging PTP messages. The PTP protocol is mainly designed for relatively localized, networked systems, with good subnets and relatively stable internal components. Due to the advantages of the PTP protocol, such as simple implementation and less network and computing resources occupied, it is widely used in distributed systems.

[0042] IEEE1588 is a precision clock synchronization protocol standard for network measurement and control systems, referred to as the precision clock protocol. Through message transmission between the master and slave devices, the time and frequency offset are calculated to achieve frequency and time synchronization between the master and slave devices, with an accuracy of sub-microseconds. The purpose of this standard is to accurately synchronize the decentralized and independently running clocks in the measurement and control system.

[0043] Traditional clock synchronization protocols include precise clock synchronization protocols defined by IEEE 1588, such as the PTP protocol. When the PTP protocol is used to synchronize the clocks of two systems, the compensation time in the inbound and outbound directions is written into the CF field of the time message through hardware. When the inbound message is sent to the calculation unit to calculate the accuracy, the value of the CF field is subtracted from the packet receiving time, and the value of the CF field is added by the hardware to obtain the packet sending time. Ultimately, the time carried by the message is close to the time when the hardware receives and sends the packet.

[0044] The present disclosure adds multiple CF field writing units based on the traditional clock synchronization system. Figure 1 A schematic diagram of a clock synchronization system is shown, and the clock synchronization system can be applied to the clock synchronization method in various embodiments of the present disclosure. After the time message receiving module 110 receives the time message sent by the master clock, it copies the time message to obtain multiple copies of the time message, and broadcasts the multiple copies of the time message; the message processing module 120 receives the multiple copies of the time message, measures the compensation time of the multiple copies of the time message, obtains multiple compensation times of the time message, and can write the multiple compensation times of the time message into their respective CF fields through multiple CF field writing units, such as Figure 1CF field writing unit 121, CF field writing unit 122 and CF field writing unit 123, etc., where the number of CF field writing units is unlimited, and then the time message for writing the compensation time is uploaded to the calculation module 130, the calculation module 130 reads the CF field of each copied time message, obtains the compensation time set, calculates the weighted compensation time according to the compensation time set, and uploads the obtained weighted compensation time to the configuration module 140, the configuration module 140 configures the local clock of the slave clock according to the weighted compensation time to synchronize the clocks of the master and slave clocks.

[0045] The present exemplary implementation is described in detail below with reference to the accompanying drawings and embodiments.

[0046] First, a clock synchronization method is provided in an embodiment of the present disclosure. The method can be applied to a slave clock or executed by any electronic device with computing and processing capabilities.

[0047] Figure 2 A flow chart of a clock synchronization method in an embodiment of the present disclosure is shown as follows: Figure 2 As shown, the clock synchronization method provided in the embodiment of the present disclosure includes the following steps:

[0048] S202, obtain multiple compensation times of the time message and obtain a compensation time set, wherein the compensation time is the difference between a first moment and a second moment, the first moment is the moment when the time message sent by the master clock is received, and the second moment is the moment when the time message is forwarded to the slave clock and the slave clock starts processing the time message.

[0049] It should be noted that the above-mentioned compensation time set includes multiple compensation times of the time message; in one embodiment of the present disclosure, after receiving the time message sent by the master clock, the time message can be copied first to obtain multiple copies of the time message, the copied time message can be broadcast, the compensation time of each copied time message can be measured to obtain the compensation time of each copied time message, and the compensation time can be written into the CF field of the corresponding time message, and the compensation time set can be obtained by reading the CF field of each time message.

[0050] The time message mentioned in each embodiment of the present disclosure can be various time messages defined by the PTP protocol. The PTP protocol defines two types of messages. One is a time message, which needs to be timestamped at the time of sending and receiving, and uses an event port for sending and receiving. The port number of the event port is 319; the other is a common message, which does not need to be timestamped at the time of sending and receiving, and uses a universal port for sending and receiving. The port number of the universal port is 320. Time messages include, but are not limited to: synchronization (Sync) messages, delay request (Delay_Req) ​​messages, peer delay request (Pdelay_Req) ​​messages, and peer delay response (Pdelay_Resp) messages. Correspondingly, common messages include, but are not limited to: notification (Announce) messages, follow (Follow_Up) messages, delay response (Delay_Resp) messages, peer delay response follow (Pdelay_Resp_Follow_Up) messages, management (Managment) messages, and signaling (Signaling) messages. The PTP time message in the embodiment of the present disclosure complies with the format specified by the PTP protocol, for example, including a timestamp (TS) field, a CF field, a PTP message type field, a PTP message sequence number field, and a PTP message port field.

[0051] S204: Based on the compensation time set, configure the local clock of the slave clock to synchronize the slave clock with the master clock.

[0052] It should be noted that the local clock of the slave clock can be configured according to multiple compensation times of the time message in the compensation time set. For example, the weight values ​​of all compensation times in the compensation time set are calculated first, where the weight value of each compensation time in the compensation time set can be the same or different. Then, based on the compensation time set and the weight value, the weighted values ​​of all compensation times in the compensation time set are calculated. Finally, according to the weighted values ​​of all compensation times in the compensation time set, the local clock of the slave clock is configured.

[0053] The clock synchronization method provided by the embodiment of the present disclosure obtains a compensation time set by acquiring multiple compensation times of a time message, wherein the compensation time is the difference between a first moment and a second moment, the first moment is the moment when the time message sent by the master clock is received, and the second moment is the moment when the time message is forwarded to the slave clock and the slave clock starts to process the time message. Based on the compensation time set, the local clock of the slave clock is configured to synchronize the slave clock with the master clock. The present disclosure configures the local clock of the slave clock according to the calculation results of the multiple compensation times of the time message, thereby improving the accuracy of the master-slave clock synchronization.

[0054] It should be noted that the clock synchronization method disclosed in the present invention can be applied to scenarios such as clock synchronization of hardware between networking network elements, clock synchronization of server clusters, and clock synchronization between a server resource pool and physical network elements.

[0055] The clock synchronization method provided by the present invention adds multiple CF field writing modules on the basis of the existing traditional time compensation device. After receiving the time message sent by the master clock, multiple compensation times of the time message are measured, and each compensation time of the time message is written into the respective CF field by using the multiple CF field writing modules, and uploaded to the calculation unit for weighted compensation time calculation. According to the obtained weighted compensation time, the local clock of the slave clock is configured to improve the accuracy of the master-slave clock synchronization.

[0056] In one embodiment of the present disclosure, Figure 3 The steps disclosed in the above are used to obtain multiple compensation times of the time message and obtain the compensation time set, see Figure 3 Another clock synchronization method flow chart shown may include the following steps:

[0057] S302, receiving a time message sent by a master clock, and determining the time when the time message is received;

[0058] S304, copying the time message to obtain multiple copies of the time message, sending the multiple copies of the time message to the slave clock through different paths respectively, and determining the time when the slave clock starts to process each copy of the time message;

[0059] S306, obtaining multiple compensation times of the time message according to the time when the time message is received and the time when each copied time message is processed from the clock;

[0060] S308, writing the multiple compensation times of the time message into the correction domain CF field of the corresponding time message respectively.

[0061] It should be noted that, in one embodiment of the present disclosure, see Figure 4 The schematic diagram of a clock synchronization method shown in the figure, after receiving a time message sent by the master clock, the time message here can be a Sync message, and recording the time t1 when the time message is sent from the master clock and the time t2 when the slave clock receives the time message. Subsequently, the slave clock returns a delay_req message to the master clock, and records the time t3 when the slave clock sends the delay_req message and the time t4 when the master clock receives the delay_req message. The compensation time offset and transmission delay delay of the time message can be calculated by the following formula:

[0062] offset=((t2-t1)-(t4-t3)) / 2 (1)

[0063] delay=((t2-t1)+(t4-t3)) / 2 (2)

[0064] After the compensation time of each time message is obtained, each compensation time of the time message is written into the respective CF field, and then the compensation time set is obtained by reading the CF field of each time message.

[0065] In one embodiment of the present disclosure, after obtaining multiple compensation times of the time message and obtaining a compensation time set, the method further includes: screening the compensation time in the compensation time set that meets the preset range value. Here, for example, the obtained compensation time set is N = {n1, n2, n3, ..., n i}, i is a positive integer, the time precision standard value is set to k, then the preset time range value is [-k, k], and the compensation time that meets the preset range value in the compensation time set is filtered to obtain the filtered compensation time set N1 = {n j ∈N, -k≤n j ≤k}, j is a positive integer. The present disclosure sets a preset range value, and screens the compensation time in the compensation time set that meets the preset range value according to the preset range value, so as to remove invalid compensation time in the compensation time set and improve the reliability of data.

[0066] In one embodiment of the present disclosure, Figure 5 The steps disclosed in the implementation of the compensation time set based on the configuration of the local clock of the slave clock, see Figure 5 Another clock synchronization method flow chart shown may include the following steps:

[0067] S502, calculating a weighted compensation time according to the compensation time set;

[0068] S504: Configure the local clock of the slave clock based on the weighted compensation time.

[0069] It should be noted that, in one embodiment of the present disclosure, the above-screened compensation time set N1={n j ∈N, -k≤n j ≤k} as an example, the compensation time weight can be calculated based on the compensation time set, and then the weighted compensation time can be calculated based on the compensation time set and the compensation time weight. The compensation time weight can be calculated by calculating the sum of the reciprocals of all compensation times in the compensation time set; the compensation time weight can be calculated based on the sum of the reciprocals of all compensation times in the compensation time set and the compensation time set.

[0070] In one embodiment of the present disclosure, the sum S of the reciprocals of all compensation times in the compensation time set N1 and the compensation time weight A may be calculated by the following formula:

[0071]

[0072]

[0073] Wherein, S is the sum of the reciprocals of all compensation times in the compensation time set N1, and m is the number of elements in the compensation time set N1.

[0074] In one embodiment of the present disclosure, the weighted compensation time T of the compensation time set N1 may be calculated by the following formula:

[0075]

[0076] The clock synchronization method provided by the embodiment of the present disclosure obtains the final compensation time, that is, the weighted compensation time, through a weighted algorithm, and optimizes the algorithm for the compensation time written by the traditional hardware, thereby ultimately improving the accuracy of clock synchronization and reducing the error caused by manufacturing process deviation. At the same time, under multiple weighted compensation time acquisition lines, the optimal message packet sending line is obtained according to the calculation, and a better line can be automatically selected for the current environment without having to obtain a better clock synchronization network element by replacing the equipment, thereby reducing production costs.

[0077] In one embodiment of the present disclosure, Figure 6 The steps disclosed in the implementation are to calculate the weighted compensation time according to the compensation time set, see Figure 6 Another clock synchronization method flow chart shown may include the following steps:

[0078] S602, calculating the compensation time weight according to the compensation time set;

[0079] S604: Calculate a weighted compensation time according to the compensation time set and the compensation time weight.

[0080] In one embodiment of the present disclosure, the compensation time weight is calculated according to the compensation time set, including: calculating the sum of the reciprocals of all compensation times in the compensation time set; calculating the compensation time weight according to the sum of the reciprocals of all compensation times in the compensation time set and the compensation time set.

[0081] In one embodiment of the present disclosure, the weighted compensation time is calculated according to the compensation time set and the compensation time weight, including: calculating the sum of the products of all compensation times in the compensation time set and the compensation time weight to obtain the weighted compensation time.

[0082] Based on the same inventive concept, the present disclosure also provides a clock synchronization device, such as the following embodiment. Since the principle of solving the problem in the device embodiment is similar to that in the above method embodiment, the implementation of the device embodiment can refer to the implementation of the above method embodiment, and the repeated parts will not be repeated.

[0083] Figure 7 A schematic diagram of a clock synchronization device in an embodiment of the present disclosure is shown. Figure 7 As shown, the device comprises:

[0084] A set acquisition module 710 is used to acquire multiple compensation times of the time message to obtain a compensation time set, wherein the compensation time is the difference between a first moment and a second moment, the first moment is the moment when the time message sent by the master clock is received, and the second moment is the moment when the time message is forwarded to the slave clock and the slave clock starts processing the time message;

[0085] The clock configuration module 720 is used to configure the local clock of the slave clock based on the compensation time set so that the slave clock is synchronized with the clock of the master clock.

[0086] In one embodiment of the present disclosure, the above-mentioned device further includes a deviation value screening module, and the deviation value screening module is used to screen the compensation time in the compensation time set that meets the preset range value.

[0087] In one embodiment of the present disclosure, the above-mentioned set acquisition module 710 is also used to receive a time message sent by the master clock, determine the time when the time message is received; copy the time message to obtain multiple copies of the time message, send the multiple copies of the time message to the slave clock through different paths, and determine the time when the slave clock starts to process each copied time message; obtain multiple compensation times of the time message according to the time when the time message is received and the time when the slave clock starts to process each copied time message; write the multiple compensation times of the time message into the correction domain CF field of the corresponding time message.

[0088] In one embodiment of the present disclosure, the clock configuration module 720 is further configured to calculate a weighted compensation time according to the compensation time set; and configure the local clock of the slave clock based on the weighted compensation time.

[0089] In one embodiment of the present disclosure, the clock configuration module 720 is further configured to calculate a compensation time weight according to the compensation time set; and to calculate a weighted compensation time according to the compensation time set and the compensation time weight.

[0090] In one embodiment of the present disclosure, the clock configuration module 720 is further used to calculate the sum of the reciprocals of all compensation times in the compensation time set; and calculate the compensation time weight according to the sum of the reciprocals of all compensation times in the compensation time set and the compensation time set.

[0091] In one embodiment of the present disclosure, the clock configuration module 720 is further configured to calculate the sum of the products of all compensation times in the compensation time set and the compensation time weights to obtain the weighted compensation time.

[0092] Those skilled in the art will appreciate that various aspects of the present disclosure may be implemented as systems, methods or program products. Therefore, various aspects of the present disclosure may be specifically implemented in the following forms, namely: complete hardware implementation, complete software implementation (including firmware, microcode, etc.), or a combination of hardware and software, which may be collectively referred to herein as "circuits", "modules" or "systems".

[0093] Refer to the following Figure 8 The electronic device 800 according to this embodiment of the present disclosure is described. Figure 8 The electronic device 800 shown is merely an example and should not bring any limitation to the functions and scope of use of the embodiments of the present disclosure.

[0094] like Figure 8 As shown, the electronic device 800 is in the form of a general computing device. The components of the electronic device 800 may include but are not limited to: at least one processing unit 810, at least one storage unit 820, and a bus 830 connecting different system components (including the storage unit 820 and the processing unit 810).

[0095] The storage unit stores program codes, and the program codes can be executed by the processing unit 810, so that the processing unit 810 executes the steps described in the above "Exemplary Method" section of this specification according to various exemplary embodiments of the present disclosure. For example, the processing unit 810 can execute the following steps of the above method embodiment: obtain multiple compensation times of the time message to obtain a compensation time set, wherein the compensation time is the difference between a first moment and a second moment, the first moment is the moment when the time message sent by the master clock is received, and the second moment is the moment when the time message is forwarded to the slave clock and the slave clock starts to process the time message; based on the compensation time set, configure the local clock of the slave clock to synchronize the clock of the slave clock with the clock of the master clock.

[0096] In some embodiments, in the electronic device provided in the embodiments of the present disclosure, the processing unit 810 is also used to: receive a time message sent by a master clock, and determine the moment when the time message is received; copy the time message to obtain multiple copies of the time message, and send the multiple copies of the time message to the slave clock through different paths, and determine the moment when the slave clock starts processing each copied time message; obtain multiple compensation times of the time message according to the moment when the time message is received and the moment when the slave clock starts processing each copied time message; and write the multiple compensation times of the time message into the correction domain CF field of the corresponding time message.

[0097] In some embodiments, in the electronic device provided in the embodiments of the present disclosure, the processing unit 810 is further used to: filter the compensation time in the compensation time set that meets the preset range value.

[0098] In some embodiments, in the electronic device provided in the embodiments of the present disclosure, the processing unit 810 is further used to: calculate a weighted compensation time according to a compensation time set; and configure a local clock of a slave clock based on the weighted compensation time.

[0099] In some embodiments, in the electronic device provided in the embodiments of the present disclosure, the processing unit 810 is further used to: calculate the compensation time weight according to the compensation time set; and calculate the weighted compensation time according to the compensation time set and the compensation time weight.

[0100] In some embodiments, in the electronic device provided in the embodiments of the present disclosure, the processing unit 810 is also used to: calculate the sum of the reciprocals of all compensation times in the compensation time set; calculate the compensation time weight based on the sum of the reciprocals of all compensation times in the compensation time set and the compensation time set.

[0101] In some embodiments, in the electronic device provided in the embodiments of the present disclosure, the processing unit 810 is further used to: calculate the sum of the products of all compensation times in the compensation time set and the compensation time weights to obtain the weighted compensation time.

[0102] The storage unit 820 may include a readable medium in the form of a volatile storage unit, such as a random access memory unit (RAM) 8201 and / or a cache memory unit 8202 , and may further include a read-only memory unit (ROM) 8203 .

[0103] The storage unit 820 may also include a program / utility 8204 having a set (at least one) of program modules 8205, such program modules 8205 including but not limited to: an operating system, one or more application programs, other program modules, and program data, each of which or some combination may include an implementation of a network environment.

[0104] Bus 830 may represent one or more of several types of bus structures, including a memory unit bus or memory unit controller, a peripheral bus, an accelerated graphics port, a processing unit, or a local bus using any of a variety of bus architectures.

[0105] The electronic device 800 may also communicate with one or more external devices 840 (e.g., keyboards, pointing devices, Bluetooth devices, etc.), may also communicate with one or more devices that enable a user to interact with the electronic device 800, and / or communicate with any device that enables the electronic device 800 to communicate with one or more other computing devices (e.g., routers, modems, etc.). Such communication may be performed via an input / output (I / O) interface 850. Furthermore, the electronic device 800 may also communicate with one or more networks (e.g., local area networks (LANs), wide area networks (WANs), and / or public networks, such as the Internet) via a network adapter 860. As shown, the network adapter 860 communicates with other modules of the electronic device 800 via a bus 830. It should be understood that, although not shown in the figure, other hardware and / or software modules may be used in conjunction with the electronic device 800, including but not limited to: microcode, device drivers, redundant processing units, external disk drive arrays, RAID systems, tape drives, and data backup storage systems, etc.

[0106] Through the description of the above implementation, it is easy for those skilled in the art to understand that the example implementation described here can be implemented by software, or by software combined with necessary hardware. Therefore, the technical solution according to the implementation of the present disclosure can be embodied in the form of a software product, which can be stored in a non-volatile storage medium (which can be a CD-ROM, a USB flash drive, a mobile hard disk, etc.) or on a network, including several instructions to enable a computing device (which can be a personal computer, a server, a terminal device, or a network device, etc.) to execute the method according to the implementation of the present disclosure.

[0107] In an exemplary embodiment of the present disclosure, a computer-readable storage medium is also provided, which may be a readable signal medium or a readable storage medium. A program product capable of implementing the above method of the present disclosure is stored thereon. In some possible implementations, various aspects of the present disclosure may also be implemented in the form of a program product, which includes a program code, and when the program product is run on a terminal device, the program code is used to enable the terminal device to execute the steps according to various exemplary implementations of the present disclosure described in the above "Exemplary Method" section of this specification. For example, when the computer program stored on the computer-readable storage medium in the embodiment of the present disclosure is executed by the processor, the following steps of the following method may be implemented: obtaining multiple compensation times of the time message, obtaining a compensation time set, wherein the compensation time is the difference between the first moment and the second moment, the first moment is the moment when the time message sent by the master clock is received, and the second moment is the moment when the time message is forwarded to the slave clock and the slave clock starts to process the time message; based on the compensation time set, configuring the local clock of the slave clock to synchronize the clock of the slave clock with the clock of the master clock.

[0108] In some embodiments, when the computer program stored on the computer-readable storage medium in the embodiments of the present disclosure is executed by the processor, the following steps of the following method can also be implemented: receiving a time message sent by the master clock, and determining the moment when the time message is received; copying the time message to obtain multiple copies of the time message, and sending the multiple copies of the time message to the slave clock through different paths, and determining the moment when the slave clock starts processing each copied time message; obtaining multiple compensation times of the time message according to the moment when the time message is received and the moment when the slave clock starts processing each copied time message; and writing the multiple compensation times of the time message into the correction domain CF field of the corresponding time message.

[0109] In some embodiments, when the computer program stored on the computer-readable storage medium in the embodiments of the present disclosure is executed by a processor, the following steps of the following method can also be implemented: screening the compensation time in the compensation time set that meets the preset range value.

[0110] In some embodiments, when the computer program stored on the computer-readable storage medium in the embodiments of the present disclosure is executed by the processor, the following steps of the following method can also be implemented: according to the compensation time set, the weighted compensation time is calculated; based on the weighted compensation time, the local clock of the slave clock is configured.

[0111] In some embodiments, when the computer program stored on the computer-readable storage medium in the embodiments of the present disclosure is executed by the processor, the following steps of the following method can also be implemented: calculating the compensation time weight according to the compensation time set; calculating the weighted compensation time according to the compensation time set and the compensation time weight.

[0112] In some embodiments, when the computer program stored on the computer-readable storage medium in the embodiments of the present disclosure is executed by the processor, the following steps of the following method can also be implemented: calculating the sum of the reciprocals of all compensation times in the compensation time set; calculating the compensation time weight based on the sum of the reciprocals of all compensation times in the compensation time set and the compensation time set.

[0113] In some embodiments, when the computer program stored on the computer-readable storage medium in the embodiments of the present disclosure is executed by the processor, the following steps of the following method can also be implemented: calculating the sum of the products of all compensation times in the compensation time set and the compensation time weights to obtain the weighted compensation time.

[0114] More specific examples of computer-readable storage media in the present disclosure may include, but are not limited to, an electrical connection having one or more conductors, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.

[0115] In the present disclosure, a computer readable storage medium may include a data signal propagated in baseband or as part of a carrier wave, wherein a readable program code is carried. Such propagated data signals may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. A readable signal medium may also be any readable medium other than a readable storage medium, which may send, propagate, or transmit a program for use by or in conjunction with an instruction execution system, apparatus, or device.

[0116] Alternatively, the program code contained on the computer-readable storage medium may be transmitted using any appropriate medium, including but not limited to wireless, wired, optical cable, RF, etc., or any suitable combination of the foregoing.

[0117] In a specific implementation, the program code for performing the operations of the present disclosure may be written in any combination of one or more programming languages, including object-oriented programming languages ​​such as Java, C++, etc., and conventional procedural programming languages ​​such as "C" or similar programming languages. The program code may be executed entirely on the user computing device, partially on the user device, as a separate software package, partially on the user computing device and partially on a remote computing device, or entirely on a remote computing device or server. In the case of a remote computing device, the remote computing device may be connected to the user computing device through any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computing device (e.g., using an Internet service provider to connect through the Internet).

[0118] It should be noted that, although several modules or units of the device for action execution are mentioned in the above detailed description, this division is not mandatory. In fact, according to the embodiments of the present disclosure, the features and functions of two or more modules or units described above can be embodied in one module or unit. On the contrary, the features and functions of one module or unit described above can be further divided into multiple modules or units to be embodied.

[0119] In addition, although the steps of the method in the present disclosure are described in a specific order in the drawings, this does not require or imply that the steps must be performed in this specific order, or that all the steps shown must be performed to achieve the desired results. Additionally or alternatively, some steps may be omitted, multiple steps may be combined into one step, and / or one step may be decomposed into multiple steps, etc.

[0120] Through the description of the above implementation, it is easy for those skilled in the art to understand that the example implementation described here can be implemented by software, or by software combined with necessary hardware. Therefore, the technical solution according to the implementation of the present disclosure can be embodied in the form of a software product, which can be stored in a non-volatile storage medium (which can be a CD-ROM, a USB flash drive, a mobile hard disk, etc.) or on a network, including several instructions to enable a computing device (which can be a personal computer, a server, a mobile terminal, or a network device, etc.) to execute the method according to the implementation of the present disclosure.

[0121] Those skilled in the art will readily appreciate other embodiments of the present disclosure after considering the specification and practicing the invention disclosed herein. The present disclosure is intended to cover any variations, uses or adaptations of the present disclosure, which follow the general principles of the present disclosure and include common knowledge or customary techniques in the art that are not disclosed in the present disclosure. The description and examples are intended to be exemplary only, and the true scope and spirit of the present disclosure are indicated by the appended claims.

Claims

1. A clock synchronization method, characterized in that: Applied to a clock synchronization system, the clock synchronization system comprises: a plurality of CF field writing units; comprising: Acquire multiple compensation times of the time message to obtain a compensation time set, wherein the compensation time is the difference between a first moment and a second moment, the first moment is the moment when the time message sent by the master clock is received, and the second moment is the moment when the time message is forwarded to the slave clock and the slave clock starts to process the time message; Based on the compensation time set, configuring a local clock of a slave clock so that the slave clock is synchronized with a clock of the master clock; Get multiple compensation times of the time message and get a compensation time set, including: Receive the time message sent by the master clock and determine the time when the time message is received; Copying the time message to obtain multiple copies of the time message, sending the multiple copies of the time message to the slave clock through different paths respectively, and determining the time when the slave clock starts processing each copied time message; For any one of the multiple CF field writing units, the any one CF field writing unit obtains a compensation time of the time message according to a time when the time message is received and a time when the corresponding copied time message is processed from a clock, thereby obtaining multiple compensation times of the time message corresponding to the multiple CF field writing units; The multiple CF field writing units write the multiple compensation times of the time message into the correction domain CF field of the corresponding copied time message respectively to obtain a compensation time set.

2. The clock synchronization method according to claim 1, characterized in that: After acquiring multiple compensation times of the time message to obtain a compensation time set, the method further includes: The compensation time set is filtered to have a compensation time that meets a preset range value.

3. The clock synchronization method according to claim 1, characterized in that: Configuring the local clock of the slave clock based on the compensation time set includes: Calculating a weighted compensation time according to the compensation time set; Based on the weighted compensation time, a local clock of the slave clock is configured.

4. The clock synchronization method according to claim 3, characterized in that: Calculating a weighted compensation time according to the compensation time set includes: Calculating a compensation time weight according to the compensation time set; A weighted compensation time is calculated according to the compensation time set and the compensation time weight.

5. The clock synchronization method according to claim 4, characterized in that: Calculating the compensation time weight according to the compensation time set includes: Calculating the sum of the reciprocals of all compensation times in the compensation time set; The compensation time weight is calculated according to the sum of the reciprocals of all compensation times in the compensation time set and the compensation time set.

6. The clock synchronization method according to claim 4, characterized in that: Calculating a weighted compensation time according to the compensation time set and the compensation time weight includes: The sum of the products of all compensation times in the compensation time set and the compensation time weights is calculated to obtain the weighted compensation time.

7. A clock synchronization device, characterized in that: Applied to a clock synchronization system, the clock synchronization system comprises: a plurality of CF field writing units; comprising: A set acquisition module, used to acquire multiple compensation times of a time message to obtain a compensation time set, wherein the compensation time is the difference between a first moment and a second moment, the first moment is the moment when the time message sent by the master clock is received, and the second moment is the moment when the time message is forwarded to the slave clock and the slave clock starts processing the time message; A clock configuration module, configured to configure a local clock of the slave clock based on the compensation time set so that the slave clock is synchronized with the clock of the master clock; The set acquisition module is also used to receive a time message sent by the master clock and determine the time when the time message is received; copy the time message to obtain multiple copies of the time message, send the multiple copies of the time message to the slave clock through different paths, and determine the time when the slave clock starts to process each copied time message; for any one of the multiple CF field writing units, the any one CF field writing unit obtains the compensation time of the time message based on the time when the time message is received and the time when the slave clock starts to process the corresponding copied time message, thereby obtaining multiple compensation times of the time message corresponding to the multiple CF field writing units; the multiple CF field writing units write the multiple compensation times of the time message into the correction domain CF field of the corresponding copied time message to obtain a compensation time set.

8. An electronic device, characterized in that: include: processor; as well as A memory, configured to store executable instructions of the processor; The processor is configured to execute the clock synchronization method according to any one of claims 1 to 6 by executing the executable instructions.

9. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the clock synchronization method according to any one of claims 1 to 6 is implemented.

Citation Information

Patent Citations

  • Clock synchronization using multiple network paths

    CN104247309A

  • Centralized method for realizing 1588 time synchronization on distributed system

    CN107294634A