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

By calculating the interactive timestamp and establishing a frequency control method, using Kalman filter and MPC to dynamically adjust the frequency, the problem of poor clock synchronization accuracy and stability in the prior art is solved, and more efficient clock synchronization is achieved.

CN115333665BActive Publication Date: 2024-11-12CHINA TELECOM CORP LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202210976053.1
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-08-15
Publication Date
2024-11-12
Estimated Expiration
2042-08-15

AI Technical Summary

Technical Problem

The existing clock synchronization method only considers the master-slave time difference in frequency control, and most controller parameters need to be manually adjusted, resulting in poor time synchronization accuracy and stability.

Method used

By obtaining the interactive timestamp, the parameters to be filtered are calculated, the main clock state estimation is performed, the frequency control method is established, the frequency adjustment is used to use Kalman filter and model prediction control (MPC) to perform frequency adjustment, and the controller parameters are dynamically adjusted to optimize clock synchronization.

Benefits of technology

Adjust the master-slave clock error to a limited time, which improves the accuracy, accuracy and stability of clock synchronization and avoids adaptive parameter tuning of additional intelligent algorithms.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115333665B_ABST
    Figure CN115333665B_ABST
Patent Text Reader

Abstract

The present disclosure belongs to the field of network technology and security technology, and relates to a clock synchronization method and device, a storage medium, and an electronic device. The method includes: obtaining an interaction timestamp, and calculating the interaction timestamp to obtain a parameter to be filtered; estimating the master clock state of the parameter to be filtered to obtain the master clock time, and establishing a frequency control method according to the master clock time to obtain a target control sequence; calculating the parameter to be filtered and the target control sequence to obtain a frequency adjustment value, and performing frequency control according to the frequency adjustment value to obtain a slave clock time. The present disclosure takes into account the jitter and instability of the timestamp and the network link delay, estimates the master clock state of the parameter to be filtered, and determines the frequency adjustment value of the slave clock at the same time, without the need to add other intelligent algorithms to perform adaptive parameter setting of the controller, and can adjust the master-slave clock error to the minimum within a limited time, thereby improving the precision, accuracy, and stability of clock synchronization.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present disclosure relates to the fields of network technology and security technology, and in particular to a clock synchronization method and a clock synchronization device, a computer-readable storage medium, and an electronic device. Background Art

[0002] IEEE 1588 protocol is the basic technology for network time synchronization. Among them, frequency control is a key link in time synchronization. The previous frequency control method mainly uses PID (Proportional Integral Derivative) controller for frequency control and compensation.

[0003] However, the controller only considers the master-slave time difference as the controller input to solve the control output, and most of the controller parameters are manually adjusted in the early stage of synchronization and are fixed, or other intelligent algorithms can only be added to adjust the parameters, which is time-consuming and difficult to make real-time adjustments, thus affecting the accuracy and stability of time synchronization.

[0004] In view of this, there is an urgent need in the art to develop a new clock synchronization method and device.

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

[0006] The purpose of the present disclosure is to provide a clock synchronization method, a clock synchronization device, a computer-readable storage medium and an electronic device, thereby overcoming the technical problems of poor accuracy and stability caused by the limitations of related technologies at least to a certain extent.

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

[0008] According to a first aspect of an embodiment of the present invention, a clock synchronization method is provided, the method comprising:

[0009] Obtaining an interaction timestamp, and calculating the interaction timestamp to obtain a parameter to be filtered;

[0010] Performing master clock state estimation on the parameter to be filtered to obtain master clock time, and establishing a frequency control method according to the master clock time to obtain a target control sequence;

[0011] The parameter to be filtered and the target control sequence are calculated to obtain a frequency adjustment value, and frequency control is performed according to the frequency adjustment value to obtain a slave clock time.

[0012] In an exemplary embodiment of the present invention, the parameters to be filtered include: link delay parameters, synchronization cycle parameters, and master clock frequency ratio.

[0013] In an exemplary embodiment of the present invention, the step of calculating the interaction timestamp to obtain the parameter to be filtered includes:

[0014] Calculating the interaction timestamp to obtain a link delay parameter, and defining the synchronization cycle parameter according to the interaction timestamp;

[0015] The synchronization period parameter is calculated to obtain a main clock frequency ratio.

[0016] In an exemplary embodiment of the present invention, the step of estimating the master clock state of the parameter to be filtered to obtain the master clock time includes:

[0017] Establishing a master clock dynamic model according to the interaction timestamp and the parameters to be filtered, and initializing the filter;

[0018] The initialized filter is used to estimate the master clock state of the parameter to be filtered to obtain the master clock time.

[0019] In an exemplary embodiment of the present invention, the filter is a Kalman filter.

[0020] In an exemplary embodiment of the present invention, the method for establishing a frequency control according to the master clock time to obtain a target control sequence includes:

[0021] Establishing a controlled slave clock model, and establishing a master-slave time error model based on the master clock dynamic model and the controlled slave clock model;

[0022] The controlled time is acquired, and a frequency control method is established according to the master clock time and the controlled time to obtain a target control sequence.

[0023] In an exemplary embodiment of the present invention, the frequency control method includes: a state feedback controller.

[0024] According to a second aspect of an embodiment of the present invention, there is provided a clock synchronization device, including:

[0025] A time calculation module is configured to obtain an interaction timestamp and calculate the interaction timestamp to obtain a parameter to be filtered;

[0026] A sequence solving module is configured to estimate the master clock state of the parameter to be filtered to obtain the master clock time, and establish a frequency control method according to the master clock time to obtain a target control sequence;

[0027] The frequency control module is configured to calculate the parameter to be filtered and the target control sequence to obtain a frequency adjustment value, and perform frequency control according to the frequency adjustment value to obtain a slave clock time.

[0028] According to a third aspect of an embodiment of the present invention, there is provided an electronic device, comprising: a processor and a memory; wherein the memory stores computer-readable instructions, and when the computer-readable instructions are executed by the processor, the clock synchronization method in any of the above exemplary embodiments is implemented.

[0029] According to a fourth aspect of an embodiment of the present invention, there is provided a computer-readable storage medium having a computer program stored thereon, wherein when the computer program is executed by a processor, the clock synchronization method in any of the above exemplary embodiments is implemented.

[0030] It can be seen from the above technical solutions that the clock synchronization method, clock synchronization device, computer storage medium and electronic device in the exemplary embodiments of the present disclosure have at least the following advantages and positive effects:

[0031] In the method and device provided by the exemplary embodiments of the present disclosure, the jitter and instability of timestamps and network link delays are taken into account, the master clock state is estimated for the filtering parameters, and the frequency adjustment value of the slave clock is determined at the same time. There is no need to add other intelligent algorithms to perform adaptive parameter adjustment of the controller. The master-slave clock error can be adjusted to the minimum within a limited time, thereby improving the precision, accuracy and stability of clock synchronization.

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

[0033] 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.

[0034] Figure 1 A schematic diagram schematically illustrates a flow chart of a clock synchronization method in an exemplary embodiment of the present disclosure;

[0035] Figure 2 A schematic diagram of time synchronization based on the IEEE 1588 protocol in an exemplary embodiment of the present disclosure is schematically shown;

[0036] Figure 3 A schematic diagram schematically illustrates a flow chart of a method for calculating an interaction timestamp in an exemplary embodiment of the present disclosure;

[0037] Figure 4 A flowchart schematically illustrating a method for estimating master clock time in an exemplary embodiment of the present disclosure;

[0038] Figure 5 A schematic diagram schematically illustrates a flow chart of a method for generating a target control sequence in an exemplary embodiment of the present disclosure;

[0039] Figure 6 A block diagram schematically illustrates a frequency control system in an exemplary embodiment of the present disclosure;

[0040] Figure 7 A schematic diagram schematically illustrates a flow chart of a clock synchronization method in an application scenario in an exemplary embodiment of the present disclosure;

[0041] Figure 8 A schematic diagram schematically shows the structure of a clock synchronization system in an application scenario in an exemplary embodiment of the present disclosure;

[0042] Fig. 9 A schematic diagram schematically shows the structure of a clock synchronization device in an exemplary embodiment of the present disclosure;

[0043] Fig.10 Schematically illustrates an electronic device for implementing a clock synchronization method in an exemplary embodiment of the present disclosure;

[0044] Fig.11 The present invention schematically illustrates a computer-readable storage medium for implementing a clock synchronization method in an exemplary embodiment of the present disclosure. DETAILED DESCRIPTION

[0045] 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.

[0046] The terms "a", "an", "the" and "said" are used in this specification to indicate the presence of one or more elements / components / etc.; the terms "including" and "having" are used to express an open-ended inclusion and mean that additional elements / components / etc. may exist in addition to the listed elements / components / etc.; the terms "first" and "second" etc. are used only as labels and are not intended to limit the quantity of their objects.

[0047] 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 drawings represent the same or similar parts, and their repeated descriptions 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.

[0048] In view of the problems existing in the related art, the present disclosure proposes a clock synchronization method. Figure 1 A flow chart of a clock synchronization method is shown, such as Figure 1 As shown, the clock synchronization method at least includes the following steps:

[0049] Step S110: Obtain the interaction timestamp, and calculate the interaction timestamp to obtain the parameter to be filtered.

[0050] Step S120: Perform master clock state estimation on the filter parameters to obtain the master clock time, and establish a frequency control method according to the master clock time to obtain a target control sequence.

[0051] Step S130: Calculate the filtering parameter and the target control sequence to obtain a frequency adjustment value, and perform frequency control according to the frequency adjustment value to obtain a slave clock time.

[0052] In an exemplary embodiment of the present disclosure, the jitter and instability of timestamps and network link delays are taken into account, the master clock state estimation is performed on the filtering parameters, and the frequency adjustment value of the slave clock is determined at the same time. There is no need to add other intelligent algorithms to perform adaptive parameter adjustment of the controller. The master-slave clock error can be adjusted to the minimum within a limited time, thereby improving the precision, accuracy and stability of clock synchronization.

[0053] The following describes in detail the various steps of the clock synchronization method.

[0054] In step S110, the interaction timestamp is obtained, and the interaction timestamp is calculated to obtain the parameter to be filtered.

[0055] In an exemplary embodiment of the present disclosure, a master-slave relationship is established between two devices, and synchronization begins.

[0056] Figure 2 A schematic diagram of time synchronization based on the IEEE 1588 protocol is shown, Figure 2As shown, the time synchronization mode is implemented by a clock model based on the PTP (Precision Time Protocol) time synchronization protocol. The PTP protocol interaction generates timestamps t1(k), t2(k), t3(k) and t4(k) as interaction timestamps.

[0057] Furthermore, the parameters to be filtered can be calculated according to the interaction timestamp.

[0058] In an optional embodiment, the parameters to be filtered include: link delay parameters, synchronization cycle parameters, and master clock frequency ratio.

[0059] Among them, the link delay parameter can be used The synchronization period parameter can be expressed as Δt(k), and the master clock frequency ratio can be expressed as express.

[0060] In an alternative embodiment, Figure 3 A flow chart of a method for calculating an interaction timestamp is shown, such as Figure 3 As shown, the method may at least include the following steps: In step S310, the interaction timestamp is calculated to obtain a link delay parameter, and a synchronization cycle parameter is defined according to the interaction timestamp.

[0061] Use d(k) to represent the line delay estimate finally used for the kth synchronization message, as shown in formula (1):

[0062]

[0063] Usually, the link delay parameter is estimated using the average value of several consecutive line delays, as shown in formula (2):

[0064]

[0065] according to Figure 2 The IEEE 1588 protocol interaction process shown in the figure takes the master clock line as the reference line. It is assumed that the time when the sync message sent by the master clock arrives at the slave clock (t2(k)) corresponds to the master clock time x(k). Therefore, it can be seen that x(k+1)-x(k) and t2(k+1)-t2(k) are the measurements of the master clock and the slave clock for the same time interval in the real world, respectively.

[0066] Based on this, the time interval between two adjacent syncs, i.e. the synchronization period parameter, is defined according to formula (3):

[0067] Δt(k)=t2(k+1)-t2(k) (3)

[0068] In step S320, the synchronization period parameter is calculated to obtain the main clock frequency ratio.

[0069] Furthermore, the dynamic equation of the master clock time can be expressed as:

[0070] x(k+1)=x(k)+Δt(k)r(k) (4)

[0071] Where r(k) is the ratio of the frequencies of the master clock and the slave clock in the kth synchronization cycle, and its estimated value is:

[0072]

[0073]

[0074] In this exemplary embodiment, the corresponding parameters to be filtered are calculated according to the interaction timestamp, which provides a data basis and theoretical support for estimating the main clock time.

[0075] In step S120, the master clock state is estimated for the parameters to be filtered to obtain the master clock time, and a frequency control method is established according to the master clock time to obtain a target control sequence.

[0076] In an exemplary embodiment of the present disclosure, after the parameters to be filtered are calculated, the master clock time may be further estimated.

[0077] In an alternative embodiment, Figure 4 A flow chart of a method for estimating master clock time is shown, Figure 4 As shown, the method may at least include the following steps: in step S410, a master clock dynamic model is established according to the interaction timestamp and the parameters to be filtered, and the filter is initialized.

[0078] Assume that

[0079]

[0080] Among them, the random variable Will As the system input,

[0081] The system state transition equation is:

[0082]

[0083] The time y(k) when the master clock synchronization sync packet is sent is shown in formula (9):

[0084] y(k)=x(k)-d(k)r(k)+v(k) (9)

[0085] in Bring in The observation equation is obtained:

[0086]

[0087] The output of this observation equation is t1(k).

[0088] In an optional embodiment, the filter is a Kalman filter.

[0089] When designing the Kalman filter algorithm, obtain its estimated value

[0090] For the convenience of distinction, the prior estimate is represents the estimated value of x without fusion measurement t1. The posterior estimate is represents the estimated value of x after fusion of the measured value t1. Assume that the initial state x 0 =x(0), initial input Initialize the filter as follows:

[0091]

[0092]

[0093] In step S420, the initialized filter is used to perform master clock state estimation on the parameters to be filtered to obtain the master clock time.

[0094] For k ≥ 1, the Kalman filter process is:

[0095] First, the state one-step prediction is

[0096] Second, the covariance one-step forecast is

[0097] Third, the Kalman gain is

[0098] Fourth, update the status to

[0099] Fifth, update the covariance to P + (k) = (1-g(k))P - (k);

[0100] Finally, the filtering result is the a posteriori estimate That is, the master clock time, and, below refers to

[0101] Furthermore, a frequency control method can be established according to the estimated master clock time to obtain an optimal target control sequence.

[0102] In an alternative embodiment, Figure 5 A flow chart of a method for generating a target control sequence is shown, as Figure 5 As shown, the method may at least include the following steps: in step S510, a controlled slave clock model is established, and a master-slave time error model is established according to the master clock dynamic model and the controlled slave clock model.

[0103] The slave clock obtains the timestamp information from the PTP interaction and performs Kalman filtering to estimate the master clock time corresponding to the received message time t2(k). Let t2(k) be the set point.

[0104] In practical applications, slave node devices usually also need to estimate the master clock time between set points, and the time estimation is required to be continuous.

[0105] For this purpose, a local dynamic variable x from the slave clock is introduced s , called controlled time. The controlled time is the time estimate between two adjacent master clocks. and Linear interpolation is performed between x s is the local slave clock time, divided by a variable factor r s (k) Adjusted to track master clock time

[0106] r s (k) is the offset compensation factor that compensates for the frequency skew between the slave clock and the master clock. Therefore, starting from the set point k, the controlled time of any local time τ before the next set point is:

[0107] x s (τ) = x s (k)+r s (k)(τ-t2(k)) (11)

[0108] Between two set points x s Continuous, then:

[0109] x s (k+1)=x s (k)+Δt(k)r s (k) (12)

[0110] Among them, Δt(k)=t2(k)-t2(k-1) is the local time interval between the arrival of two synchronization messages from the slave clock. It can be set to a fixed value Δt(k)≡Δt, and the controlled time dynamic equation is:

[0111] x s (k+1)=x s (k)+Δtr s(k) (13)

[0112] According to the above formula (4), the main clock time dynamic equation is:

[0113] x(k+1)=x(k)+Δtr(k) (14)

[0114] The clock synchronization problem is described as: find r s (k) makes x s Track x. Let u(k) = r(k) - r s (k) and define:

[0115] e=xx s

[0116] Then, the master-slave time error model is:

[0117] e(k+1)=e(k)+Δtu(k) (15)

[0118] In step S520, the controlled time is acquired, and a frequency control method is established according to the master clock time and the controlled time to obtain a target control sequence.

[0119] The clock synchronization problem is equivalent to finding u(k) so that the error variable e tends to 0.

[0120] In an optional embodiment, the frequency control method includes: a state feedback controller.

[0121] Specifically, the state feedback controller may be a new controller, such as MPC (Model Predictive Control).

[0122] Consider using MPC to control the system of formula (15) in a time window of length N. Starting from the synchronization message time k, at times k, k+1, ..., k+N-1, calculate the control variables of N systems (15) to minimize the defined cost function.

[0123] To conveniently represent this rolling window, the system model of formula (15) is rewritten as:

[0124] e(i+1)=e(i)+Δtu(i) (16)

[0125] Where i = k, k + 1, ..., k + N-1 and the initial condition e(k) = 0. The cost function (performance index) is defined as:

[0126]

[0127] Among them, the parameter q is a non-negative real number, the parameter r is a positive real number, and N is the data window length (prediction step).

[0128] To minimize the above performance indicators, the optimal control sequence of linear state feedback is:

[0129]

[0130] in, is the estimated value of the system state e(i), and L(i) is the feedback gain:

[0131] L(i)=[Q(i+1)Δt 2 +r] -1 Q(i+1)Δt (19)

[0132] where Q(i) is a non-negative solution to the following equation:

[0133] Q(i)=[1-ΔtL(i)] 2 Q(i+1)+L 2 (i)r+q (20)

[0134] And the boundary conditions are:

[0135] Q(N)=0 (21)

[0136] Substituting L(i) into the recursive equation of Q(i), we have

[0137] Q(i)=q+Q(i+1)-Q(i+1)Δt[Q(i+1)Δt 2 +r] -1 Q(i+1)Δt (22)

[0138] For the convenience of calculation, define:

[0139] Z 1 (i) = q + Q (i + 1) (23)

[0140] Z 2 (i) = Q(i+1)Δt (24)

[0141] Z 3 (i)=(i+1)Δt 2 +r (25)

[0142] have:

[0143]

[0144]

[0145] Therefore, the optimal control L(i) can be solved as follows:

[0146] (1) Based on the known boundary condition Q(N) = 0, let i = k + N-1 to calculate Z 1 (i) Z 2 (i) Z 3 (i);

[0147] (2) Calculate L(i) and Q(i) using formula (19) and formula (20), and obtain

[0148] (3) Let i = k+N-2, k+N-3,…, k+1, k. Repeat steps (1) and (2).

[0149] Taking the kth moment as the initial moment, the above algorithm finally obtains the control sequence u * (k),u * (k+1),…,u * (k+N-1). The first control quantity u * (k) Used in the system.

[0150] Then, in the next cycle, the initial time becomes k+1, and the control sequence u is calculated again by the above algorithm * (k+1),u * (k+2),…,u * (k+N), similarly, the first control quantity u * (k+1) is applied to the system and the cycle repeats.

[0151] In step S130, the filtering parameter and the target control sequence are calculated to obtain a frequency adjustment value, and frequency control is performed according to the frequency adjustment value to obtain a slave clock time.

[0152] In an exemplary embodiment of the present disclosure, since MPC is a state feedback controller, it is necessary to obtain the state e(i), i=k, k+1, ..., k+N-1.

[0153] The Kalman filter is based on the noisy observations e(i) = x(i) - x s (i) , calculate the estimated value Note that x s No noise,

[0154] x(i) needs to use a Kalman filter to obtain an estimate from the noisy observation t1(k) Therefore, there are:

[0155]

[0156] In fact, the controlled object is not the master-slave time error model, but the controlled time of the slave clock:

[0157]

[0158] In addition to estimating x(i), it is also necessary to estimate r(i) to use it as the set point of the slave clock control signal.

[0159] Combining Kalman filter and MPC control, the control signal r s That is, the input of the slave clock controlled time is calculated by the following formula:

[0160]

[0161] in L(i) is as shown above, Figure 6 A block diagram of a frequency control system is shown, such as Figure 6 As shown, for any local time τ between two set points t2(k) and t2(k+1) at i=k, the corresponding master time is given by:

[0162]

[0163] The clock synchronization method in the embodiment of the present disclosure is described in detail below in conjunction with an application scenario.

[0164] Figure 7 A schematic diagram of a clock synchronization method in an application scenario is shown, such as Figure 7 As shown, in step S710, synchronization starts: the synchronization initialization of the two clocks is completed.

[0165] The two devices establish a master-slave relationship and start synchronization.

[0166] In step S720, a master-slave clock dynamic model is established according to the PTP protocol.

[0167] Time synchronization is achieved based on the clock model of the PTP time synchronization protocol. The PTP protocol interaction generates timestamps t1(k), t2(k), t3(k) and t4(k) as interaction timestamps.

[0168] Furthermore, the parameters to be filtered can be calculated according to the interaction timestamp.

[0169] Among them, the link delay parameter can be used The synchronization period parameter can be expressed as Δt(k), and the master clock frequency ratio can be expressed as express.

[0170] Use d(k) to represent the line delay estimate ultimately used for the kth synchronization message, as shown in formula (1).

[0171] Typically, the link delay parameter is estimated using the average value of several consecutive line delays, as shown in formula (2).

[0172] According to the IEEE 1588 protocol interaction process, the master clock line is used as the reference line. Assuming that the sync message sent by the master clock arrives at the slave clock (t2(k)) at the time corresponding to the master clock time x(k), it can be seen that x(k+1)-x(k) and t2(k+1)-t2(k) are the measurements of the master clock and the slave clock for the same time interval in the real world, respectively.

[0173] Based on this, the time interval between two adjacent syncs, ie, the synchronization period parameter, is defined according to formula (3).

[0174] Furthermore, the dynamic equation of the master clock time can be expressed as formula (4).

[0175] In step S730, the master clock time is estimated using Kalman.

[0176] After the parameters to be filtered are calculated, the master clock time can be further estimated.

[0177] The master clock dynamic model is established according to the interaction timestamp and the parameters to be filtered, and the filter is initialized.

[0178] Assume that

[0179]

[0180] Among them, the random variable Will As the system input,

[0181] The system state transition equation is:

[0182]

[0183] The time y(k) when the master clock synchronizes the sync packet is sent is shown in formula (9). Substituting The observation equation is obtained:

[0184]

[0185] When designing the Kalman filter algorithm, obtain its estimated value

[0186] For the convenience of distinction, the prior estimate is represents the estimated value of x without fusion measurement t1. The posterior estimate is represents the estimated value of x after fusion of the measured value t1. Assume that the initial state x 0 =x(0), initial input Then, the filter is initialized.

[0187] The initialized filter is used to estimate the master clock state of the filter parameters to obtain the master clock time.

[0188] For k ≥ 1, the Kalman filter process is:

[0189] First, the state one-step prediction is

[0190] Second, the covariance one-step forecast is

[0191] Third, the Kalman gain is

[0192] Fourth, update the status to

[0193] Fifth, update the covariance to P + (k) = (1-g(k))P - (k);

[0194] Finally, the filtering result is the a posteriori estimate That is, the master clock time, and, below refers to

[0195] at this time, is Kalman's optimal estimate of x(k) (the time when the sync message sent by the master clock arrives at the slave clock (t2(k)) corresponds to the master clock time x(k)).

[0196] In step S740, a master-slave time error model is obtained based on the master clock and the controlled slave clock model, and a frequency compensation factor is introduced.

[0197] The slave clock obtains the timestamp information from the PTP interaction and performs Kalman filtering to estimate the master clock time corresponding to the received message time t2(k). Let t2(k) be the set point.

[0198] In practical applications, slave node devices usually also need to estimate the master clock time between set points, and the time estimation is required to be continuous.

[0199] For this purpose, a local dynamic variable x from the slave clock is introduced s , called controlled time. The controlled time is the time estimate between two adjacent master clocks. and Linear interpolation is performed between x s is the local slave clock time, divided by a variable factor r s (k) Adjusted to track master clock time

[0200] r s (k) is an offset compensation factor that compensates for the frequency skew between the slave clock and the master clock. Therefore, starting from the set point k, the controlled time of any local time τ before the next set point is as shown in formula (11).

[0201] Between two set points x s Continuous, then:

[0202] x s (k+1)=x s (k)+Δt(k)r s (k)

[0203] Wherein, Δt(k)=t2(k)-t2(k-1) is the local time interval between the arrival of two synchronization messages from the slave clock. It can be set to a fixed value Δt(k)≡Δt, and the controlled time dynamic equation is shown in formula (13).

[0204] The clock synchronization problem is described as: find r s (k) makes x s Track x. Let u(k) = r(k) - r s (k) and define:

[0205] e=xx s

[0206] Then, the master-slave time error model is shown in formula (15).

[0207] In step S750, an MPC-based frequency compensation control method is established according to the master clock time estimate value estimated by Kalman estimation and the controlled time.

[0208] The clock synchronization problem is equivalent to finding u(k) so that the error variable e tends to 0.

[0209] Consider using MPC to control the system of formula (15) in a time window of length N. Starting from the synchronization message time k, at times k, k+1, ..., k+N-1, calculate the control variables of N systems (15) to minimize the defined cost function.

[0210] To conveniently represent this rolling window, the system model of formula (15) is rewritten as formula (16).

[0211] Define the cost function (performance index) as formula (17).

[0212] To minimize the above performance indicators, the optimal control sequence of linear state feedback is formula (18).

[0213] in, is the estimated value of the system state e(i), and L(i) is the feedback gain:

[0214] L(i)=[Q(i+1)Δt 2 +r] -1 Q(i+1)Δt

[0215] where Q(i) is a non-negative solution to the following equation:

[0216] Q(i)=[1-ΔtL(i)] 2 Q(i+1)+L 2 (i)r+q

[0217] And the boundary conditions are:

[0218] Q(N)=0

[0219] Substituting L(i) into the recursive equation of Q(i), we have

[0220] Q(i)=q+Q(i+1)-Q(i+1)Δt[Q(i+1)Δt 2 +r] -1 Q(i+1)Δt

[0221] For the convenience of calculation, define:

[0222] Z 1 (i) = q + Q (i + 1)

[0223] Z 2 (i) = Q(i+1)Δt

[0224] Z 3 (i)=(i+1)Δt 2 +r

[0225] have:

[0226]

[0227]

[0228] In step S760, the optimal control sequence is obtained according to the MPC, and the difference between the optimal control sequence and the master clock frequency is the controlled slave clock frequency compensation value.

[0229] Therefore, the optimal control L(i) can be solved as follows:

[0230] (1) Based on the known boundary condition Q(N) = 0, let i = k + N-1 to calculate Z 1 (i) Z 2 (i) Z 3 (i);

[0231] (2) Calculate L(i) and Q(i) using formula (19) and formula (20), and obtain

[0232] (3) Let i = k+N-2, k+N-3,…, k+1, k. Repeat steps (1) and (2).

[0233] Taking the kth moment as the initial moment, the above algorithm finally obtains the control sequence u * (k),u * (k+1),…,u * (k+N-1). The first control quantity u * (k) Used in the system.

[0234] Then, in the next cycle, the initial time becomes k+1, and the control sequence u is calculated again by the above algorithm * (k+1),u * (k+2),…,u * (k+N), similarly, the first control quantity u * (k+1) is applied to the system and the cycle repeats.

[0235] Since MPC is a state feedback controller, it is necessary to obtain the state e(i), i=k, k+1,…, k+N-1.

[0236] The Kalman filter is based on the noisy observations e(i) = x(i) - x s (i) , calculate the estimated value Note that x s No noise,

[0237] x(i) needs to use a Kalman filter to obtain an estimate from the noisy observation t1(k) Therefore, there are:

[0238]

[0239] In fact, the controlled object is not the master-slave time error model, but the controlled time of the slave clock:

[0240]

[0241] In addition to estimating x(i), it is also necessary to estimate r(i) to use it as the set point of the slave clock control signal.

[0242] In step S770, the slave clock uses the frequency compensation value to control the frequency and outputs the current time as feedback for updating for the next synchronization.

[0243] Combining Kalman filter and MPC control, the control signal r s That is, the input of the slave clock controlled time is calculated by the following formula:

[0244]

[0245] in L(i) is as shown above, Figure 6 A block diagram of the system is shown in FIG. Figure 6 As shown, for any local time τ between two set points t2(k) and t2(k+1) at i=k, the corresponding master time is given by:

[0246]

[0247] The local slave clock time x is output s (k), fed back to the controller input, and the master clock time The synchronization error is obtained by subtracting the time difference between the master and the slave. The slave clock continuously adjusts the frequency to make the master-slave time difference as small as possible, completing this synchronization and updating the next synchronization.

[0248] Figure 8 The schematic diagram of the clock synchronization system in the application scenario is shown in FIG. Figure 8 As shown, the two devices establish a master-slave relationship and start synchronization: PTP protocol interaction generates timestamps t1(k), t2(k), t3(k), and t4(k). Calculate the path delay based on the above timestamps Synchronous period Δt(k) and master clock frequency ratio Or estimated values ​​of the above parameters.

[0249] according to Δt(k), The master clock dynamic model is established based on the observed timestamp t1(k), and the Kalman kernel is used to estimate the master clock state output. at this time, is Kalman's optimal estimate of x(k) (the time when the sync message sent by the master clock arrives at the slave clock (t2(k)) corresponds to the master clock time x(k)).

[0250] Then, a controlled slave clock model is established and a frequency compensation factor is introduced.

[0251] According to the master clock and the controlled slave clock, the master-slave time difference model can be obtained

[0252] The MPC frequency control method is established with the goal of minimizing the time error e(k). Select N window lengths of synchronous data (prediction step length) and use the formula Solve to output the optimal control sequence u * (i).

[0253] According to the obtained master clock frequency ratio And the obtained MPC optimal controller outputs the control sequence u * (i), the difference between the two is That is the controlled slave clock frequency adjustment value.

[0254] From the clock Continuously adjust the frequency and output the local slave clock time x s (k) Feedback to the controller input, with the master clock time The slave clock continuously adjusts the frequency to make the master-slave time difference as small as possible, completes this synchronization, and is updated for the next synchronization.

[0255] Compared with the traditional PID method controlled from clock frequency, the clock synchronization method in this application scenario uses MPC to calculate the state feedback gain within N time steps. The control gain is time-varying within the prediction range N. The time window rolls continuously with the progress of time synchronization, and control is performed in the rolling time domain. The frequency parameters of the control are adaptively adjusted without the need for additional intelligent algorithms to complete parameter setting.

[0256] Compared with the traditional PID frequency control method and system, in addition to considering the minimization of the master-slave clock difference as the controller optimization direction, the master clock frequency ratio estimation is also added.

[0257] Taking into account the jitter and uncertainty of timestamp and network link delay, a reference master clock model and a controlled slave time model are established based on the PTP protocol. A new controller is also used to control the slave clock frequency, which can adjust the master-slave clock error to the smallest possible within a limited time N.

[0258] Fig. 9 A schematic diagram of the structure of the clock synchronization device is shown in FIG. Fig. 9 As shown, the clock synchronization device 90 may include: a time calculation module 910, a sequence solution module 920 and a frequency control module 930. Among them:

[0259] The time calculation module 910 is configured to obtain an interaction timestamp and calculate the interaction timestamp to obtain a parameter to be filtered;

[0260] The sequence solving module 920 is configured to estimate the master clock state of the parameter to be filtered to obtain the master clock time, and establish a frequency control method according to the master clock time to obtain a target control sequence;

[0261] The frequency control module 930 is configured to calculate the parameter to be filtered and the target control sequence to obtain a frequency adjustment value, and perform frequency control according to the frequency adjustment value to obtain a slave clock time.

[0262] In an exemplary embodiment of the present invention, the parameters to be filtered include: link delay parameters, synchronization cycle parameters, and master clock frequency ratio.

[0263] In an exemplary embodiment of the present invention, the step of calculating the interaction timestamp to obtain the parameter to be filtered includes:

[0264] Calculating the interaction timestamp to obtain a link delay parameter, and defining the synchronization cycle parameter according to the interaction timestamp;

[0265] The synchronization period parameter is calculated to obtain a main clock frequency ratio.

[0266] In an exemplary embodiment of the present invention, the step of estimating the master clock state of the parameter to be filtered to obtain the master clock time includes:

[0267] Establishing a master clock dynamic model according to the interaction timestamp and the parameters to be filtered, and initializing the filter;

[0268] The initialized filter is used to estimate the master clock state of the parameter to be filtered to obtain the master clock time.

[0269] In an exemplary embodiment of the present invention, the filter is a Kalman filter.

[0270] In an exemplary embodiment of the present invention, the method for establishing a frequency control according to the master clock time to obtain a target control sequence includes:

[0271] Establishing a controlled slave clock model, and establishing a master-slave time error model based on the master clock dynamic model and the controlled slave clock model;

[0272] The controlled time is acquired, and a frequency control method is established according to the master clock time and the controlled time to obtain a target control sequence.

[0273] In an exemplary embodiment of the present invention, the frequency control method includes: a state feedback controller.

[0274] The specific details of the above-mentioned clock synchronization device 900 have been described in detail in the corresponding clock synchronization method, so they are not repeated here.

[0275] It should be noted that, although several modules or units of the clock synchronization device 900 are mentioned in the above detailed description, such division is not mandatory. In fact, according to the embodiments of the present disclosure, the features and functions of two or more modules or units described above can be embodied in one module or unit. Conversely, the features and functions of one module or unit described above can be further divided into multiple modules or units to be embodied.

[0276] In addition, in an exemplary embodiment of the present disclosure, an electronic device capable of implementing the above method is also provided.

[0277] Refer to the following Fig.10 The electronic device 1000 according to such an embodiment of the present invention will be described. Fig.10 The electronic device 1000 shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present invention.

[0278] like Fig.10 As shown, the electronic device 1000 is in the form of a general computing device. The components of the electronic device 1000 may include but are not limited to: the at least one processing unit 1010, the at least one storage unit 1020, a bus 1030 connecting different system components (including the storage unit 1020 and the processing unit 1010), and a display unit 1040.

[0279] The storage unit stores program codes, which can be executed by the processing unit 1010, so that the processing unit 1010 executes the steps according to various exemplary embodiments of the present invention described in the above “Exemplary Method” section of this specification.

[0280] The storage unit 1020 may include a readable medium in the form of a volatile storage unit, such as a random access memory unit (RAM) 1021 and / or a cache memory unit 1022 , and may further include a read-only memory unit (ROM) 1023 .

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

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

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

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

[0285] In an exemplary embodiment of the present disclosure, a computer-readable storage medium is also provided, on which a program product capable of implementing the above method of the present specification is stored. In some possible embodiments, various aspects of the present invention can also be implemented in the form of a program product, which includes a program code, and when the program product is run on a terminal device, the program code is used to enable the terminal device to perform the steps according to various exemplary embodiments of the present invention described in the above "Exemplary Method" section of the present specification.

[0286] refer to Fig.11 As shown, a program product 1100 for implementing the above method according to an embodiment of the present invention is described, which can adopt a portable compact disk read-only memory (CD-ROM) and include program code, and can be run on a terminal device, such as a personal computer. However, the program product of the present invention is not limited thereto. In this document, a readable storage medium can be any tangible medium containing or storing a program, which can be used by or in combination with an instruction execution system, an apparatus or a device.

[0287] The program product may use any combination of one or more readable media. The readable medium may be a readable signal medium or a readable storage medium. The readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples (non-exhaustive list) of readable storage media include: an electrical connection with one or more wires, a portable disk, 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 disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above.

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

[0289] The program code embodied on the readable medium may be transmitted using any appropriate medium, including but not limited to wireless, wired, optical cable, RF, etc., or any suitable combination of the foregoing.

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

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

Claims

1. A clock synchronization method, characterized in that: The method comprises: Obtaining an interaction timestamp, and calculating the interaction timestamp to obtain a parameter to be filtered; Performing master clock state estimation on the parameter to be filtered to obtain the master clock time, establishing a controlled slave clock model, and establishing a master-slave time error model based on the master clock dynamic model and the controlled slave clock model, wherein the master clock dynamic model is determined based on the interaction timestamp and the parameter to be filtered; Acquire the controlled time, and establish a frequency control method according to the master clock time and the controlled time to obtain a target control sequence; The parameter to be filtered and the target control sequence are calculated to obtain a frequency adjustment value, and frequency control is performed according to the frequency adjustment value to obtain a slave clock time.

2. The clock synchronization method according to claim 1, characterized in that: The parameters to be filtered include: link delay parameters, synchronization cycle parameters, and main clock frequency ratio.

3. The clock synchronization method according to claim 2, characterized in that: The step of calculating the interaction timestamp to obtain the parameter to be filtered includes: Calculating the interaction timestamp to obtain a link delay parameter, and defining the synchronization cycle parameter according to the interaction timestamp; The synchronization period parameter is calculated to obtain a main clock frequency ratio.

4. The clock synchronization method according to claim 1, characterized in that: The step of estimating the master clock state of the parameter to be filtered to obtain the master clock time includes: Establishing a master clock dynamic model according to the interaction timestamp and the parameters to be filtered, and initializing the filter; The initialized filter is used to estimate the master clock state of the parameter to be filtered to obtain the master clock time.

5. The clock synchronization method according to claim 4, characterized in that: The filter is a Kalman filter.

6. The clock synchronization method according to claim 1, characterized in that: The frequency control method includes: a state feedback controller.

7. A clock synchronization device, characterized in that: include: A time calculation module is configured to obtain an interaction timestamp and calculate the interaction timestamp to obtain a parameter to be filtered; A sequence solving module is configured to perform master clock state estimation on the parameter to be filtered to obtain the master clock time, establish a controlled slave clock model, and establish a master-slave time error model based on the master clock dynamic model and the controlled slave clock model, wherein the master clock dynamic model is determined based on the interaction timestamp and the parameter to be filtered, obtain the controlled time, and establish a frequency control method based on the master clock time and the controlled time to obtain a target control sequence; The frequency control module is configured to calculate the parameter to be filtered and the target control sequence to obtain a frequency adjustment value, and perform frequency control according to the frequency adjustment value to obtain a slave clock time.

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

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