Time synchronization method and device, equipment and storage medium

By using preset exception boundary thresholds and deviation processing strategies generated based on historical data in the time synchronization system, the problem of difficulty in adjusting filter parameters in the prior art is solved, and the stability and timeliness of slave device time synchronization are achieved.

CN119906512APending Publication Date: 2025-04-29FOSS (HANGZHOU) INTELLIGENT TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411968863.8
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-12-30
Publication Date
2025-04-29

AI Technical Summary

Technical Problem

The existing time synchronization abnormal deviation filtering method depends on the user setting reasonable filter parameters, making it difficult to achieve the optimal filtering effect, affecting the stability of time synchronization between slave and master equipment.

Method used

By obtaining the master device time and slave device time, the current master-slave deviation value is determined, and the deviation interval is determined based on the preset abnormal boundary threshold, and the corresponding deviation processing strategy is queried to update the slave device time. The preset exception boundary threshold is generated based on master-slave time deviation data in the historical synchronization period.

Benefits of technology

Without the need for users to manually adjust the boundary threshold, it can respond accurately to different master-slave deviation values, ensuring the stability and timeliness of slave device time synchronization.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119906512A_ABST
    Figure CN119906512A_ABST
Patent Text Reader

Abstract

The invention discloses a time synchronization method and device, equipment and a storage medium, and relates to the technical field of communication, and the method comprises the steps: obtaining master equipment time, and determining a current master-slave deviation value according to the master equipment time and slave equipment time; a deviation interval to which the current master-slave deviation value belongs is determined according to a preset abnormal boundary threshold value, a deviation processing strategy corresponding to the deviation interval is inquired, and the preset abnormal boundary threshold value is generated based on master-slave time deviation data in a historical synchronization period; and updating the slave device time based on a deviation processing strategy corresponding to the deviation interval. The reasonable and reliable preset abnormal boundary threshold value can be generated based on the master-slave time deviation data in the historical synchronization period, so that compared with an existing mode, manual adjustment of a user is not needed; and the corresponding deviation processing strategy is accurately inquired according to the deviation interval to which the current master-slave deviation value belongs so as to update the time of the slave device, so that the stability of time synchronization of the slave device is guaranteed.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of communication technology, and in particular to a time synchronization method, apparatus, device and storage medium. Background Art

[0002] Time synchronization refers to synchronizing the clocks between multiple devices to ensure their time consistency. In a time synchronization system, devices can be divided into master devices and slave devices. Abnormal time synchronization deviation refers to the unreasonable deviation between the master device and the slave device time within a synchronization cycle. In order to improve the stability of time synchronization, after obtaining the time of the master device, the slave device can calculate the deviation between the master device and its own time (i.e., the master-slave deviation value) and filter the deviation value to reduce the impact of abnormal time synchronization deviation on the slave device time.

[0003] However, common time synchronization anomaly deviation filtering methods (such as Kalman filtering algorithm and adaptive filtering parameter algorithm, etc.) rely on the rationality of the filter boundary range setting, requiring users to repeatedly adjust parameters such as the filter processing boundary threshold. This makes it difficult to achieve the best filtering processing effect in practical applications, thereby affecting the stability of time synchronization between the slave device and the master device. Summary of the invention

[0004] The main purpose of this application is to provide a time synchronization method, apparatus, device and storage medium, aiming to solve the technical problem that the existing time synchronization abnormal deviation filtering method relies on the user to set reasonable filtering parameters, which is difficult to achieve the best filtering effect in practical applications and affects the stability of time synchronization between the slave device and the master device.

[0005] To achieve the above object, the present application proposes a time synchronization method, which includes:

[0006] Obtaining the master device time, and determining the current master-slave deviation value according to the master device time and the slave device time;

[0007] Determine the deviation interval to which the current master-slave deviation value belongs according to a preset abnormal boundary threshold, and query the deviation processing strategy corresponding to the deviation interval, wherein the preset abnormal boundary threshold is generated based on the master-slave time deviation data in the historical synchronization cycle;

[0008] The slave device time is updated based on the deviation processing strategy corresponding to the deviation interval.

[0009] In one embodiment, before the step of determining the deviation interval to which the current master-slave deviation value belongs according to a preset abnormal boundary threshold, the step includes:

[0010] Obtain master-slave time deviation data based on the master device historical time and the corresponding slave device historical time in the historical synchronization cycle;

[0011] Constructing a deviation probability function model according to the master-slave time deviation data;

[0012] The deviation probability function model is divided into a plurality of deviation probability intervals based on preset division parameters, and a preset abnormal boundary threshold is determined according to each of the deviation probability intervals.

[0013] In one embodiment, the step of constructing a deviation probability function model according to the master-slave time deviation data includes:

[0014] Based on the maximum likelihood estimation algorithm, determine the current deviation mean and the current standard deviation according to the master-slave time deviation data;

[0015] A deviation probability function model is constructed according to the current deviation mean and the current standard deviation.

[0016] In one embodiment, the step of dividing the deviation probability function model into a plurality of deviation probability intervals based on a preset division parameter, and determining a preset abnormal boundary threshold according to each of the deviation probability intervals, comprises:

[0017] Determine the number of target intervals and interval adjustment coefficients according to the preset division parameters;

[0018] Dividing the deviation probability function model into deviation probability intervals corresponding to the number of target intervals according to the order of deviation probability;

[0019] The boundary value corresponding to each of the deviation probability intervals is set according to the preset boundary reference value and the interval adjustment coefficient, and the boundary value is determined as the preset abnormal boundary threshold.

[0020] In one embodiment, the step of determining the deviation interval to which the current master-slave deviation value belongs according to a preset abnormal boundary threshold, and querying the deviation processing strategy corresponding to the deviation interval includes:

[0021] Comparing the current master-slave deviation value with the preset abnormal boundary threshold, and determining the deviation interval to which the current master-slave deviation value belongs in each of the deviation probability intervals according to the comparison result;

[0022] The deviation handling strategy corresponding to the deviation interval is queried in the exception handling strategy set, and the exception handling strategy set includes the deviation handling strategies corresponding to each of the deviation probability intervals.

[0023] In one embodiment, the deviation interval is: a high probability interval, a medium probability interval or a low probability interval; the step of updating the slave device time based on the deviation processing strategy corresponding to the deviation interval includes:

[0024] When the deviation interval is a high probability interval, updating the slave device time according to the difference between the slave device time and the current master-slave deviation value;

[0025] When the deviation interval is a medium probability interval, determining an average master-slave deviation value within a preset synchronization period according to the current master-slave deviation value, and updating the slave device time according to the difference between the slave device time and the average master-slave deviation value;

[0026] When the deviation interval is a low probability interval, the slave device time is updated according to the current master-slave deviation value.

[0027] In one embodiment, after the step of updating the slave device time based on the deviation processing strategy corresponding to the deviation interval, the method includes:

[0028] The preset abnormal boundary threshold is updated according to the updated slave device time.

[0029] In addition, to achieve the above purpose, the present application also proposes a time synchronization device, the device comprising:

[0030] The deviation calculation module is used to obtain the master device time and determine the current master-slave deviation value according to the master device time and the slave device time;

[0031] A deviation segmentation module, used to determine the deviation interval to which the current master-slave deviation value belongs according to a preset abnormal boundary threshold, and query the deviation processing strategy corresponding to the deviation interval, wherein the preset abnormal boundary threshold is generated based on the master-slave time deviation data in the historical synchronization cycle;

[0032] A strategy updating module is used to update the slave device time based on the deviation processing strategy corresponding to the deviation interval.

[0033] In addition, to achieve the above-mentioned purpose, the present application also proposes a time synchronization device, which includes: a memory, a processor, and a time synchronization program stored in the memory and executable on the processor, and when the time synchronization program is executed by the processor, the steps of the time synchronization method described above are implemented.

[0034] In addition, to achieve the above-mentioned purpose, the present application also proposes a storage medium, on which a time synchronization program is stored, and when the time synchronization program is executed by a processor, the steps of the time synchronization method described above are implemented.

[0035] The present application discloses a time synchronization method, including: obtaining the master device time, and determining the current master-slave deviation value according to the master device time and the slave device time; determining the deviation interval to which the current master-slave deviation value belongs according to a preset abnormal boundary threshold, and querying the deviation processing strategy corresponding to the deviation interval, wherein the preset abnormal boundary threshold is generated based on the master-slave time deviation data in the historical synchronization cycle; updating the slave device time based on the deviation processing strategy corresponding to the deviation interval. Since the preset abnormal boundary threshold in the present application is generated based on the master-slave time deviation data in the historical synchronization cycle, a reasonable and reliable boundary threshold can be obtained without manual adjustment by the user; and querying the corresponding deviation processing strategy according to the deviation interval to which the current master-slave deviation value belongs to update the slave device time, the strategy response can be accurately made for different master-slave deviation values, thereby ensuring the stability of the slave device time synchronization. BRIEF DESCRIPTION OF THE DRAWINGS

[0036] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present application and, together with the description, serve to explain the principles of the present application.

[0037] In order to more clearly illustrate the technical solutions in the embodiments of the present application or the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, for ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.

[0038] Figure 1 This is a flow chart of the first embodiment of the time synchronization method of the present application;

[0039] Figure 2 This is a flow chart of the second embodiment of the time synchronization method of the present application;

[0040] Figure 3 This is a schematic diagram of the deviation probability interval division in the second embodiment of the time synchronization method of this application;

[0041] Figure 4 This is a flowchart of the third embodiment of the time synchronization method of the present application;

[0042] Figure 5 This is a schematic diagram of the entire process of the time synchronization method of this application;

[0043] Figure 6 This is a schematic diagram of the module structure of the first embodiment of the time synchronization device of the present application;

[0044] Figure 7 A schematic diagram of the device structure of the hardware operating environment involved in the time synchronization method in the embodiment of the present application.

[0045] The realization of the purpose, functional features and advantages of this application will be further explained in conjunction with embodiments and with reference to the accompanying drawings. DETAILED DESCRIPTION

[0046] It should be understood that the specific embodiments described herein are only used to explain the technical solutions of the present application and are not used to limit the present application.

[0047] It should be noted that abnormal time synchronization deviation refers to the unreasonable deviation value between the master device and the slave device in a synchronization cycle. In a time synchronization system, when the master device is frequently disturbed or an uncompensable error is introduced in the transmission link, the synchronization time output by the master device fluctuates greatly, causing the slave device to fluctuate frequently. And when multiple slave devices are synchronized with the master device, there may be relatively large time differences between the slave devices.

[0048] In the automotive field and industrial fields with high real-time requirements, time fluctuations may cause the reception time to be less than the sending time during data transmission. In order to ensure the continuity and stability of time synchronization as much as possible, the master-slave deviation value is usually filtered by using the time synchronization abnormal deviation filtering method.

[0049] Among various time synchronization abnormal deviation filtering methods, the sliding window filtering method has a wider application range. However, when the time of the time synchronization source, i.e., the master device, fluctuates, this method will lead to poor time synchronization follow-up of the slave device. The Kalman filtering algorithm relies on the accuracy of modeling the time synchronization system and the rationality of setting the filter parameters. If the model or parameters are inaccurate, the actual effect is difficult to meet the theoretical expectations. The adaptive filtering parameter algorithm also requires users to repeatedly adjust parameters, and it is also difficult to achieve the best effect. The multi-clock source information fusion algorithm relies on setting multiple time synchronization sources in the time synchronization system, which has high hardware cost requirements.

[0050] Therefore, in order to solve the above-mentioned defects, the present embodiment provides a time synchronization method, which can generate a preset abnormal boundary threshold based on the master-slave time deviation data in the historical synchronization cycle, ensuring the rationality and reliability of the obtained boundary threshold without the need for manual adjustment by the user; and can query the corresponding deviation processing strategy according to the deviation interval to which the current master-slave deviation value belongs to update the slave device time, and can accurately respond to different master-slave deviation values. The strategy is suitable for a variety of time synchronization systems, and ensures the timeliness and stability of slave device time synchronization.

[0051] In order to better understand the technical solution of the present application, a detailed description will be given below in conjunction with the accompanying drawings and specific implementation methods.

[0052] The present application embodiment provides a time synchronization method, referring to Figure 1 , Figure 1This is a flow chart of the first embodiment of the time synchronization method of the present application. In this embodiment, the method includes: Steps S10 to S30:

[0053] Step S10: Acquire the master device time, and determine the current master-slave deviation value according to the master device time and the slave device time.

[0054] It should be noted that this embodiment can be applied to the scenario where a slave device in a time synchronization system realizes time synchronization. The execution subject of this embodiment can be a computing electronic device with functions such as data processing, network communication, and program running, such as a slave device in a car time synchronization system such as a vehicle sensor and a vehicle controller, or other electronic devices that act as slave devices in an industrial time synchronization system, and this embodiment does not limit this. The following takes a time synchronization device (referred to as a "slave device") as an example to explain this embodiment and the following embodiments.

[0055] It should be understood that the master device time is the absolute timestamp of the master device obtained by the slave device through its own synchronization protocol. In the time synchronization system, the master device (Master) periodically sends a time synchronization message (Sync message), and the slave device (Slave) receives and parses the Sync message based on the time synchronization protocol to obtain the master device timestamp.

[0056] The slave device time is the local timestamp of the slave device itself. After receiving the timestamp of the master device, the slave device calculates the difference between the timestamp of the master device and the local timestamp, and determines the difference as the current master-slave deviation value.

[0057] Step S20: determining the deviation interval to which the current master-slave deviation value belongs according to a preset abnormal boundary threshold, and querying the deviation processing strategy corresponding to the deviation interval, wherein the preset abnormal boundary threshold is generated based on the master-slave time deviation data in the historical synchronization cycle.

[0058] It should be noted that the preset abnormal boundary threshold may be determined based on master-slave time deviation data in multiple synchronization cycles in the historical synchronization cycle, and the preset abnormal boundary threshold may also be continuously updated based on the current master-slave deviation value.

[0059] The number of preset abnormal boundary thresholds may not be unique, that is, it may be several abnormal boundary thresholds, each abnormal boundary threshold is used to divide a corresponding number of deviation intervals. When the current master-slave deviation falls into any deviation interval, the deviation processing strategy corresponding to the deviation interval can be queried.

[0060] In order to specifically explain how to determine the preset abnormal boundary threshold based on the master-slave time deviation data in the historical synchronization cycle, before step S20, the following steps are also included: Steps S01 to S03:

[0061] Step S01: obtaining master-slave time deviation data according to the historical time of the master device and the corresponding historical time of the slave device in the historical synchronization cycle.

[0062] It should be understood that a sliding window can be constructed to test the difference between the timestamps of the master device and the slave device in multiple time synchronization cycles of the historical synchronization cycle, that is, the master-slave time deviation data. In order to ensure that the sample size of the master-slave time deviation data is large enough to ensure the reliability of the subsequent model, the historical synchronization cycle can include 1000 time synchronization cycles.

[0063] In addition, for a time synchronization system with a short single time synchronization period, such as a time synchronization system based on the generalized precision time protocol (gPTP), more reliable time deviation data can be obtained by increasing the statistics of the time synchronization period in the historical synchronization period.

[0064] In the specific implementation, in the kth time synchronization cycle, the slave device receives the Sync message from the master device, parses the Sync message to obtain the master device timestamp, and obtains its own local timestamp (slave device timestamp), and calculates the timestamp difference between the master device and the slave device, that is, the master-slave time deviation E(k). The master-slave time deviation in the entire historical time synchronization cycle is stored, that is, the master-slave time deviation data is obtained.

