[go: up one dir, main page]

CN115276869B - Clock synchronization method, device, electronic device and storage medium - Google Patents

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

Info

Publication number
CN115276869B
CN115276869B CN202210877974.2A CN202210877974A CN115276869B CN 115276869 B CN115276869 B CN 115276869B CN 202210877974 A CN202210877974 A CN 202210877974A CN 115276869 B CN115276869 B CN 115276869B
Authority
CN
China
Prior art keywords
time
compensation
clock
message
time message
Prior art date
Legal status (The legal status 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 status listed.)
Active
Application number
CN202210877974.2A
Other languages
Chinese (zh)
Other versions
CN115276869A (en
Inventor
林力帆
李鹏
欧亮
卢兰
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
China Telecom Corp Ltd
Original Assignee
China Telecom Corp Ltd
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 China Telecom Corp Ltd filed Critical China Telecom Corp Ltd
Priority to CN202210877974.2A priority Critical patent/CN115276869B/en
Publication of CN115276869A publication Critical patent/CN115276869A/en
Application granted granted Critical
Publication of CN115276869B publication Critical patent/CN115276869B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

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
    • 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

Landscapes

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

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 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, 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.

Description

Clock synchronization method, clock synchronization device, electronic equipment and storage medium
Technical Field
The disclosure relates to the technical field of communication, and in particular relates to a clock synchronization method, a clock synchronization device, electronic equipment and a storage medium.
Background
The data transmission of the information transmission system needs to keep the data transmission speed consistent at the upstream and downstream of the data transmission under the condition of clock synchronization, so as to avoid data loss. In a clock synchronization system, a master clock issues a time message to a slave clock, and the slave clock adjusts a local clock according to the time message so as to synchronize clocks of the master clock and the slave clock.
The prior clock synchronization device needs to provide a time difference value for the time message, corrects the receiving time of the time message actually received by the slave clock, and improves the clock synchronization precision. However, in the case where the actual manufacturing process cannot ensure the full accuracy, the time difference measured by the clock synchronization device varies in measurement accuracy between devices of the same type, so that the time difference deviates from the actual value, and the clock synchronization is inaccurate.
Based on this, how to improve the accuracy of master-slave clock synchronization becomes a technical problem to be solved.
It should be noted that the information disclosed in the above background section is only for enhancing understanding of the background of the present disclosure and thus may include information that does not constitute prior art known to those of ordinary skill in the art.
Disclosure of Invention
The disclosure provides a clock synchronization method, a clock synchronization device, an electronic device and a storage medium, which at least overcome the problem of low master-slave clock synchronization precision in the related art to a certain extent.
Other features and advantages of the present disclosure will be apparent from the following detailed description, or may be learned in part by the practice of the disclosure.
According to one aspect of the disclosure, a clock synchronization method is provided, which comprises the steps of obtaining a plurality of compensation times of a time message, and obtaining a compensation time set, wherein the compensation time is a difference value between a first time and a second time, the first time is a time when the time message sent by a master clock is received, the second time is a time when the time message is forwarded to a slave clock and the slave clock starts to process the time message, and the local clock of the slave clock is configured based on the compensation time set so as to synchronize the slave clock with the clock of the master clock.
In one embodiment of the disclosure, a plurality of compensation times of a time message are acquired to obtain a compensation time set, wherein the compensation time set comprises a time message sent by a master clock, a time moment when the time message is received is determined, the time message is copied to obtain a plurality of copied time messages, the time moment when the time message of each copy is processed from a slave clock is determined by sending the time messages of the plurality of copies to the slave clock through different paths, the compensation time of the time message is obtained according to the time moment when the time message is received and the time moment when the time message of each copy is processed from the slave clock, and the compensation time of the time message is written into a correction field CF field of the corresponding time message.
In one embodiment of the disclosure, after obtaining the plurality of compensation times of the time message and obtaining the compensation time set, the method further includes screening the compensation times in the compensation time set, wherein the compensation times accord with a preset range value.
In one embodiment of the disclosure, configuring the local clock of the slave clock based on the set of compensation times includes calculating a weighted compensation time from the set of compensation times and configuring the local clock of the slave clock based on the weighted compensation time.
In one embodiment of the disclosure, calculating the weighted compensation time according to the compensation time set comprises calculating a 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.
In one embodiment of the present disclosure, calculating a compensation time weight from the compensation time set includes calculating a sum of the reciprocals of all compensation times in the compensation time set, and calculating the compensation time weight from the sum of the reciprocals of all compensation times in the compensation time set and the compensation time set.
In one embodiment of the present disclosure, calculating a weighted compensation time from the set of compensation times and the compensation time weight includes calculating a sum of products of all compensation times in the set of compensation times and the compensation time weight to obtain the weighted compensation time.
According to another aspect of the disclosure, a clock synchronization device is provided, which comprises a set acquisition module, a clock configuration module and a clock configuration module, wherein the set acquisition module is used for acquiring a plurality of compensation times of a time message to obtain a compensation time set, the compensation time is a difference value between a first time and a second time, the first time is a time when the time message sent by a master clock is received, the second time is a time when the time message is forwarded to a slave clock and the slave clock starts to process the time message, and the clock configuration module is used for configuring a local clock of the slave clock based on the compensation time set so as to synchronize the slave clock with a clock of the master clock.
In one embodiment of the disclosure, the set obtaining module is further configured to receive a time message sent by a master clock, determine a time when the time message is received, copy the time message to obtain a plurality of copied time messages, send the plurality of copied time messages to a slave clock through different paths, determine a time when the slave clock starts to process each copied time message, obtain a plurality of 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 write the plurality of compensation times of the time message into a correction field CF of the corresponding time message.
In an embodiment of the disclosure, the apparatus further includes a bias value screening module, where the bias value screening module is configured to screen the compensation time set for a compensation time that meets a preset range value.
In one embodiment of the present disclosure, the clock configuration module is further configured to calculate a weighted compensation time according to the compensation time set, and configure a local clock of the slave clock based on the weighted compensation time.
In one embodiment of the present disclosure, the clock configuration module is further configured to calculate a compensation time weight according to the compensation time set, and calculate a weighted compensation time according to the compensation time set and the compensation time weight.
In one embodiment of the present disclosure, the clock configuration module is further configured to calculate a sum of the inverses of all the compensation times in the compensation time set, and calculate the compensation time weight according to the sum of the inverses of all the compensation times in the compensation time set and the compensation time set.
In one embodiment of the present disclosure, the clock configuration module is further configured to calculate a sum of products of all compensation times in the compensation time set and the compensation time weights, to obtain the weighted compensation time.
According to yet 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-described clock synchronization method via execution of the executable instructions.
According to yet another aspect of the present disclosure, there is provided a computer-readable storage medium having stored thereon a computer program which, when executed by a processor, implements the above-described clock synchronization method.
The clock synchronization method comprises the steps of obtaining a compensation time set by obtaining a plurality of compensation times of a time message, wherein the compensation time is a difference value between a first time and a second time, the first time is a time when the time message sent by a master clock is received, the second time is a time when the time message is forwarded to a slave clock, the slave clock starts to process the time message, and a local clock of the slave clock is configured based on the compensation time set so as to enable the slave clock to be synchronous with a clock of a master clock.
Further, the method and the device screen and filter the compensation time meeting the preset range value in the compensation time set according to the preset range value to remove invalid compensation time in the compensation time set and improve the reliability of data.
It is to be understood that both the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the disclosure.
Drawings
The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the disclosure and together with the description, serve to explain the principles of the disclosure. It will be apparent to those of ordinary skill in the art that the drawings in the following description are merely examples of the disclosure and that other drawings may be derived from them without undue effort.
FIG. 1 illustrates a schematic diagram of a clock synchronization system in an embodiment of the present disclosure;
FIG. 2 illustrates a flow chart of a clock synchronization method in an embodiment of the present disclosure;
FIG. 3 illustrates another clock synchronization method flow diagram in an embodiment of the present disclosure;
FIG. 4 illustrates a schematic diagram of a clock synchronization method in an embodiment of the present disclosure;
FIG. 5 illustrates another clock synchronization method flow diagram in an embodiment of the present disclosure;
FIG. 6 illustrates another clock synchronization method flow diagram in an embodiment of the present disclosure;
FIG. 7 shows a schematic diagram of a clock synchronization apparatus in an embodiment of the disclosure, and
Fig. 8 shows a block diagram of an electronic device in an embodiment of the disclosure.
Detailed Description
Example embodiments will now be described more fully with reference to the accompanying drawings. However, the exemplary embodiments may be embodied in many forms and should not be construed as limited to the examples set forth herein, but rather, these embodiments are provided so that this disclosure will be thorough and complete, and will fully convey the concept of the exemplary 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.
Furthermore, the drawings are merely schematic illustrations of the present disclosure and are not necessarily drawn to scale. The same reference numerals in the drawings denote the same or similar parts, and thus a repetitive description thereof will be omitted. Some of the block diagrams shown in the figures are functional entities and do not necessarily correspond to physically or logically separate entities. These functional entities may be implemented in software or in one or more hardware modules or integrated circuits or in different networks and/or processor devices and/or microcontroller devices.
As mentioned in the foregoing background art, the existing clock synchronization device needs to provide a time difference value for the time message, correct the receiving time of the time message actually received by the slave clock, and improve the clock synchronization precision. However, in the case where the actual manufacturing process cannot ensure the full accuracy, the time difference measured by the clock synchronization device varies in measurement accuracy between devices of the same type, so that the time difference deviates from the actual value, and the clock synchronization is inaccurate.
Based on the above, the present disclosure provides a clock synchronization method, apparatus, electronic device and storage medium, which improves accuracy of clock synchronization of master clock and slave clock by configuring local clocks of slave clocks according to a plurality of compensation times of time messages.
For ease of understanding, the following first explains the several terms involved in this disclosure as follows:
The PTP (PRECISE TIME Protocol, precision time synchronization Protocol) Protocol is a Protocol for performing time and frequency synchronization on standard ethernet terminal equipment, and is also called IEEE 1588, abbreviated as 1588. In a PTP clock synchronization system (i.e. PTP domain), there is and only one synchronization clock, with which all terminal devices in the PTP domain remain synchronized. The node which issues the synchronous clock in the PTP domain is a master node, and the node which receives the synchronous clock is a slave node. The master node and the slave node can realize clock synchronization by interacting PTP messages by using 1588 clock synchronization algorithm. The PTP protocol is mainly designed for relatively localized, networked systems, better subnetworks, and relatively stable environments of internal components. The PTP protocol is easy to realize, and has the advantages of small occupied network and computing resources, and the like, so that the PTP protocol is widely applied to a distributed system.
IEEE1588 is a precision clock synchronization protocol standard, abbreviated as precision clock protocol, of a network measurement and control system. The time and frequency offset is calculated through the message transmission between the master device and the slave device, so that the frequency and time synchronization of the master device and the slave device is achieved, and the accuracy can reach the sub microsecond level. The purpose of this standard is to accurately synchronize measurements with a decentralized, independently operating clock in the control system.
The conventional clock synchronization protocol includes an IEEE 1588 defined accurate clock synchronization protocol, such as PTP protocol, where when two systems clock are synchronized by PTP protocol, the time for compensating the incoming direction and the outgoing direction will be written into the CF field of the time packet by hardware, the time for receiving the packet minus the value of the CF field when the incoming direction packet is sent to the calculation unit to calculate the accuracy, and the time for obtaining the packet sending time will be added to the outgoing direction by hardware, so that the time carried by the packet is close to the time for receiving and sending the packet by hardware.
The present disclosure adds a plurality of CF field writing units on the basis of a conventional clock synchronization system, and referring to a schematic diagram of a clock synchronization system shown in fig. 1, the clock synchronization system may be applied to the clock synchronization method in various embodiments of the present disclosure. The message processing module 120 receives the time messages of the multiple copies, measures the compensation time of the time messages of the multiple copies, obtains multiple compensation time of the time messages, writes the multiple compensation time of the time messages into respective CF fields through a plurality of CF field writing units, such as CF field writing unit 121, CF field writing unit 122, CF field writing unit 123 and the like in FIG. 1, wherein the number of the CF field writing units is not limited, uploads the time messages written with the compensation time to the computing module 130, the computing module 130 reads the CF fields of each copied time message, obtains a compensation time set, calculates a weighted compensation time according to the compensation time set, uploads the obtained weighted compensation time to the configuration module 140, and the configuration module 140 configures the local clock of the slave clock according to the weighted compensation time so as to synchronize clocks of the master clock and the slave clock.
The present exemplary embodiment will be described in detail below with reference to the accompanying drawings and examples.
First, in the embodiments of the present disclosure, a clock synchronization method is provided, which may be applied to a slave clock, or may be executed by any electronic device having computing processing capability.
Fig. 2 shows a flowchart of a clock synchronization method in an embodiment of the disclosure, and as shown in fig. 2, the clock synchronization method provided in the embodiment of the disclosure includes the following steps:
S202, acquiring a plurality of compensation times of the time message to obtain a compensation time set, wherein the compensation time is a difference value between a first time and a second time, the first time is a time when the time message sent by the master clock is received, and the second time is a time when the time message is forwarded to the slave clock and the slave clock starts to process the time message.
In one embodiment of the disclosure, after receiving a time message sent by a master clock, the time message may be copied first to obtain a plurality of copied time messages, the copied time messages are broadcasted, the compensation time measurement is performed on each copied time message to obtain the compensation time of each copied time message, and the compensation time is written into a CF field of the corresponding time message, and the compensation time set is obtained by reading the CF field of each time message.
The time messages mentioned in the embodiments of the present disclosure may be various time messages defined by PTP protocol, which defines two types of messages, one is a time message, which needs to be time stamped at the time of transceiving and uses an event port for transceiving, the port number of the event port is 319, and the other is a normal message, which does not need to be time stamped at the time of transceiving and uses a general port for transceiving, and the port number of the general port is 320. The time messages include, but are not limited to, synchronization (Sync) messages, delay request (delay_req) messages, peer-to-peer Delay request (pdelay_req) messages, and peer-to-peer Delay response (pdelay_resp) messages. Accordingly, common messages include, but are not limited to, notification (Announce) messages, follow (Follow_Up) messages, delayed response (delay_Resp) messages, peer-to-peer delayed 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 conforms to a format specified by the PTP protocol, and includes, for example, a TimeStamp (TS) field, a CF field, a PTP message type field, a PTP message sequence number field, a PTP message port field, and the like.
S204, based on the compensated time set, configuring the local clock of the slave clock to synchronize the slave clock with the clock of the master clock.
It should be noted that, the local clock of the slave clock may be configured according to a plurality of compensating times of the time packet in the compensating time set, for example, the weight value of all compensating times in the compensating time set may be calculated first, where the weight value of each compensating time in the compensating time set may be the same or different, then the weight value of all compensating times in the compensating time set is calculated according to the compensating time set and the weight value, and finally the local clock of the slave clock is configured according to the weight values of all compensating times in the compensating time set.
According to the clock synchronization method provided by the embodiment of the disclosure, the compensation time set is obtained by obtaining the plurality of compensation times of the time message, wherein the compensation time is the difference between the first time and the second time, the first time is the time when the time message sent by the master clock is received, the second time is the time when the time message is forwarded to the slave clock and the slave clock starts to process the time message, the local clock of the slave clock is configured based on the compensation time set so as to synchronize the clocks of the slave clock and the master clock, and the local clock of the slave clock is configured according to the calculation results of the plurality of compensation times of the time message, so that the clock synchronization accuracy of the master clock and the slave clock is improved.
It should be noted that, the clock synchronization method of the present disclosure may be applied to scenarios such as clock synchronization of hardware between networking network elements, clock synchronization of a server cluster, clock synchronization between a server resource pool and an entity network element, and the like.
According to the clock synchronization method provided by the disclosure, on the basis of the existing traditional time compensation device, a plurality of CF field writing modules are added, after a time message sent by a master clock is received, a plurality of compensation times of the time message are measured, each compensation time of the time message is written into a respective CF field by the aid of the plurality of CF field writing modules, the time message is uploaded to a computing unit to perform weighted compensation time calculation, a local clock of a slave clock is configured according to the obtained weighted compensation time, and clock synchronization accuracy of the master clock and the slave clock is improved.
In one embodiment of the present disclosure, the obtaining a plurality of compensation times of the time packet through the steps disclosed in fig. 3 to obtain a compensation time set, referring to another clock synchronization method flowchart shown in fig. 3, may include the following steps:
S302, receiving a time message sent by a master clock, and determining the moment when the time message is received;
S304, copying the time messages to obtain a plurality of copied time messages, respectively transmitting the plurality of copied time messages to a slave clock through different paths, and determining the moment when the slave clock starts to process each copied time message;
S306, obtaining a plurality of compensation times of the time messages according to the time when the time messages are received and the time when the time messages of each copy are processed from the clock;
S308, writing a plurality of compensation times of the time message into the correction domain CF field of the corresponding time message.
It should be noted that, in an embodiment of the present disclosure, referring to a clock synchronization method shown in fig. 4, after receiving a time message sent by a master clock, the time message may be a Sync message, and the time t1 of the time message sent by the master clock and the time t2 of the time message received by the slave clock are recorded. Then, 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 offset time offset and the propagation delay of the time message can be calculated by the following formula:
offset=((t2-t1)-(t4-t3))/2 (1)
delay=((t2-t1)+(t4-t3))/2 (2)
After the compensation time of each time message is obtained, writing each compensation time of the time message into a respective CF field, and obtaining a compensation time set by reading the CF field of each time message.
In one embodiment of the disclosure, after obtaining the plurality of compensation times of the time message and obtaining the compensation time set, the method further includes screening the compensation times in the compensation time set, which meet a preset range value. Here, for example, the obtained compensation time set is n= { N 1,n2,n3,...,ni }, i is a positive integer, and the time precision standard value is set to be k, then the preset time range value is [ -k, k ], the compensation time meeting the preset range value in the compensation time set is filtered, and the filtered compensation time set n1= { N j∈N,-k≤nj +.k } is obtained, and j is a positive integer. According to the method and the device, the preset range value is set, the compensation time conforming to the preset range value in the compensation time set is screened according to the preset range value, so that invalid compensation time in the compensation time set is removed, and the reliability of data is improved.
In one embodiment of the present disclosure, configuring a local clock of a slave clock based on a set of compensation times may be implemented through the steps disclosed in fig. 5, referring to another clock synchronization method flowchart shown in fig. 5, may include the steps of:
s502, calculating to obtain weighted compensation time according to the compensation time set;
s504, configuring a local clock of the slave clock based on the weighted compensation time.
In one embodiment of the present disclosure, taking the filtered compensation time set n1= { N j∈N,-k≤nj +.ltoreq.k } as an example, the compensation time weight may be calculated according to the compensation time set, and then the weighted compensation time may be calculated according to the compensation time set and the compensation time weight. The compensation time weight may be calculated by calculating the sum of the reciprocals of all the compensation times in the compensation time set, based on the sum of the reciprocals of all the compensation times in the compensation time set, and the compensation time set.
In one embodiment of the present disclosure, the sum S of the reciprocals of all the compensation times in the compensation time set N1 and the compensation time weight a may be calculated by the following formula:
wherein S is the sum of the reciprocals of all the compensation times in the compensation time set N1, and m is the number of elements in the compensation time set N1.
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:
According to the clock synchronization method provided by the embodiment of the disclosure, the final compensation time is obtained through the weighting algorithm, namely the weighting compensation time, the algorithm optimization is performed on the compensation time written in the traditional hardware, the clock synchronization precision is finally improved, and the error caused by the manufacturing process deviation is reduced. Meanwhile, under the condition that a plurality of weighted compensation time acquisition circuits are adopted, an optimal message packet sending circuit is obtained according to calculation, a better circuit can be automatically selected for the current environment without obtaining a better clock synchronization network element through equipment replacement, and production cost is reduced.
In one embodiment of the present disclosure, the weighted compensation time obtained by calculating the compensation time set according to the steps disclosed in fig. 6 may be implemented, referring to another clock synchronization method flowchart shown in fig. 6, and may include the following steps:
s602, calculating compensation time weight according to the compensation time set;
S604, calculating to obtain weighted compensation time according to the compensation time set and the compensation time weight.
In one embodiment of the present disclosure, calculating the compensation time weight from the set of compensation times includes calculating a sum of the reciprocals of all compensation times in the set of compensation times, calculating the compensation time weight from the sum of the reciprocals of all compensation times in the set of compensation times, and the set of compensation times.
In one embodiment of the present disclosure, calculating a weighted compensation time from a set of compensation times and a compensation time weight includes calculating a sum of products of all compensation times in the set of compensation times and the compensation time weight to obtain the weighted compensation time.
Based on the same inventive concept, a clock synchronization device is also provided in the embodiments of the present disclosure, such as the following embodiments. Since the principle of solving the problem of the embodiment of the device is similar to that of the embodiment of the method, the implementation of the embodiment of the device can be referred to the implementation of the embodiment of the method, and the repetition is omitted.
Fig. 7 shows a schematic diagram of a clock synchronization apparatus according to an embodiment of the disclosure, as shown in fig. 7, the apparatus includes:
The set obtaining module 710 is configured to obtain a set of compensation times of the time packet, where the compensation times are differences between a first time and a second time, the first time is a time when the time packet sent by the master clock is received, and the second time is a time when the time packet is forwarded to the slave clock and the slave clock starts to process the time packet;
The clock configuration module 720 is configured to configure a local clock of the slave clock based on the compensated time set, so as to synchronize the slave clock with the clock of the master clock.
In an embodiment of the disclosure, the apparatus further includes a bias value screening module, where the bias value screening module is configured to screen a compensation time set that meets a preset range value.
In one embodiment of the disclosure, the set obtaining module 710 is further configured to receive a time message sent by a master clock, determine a 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 a slave clock through different paths, determine a time when each copy of the time message is processed from the slave clock, obtain multiple compensation times of the time message according to the time when the time message is received and the time when each copy of the time message is processed from the slave clock, and write the multiple compensation times of the time message into a correction field CF of the corresponding time message.
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 a local clock of the slave clock based on the weighted compensation time.
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 calculate a weighted compensation time according to the compensation time set and the compensation time weight.
In one embodiment of the present disclosure, the clock configuration module 720 is further configured to calculate a sum of the inverses of all the compensation times in the compensation time set, and calculate the compensation time weight according to the sum of the inverses of all the compensation times in the compensation time set and the compensation time set.
In one embodiment of the present disclosure, the clock configuration module 720 is further configured to calculate a sum of products of all compensation times and the compensation time weights in the compensation time set, so as to obtain a weighted compensation time.
Those skilled in the art will appreciate that the various aspects of the present disclosure may be implemented as a system, method, or program product. Accordingly, aspects of the present disclosure may be embodied in the form of an entirely hardware embodiment, an entirely software embodiment (including firmware, micro-code, etc.) or an embodiment combining hardware and software aspects that may be referred to herein collectively as a "circuit," module, "or" system.
An electronic device 800 according to such an embodiment of the present disclosure is described below with reference to fig. 8. The electronic device 800 shown in fig. 8 is merely an example and should not be construed to limit the functionality and scope of use of embodiments of the present disclosure in any way.
As shown in fig. 8, the electronic device 800 is embodied in the form of a general purpose computing device. The components of electronic device 800 may include, but are not limited to, at least one processing unit 810 described above, at least one memory unit 820 described above, and a bus 830 that connects the various system components, including memory unit 820 and processing unit 810.
Wherein the storage unit stores program code that is executable by the processing unit 810 such that the processing unit 810 performs steps according to various exemplary embodiments of the present disclosure described in the above section of the present specification. For example, the processing unit 810 may perform the steps of obtaining a plurality of compensation times of the time message to obtain a compensation time set, where the compensation time is a difference between a first time and a second time, the first time is a time when the time message sent by the master clock is received, the second time is a time when the time message is forwarded to the slave clock and the slave clock starts to process the time message, and based on the compensation time set, configuring a local clock of the slave clock to synchronize clocks of the slave clock and the master clock.
In some embodiments, in the electronic device provided in the embodiments of the present disclosure, the processing unit 810 is further configured to receive a time packet sent by the master clock, determine a time when the time packet is received, copy the time packet to obtain a plurality of copies of the time packet, send the plurality of copies of the time packet to the slave clock through different paths, determine a time when processing each copy of the time packet from the slave clock, obtain a plurality of compensation times of the time packet according to the time when the time packet is received and the time when processing each copy of the time packet from the slave clock, and write the plurality of compensation times of the time packet into the correction field CF of the corresponding time packet.
In some embodiments, in the electronic device provided in the embodiments of the present disclosure, the processing unit 810 is further configured to filter the compensation time set that meets a preset range value.
In some embodiments, in the electronic device provided in the embodiments of the present disclosure, the processing unit 810 is further configured to calculate a weighted compensation time according to the compensation time set, and configure a local clock of the slave clock based on the weighted compensation time.
In some embodiments, in the electronic device provided in the embodiments of the present disclosure, the processing unit 810 is further configured to calculate a compensation time weight according to the compensation time set, and calculate a weighted compensation time according to the compensation time set and the compensation time weight.
In some embodiments, in the electronic device provided in the embodiments of the present disclosure, the processing unit 810 is further configured to calculate a sum of the reciprocals of all the compensation times in the compensation time set, and calculate the compensation time weight according to the sum of the reciprocals of all the compensation times in the compensation time set and the compensation time set.
In some embodiments, in the electronic device provided in the embodiments of the present disclosure, the processing unit 810 is further configured to calculate a sum of products of all compensation times and the compensation time weights in the compensation time set, to obtain a weighted compensation time.
The storage unit 820 may include readable media in the form of volatile storage units, such as Random Access Memory (RAM) 8201 and/or cache memory 8202, and may further include Read Only Memory (ROM) 8203.
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 or some combination of which may include an implementation of a network environment.
Bus 830 may be 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.
The electronic device 800 may also communicate with one or more external devices 840 (e.g., keyboard, pointing device, bluetooth device, etc.), one or more devices that enable a user to interact with the electronic device 800, and/or any device (e.g., router, modem, etc.) that enables the electronic device 800 to communicate with one or more other computing devices. Such communication may occur through an input/output (I/O) interface 850. Also, electronic device 800 may communicate with one or more networks such as a Local Area Network (LAN), a Wide Area Network (WAN), and/or a public network, such as the Internet, through network adapter 860. As shown, network adapter 860 communicates with other modules of electronic device 800 over bus 830. It should be appreciated that although not shown, other hardware and/or software modules may be used in connection with electronic device 800, including, but not limited to, microcode, device drivers, redundant processing units, external disk drive arrays, RAID systems, tape drives, data backup storage systems, and the like.
From the above description of embodiments, those skilled in the art will readily appreciate that the example embodiments described herein may be implemented in software, or may be implemented in software in combination with the necessary hardware. Thus, the technical solution according to the embodiments of the present disclosure may be embodied in the form of a software product, which may be stored in a non-volatile storage medium (may be a CD-ROM, a U-disk, a mobile hard disk, etc.) or on a network, including several instructions to cause a computing device (may be a personal computer, a server, a terminal device, or a network device, etc.) to perform the method according to the embodiments of the present disclosure.
In an exemplary embodiment of the present disclosure, a computer-readable storage medium, which may be a readable signal medium or a readable storage medium, is also provided. On which a program product is stored which enables the implementation of the method described above of the present disclosure. In some possible implementations, various aspects of the disclosure may also be implemented in the form of a program product comprising program code for causing a terminal device to carry out the steps according to the various exemplary embodiments of the disclosure as described in the "exemplary methods" section of this specification, when the program product is run on the terminal device. For example, when the computer program stored on the computer readable storage medium in the embodiments of the present disclosure is executed by the processor, the steps of obtaining a plurality of compensation times of the time message, and obtaining a compensation time set, where the compensation time is a difference between a first time and a second time, the first time is a time when the time message sent by the master clock is received, the second time is a time when the time message is forwarded to the slave clock and the slave clock starts to process the time message, and configuring a local clock of the slave clock based on the compensation time set so as to synchronize the slave clock with a clock of the master clock.
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 method may further include the steps of receiving a time message sent by the master clock, determining a time when the time message is received, copying the time message, obtaining a plurality of copies of the time message, sending the plurality of copies of the time message to the slave clock by different paths, determining a time when processing each copy of the time message from the slave clock, obtaining a plurality of compensation times of the time message according to the time when the time message is received and the time when processing each copy of the time message from the slave clock, and writing the plurality of compensation times of the time message into the correction field CF of the corresponding time message.
In some embodiments, the computer program stored on the computer readable storage medium in the embodiments of the present disclosure, when executed by the processor, may further implement the step of screening the set of compensation times for compensation times that meet a preset range of values.
In some embodiments, the computer program stored on the computer readable storage medium in the embodiments of the present disclosure, when executed by the processor, may further implement the steps of calculating a weighted compensation time from the set of compensation times, and configuring a local clock of the slave clock based on the weighted compensation time.
In some embodiments, the computer program stored on the computer readable storage medium in the embodiments of the present disclosure, when executed by the processor, may further implement the steps of calculating a compensation time weight from the compensation time set, and calculating a weighted compensation time from the compensation time set and the compensation time weight.
In some embodiments, the computer program stored on the computer readable storage medium in the embodiments of the present disclosure, when executed by the processor, may further implement the steps of calculating a sum of the reciprocals of all the compensation times in the set of compensation times, calculating the compensation time weight based on the sum of the reciprocals of all the compensation times in the set of compensation times, and the set of compensation times.
In some embodiments, the computer program stored on the computer readable storage medium in the embodiments of the present disclosure, when executed by the processor, may further implement the step of calculating the sum of products of all compensation times in the set of compensation times and the compensation time weights to obtain a weighted compensation time.
More specific examples of a computer-readable storage medium in the disclosure can include, but are not limited to, an electrical connection having one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
In this disclosure, a computer readable storage medium may include a data signal propagated in baseband or as part of a carrier wave, with readable program code embodied therein. Such a propagated data signal may take any of a variety of forms, including, but not limited to, electro-magnetic, optical, or any suitable combination of the foregoing. A readable signal medium may also be any readable medium that is not a readable storage medium and that can communicate, propagate, or transport a program for use by or in connection with an instruction execution system, apparatus, or device.
Alternatively, the program code embodied on a computer readable storage medium may be transmitted using any appropriate medium, including but not limited to wireless, wireline, optical fiber cable, RF, etc., or any suitable combination of the foregoing.
In particular implementations, the program code for carrying out operations of the present disclosure may be written in any combination of one or more programming languages, including an object oriented programming language such as Java, C++ or the like and conventional procedural programming languages, such as the "C" programming language or similar programming languages. The program code may execute entirely on the user's computing device, partly on the user's device, as a stand-alone software package, partly on the user's computing device, partly on a remote computing device, or entirely on the remote computing device or server. In the case of remote computing devices, the remote computing device may be connected to the user computing device through any kind 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., connected via the Internet using an Internet service provider).
It should be noted that although in the above detailed description several modules or units of a device for action execution are mentioned, such a division is not mandatory. Indeed, the features and functionality of two or more modules or units described above may be embodied in one module or unit in accordance with embodiments of the present disclosure. Conversely, the features and functions of one module or unit described above may be further divided into a plurality of modules or units to be embodied.
Furthermore, although the steps of the methods in the present disclosure are depicted in a particular order in the drawings, this does not require or imply that the steps must be performed in that particular order, or that all illustrated steps be performed, to achieve desirable results. Additionally or alternatively, certain steps may be omitted, multiple steps combined into one step to perform, and/or one step decomposed into multiple steps to perform, etc.
From the description of the above embodiments, those skilled in the art will readily appreciate that the example embodiments described herein may be implemented in software, or may be implemented in software in combination with the necessary hardware. Thus, the technical solution according to the embodiments of the present disclosure may be embodied in the form of a software product, which may be stored in a non-volatile storage medium (may be a CD-ROM, a U-disk, a mobile hard disk, etc.) or on a network, including several instructions to cause a computing device (may be a personal computer, a server, a mobile terminal, or a network device, etc.) to perform the method according to the embodiments of the present disclosure.
Other embodiments of the disclosure will be apparent to those skilled in the art from consideration of the specification and practice of the disclosure disclosed herein. This disclosure is intended to cover any adaptations, uses, or adaptations of the disclosure following the general principles of the disclosure and including such departures from the present disclosure as come within known or customary practice within the art to which the disclosure pertains. It is intended that the specification and examples be considered as exemplary only, with a true scope and spirit of the disclosure being indicated by the following claims.

Claims (9)

1. The clock synchronization method is applied to a clock synchronization system, and the clock synchronization system comprises a plurality of CF field writing units, wherein the clock synchronization method comprises the following steps:
Obtaining a plurality of compensation times of a time message to obtain a compensation time set, wherein the compensation time is a difference value between a first time and a second time, the first time is a time when the time message sent by a master clock is received, and the second time is a time when the time message is forwarded to a slave clock and is processed from the slave clock;
configuring a local clock of a slave clock based on the set of compensation times to synchronize the slave clock with a clock of the master clock;
obtaining a plurality of compensation times of the time message to obtain a compensation time set, including:
Receiving a time message sent by a master clock, and determining the moment when the time message is received;
Copying the time messages to obtain a plurality of copied time messages, respectively transmitting the plurality of copied time messages to a slave clock through different paths, and determining the moment when the slave clock starts to process each copied time message;
The method comprises the steps that for any one CF field writing unit of the CF field writing units, the compensation time of the time message is obtained according to the time when the time message is received and the time when the corresponding copied time message is processed from a clock, so that a plurality of compensation times of the time message corresponding to the CF field writing units are obtained;
And the plurality of CF field writing units write the plurality of compensation times of the time message into the correction field CF fields of the corresponding copied time message respectively to obtain a compensation time set.
2. The clock synchronization method of claim 1, wherein after obtaining a plurality of compensation times for the time message, the method further comprises:
and screening the compensation time which accords with a preset range value in the compensation time set.
3. The clock synchronization method of claim 1, wherein configuring the local clock of the slave clock based on the set of compensation times comprises:
according to the compensation time set, calculating to obtain weighted compensation time;
And configuring a local clock of the slave clock based on the weighted compensation time.
4. A clock synchronization method according to claim 3, characterized in that calculating a weighted compensation time from the set of compensation times comprises:
calculating compensation time weight according to the compensation time set;
and calculating to obtain weighted compensation time according to the compensation time set and the compensation time weight.
5. The clock synchronization method of claim 4, wherein calculating a compensation time weight from the set of compensation times comprises:
calculating the sum of the reciprocal of all the compensation times in the compensation time set;
And calculating the compensation time weight according to the sum of the reciprocal numbers of all the compensation times in the compensation time set and the compensation time set.
6. The clock synchronization method of claim 4, wherein calculating a weighted compensation time based on the set of compensation times and the compensation time weight comprises:
and calculating the sum of products of all compensation times and the compensation time weights in the compensation time set to obtain the weighted compensation time.
7. The clock synchronization device is applied to a clock synchronization system, and the clock synchronization system comprises a plurality of CF field writing units, wherein the clock synchronization device comprises:
The system comprises a set acquisition module, a time message processing module and a time message processing module, wherein the set acquisition module is used for acquiring a plurality of compensation times of a time message to obtain a compensation time set, wherein the compensation time is a difference value between a first moment and a second moment, the first moment is a moment when the time message sent by a master clock is received, and the second moment is a moment when the time message is forwarded to a slave clock and is processed from the slave clock;
a clock configuration module, configured to configure a local clock of the slave clock based on the compensated time set, so as to synchronize the slave clock with a clock of the master clock;
The set acquisition module is further used for receiving the time message sent by the master clock and determining the moment when the time message is received, copying the time message to obtain a plurality of copied time messages, respectively sending the plurality of copied time messages to the slave clock by different paths and determining the moment when each copied time message is processed from the clock, and according to the moment when the time message is received and the moment when the corresponding copied time message is processed from the clock, obtaining the compensation time of the time message by any CF field writing unit, so as to obtain a plurality of compensation times of the time message corresponding to the plurality of CF field writing units, and the plurality of CF field writing units respectively write the plurality of compensation times of the time message into the corresponding correction fields CF fields of the copied time message to obtain a compensation time set.
8. An electronic device, comprising:
processor, and
A memory for storing executable instructions of the processor;
wherein the processor is configured to perform the clock synchronization method of any one of claims 1-6 via execution of the executable instructions.
9. A computer readable storage medium having stored thereon a computer program, wherein the computer program when executed by a processor implements the clock synchronization method of any one of claims 1 to 6.
CN202210877974.2A 2022-07-25 2022-07-25 Clock synchronization method, device, electronic device and storage medium Active CN115276869B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202210877974.2A CN115276869B (en) 2022-07-25 2022-07-25 Clock synchronization method, device, electronic device and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202210877974.2A CN115276869B (en) 2022-07-25 2022-07-25 Clock synchronization method, device, electronic device and storage medium

Publications (2)

Publication Number Publication Date
CN115276869A CN115276869A (en) 2022-11-01
CN115276869B true CN115276869B (en) 2025-03-04

Family

ID=83769236

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202210877974.2A Active CN115276869B (en) 2022-07-25 2022-07-25 Clock synchronization method, device, electronic device and storage medium

Country Status (1)

Country Link
CN (1) CN115276869B (en)

Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104247309A (en) * 2012-02-09 2014-12-24 马维尔以色列(M.I.S.L.)有限公司 Clock synchronization using multiple network paths
CN107294634A (en) * 2017-06-13 2017-10-24 烽火通信科技股份有限公司 The centralized approach of 1588 time synchronizeds is realized in a kind of distributed system

Family Cites Families (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2015003364A1 (en) * 2013-07-11 2015-01-15 Telefonaktiebolaget Lm Ericsson (Publ) Apparatus and method for two-way timestamp exchange
CN104601269B (en) * 2014-12-31 2016-12-28 国家电网公司 Master-salve clock synchronous method and system
CN108880727B (en) * 2018-06-13 2019-11-15 合肥工业大学 A Realization Method of Accurate Clock Synchronization Based on PTPd2 Protocol

Patent Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104247309A (en) * 2012-02-09 2014-12-24 马维尔以色列(M.I.S.L.)有限公司 Clock synchronization using multiple network paths
CN107294634A (en) * 2017-06-13 2017-10-24 烽火通信科技股份有限公司 The centralized approach of 1588 time synchronizeds is realized in a kind of distributed system

Also Published As

Publication number Publication date
CN115276869A (en) 2022-11-01

Similar Documents

Publication Publication Date Title
JP7401656B2 (en) METHODS, APPARATUS AND SYSTEM AND STORAGE MEDIA FOR SELECTING CLOCK SOURCES
US8738792B2 (en) Server time protocol messages and methods
CN104468017B (en) Perform the network synchronization method and device of the time synchronized between node
CN108650050A (en) A kind of distributed network clock synchronous method
EP2658161B1 (en) Transmission device, transmission method and computer program
CN102412955B (en) Time deviation acquisition methods when optical fiber is asymmetric between master-slave equipment and communication system
CN108599888A (en) A kind of distributed network clock synchronizing system
CN110719135A (en) Time calibration method and system and electronic device
CN109392074A (en) Clock correcting method and device
JP2023538335A (en) Clock synchronization mode instruction method and communication device
WO2022176026A1 (en) Network translator and device translator
CN114258126A (en) Data processing method and device
CN115276869B (en) Clock synchronization method, device, electronic device and storage medium
CN112039621B (en) A time synchronization method and system
CN119945609A (en) A method, system, storage medium and device for adaptive frequency distributed clock synchronization
CN119946793A (en) Clock synchronization method, device, computer readable medium and electronic device
CN118353566A (en) GPTP protocol-based time synchronization method and device, medium and equipment
CN113132041B (en) Data transmission delay calculation method and device
KR20190072745A (en) Stable Network-based Time Synchronization Method
CN113259039A (en) Time synchronization method and device, computer equipment and storage medium
CN106533597A (en) Selection method of time source and network element node
CN112152744A (en) Clock synchronization method and device, FPGA chip and optical fiber communication network
US20250392402A1 (en) Gating scheduling method, controller, node, and computer readable medium
CN117956564A (en) SIB9 timing method, network device and storage medium
CN117015024A (en) Time synchronization method, network equipment and communication system

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant