Estimation compensation method, system and device for clock synchronization and storage medium
By building a peer timer on the main control unit on the local side and updating the received time stamp moment using prediction and estimation algorithm or back-reflection estimation algorithm, the problem of unstable clock synchronization in old equipment in industrial systems is solved, and a relatively stable clock deviation calculation is achieved.
Patent Information
- Application Number
- CN202510002713.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-01-02
- Publication Date
- 2025-04-29
AI Technical Summary
The prior art is difficult to realize clock synchronization in special equipment communication scenarios or closed networks, especially in old equipment in industrial systems, and due to the large number of communication links between devices, the clock synchronization offset estimate is unstable.
By constructing a peer timer with a time interval T in the main control unit on the local side, the sending time interval T of the time stamp information of the main control unit on the side is simulated, and the receiving time stamp moment is updated using the prediction estimation algorithm or the back-reflection estimation algorithm until the remaining unprocessed timestamp number is cleared.
This method does not require a special time synchronization protocol, which can greatly reduce the time stamp fluctuation interference caused by the intermediate forwarding unit, and obtain relatively stable and accurate clock deviations between the two parties. It is suitable for systems with low synchronization accuracy requirements or limited to software and hardware transformation.
Smart Images

Figure CN119906513A_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the technical field of clock synchronization, and in particular to an estimation compensation method, system, device and storage medium for clock synchronization. Background Art
[0002] Clock synchronization is critical for monitoring the timeliness of communication data between the two communicating parties. When the deviation value from the other party's clock is known, the two communicating parties can implement key functions such as anomaly detection, data estimation, and event record verification. Common time synchronization protocols such as NTP, PTP, and GPS are based on special network architectures (multi-level NTP servers), special timing hardware, and specialized interactive protocols. They are difficult to implement and costly for some special device communication scenarios or closed networks, especially for old equipment in industrial systems. It is difficult to transform and upgrade software protocols. Often, the communicating party only provides a basic clock stamp information, and only calculates and implements clock synchronization by itself, which is one-way clock synchronization. In addition, if Figure 1 As shown in the figure, the master control of the opposite device generates a timestamp, which needs to go through multiple links before it can reach the master control of the local end. The interface of the opposite end and the interface unit of the local end communicate according to independent forwarding cycles, which makes the intervals received by the receiving end very discrete. For example, if multiple timestamps are received in a short period of time or there is no timestamp for a long period of time, if the receiving time is directly used for estimation, a large error may occur, and this error is not the real time deviation between the two parties. Figure 2 As shown, the existing technical solutions NTP, PTP, LTS, etc. are all general time synchronization solutions with perfect functions and high synchronization accuracy for the Internet or dedicated networks (financial transactions, industrial automation) and other fields, and all require relatively complex information exchange to meet the requirements of high-performance and networked synchronization. Taking the relatively simple NTP algorithm as an example, the NTP server needs to exchange the timestamps of both parties.
[0003] In summary, the existing technology lacks a method to achieve clock synchronization in some special device communication scenarios or closed network conditions, especially in the case of old equipment in industrial systems; in addition, due to the large number of communication links between devices in the existing technology, the time when the party receives the communication stamp information of the communicating party is relatively discrete, making it difficult to calculate a stable clock synchronization offset estimate; and the existing technology requires more complex information exchange to meet high-performance, networked synchronization requirements. Summary of the invention
[0004] The embodiments of the present disclosure provide an estimation compensation method, system, device and storage medium for clock synchronization to solve or alleviate one or more of the above technical problems in the prior art.
[0005] According to one aspect of the present disclosure, there is provided an estimation compensation method for clock synchronization, comprising:
[0006] A peer timer with a time interval of T is established in the local main control unit, and the peer timer is used to simulate the time interval T of sending the timestamp information of the opposite main control unit;
[0007] Get the total number of timestamps allNum according to the peer timer period with a time interval of T;
[0008] When the total number of timestamps allNum is greater than 0, the time when the local main control unit receives the timestamp is updated through a prediction estimation algorithm or a back-estimation algorithm until the current number of remaining unprocessed timestamps curNum is cleared.
[0009] In a possible implementation, when the total number of timestamps allNum is greater than 0, the time when the local main control unit receives the timestamp is updated by a prediction estimation algorithm or a back-estimation algorithm until the current number of remaining unprocessed timestamps curNum is cleared to zero, including:
[0010] Record and assign the total number of timestamps allNum of the current cycle to the total number of timestamps oldAllNum obtained in the previous cycle.
[0011] In a possible implementation, obtaining the total number of timestamps allNum according to the peer timer period with a time interval T includes:
[0012] When the total number of timestamps allNum is 0, it is determined whether the time when the local main control unit receives the timestamp is updated by the prediction estimation algorithm in the previous cycle;
[0013] When the time when the local main control unit receives the timestamp is updated by the prediction estimation algorithm in the previous cycle, it is determined whether the total number of timestamps oldNum obtained in the previous cycle is 0;
[0014] When the total number of timestamps oldNum obtained in the previous cycle is not 0, the time when the local main control unit receives the timestamp is updated through the prediction estimation algorithm until the total number of timestamps oldNum obtained in the previous cycle is cleared;
[0015] When the previous cycle is not updated by the prediction estimation algorithm, and / or the total number of timestamps oldNum acquired in the previous cycle is 0, the state of the previous cycle is modified to update the time when the local main control unit receives the timestamp by the back-pushing estimation algorithm.
[0016] In a possible implementation, updating the receiving timestamp moment of the local main control unit by using a prediction estimation algorithm or a back-estimation algorithm includes:
[0017] Get the receiving time value Tlocal of the peer timer of the local master control unit;
[0018] Select the prediction estimation algorithm or the back-estimation algorithm to update the receiving timestamp time Tlocal` of the local main control unit;
[0019] When the prediction estimation algorithm is selected, the target reception time value Tlocal of the local master control unit is calculated according to the reception time value Tlocal of the peer timer of the local master control unit, the total number of timestamps allNum, the number of currently remaining unprocessed timestamps curNum and the time interval T;
[0020] When the push-back estimation algorithm is selected, the time Tlocal` at which the local master control unit receives the timestamp is calculated according to the local master control unit peer timer reception time value Tlocal, the current number of remaining unprocessed timestamps curNum and the time interval T.
[0021] In a possible implementation, selecting a prediction estimation algorithm or a back-estimation algorithm to update the receiving timestamp time Tlocal` of the local main control unit includes:
[0022] Determine whether the local main control unit obtains a total number allNum of multiple timestamps in a peer timer cycle. If so, calculate the time of receiving timestamps of multiple future peer timer cycles according to the prediction estimation algorithm;
[0023] It is determined whether the total number of timestamps allNum obtained by the local main control unit in multiple consecutive peer timer periods is 0. If so, the reception time of the timestamps of multiple past peer timer periods is calculated according to the back-estimation algorithm.
[0024] In one possible implementation:
[0025] The calculation formula of the prediction estimation algorithm is:
[0026] Tlocal`=Tlocal+((allNum-curNum)*T);
[0027] The calculation formula of the back-estimation algorithm is:
[0028] Tlocal`=Tlocal-((curNum-1)*T);
[0029] Wherein, Tlocal` indicates the time when the local master control unit receives the timestamp; allNum indicates the total number of timestamps; curNum indicates the number of remaining unprocessed timestamps; T indicates the time interval; and Tlocal indicates the time value of the peer timer receiving the local master control unit.
[0030] According to one aspect of the present disclosure, there is provided an estimation compensation system for clock synchronization, comprising:
[0031] A construction unit, used for constructing a peer timer with a time interval of T in the local main control unit, and simulating the time interval T of sending timestamp information of the opposite main control unit through the peer timer;
[0032] An acquisition unit, configured to acquire a total number of timestamps allNum according to a peer timer period with a time interval T;
[0033] The first updating unit is used to update the time when the total number of timestamps allNum is greater than 0, by using a prediction estimation algorithm or a back-estimation algorithm, when the timestamp number curNum remaining unprocessed is cleared.
[0034] In a possible implementation, the estimation and compensation system for clock synchronization further includes:
[0035] The record assignment unit is used to record and assign the total number of timestamps allNum of the current cycle to the total number of timestamps oldAllNum obtained in the previous cycle.
[0036] In a possible implementation, the estimation and compensation system for clock synchronization further includes:
[0037] The first judgment unit is used to judge whether the time when the timestamp total number allNum is 0 is updated by the prediction estimation algorithm in the previous cycle.
[0038] The second judgment unit is used to judge whether the total number of timestamps oldNum obtained in the previous cycle is 0 when the time when the local main control unit receives the timestamp is updated by the prediction estimation algorithm in the previous cycle;
[0039] The second updating unit is used to update the time when the total number of timestamps oldNum obtained in the previous period is not 0 by using a prediction estimation algorithm, until the total number of timestamps oldNum obtained in the previous period is cleared to zero;
[0040] The modification unit modifies the state of the previous cycle to update the receiving time stamp of the local main control unit through the back-pushing estimation algorithm when the previous cycle is not updated through the prediction estimation algorithm and / or the total number of timestamps oldNum obtained in the previous cycle is 0.
[0041] In a possible implementation, the first updating unit includes:
[0042] An acquisition module, used for acquiring a receiving time value Tlocal of a peer timer of a local master control unit;
[0043] A selection module is used to select a prediction estimation algorithm or a back-estimation algorithm to update the receiving timestamp moment Tlocal` of the local main control unit;
[0044] A prediction and estimation module, used for calculating a target reception time value Tlocal` of the local master control unit according to the reception time value Tlocal of the peer timer of the local master control unit, the total number of timestamps allNum, the number of currently remaining unprocessed timestamps curNum and the time interval T when the prediction and estimation algorithm is selected;
[0045] The pushback estimation module is used to calculate the time Tlocal` at which the local main control unit receives the timestamp according to the local main control unit peer timer reception time value Tlocal, the current remaining unprocessed timestamp number curNum and the time interval T when the pushback estimation algorithm is selected.
[0046] In a possible implementation, the selection module includes:
[0047] The first judgment submodule is used to judge whether the local main control unit obtains the total number allNum of multiple timestamps in one peer timer cycle, and if so, calculate the reception time of multiple future peer timer cycle timestamps according to the prediction estimation algorithm;
[0048] The second judgment submodule is used to judge whether the total number of timestamps allNum obtained by the local main control unit in multiple consecutive peer timer periods is 0. If so, calculate the reception time of the timestamps of multiple past peer timer periods according to the back-estimation algorithm.
[0049] In one possible implementation:
[0050] The calculation formula of the prediction estimation algorithm is:
[0051] Tlocal`=Tlocal+((allNum-curNum)*T);
[0052] The calculation formula of the back-estimation algorithm is:
[0053] Tlocal`=Tlocal-((curNum-1)*T);
[0054] Wherein, Tlocal` indicates the time when the local master control unit receives the timestamp; allNum indicates the total number of timestamps; curNum indicates the number of remaining unprocessed timestamps; T indicates the time interval; and Tlocal indicates the time value of the peer timer receiving the local master control unit.
[0055] According to one aspect of the present disclosure, there is provided a device, comprising:
[0056] Processor and memory;
[0057] The memory is used to store a computer program, and the processor calls the computer program stored in the memory to execute any one of the estimation and compensation methods for clock synchronization described above.
[0058] According to one aspect of the present disclosure, a computer-readable storage medium is provided, in which a computer program is stored. When the computer program is executed by a processor, the processor is enabled to execute any of the estimation compensation methods for clock synchronization described above.
[0059] The present disclosure has the following beneficial effects: the present disclosure does not require a special time synchronization protocol. By constructing a timer at the local end with the same time interval as the other end to be synchronized for calculation, the clock deviation calculation is realized based on a compensation algorithm of predictive estimation and back-estimation. This can greatly reduce the timestamp fluctuation interference caused by the intermediate forwarding unit, and obtain a relatively stable and accurate clock deviation of both parties. The method is simple and practical, and is suitable for systems with low synchronization accuracy requirements (millisecond level) or are limited by software and hardware modifications.
[0060] The details of one or more embodiments of the present application are presented in the following drawings and descriptions. Other features and advantages of the present application will become apparent from the accompanying drawings. It should be understood that the above general description and the detailed descriptions below are only exemplary and explanatory and cannot limit the present disclosure. BRIEF DESCRIPTION OF THE DRAWINGS
[0061] 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.
[0062] Figure 1 This is a schematic diagram of the difference between the timestamp sending interval and the receiving interval;
[0063] Figure 2 This is a schematic diagram of the NTP interactive synchronization protocol;
[0064] Figure 3 It is a schematic diagram of clock synchronization;
[0065] Figure 4 It is a schematic diagram showing the deviation between the receiving timestamp time and the sending timestamp time;
[0066] Figure 5 is a flow chart of an estimation compensation method for clock synchronization;
[0067] Figure 6This is a flow chart of the compensation calculation for the timestamp received this time;
[0068] Figure 7 It is a schematic diagram of the sub-process for calculating the clock deviation based on estFwd;
[0069] Figure 8 is an example graph of repeated estimation errors;
[0070] Fig. 9 This is an example diagram of the calculation results after the estimated predicted total number protection is performed;
[0071] Fig.10 is a block diagram of an estimation compensation system for clock synchronization of the present exemplary embodiment;
[0072] Fig.11 It is a schematic structural diagram of a device of this exemplary embodiment. DETAILED DESCRIPTION
[0073] 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 being limited to the examples set forth herein; on the contrary, these embodiments are provided so that the present disclosure will be more comprehensive and complete, and the concepts of the example embodiments are fully conveyed to those skilled in the art. The described features, structures, or characteristics may be combined in one or more embodiments in any suitable manner. In the following description, many specific details are provided to provide a full understanding of the embodiments of the present disclosure. However, those skilled in the art will appreciate that the technical solutions of the present disclosure may be practiced while omitting one or more of the specific details, or other methods, components, devices, steps, etc. may be adopted. In other cases, known technical solutions are not shown or described in detail to avoid obscuring various aspects of the present disclosure.
[0074] 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 thus 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 units or integrated circuits, or implemented in different networks and / or processor devices and / or microcontroller devices.
[0075] The flowcharts shown in the accompanying drawings are only exemplary and do not necessarily include all the steps. For example, some steps may be decomposed, while some steps may be combined or partially combined, so the actual execution order may change according to the actual situation.
[0076] The terms "first", "second", etc. in the specification and claims of the present application and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the terms used in this way can be interchanged where appropriate, so that the embodiments of the present application described herein can be implemented in an order other than those illustrated or described herein, for example.
[0077] In addition, the terms "include" and "have" and any variations thereof are intended to cover non-exclusive inclusions. For example, a process, method, system, product, or apparatus comprising a series of steps or sub-modules is not necessarily limited to those steps or sub-modules explicitly listed, but may include other steps or sub-modules not explicitly listed or inherent to these processes, methods, products, or apparatuses.
[0078] The present invention is used to solve the problem that the communication (timestamp) interval is too discrete and cannot be used for time deviation estimation when there is only one-way timestamp. It is suitable for occasions where the device clock synchronization accuracy is not high and a relatively stable time deviation needs to be obtained. It is an ultra-lightweight synchronization compensation algorithm and has certain advantages in special communication scenarios such as low-cost, embedded and point-to-point. Figure 3 As shown, the local device only uses the timestamp sent unidirectionally by the peer device.
[0079] like Figure 4 As shown in the figure, assuming that the opposite master control unit sends timestamp information at a time interval of T, after the timestamp information passes through the forwarding unit, the interval of the forwarded data fluctuates due to the interference of the forwarding unit. It is possible that the timestamps are "stuck" and received at the same time, or the new timestamp is received after the interval exceeds T. When the time of receiving the timestamp by the master control unit is directly used as the calculation basis for time synchronization, the calculation result will fluctuate greatly. For this reason, Figure 5 ( Figure 5 , which is a flow chart of an estimation compensation method for clock synchronization of the exemplary embodiment of the present disclosure, an exemplary embodiment of the present disclosure provides an estimation compensation method for clock synchronization, including:
[0080] A peer timer with a time interval of T is established in the local main control unit, and the peer timer is used to simulate the time interval T of sending the timestamp information of the opposite main control unit;
[0081] Get the total number of timestamps allNum according to the peer timer period with a time interval of T;
[0082] When the total number of timestamps allNum is greater than 0, the time when the local main control unit receives the timestamp is updated by the prediction estimation algorithm or the back-estimation algorithm until the current number of remaining unprocessed timestamps curNum is cleared. It is worth noting that each time the prediction estimation algorithm or the back-estimation algorithm is updated, the current number of remaining unprocessed timestamps curNum is reduced by 1.
[0083] In this embodiment, a peer timer with a time interval of T is constructed in the local main control unit to simulate the theoretical sending time interval of the opposite main control unit. Considering that the clock accuracy of this end / the opposite end is generally much higher than the sending interval (for example, the crystal oscillator of general equipment is in the nanosecond level, while the communication cycle is in the second level), it can be basically considered to be consistent with the interval T of the opposite main control unit.
[0084] The timestamp of the peer master unit increases with an interval of T, and the timestamp increment result is an integer multiple of T. Therefore, the timestamp of the peer can be considered to be Tremote+n*T, where Tremote is the timestamp value sent by the peer.
[0085] If there is no influence of the forwarding unit, theoretically, the local master control unit will also receive the corresponding timestamp at time n*T based on the peer timer. The receiving time is Tlocal+n*T, where Tlocal is the time value (timestamp) received by the local peer clock.
[0086] Therefore, the deviation is calculated by combining the timestamp sent by the other end with the local received time, and n*T has no effect. However, due to interference, the received time may not be accurate to Tlocal+n*T, resulting in errors.
[0087] This embodiment is to estimate and compensate for the reception time deviation caused by the forwarding unit processing by rearranging the time stamp of the opposite end received by the local main control unit on the local clock system (estimated according to the interval T). Figure 6 and Figure 7 This is a clock synchronization processing flow chart. The logic should be called according to the peer timer cycle with a time interval of T. Each call cycle is used to update the current estimation state (predicted estimation or back-estimation) and store it using the static variable estFwd. When there is no timestamp data in a cycle, the execution result of the previous cycle can be judged based on the stored estFwd.
[0088] Specifically, when the total number of timestamps allNum is greater than 0, the time when the local main control unit receives the timestamp is updated by a prediction estimation algorithm or a back-estimation algorithm until the current number of remaining unprocessed timestamps curNum is cleared to zero, including:
[0089] Record and assign the total number of timestamps allNum of the current cycle to the total number of timestamps oldAllNum obtained in the previous cycle.
[0090] This embodiment records the most recently received allNum to confirm that all predicted and estimated time intervals N*T have ended (minus one for each calculation) before performing a back-estimation check to avoid repeated calculations of the predicted and back-estimation. That is, the results of the next N time intervals are first calculated through the predicted estimate, and then M timestamps are received and M back-estimation intervals are calculated. Such calculation errors will cause the deviation value to fluctuate more.
[0091] Specifically, obtaining the total number of timestamps allNum according to the peer timer period with a time interval of T includes:
[0092] When the total number of timestamps allNum is 0, it is determined whether the time when the local main control unit receives the timestamp is updated by the prediction estimation algorithm in the previous cycle;
[0093] When the time when the local main control unit receives the timestamp is updated by the prediction estimation algorithm in the previous cycle, it is determined whether the total number of timestamps oldNum obtained in the previous cycle is 0;
[0094] When the total number of timestamps oldNum obtained in the previous cycle is not 0, the time when the local main control unit receives the timestamp is updated through the prediction estimation algorithm until the total number of timestamps oldNum obtained in the previous cycle is cleared;
[0095] When the previous cycle is not updated by the prediction estimation algorithm, and / or the total number of timestamps oldNum acquired in the previous cycle is 0, the state of the previous cycle is modified to update the time when the local main control unit receives the timestamp by the back-pushing estimation algorithm.
[0096] It is worth noting that each time the local main control unit receives the timestamp moment updated by the prediction estimation algorithm, the total number of timestamps oldNum obtained in the previous cycle will be reduced by 1 accordingly until the total number of timestamps oldNum obtained in the previous cycle is cleared.
[0097] Specifically, updating the receiving timestamp moment of the local main control unit by using the prediction estimation algorithm or the back-estimation algorithm includes:
[0098] Get the receiving time value Tlocal of the peer timer of the local master control unit;
[0099] Select the prediction estimation algorithm or the back-estimation algorithm to update the receiving timestamp time Tlocal` of the local main control unit;
[0100] When the prediction estimation algorithm is selected, the target reception time value Tlocal of the local master control unit is calculated according to the reception time value Tlocal of the peer timer of the local master control unit, the total number of timestamps allNum, the number of currently remaining unprocessed timestamps curNum and the time interval T;
[0101] When the push-back estimation algorithm is selected, the time Tlocal` at which the local master control unit receives the timestamp is calculated according to the local master control unit peer timer reception time value Tlocal, the current number of remaining unprocessed timestamps curNum and the time interval T.
[0102] Specifically, selecting a prediction estimation algorithm or a back-estimation algorithm to update the receiving timestamp time Tlocal` of the local main control unit includes:
[0103] Determine whether the local main control unit obtains a total number allNum of multiple timestamps in a peer timer cycle. If so, calculate the time of receiving timestamps of multiple future peer timer cycles according to the prediction estimation algorithm;
[0104] It is determined whether the total number of timestamps allNum obtained by the local main control unit in multiple consecutive peer timer periods is 0. If so, the reception time of the timestamps of multiple past peer timer periods is calculated according to the back-estimation algorithm.
[0105] Specifically, the calculation formula of the prediction estimation algorithm is:
[0106] Tlocal`=Tlocal+((allNum-curNum)*T);
[0107] The calculation formula of the back-estimation algorithm is:
[0108] Tlocal`=Tlocal-((curNum-1)*T);
[0109] Wherein, Tlocal` indicates the time when the local master control unit receives the timestamp; allNum indicates the total number of timestamps; curNum indicates the number of remaining unprocessed timestamps; T indicates the time interval; and Tlocal indicates the time value of the peer timer receiving the local master control unit.
[0110] Theoretically, the local master control unit should only receive one timestamp in each peer clock cycle. If the local master control unit receives allNum=N timestamps at one time, then no timestamps should be received in the next N-1 peer cycles. At this time, the future receiving time should be estimated according to the current peer clock receiving time, that is, the predicted estimate, which can be calculated by the formula Tlocal`=Tlocal+((allNum-curNum)*T), as shown below:
[0111] Assume that N=3 (600ms, 700ms, 800ms), T=100ms, and the receiving time of the local main control unit is 2100ms, as shown in Table 1 (the calculation result table of the receiving time of the local main control unit after the prediction estimation adjustment):
[0112] Table 1
[0113] allNum 3 3 3 curNum 3 2 1 Peer master control timestamp 600ms 700ms 800ms Adjusted receiving time of the local main control unit 2100ms 2200ms 2300ms
[0114] Assume that N=3 (600ms, 700ms, 800ms), T=100ms, the receiving time of the local main control unit is 2100ms, and no timestamp is received within M consecutive peer cycles, which means that M timestamps will be received next. When there is an idle clock cycle (no data is received), the past receiving time should be estimated one by one, that is, back-estimation, as shown in Table 2 (the calculation result table of the receiving time of the local main control unit after adjustment using back-estimation), which can be calculated by the formula Tlocal`=Tlocal-((curNum-1)*T).
[0115] Table 2
[0116] curNum 3 2 1 Peer master control timestamp 600ms 700ms 800ms Adjusted receiving time of the local main control unit 1900ms 2000ms 2100ms
[0117] Where T is the time interval, curNum is the number of current timestamps, and the loop process decreases by 1 each time a timestamp is processed until the next receiving process is completed.
[0118] For a certain time interval, when N timestamps are received, the prediction estimation should be performed (estFwd = True), and when there is no timestamp at this time, the back-calculation estimation should be switched to (estFwd = False), so that the back-calculation calculation can be performed when M timestamps are received later. It should be noted that in order to avoid repeated calculation of the prediction estimation and the back-calculation estimation, that is, the results of the next N time intervals are calculated by the prediction estimation first, and then M back-calculation intervals are calculated when M timestamps are received. Such calculation errors will cause the deviation value to fluctuate more, such as Figure 8 As shown, the red part in the middle two time periods was calculated twice, marked with data 3 and 4 respectively, causing the deviation value to fluctuate back and forth.
[0119] Therefore, it is necessary to record the most recently received allNum to confirm that all the predicted estimated time intervals N*T have ended (minus one for each calculation) before the back-estimation check can be performed. Fig. 9 As shown, although there is no data in the middle two time intervals, since they have been predicted and estimated, it is considered that there is data in the corresponding interval until M data are received, so the prediction and estimation are still performed.
[0120] In general, when the forwarding unit processing cycle and the main control unit hardware receiving cycle are much smaller than the time interval T, N and M are basically both 1; when close to T, N and M may be 2; when greater than T, N and M may be greater than 2. Under the adjustment of this compensation algorithm, the clock deviation fluctuations of the opposite end and the local end caused by the forwarding unit can be basically eliminated, and a relatively stable clock deviation value between the local end and the opposite end, that is, the clock synchronization deviation value, can be obtained.
[0121] Fig.10 is a block diagram of an estimation compensation system for clock synchronization of the present exemplary embodiment, such as Fig.10 As shown, an exemplary embodiment of the present disclosure provides an estimation compensation system for clock synchronization, comprising:
[0122] A construction unit, used for constructing a peer timer with a time interval of T in the local main control unit, and simulating the time interval T of sending timestamp information of the opposite main control unit through the peer timer;
[0123] An acquisition unit, configured to acquire a total number of timestamps allNum according to a peer timer period with a time interval T;
[0124] The first updating unit is used to update the time when the total number of timestamps allNum is greater than 0, by using a prediction estimation algorithm or a back-estimation algorithm, when the timestamp number curNum remaining unprocessed is cleared.
[0125] Specifically, the estimation compensation system for clock synchronization also includes:
[0126] The record assignment unit is used to record and assign the total number of timestamps allNum of the current cycle to the total number of timestamps oldAllNum obtained in the previous cycle.
[0127] Specifically, the estimation compensation system for clock synchronization also includes:
[0128] The first judgment unit is used to judge whether the time when the timestamp total number allNum is 0 is updated by the prediction estimation algorithm in the previous cycle.
[0129] The second judgment unit is used to judge whether the total number of timestamps oldNum obtained in the previous cycle is 0 when the time when the local main control unit receives the timestamp is updated by the prediction estimation algorithm in the previous cycle;
[0130] The second updating unit is used to update the time when the total number of timestamps oldNum obtained in the previous period is not 0 by using a prediction estimation algorithm, until the total number of timestamps oldNum obtained in the previous period is cleared to zero;
[0131] The modification unit modifies the state of the previous cycle to update the receiving time stamp of the local main control unit through the back-pushing estimation algorithm when the previous cycle is not updated through the prediction estimation algorithm and / or the total number of timestamps oldNum obtained in the previous cycle is 0.
[0132] Specifically, the first updating unit includes:
[0133] An acquisition module, used for acquiring a receiving time value Tlocal of a peer timer of a local master control unit;
[0134] A selection module is used to select a prediction estimation algorithm or a back-estimation algorithm to update the receiving timestamp moment Tlocal` of the local main control unit;
[0135] A prediction and estimation module, used for calculating a target reception time value Tlocal` of the local master control unit according to the reception time value Tlocal of the peer timer of the local master control unit, the total number of timestamps allNum, the number of currently remaining unprocessed timestamps curNum and the time interval T when the prediction and estimation algorithm is selected;
[0136] The pushback estimation module is used to calculate the time Tlocal` at which the local main control unit receives the timestamp according to the local main control unit peer timer reception time value Tlocal, the current remaining unprocessed timestamp number curNum and the time interval T when the pushback estimation algorithm is selected.
[0137] Specifically, the selection modules include:
[0138] The first judgment submodule is used to judge whether the local main control unit obtains the total number allNum of multiple timestamps in one peer timer cycle, and if so, calculate the reception time of multiple future peer timer cycle timestamps according to the prediction estimation algorithm;
[0139] The second judgment submodule is used to judge whether the total number of timestamps allNum obtained by the local main control unit in multiple consecutive peer timer periods is 0. If so, calculate the reception time of the timestamps of multiple past peer timer periods according to the back-estimation algorithm.
[0140] Specifically, the calculation formula of the prediction estimation algorithm is:
[0141] Tlocal`=Tlocal+((allNum-curNum)*T);
[0142] The calculation formula of the back-estimation algorithm is:
[0143] Tlocal`=Tlocal-((curNum-1)*T);
[0144] Wherein, Tlocal` indicates the time when the local master control unit receives the timestamp; allNum indicates the total number of timestamps; curNum indicates the number of remaining unprocessed timestamps; T indicates the time interval; and Tlocal indicates the time value of the peer timer receiving the local master control unit.
[0145] In summary, the calculation of the clock deviation value between the local end and the opposite end in the present disclosure only relies on a unidirectional fixed-interval timestamp; the present disclosure constructs a local timer for processing the opposite end timestamp; the moment value of the local main control unit used for time synchronization calculation in the present disclosure is specifically divided into a calculation method of predictive estimation and back-propagation estimation; the present disclosure designs the switching conditions between predictive estimation and back-propagation estimation, and proposes a mechanism to avoid repeated calculation designs.
[0146] Fig.11 Schematic diagram of the structure of a device of this exemplary embodiment. Fig.11 As shown, corresponding to the estimation compensation method for clock synchronization provided above, the present disclosure also provides a device. Since the embodiment of the device is similar to the above method embodiment, the description is relatively simple. For relevant parts, please refer to the description of the above method embodiment part. The device described below is only schematic. The device may include: a processor (processor) 1, a memory (memory) 2 and a communication bus (i.e., the above device bus) and a search engine, wherein the processor 1 and the memory 2 communicate with each other through the communication bus and communicate with the outside through the communication interface. The processor 1 can call the logic instructions in the memory 2 to execute the estimation compensation method for clock synchronization.
[0147] In addition, the logic instructions in the above-mentioned memory 2 can be implemented in the form of a software functional unit and can be stored in a computer-readable storage medium when it is sold or used as an independent product. Based on such an understanding, the technical solution of the present disclosure is essentially or the part that contributes to the prior art or the part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a number of instructions to enable a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the various embodiments of the present disclosure. The aforementioned storage medium includes: a storage chip, a U disk, a mobile hard disk, a read-only memory (ROM, Read-Only Memory), a random access memory (RAM, Random Access Memory), a disk or an optical disk, and other media that can store program codes.
[0148] On the other hand, an embodiment of the present disclosure further provides a processor-readable storage medium on which a computer program 3 is stored. When the computer program 3 is executed by the processor 1, it is implemented to execute the estimation compensation method for clock synchronization provided in the above-mentioned embodiments.
[0149] The processor-readable storage medium can be any available medium or data storage device that can be accessed by the processor 1, including but not limited to magnetic storage (such as floppy disks, hard disks, magnetic tapes, magneto-optical disks (MO), etc.), optical storage (such as CD, DVD, BD, HVD, etc.), and semiconductor storage (such as ROM, EPROM, EEPROM, non-volatile memory (NANDFLASH), solid-state drive (SSD)), etc.
[0150] The above are only preferred implementations of the present disclosure, and the protection scope of the present disclosure is not limited to the above embodiments. All technical solutions under the concept of the present disclosure belong to the protection scope of the present disclosure. It should be pointed out that for ordinary technicians in this technical field, some improvements and modifications without departing from the principle of the present disclosure should be regarded as the protection scope of the present disclosure.
Claims
1. An estimation compensation method for clock synchronization, characterized in that: include: A peer timer with a time interval of T is established in the local main control unit, and the peer timer is used to simulate the time interval T of sending the timestamp information of the opposite main control unit; Get the total number of timestamps allNum according to the peer timer period with a time interval of T; When the total number of timestamps allNum is greater than 0, the time when the local main control unit receives the timestamp is updated through a prediction estimation algorithm or a back-estimation algorithm until the current number of remaining unprocessed timestamps curNum is cleared.
2. The estimation compensation method for clock synchronization according to claim 1, characterized in that: When the total number of timestamps allNum is greater than 0, the time when the local main control unit receives the timestamp is updated by a prediction estimation algorithm or a back-estimation algorithm until the current number of remaining unprocessed timestamps curNum is cleared to zero, including: Record and assign the total number of timestamps allNum of the current cycle to the total number of timestamps oldAllNum obtained in the previous cycle.
3. The estimation compensation method for clock synchronization according to claim 2, characterized in that: The total number of timestamps allNum is obtained according to the peer timer cycle with a time interval T, and then includes: When the total number of timestamps allNum is 0, it is determined whether the time when the local main control unit receives the timestamp is updated by the prediction estimation algorithm in the previous cycle; When the time when the local main control unit receives the timestamp is updated by the prediction estimation algorithm in the previous cycle, it is determined whether the total number of timestamps oldNum obtained in the previous cycle is 0; When the total number of timestamps oldNum obtained in the previous cycle is not 0, the time when the local main control unit receives the timestamp is updated through the prediction estimation algorithm until the total number of timestamps oldNum obtained in the previous cycle is cleared; When the previous cycle is not updated by the prediction estimation algorithm, and / or the total number of timestamps oldNum acquired in the previous cycle is 0, the state of the previous cycle is modified to update the time when the local main control unit receives the timestamp by the back-pushing estimation algorithm.
4. The estimation compensation method for clock synchronization according to claim 1, characterized in that: Updating the receiving timestamp of the local main control unit by using the prediction estimation algorithm or the back-estimation algorithm includes: Get the receiving time value Tlocal of the peer timer of the local master control unit; Select the prediction estimation algorithm or the back-estimation algorithm to update the receiving timestamp time Tlocal` of the local main control unit; When the prediction estimation algorithm is selected, the target reception time value Tlocal of the local master control unit is calculated according to the reception time value Tlocal of the peer timer of the local master control unit, the total number of timestamps allNum, the number of currently remaining unprocessed timestamps curNum and the time interval T; When the push-back estimation algorithm is selected, the time Tlocal` at which the local master control unit receives the timestamp is calculated according to the local master control unit peer timer reception time value Tlocal, the current number of remaining unprocessed timestamps curNum and the time interval T.
5. The estimation compensation method for clock synchronization according to claim 4, characterized in that: Selecting a prediction estimation algorithm or a back-estimation algorithm to update the receiving timestamp moment Tlocal` of the local main control unit includes: Determine whether the local main control unit obtains a total number allNum of multiple timestamps in a peer timer cycle. If so, calculate the time of receiving timestamps of multiple future peer timer cycles according to the prediction estimation algorithm; It is determined whether the total number of timestamps allNum obtained by the local main control unit in multiple consecutive peer timer periods is 0. If so, the reception time of the timestamps of multiple past peer timer periods is calculated according to the back-estimation algorithm.
6. The estimation compensation method for clock synchronization according to claim 4, characterized in that: The calculation formula of the prediction estimation algorithm is: Tlocal`=Tlocal+((allNum-curNum)*T); The calculation formula of the back-estimation algorithm is: Tlocal`=Tlocal-((curNum-1)*T); Wherein, Tlocal` indicates the time when the local master control unit receives the timestamp; allNum indicates the total number of timestamps; curNum indicates the number of remaining unprocessed timestamps; T indicates the time interval; and Tlocal indicates the time value of the peer timer receiving the local master control unit.
7. An estimation compensation system for clock synchronization, characterized in that: include: A construction unit, used for constructing a peer timer with a time interval of T in the local main control unit, and simulating the time interval T of sending timestamp information of the opposite main control unit through the peer timer; An acquisition unit, configured to acquire a total number of timestamps allNum according to a peer timer period with a time interval T; The first updating unit is used to update the time when the total number of timestamps allNum is greater than 0, by using a prediction estimation algorithm or a back-estimation algorithm, when the timestamp number curNum remaining unprocessed is cleared.
8. The estimation compensation system for clock synchronization according to claim 7, characterized in that: Also includes: The record assignment unit is used to record and assign the total number of timestamps allNum of the current cycle to the total number of timestamps oldAllNum obtained in the previous cycle.
9. The estimation compensation system for clock synchronization according to claim 8, characterized in that: Also includes: The first judgment unit is used to judge whether the time when the timestamp total number allNum is 0 is updated by the prediction estimation algorithm in the previous cycle. The second judgment unit is used to judge whether the total number of timestamps oldNum obtained in the previous cycle is 0 when the time when the local main control unit receives the timestamp is updated by the prediction estimation algorithm in the previous cycle; The second updating unit is used to update the time when the total number of timestamps oldNum obtained in the previous period is not 0 by using a prediction estimation algorithm, until the total number of timestamps oldNum obtained in the previous period is cleared to zero; The modification unit modifies the state of the previous cycle to update the receiving time stamp of the local main control unit through the back-pushing estimation algorithm when the previous cycle is not updated through the prediction estimation algorithm and / or the total number of timestamps oldNum obtained in the previous cycle is 0.
10. The estimation compensation system for clock synchronization according to claim 7, characterized in that: The first update unit includes: An acquisition module, used for acquiring a receiving time value Tlocal of a peer timer of a local master control unit; A selection module is used to select a prediction estimation algorithm or a back-estimation algorithm to update the receiving timestamp moment Tlocal` of the local main control unit; A prediction and estimation module, used for calculating a target reception time value Tlocal` of the local master control unit according to the reception time value Tlocal of the peer timer of the local master control unit, the total number of timestamps allNum, the number of currently remaining unprocessed timestamps curNum and the time interval T when the prediction and estimation algorithm is selected; The pushback estimation module is used to calculate the time Tlocal` at which the local main control unit receives the timestamp according to the local main control unit peer timer reception time value Tlocal, the current remaining unprocessed timestamp number curNum and the time interval T when the pushback estimation algorithm is selected.
11. The estimation compensation system for clock synchronization according to claim 10, characterized in that: Select modules include: The first judgment submodule is used to judge whether the local main control unit obtains the total number allNum of multiple timestamps in one peer timer cycle, and if so, calculate the reception time of multiple future peer timer cycle timestamps according to the prediction estimation algorithm; The second judgment submodule is used to judge whether the total number of timestamps allNum obtained by the local main control unit in multiple consecutive peer timer periods is 0. If so, calculate the reception time of the timestamps of multiple past peer timer periods according to the back-estimation algorithm.
12. The estimation compensation system for clock synchronization according to claim 10, characterized in that: The calculation formula of the prediction estimation algorithm is: Tlocal`=Tlocal+((allNum-curNum)*T); The calculation formula of the back-estimation algorithm is: Tlocal`=Tlocal-((curNum-1)*T); Wherein, Tlocal` indicates the time when the local master control unit receives the timestamp; allNum indicates the total number of timestamps; curNum indicates the number of remaining unprocessed timestamps; T indicates the time interval; and Tlocal indicates the time value of the peer timer receiving the local master control unit.
13. A device, characterized in that: include: Processor and memory; The memory is used to store a computer program, and the processor calls the computer program stored in the memory to execute the estimation compensation method for clock synchronization according to any one of claims 1 to 6.
14. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the processor is enabled to execute the estimation compensation method for clock synchronization according to any one of claims 1 to 6.