[0065] Among them, the master-slave time deviation can be expressed as: is the timestamp of the master device in the kth time synchronization cycle, Timestamp of the slave device in the kth time synchronization cycle.

[0066] Step S02: constructing a deviation probability function model according to the master-slave time deviation data.

[0067] It should be noted that in the time synchronization system, the time synchronization between the master device and the slave device implemented through the network or other communication bus contains the following errors:

[0068] Master-slave deviation = master-slave clock frequency deviation * time synchronization period + transmission time error + software layer introduced error + synchronization source fluctuation;

[0069] Among them, the master-slave clock deviation and time synchronization cycle are basically fixed; the transmission time error is usually compensated by the time synchronization solution; the software layer error is closely related to the chip performance and algorithm rationality; the synchronization source fluctuation is usually very random, and it is generally normally distributed in actual measurement. Therefore, the master-slave time deviation E(k) obtained above should also conform to the normal distribution E(k)~N(μ,σ 2), that is, the deviation probability function model is a normal distribution model, μ is the mean of the normal distribution, and σ is the standard deviation of the normal distribution.

[0070] Step S03: dividing the deviation probability function model into a number of deviation probability intervals based on preset division parameters, and determining a preset abnormal boundary threshold according to each of the deviation probability intervals.

[0071] It can be understood that the preset division parameter can be used to preset the number of deviation probability intervals that need to be divided for the user. The function graph of the deviation probability function model has the properties of a normal distribution function graph, that is, it can be expressed as a functional relationship graph between the master-slave time deviation E(k) and the probability P. Therefore, on the functional relationship graph, a number of deviation probability intervals can be first divided based on the preset division parameters by the user, and then the specific values ​​of the master-slave time deviation corresponding to the left and right boundaries of each deviation probability interval can be further determined, and then determined as the preset abnormal boundary threshold.

[0072] It should also be noted that by repeating the above steps S01 to S03, the preset abnormal boundary value can be continuously updated to adapt to different interference environments in which the master device is located, ensuring that a highly adaptable preset abnormal boundary threshold can be obtained in different time synchronization systems.

[0073] Step S30: updating the slave device time based on the deviation processing strategy corresponding to the deviation interval.

[0074] It should be understood that different deviation probability intervals can correspond to different deviation processing strategies, thereby realizing segmented processing of current master-slave deviation values ​​in different ranges. Specifically, after determining the deviation interval to which the current master-slave deviation value belongs, the slave device can update the slave device time according to the deviation processing strategy corresponding to the deviation interval, thereby realizing time synchronization of the slave device.

[0075] In addition, after the slave device time is updated, the preset abnormal boundary threshold can also be updated according to the updated slave device time to achieve continuous real-time updating of the preset abnormal boundary threshold and ensure the reliability of subsequent slave device time update results, i.e., slave device time synchronization.

[0076] This embodiment generates a preset abnormal boundary threshold based on the master-slave time deviation data in the historical synchronization cycle, thereby ensuring the rationality and reliability of the boundary threshold without the need for manual adjustment by the user; and queries the corresponding deviation processing strategy according to the deviation interval to which the current master-slave deviation value belongs to update the slave device time, which can accurately respond to policies for different master-slave deviation values, thereby ensuring the stability and timeliness of slave device time synchronization.

[0077] Based on the first embodiment of the present application, in the second embodiment of the present application, the same or similar contents as those in the above-mentioned embodiment 1 can be referred to the above introduction, and will not be repeated in the following. Figure 2 , Figure 2 This is a flow chart of the second embodiment of the time synchronization method of the present application.

[0078] In this embodiment, in order to specifically illustrate how to construct a deviation probability function model based on normal distribution, step S02 specifically includes: steps S021-S022:

[0079] Step S021: Based on the maximum likelihood estimation algorithm, determine the current deviation mean and the current standard deviation according to the master-slave time deviation data.

[0080] Step S022: constructing a deviation probability function model according to the current deviation mean and the current standard deviation.

[0081] It should be understood that the Maximum Likelihood Estimation (MLE) algorithm can be used to estimate the statistical model parameters. Since the master-slave time deviation data conforms to the normal distribution, the current deviation mean is the mean μ of the normal distribution, and the current standard deviation is the standard deviation σ of the normal distribution. The mean calculation formula and the standard deviation calculation formula can be expressed as:

[0082]

[0083]

[0084] Wherein, n is the total number of time synchronization cycles in the historical time synchronization cycle, and E(k) is the master-slave time deviation corresponding to the kth time synchronization cycle.

[0085] Therefore, it can be determined that the deviation probability function model conforms to the normal distribution E(k)~N(μ,σ 2 ) and the corresponding function graph of the deviation probability function model can be plotted.

[0086] Further, in order to specifically illustrate how to divide the deviation probability interval based on the deviation probability function model, step S03 specifically includes: steps S031 to S033:

[0087] Step S031: Determine the number of target intervals and interval adjustment coefficients according to the preset division parameters.

[0088] It should be understood that the preset division parameters may include the target number of intervals I preset by the user, and may also include a ratio adjustment coefficient k for each interval. i .

[0089] Step S032: Divide the deviation probability function model into deviation probability intervals corresponding to the number of target intervals in order of deviation probability.

[0090] Step S033: setting a boundary value corresponding to each of the deviation probability intervals according to a preset boundary reference value and the interval adjustment coefficient, and determining the boundary value as a preset abnormal boundary threshold.

[0091] Based on the function graph corresponding to the deviation probability function model, it can be divided into the 0th deviation probability interval to the Ith deviation probability interval according to the deviation probability from high to low, with a total of I+1 deviation probability intervals (including I deviation probability intervals with double boundaries and 1 deviation probability interval with only a single boundary). The left boundary value of the i-th deviation probability interval is expressed as threshold L (i), the right boundary value is expressed as threshold R (i), where i∈[0,I), i represents a bounded deviation probability interval.

[0092] It should be noted that the preset boundary reference value can be the time fluctuation range measured within the time synchronization period under a known stable state. in The left boundary value of the fluctuation of the main device in a stable state. The right boundary value of the fluctuation of the main device in a stable state. The two boundary values ​​are the preset boundary reference values, which are used as the setting reference for the boundary values ​​corresponding to each deviation probability interval.

[0093] The boundary values ​​corresponding to each deviation probability interval can be set as follows:

[0094]

[0095]

[0096] Among them, k i is the proportional adjustment coefficient of the ith deviation probability interval and is a positive number. The specific value can be determined based on the user's demand for time stability from the device.

[0097] Therefore, the boundary value threshold corresponding to the above deviation probability interval L (i) and threshold R (i) is the preset abnormal boundary threshold, and each deviation probability interval can be divided as follows:

[0098] threshold L (0)≤E(k)≤threshold R (0), the master-slave time deviation is within the high probability interval;

[0099] threshold L (i+1)≤E(k)≤threshold L (i) or threshold R (i)≤E(k)≤threshold R When (i+1), the master-slave time deviation is in the medium probability interval;

[0100] E(k) <threshold L (I-1) or E(k)>threshold R (I-1), the master-slave time deviation is in the low probability interval.

[0101] For example, here, I=3, i.e., divided into deviation probability intervals, can be used as an example, and combined with Figure 3 The division of the above-mentioned deviation probability intervals is illustrated by examples. Figure 3 This is a schematic diagram of the deviation probability interval division in the second embodiment of the time synchronization method of the present application.

[0102] exist Figure 3 where i∈[0,3). k i is the proportional adjustment coefficient of the ith interval, k i =0, k 1 =1, k 2 =2.

[0103] The 0th deviation probability interval, i.e. the high probability interval ①, is: threshold L (0)≤E(k)≤threshold R (0);

[0104] The first deviation probability interval, that is, the first probability interval ②, is: threshold L (1)≤E(k)≤threshold L (0) or threshold R (0)≤E(k)≤threshold R (1);

[0105] The second deviation probability interval, that is, the second probability interval ③, is: threshold L (2)≤E(k)≤threshold L (1) or threshold R (1)≤E(k)≤threshold R (2);

[0106] The third deviation probability interval, i.e. the low probability interval ④, is: E(k) <threshold L(2) or E(k)>threshold R (2);

[0107] Therefore, based on Figure 3 The preset abnormal boundary thresholds determined from left to right are: threshld L (2) threshold L (1) threshld L (0),threshld R (0),threshld R (1) and threshold R (2).

[0108] It should also be noted that the medium probability interval includes the first medium probability interval and the second medium probability interval mentioned above. Figure 3 The division is only for illustrative purposes. Users can set different target interval numbers I and interval adjustment coefficients k. i And further refine the division of the deviation probability interval, which is not limited in this embodiment.

[0109] This embodiment determines the current deviation mean and the current standard deviation based on the master-slave time deviation data based on the maximum likelihood estimation algorithm; constructs a deviation probability function model based on the current deviation mean and the current standard deviation; determines the number of target intervals and the interval adjustment coefficient based on the preset division parameters; divides the deviation probability function model into deviation probability intervals corresponding to the number of target intervals in the order of high and low deviation probabilities; sets the boundary values ​​corresponding to each of the deviation probability intervals based on the preset boundary reference value and the interval adjustment coefficient, and determines the boundary value as the preset abnormal boundary threshold. Since the probability function model is constructed by combining theoretical analysis with measured analysis in this embodiment, and the preset abnormal boundary threshold is determined based on the measured preset boundary reference value, the reliability of the obtained boundary threshold is further guaranteed.

[0110] Based on the first and second embodiments of the present application, in the third embodiment of the present application, the same or similar contents as those of the first and second embodiments can be referred to the above description, and will not be described in detail later. Figure 4 , Figure 4 This is a flowchart of the third embodiment of the time synchronization method of the present application.

[0111] In this embodiment, in order to specifically explain how to determine the deviation interval to which the current master-slave deviation value belongs in combination with each deviation probability interval, step S20 specifically includes: steps S201 to S202:

[0112] Step S201: Compare the current master-slave deviation value with the preset abnormal boundary threshold, and determine the deviation interval to which the current master-slave deviation value belongs in each of the deviation probability intervals according to the comparison result.

[0113] It should be noted that by comparing the current master-slave deviation value with the above-mentioned preset abnormal boundary threshold, the deviation probability interval to which the current master-slave deviation value belongs can be determined according to the comparison result, and then the deviation interval to which the current master-slave deviation value belongs can be determined.

[0114] Step S202: Query the deviation handling strategy corresponding to the deviation interval in the exception handling strategy set.

[0115] It should be noted that the exception handling strategy set may include deviation handling strategies corresponding to each of the deviation probability intervals. Each deviation handling strategy may be set by the user for each deviation probability interval after the deviation probability interval is divided, and each deviation probability interval may be divided into: a high probability interval, a medium probability interval, and a low probability interval. Accordingly, the deviation interval to which the current master-slave deviation value belongs may also be a high probability interval, a medium probability interval, and a low probability interval.

[0116] Therefore, step S202 specifically includes: steps S2021 to S2023:

[0117] Step S2021: When the deviation interval is a high probability interval, the slave device time is updated according to the difference between the slave device time and the current master-slave deviation value.

[0118] Step S2022: When the deviation interval is a medium probability interval, determine the average master-slave deviation value within the preset synchronization period according to the current master-slave deviation value, and update the slave device time according to the difference between the slave device time and the average master-slave deviation value.

[0119] Step S2023: When the deviation interval is a low probability interval, updating the slave device time according to the current master-slave deviation value.

[0120] It should be noted that E(k) is assigned a value according to the current master-slave deviation value, and when it meets the threshold L (0)≤E(k)≤threshold R (0), the deviation interval is a high probability interval. At this time, the current master-slave deviation value can be regarded as having a high credibility, which is consistent with the actual fluctuation deviation measurement of the time synchronization system. Therefore, the current master-slave deviation value can be directly added to the slave device time to achieve the update of the slave device time.

[0121] When the current master-slave deviation value meets the threshold L(i+1)≤E(k)≤threshold L (i) or threshold R (i)≤E(k)≤threshold R (i+1), the deviation interval is a medium probability interval. After confirmation of f(i) time synchronization cycles, that is, the deviation intervals of f(i) time synchronization cycles are all medium probability intervals, then the current master-slave deviation values ​​in f(i) time synchronization cycles are averaged to obtain the average master-slave deviation value. Then, the average master-slave deviation value is added to the slave device time to update the slave device time. By adopting the average master-slave deviation value, the update of the slave device time can be made smoother and more stable. Among them, f(i) can be personalized by the user as a positive integer, and this embodiment does not limit this.

[0122] It should also be noted that in the presence of Figure 3 When the medium probability interval shown includes the division of the first medium probability interval and the second medium probability interval, f(i) corresponding to the first medium probability interval and the second medium probability interval can be set respectively, for example, set to 3 synchronization cycles or 5 synchronization cycles.

[0123] At the current master-slave deviation value E(k) <threshold L (I-1) or E(k)>threshold R (I-1), the deviation interval is a low probability interval. At this time, the master device may have a large time jump, that is, it may be a special case where the master device corrects the time or the slave device is powered on for the first time (for example, the master device jumps from the system initial time to the current world time). The current master-slave deviation value can be directly added to the slave device time to update the slave device time.

[0124] It should be distinguished that although the deviation handling strategy in the low probability interval and the aforementioned high probability interval can be the same, that is, both add the current master-slave deviation value to the slave device time. However, when the current master-slave deviation value falls within the low probability interval, the current master-slave deviation value is regarded as caused by the master device's own correction time, rather than a fluctuation abnormal deviation, so the slave device time synchronization can also be achieved directly by adding the current master-slave deviation value to the slave device time.

[0125] This embodiment compares the current master-slave deviation value with the preset abnormal boundary threshold, and determines the deviation interval to which the current master-slave deviation value belongs in each of the deviation probability intervals according to the comparison result; and queries the deviation processing strategy corresponding to the deviation interval in the abnormal processing strategy set, and the abnormal processing strategy set includes the deviation processing strategy corresponding to each of the deviation probability intervals. Thus, a segmented deviation processing strategy is implemented, so that the slave device can keep time synchronization with the master device as quickly as possible under normal circumstances (high probability interval and low probability interval), and the reliability and stability of the slave device time synchronization result is ensured by averaging the master-slave deviation value under abnormal circumstances (medium probability interval).

[0126] Furthermore, this can also be combined with Figure 5 This application describes the entire process of slave device time synchronization. Figure 5 This is a schematic diagram of the entire process of the time synchronization method of this application.

[0127] refer to Figure 5 ,First, the slave device obtains the absolute timestamp of the master device through the ,time synchronization protocol within a time synchronization cycle;

[0128] Next, the slave device calculates the master-slave time deviation between its own local timestamp and the absolute timestamp of the master device, and determines the current master-slave deviation value;

[0129] Then, based on the master-slave time deviation data under the historical synchronization cycle, the preset abnormal boundary threshold is continuously updated;

[0130] Then, the deviation interval to which the current master-slave deviation value belongs is determined according to the preset abnormal boundary threshold;

[0131] Finally, the corresponding deviation processing strategy is determined according to the deviation interval to which the current master-slave deviation value belongs, and the deviation processing strategy is executed to update the slave device time and complete the time synchronization of the slave device.

[0132] The preset abnormal boundary threshold in the present application realizes the segmented processing of the master-slave deviation value in different situations, and increases the adaptability to diversified time synchronization scenarios through real-time updates, ensuring the stability and timeliness of slave device time synchronization.

[0133] It should be noted that the above examples are only used to understand the present application and do not constitute a limitation on the time synchronization method of the present application. More simple transformations based on this technical concept are all within the scope of protection of the present application.

[0134] In addition, the present application also provides a time synchronization device, referring to Figure 6 , Figure 6 This is a structural block diagram of the first embodiment of the time synchronization device of the present application; Figure 6 As shown, the device comprises:

[0135] Deviation calculation module 601, used to obtain the master device time, and determine the current master-slave deviation value according to the master device time and the slave device time;

[0136] Deviation segmentation module 602, used to determine the deviation interval to which the current master-slave deviation value belongs according to a preset abnormal boundary threshold, and query the deviation processing strategy corresponding to the deviation interval, wherein the preset abnormal boundary threshold is generated based on the master-slave time deviation data in the historical synchronization cycle;

[0137] The strategy updating module 603 is used to update the slave device time based on the deviation processing strategy corresponding to the deviation interval.

[0138] Furthermore, the deviation segmentation module 602 is also used to obtain master-slave time deviation data based on the historical time of the master device and the corresponding historical time of the slave device under the historical synchronization cycle; construct a deviation probability function model based on the master-slave time deviation data; divide the deviation probability function model into several deviation probability intervals based on preset division parameters, and determine a preset abnormal boundary threshold based on each of the deviation probability intervals.

[0139] Furthermore, the deviation segmentation module 602 is also used to determine the current deviation mean and the current standard deviation according to the master-slave time deviation data based on the maximum likelihood estimation algorithm; and construct a deviation probability function model according to the current deviation mean and the current standard deviation.

[0140] Furthermore, the deviation segmentation module 602 is also used to determine the number of target intervals and the interval adjustment coefficient according to the preset division parameters; divide the deviation probability function model into deviation probability intervals corresponding to the number of target intervals in order of deviation probability; set the boundary value corresponding to each of the deviation probability intervals according to the preset boundary reference value and the interval adjustment coefficient, and determine the boundary value as the preset abnormal boundary threshold.

[0141] Furthermore, the deviation segmentation module 602 is also used to compare the current master-slave deviation value with the preset abnormal boundary threshold, and determine the deviation interval to which the current master-slave deviation value belongs in each of the deviation probability intervals according to the comparison result; and query the deviation processing strategy corresponding to the deviation interval in the abnormal processing strategy set, and the abnormal processing strategy set includes the deviation processing strategies corresponding to each of the deviation probability intervals.

[0142] The deviation interval is: a high probability interval, a medium probability interval or a low probability interval.

[0143] Furthermore, the policy update module 603 is also used to update the slave device time according to the difference between the slave device time and the current master-slave deviation value when the deviation interval is a high probability interval; to determine the average master-slave deviation value within the preset synchronization period according to the current master-slave deviation value when the deviation interval is a medium probability interval, and to update the slave device time according to the difference between the slave device time and the average master-slave deviation value; and to update the slave device time according to the current master-slave deviation value when the deviation interval is a low probability interval.

[0144] This embodiment generates a preset abnormal boundary threshold based on the master-slave time deviation data in the historical synchronization cycle, thereby ensuring the rationality and reliability of the boundary threshold without the need for manual adjustment by the user; and queries the corresponding deviation processing strategy according to the deviation interval to which the current master-slave deviation value belongs to update the slave device time, which can accurately respond to policies for different master-slave deviation values, thereby ensuring the stability and timeliness of slave device time synchronization.

[0145] The present application also provides a time synchronization device, which includes: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can execute the time synchronization method in the above-mentioned embodiment one.

[0146] Reference below Figure 7 , Figure 7 The schematic diagram of the structure of the time synchronization device of the present application. The time synchronization device in the embodiment of the present application may include but is not limited to mobile terminals such as mobile phones, laptop computers, digital broadcast receivers, PDAs (Personal Digital Assistants), PADs (Portable Application Descriptions), PMPs (Portable Media Players), etc., and fixed terminals such as digital TVs, desktop computers, etc. Figure 7 The time synchronization device shown is merely an example and should not bring any limitation to the functions and scope of use of the embodiments of the present application.

[0147] like Figure 7As shown, the time synchronization device may include a processing device 1001 (e.g., a central processing unit, a graphics processor, etc.), which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM: Read Only Memory) 1002 or a program loaded from a storage device 1003 to a random access memory (RAM: Random Access Memory) 1004. In RAM1004, various programs and data required for the operation of the time synchronization device are also stored. The processing device 1001, ROM1002, and RAM1004 are connected to each other through a bus 1005. An input / output (I / O) interface 1006 is also connected to the bus. Generally, the following systems can be connected to the I / O interface 1006: an input device 1007 including, for example, a touch screen, a touch pad, a keyboard, a mouse, an image sensor, a microphone, an accelerometer, a gyroscope, etc.; an output device 1008 including, for example, a liquid crystal display (LCD: Liquid Crystal Display), a speaker, a vibrator, etc.; a storage device 1003 including, for example, a magnetic tape, a hard disk, etc.; and a communication device 1009. The communication device 1009 can allow the time synchronization device to communicate with other devices wirelessly or by wire to exchange data. Although the figure shows a time synchronization device with various systems, it should be understood that it is not required to implement or have all the systems shown. More or fewer systems can be implemented or have alternatively.

[0148] The present application also provides a computer-readable storage medium having computer-readable program instructions (ie, computer programs) stored thereon, wherein the computer-readable program instructions are used to execute the time synchronization method in the above-mentioned embodiment.

[0149] The computer-readable storage medium provided in the present application may be, for example, a USB flash drive, but is not limited to electrical, magnetic, optical, electromagnetic, infrared, or semiconductor systems, systems or devices, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), 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. In this embodiment, the computer-readable storage medium may be any tangible medium containing or storing a program that can be used by or in combination with an instruction execution system, system or device. The program code contained on the computer-readable storage medium may be transmitted using any appropriate medium, including but not limited to: wires, optical cables, RF (Radio Frequency), etc., or any suitable combination of the above.

[0150] It should be noted that, in this article, the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, article or system including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or system. In the absence of further restrictions, an element defined by the sentence "comprises a ..." does not exclude the presence of other elements in the process, method, article or system including the element.

[0151] The serial numbers of the above-mentioned embodiments of the present invention are only for description and do not represent the advantages and disadvantages of the embodiments. They are only some embodiments of the present application and do not limit the patent scope of the present application. All equivalent structural transformations made by using the contents of the description and drawings of the present application under the technical concept of the present application, or direct / indirect application in other related technical fields are included in the patent protection scope of the present application.

Claims

1. A time synchronization method, characterized in that: The method comprises: Obtaining the master device time, and determining the current master-slave deviation value according to the master device time and the slave device time; Determine the deviation interval to which the current master-slave deviation value belongs according to a preset abnormal boundary threshold, and query the deviation processing strategy corresponding to the deviation interval, wherein the preset abnormal boundary threshold is generated based on the master-slave time deviation data in the historical synchronization cycle; The slave device time is updated based on the deviation processing strategy corresponding to the deviation interval.

2. The method according to claim 1, characterized in that Before the step of determining the deviation interval to which the current master-slave deviation value belongs according to the preset abnormal boundary threshold, the method includes: Obtain master-slave time deviation data based on the master device historical time and the corresponding slave device historical time in the historical synchronization cycle; Constructing a deviation probability function model according to the master-slave time deviation data; The deviation probability function model is divided into a plurality of deviation probability intervals based on preset division parameters, and a preset abnormal boundary threshold is determined according to each of the deviation probability intervals.

3. The method according to claim 2, characterized in that The step of constructing a deviation probability function model according to the master-slave time deviation data comprises: Based on the maximum likelihood estimation algorithm, determine the current deviation mean and the current standard deviation according to the master-slave time deviation data; A deviation probability function model is constructed according to the current deviation mean and the current standard deviation.

4. The method according to claim 2, characterized in that The step of dividing the deviation probability function model into a plurality of deviation probability intervals based on a preset division parameter, and determining a preset abnormal boundary threshold according to each of the deviation probability intervals, comprises: Determine the number of target intervals and interval adjustment coefficients according to the preset division parameters; Dividing the deviation probability function model into deviation probability intervals corresponding to the number of target intervals according to the order of deviation probability; The boundary value corresponding to each of the deviation probability intervals is set according to the preset boundary reference value and the interval adjustment coefficient, and the boundary value is determined as the preset abnormal boundary threshold.

5. The method according to claim 4, characterized in that The step of determining the deviation interval to which the current master-slave deviation value belongs according to the preset abnormal boundary threshold, and querying the deviation processing strategy corresponding to the deviation interval includes: Comparing the current master-slave deviation value with the preset abnormal boundary threshold, and determining the deviation interval to which the current master-slave deviation value belongs in each of the deviation probability intervals according to the comparison result; The deviation handling strategy corresponding to the deviation interval is queried in the exception handling strategy set, and the exception handling strategy set includes the deviation handling strategies corresponding to each of the deviation probability intervals.

6. The method according to claim 1, characterized in that The deviation interval is: a high probability interval, a medium probability interval or a low probability interval; the step of updating the slave device time based on the deviation processing strategy corresponding to the deviation interval includes: When the deviation interval is a high probability interval, updating the slave device time according to the difference between the slave device time and the current master-slave deviation value; When the deviation interval is a medium probability interval, determining an average master-slave deviation value within a preset synchronization period according to the current master-slave deviation value, and updating the slave device time according to the difference between the slave device time and the average master-slave deviation value; When the deviation interval is a low probability interval, the slave device time is updated according to the current master-slave deviation value.

7. The method according to claim 1, characterized in that After the step of updating the slave device time based on the deviation processing strategy corresponding to the deviation interval, the method further comprises: The preset abnormal boundary threshold is updated according to the updated slave device time.

8. A time synchronization device, characterized in that: The device comprises: The deviation calculation module is used to obtain the master device time and determine the current master-slave deviation value according to the master device time and the slave device time; A deviation segmentation module, used to determine the deviation interval to which the current master-slave deviation value belongs according to a preset abnormal boundary threshold, and query the deviation processing strategy corresponding to the deviation interval, wherein the preset abnormal boundary threshold is generated based on the master-slave time deviation data in the historical synchronization cycle; A strategy updating module is used to update the slave device time based on the deviation processing strategy corresponding to the deviation interval.

9. A time synchronization device, characterized in that: The time synchronization device comprises: a memory, a processor, and a time synchronization program stored in the memory and executable on the processor, wherein the time synchronization program implements the steps of the time synchronization method according to any one of claims 1 to 7 when executed by the processor.

10. A storage medium, characterized in that: The storage medium stores a time synchronization program, and when the time synchronization program is executed by the processor, the steps of the time synchronization method according to any one of claims 1 to 7 are implemented.