A method and device for master-slave time synchronization calibration
Patent Information
- Application Number
- TW114109452
- Authority / Receiving Office
- TW · TW
- Patent Type
- Applications
- Current Assignee / Owner
- Priority Date
- 2025-03-04
- Filing Date
- 2025-03-13
- Publication Date
- 2026-09-16
- Estimated Expiration
- 2045-03-12
AI Technical Summary
Existing PTP-based clock synchronization methods face high complexity and instability due to network latency, leading to inaccurate synchronization results, especially in high or unstable network environments.
A method and apparatus that selects the most accurate master timer by minimizing time variance and predicts correction needs, using variance calculations and noise adjustments to enhance synchronization accuracy and stability.
Improves synchronization accuracy and stability by selecting the most accurate master timer and predicting necessary corrections, aligning slave timers more precisely with the master timer.
Smart Images

Figure TWG2TA001075946_001 
Figure TWG2TA001075946_002 
Figure TWG2TA001075946_003
Abstract
Description
[Technical Field]
[0001] This invention relates to the field of network communication technology, and more particularly to a master-slave timing synchronization correction method and apparatus. [Previous Technology]
[0002] Precision Time Protocol (PTP) is a protocol for high-precision clock synchronization using network communication technology. This protocol measures and adjusts the synchronization error between clocks by exchanging event messages and timestamps between the master and slave clock devices. Through the open-source software—the Precision Time Protocol Daemon (PTPd)—the path delay and time offset between the master and slave clocks can be calculated, and adjustments can be made accordingly to achieve precise time and frequency synchronization between them.
[0003] Before clock calibration in PTP, a precise master clock must be selected. Currently, the Best Master Clock Algorithm (BMCA) is commonly used to select the master clock.
[0004] Please refer to Figure 1. After selecting the master clock, the master clock and slave clock time can be synchronized through the following process: (1) Establish the master-slave relationship between the two nodes. The master node sends the start time to the slave node; (2) The slave node records the time when the slave clock receives the message; (3) Subsequently, the slave node sends a reply message to the master node and records the time of the master clock; (4) After receiving the reply message, the master node replies to the slave node with the time of the master clock; (5) The slave node can calculate the deviation between the slave clock and the master clock according to the following formula, thereby completing the correction of the slave clock.
[0005] When using BMCA to select the master clock, multiple communications and competitions are required between devices in the network, resulting in high complexity and uncertainty regarding the stability of the master clock. Furthermore, the accuracy of PTP time synchronization is easily affected by the network environment. In cases of high or unstable network latency, the accuracy of time synchronization will decrease, thus affecting the synchronization results.
[0006] Therefore, there is a need for a master-slave timing synchronization correction method and device that can select the most accurate master timer and accurately predict the magnitude of correction required, so as to improve the synchronization, stability and accuracy of the slave timer and the master timer. [Summary of the Invention]
[0007] The main objective of this invention is to provide a correction method and apparatus for master-slave timing synchronization, which can select the most accurate master timer and accurately predict the correction range required for the slave timer, thereby improving the synchronization, stability and accuracy of the slave timer and the master timer.
[0008] This invention provides a correction method for master-slave timing synchronization, comprising: estimating the initial squared error between the master timing data and the slave timing data at an initial time point; estimating the expected deviation at a first time point based on the sum of the initial squared error and the noise variance; estimating a gain parameter based on the ratio of the expected deviation to the sum of the expected deviation and the variance; estimating the time deviation by weighting the initial deviation between the master timing data and the slave timing data at the initial time point with the gain parameter, and by correcting the slave timing data at the first time point based on the time deviation.
[0009] In this embodiment, the master timing data is generated by selecting the timer with the smallest time variance.
[0010] In this embodiment, the time variance calculation step further includes estimating the average value of the time offset data for each timer. The variance of each average value is the time variance.
[0011] In this embodiment, the initial error square is estimated using the following initial error square equation, as follows: where is the initial error square, the estimated offset is the difference between the estimated master timing data and the slave timing data, and the measurement offset is the difference between the actual measured master timing data and the slave timing data.
[0012] The present invention further provides a master-slave timing synchronization correction device, which acquires master timing data generated by the master timer and slave timing data generated by the slave timer, including a processor for executing a computer program to implement the master-slave timing synchronization correction method of claim 1.
Implementation Method
[0013] In order to facilitate those skilled in the art to understand and implement the present invention, the present invention will be further described in detail below with reference to the accompanying drawings and embodiments. It should be understood that the embodiments described herein are only for illustration and explanation of the present invention and are not intended to limit the present invention.
[0014] The present invention is a correction method and apparatus for master-slave timing synchronization, which can select the most accurate master timer and accurately predict the magnitude of correction required, so as to improve the synchronization, stability and accuracy of the slave timer and the master timer.
[0015] The master-slave timing synchronization correction method and apparatus of this embodiment can be applied to time calibration between nodes in network communication. Referring to Figure 2, the technology of this embodiment can be applied to time calibration of multiple nodes in the Internet. The Internet includes a master-slave timing synchronization correction device 1 and multiple nodes 2. The correction device 1 is connected to the multiple nodes 2. The correction device 1 includes a processor 10. Each node 2 includes a timer 20.
[0016] In this embodiment, the calibration device 1 may be a switch, router, or server, or a network calculator device capable of executing the Precision Time Protocol (PTP). The processor 10 may be used to execute a computer program for a master-slave timing synchronization calibration method, distributing a precise time source to nodes 2 in the Internet to ensure that the time of multiple nodes 2 can be synchronized.
[0017] Node 2 can be a network calculator device with timing and communication functions, such as a router, switch, server, wireless access point, base station, smart grid equipment, etc. Timer 20 can be a hardware clock or real-time clock (RTC) module, chip, or device that provides current time information. Processor 10 can receive the time information from timer 20 provided by node 2 and, using a master-slave timing synchronization correction method, determine the most accurate timer 20 based on the received time information. Processor 10 will set the most accurate timer 20 as the master timer. Subsequently, processor 10 will adjust the time synchronization of other slave timers according to the master timer. The specific process is as follows:
[0018] Before performing time correction, the processor 10 first selects the most accurate timer 20 as the master timer. The master timer is selected by choosing the timer with the smallest time variance, and the time data provided by this timer will be used as the master timing data. In this embodiment, the processor 10 first filters out multiple timers 20 that can provide relatively accurate time, and calculates the variance of each of these timers 20 based on the data provided by these timers 20. The timer 20 with the smallest variance will be set as the master timer with the most accurate time.
[0019] Please refer to Figure 3 for a detailed explanation of the complete steps for selecting the master timer by calculating the minimum variance. As shown in step S10, the processor 10 receives time offset data from more than 20 time points of each timer 20 and calculates the average value of the time offset data for each timer 20. For example, if there are currently four timers 20, the timer 20 with the more accurate time is selected. These four timers 20 can each generate 300 time offset data points within a preset time period. The processor 10 will calculate the average value of the 300 time offset data points for each timer 20. The average value Y can be calculated according to the following equation: where Y is the average value, represents the time offset data at different time points, and represents the number of time offset data points.
[0020] Next, in step S12, the processor 10 estimates the variance of the average value calculated by each timer 20. The variance can be calculated using the following formula: , where n is the total number, Y is the average value, and is the time offset data at different time points.
[0021] In this embodiment, the variance is the time variance. After the time variance is calculated, step S14 is entered. The processor 10 selects the timer 20 with the smallest time variance as the master timer to generate master timing data.
[0022] Please refer to Figure 4, which is a system block diagram of the second embodiment. To make the description clearer, the timers are distinguished as master timer 22 and slave timer 24. The connection methods and operations of the other correction device 1, processor 10, and node 2 are the same as those in the embodiment of Figure 2, so they will not be described again. There may be multiple slave timers 24, and it is not limited to the embodiment of one slave timer 24 shown in Figure 4.
[0023] Refer to Figures 4 and 5. After selecting the master timer 22 through steps S10-S14, proceed to steps S20-S28 to estimate the time deviation between the master timer 22 and the slave timer 24 to synchronize their times. First, as shown in step S20, the processor 10 estimates the initial squared error between the master timing data and the slave timing data at the initial time point. The master timing data is the timing data generated by the master timer 22 selected in steps S10-S14. The slave timing data is the timing data generated by the slave timer 24 of other nodes 2. The processor 10 estimates the initial squared error between the master timing data and the slave timing data using the following initial squared error equation: where is the initial squared error, the estimated offset is the difference between the estimated master timing data and the slave timing data, and the measured offset is the difference between the actual measured master timing data and the slave timing data.
[0024] For example, when the processor 10 estimates the initial time point using the Precision Time Protocol Daemon (PTPd) program, the difference between the master timing data and the slave timing data is 15ns. However, the actual difference between the master timing data and the slave timing data measured by the oscilloscope is 12ns, so the deviation between the two is 3ns. In this embodiment, a 10ns scale conversion is used, and the deviation after conversion is 3 / 10 = 0.3. Therefore, the initial error square formula in this embodiment is as follows: == 0.09.
[0025] After estimating the initial squared error, the process proceeds to step S22. The processor 10 estimates the expected deviation at the first time point based on the sum of the initial squared error and the noise variance Q. The noise variance Q is taken into account for noise generated by the processor 10 due to inaccuracies in its program execution, unstable synchronization signals from the synchronization source, or environmental factors such as ambient temperature and humidity, which may lead to errors in the acquired signal. In this embodiment, the noise variance Q is not a fixed value and can be adjusted as needed. A larger value of the noise variance Q indicates greater noise. A value of 0 for the noise variance Q represents an ideal state with no noise.
[0026] The expected deviation is estimated using the following expected deviation equation, as follows: where the expected deviation at the first time point is the square of the initial error, and is the noise variance.
[0027] Next, in step S24, the processor 10 estimates the gain parameter based on the ratio of the expected deviation to the sum of the expected deviation and the variable. In this embodiment, the variable can be the measurement error of the sample acquired by the chip of the processor 10.
[0028] The gain parameter is estimated using the following gain parameter equation, as follows: , where is the gain parameter, is the expected deviation, and is the variance.
[0029] Proceeding to step S26, the processor 10 estimates the time deviation at the first time point based on the initial deviation between the master timing data and the slave timing data at the initial time point, and by weighting the change between the initial deviation and the expected deviation using a gain parameter. The time deviation is estimated using the following time deviation equation: where is the time deviation, is the initial deviation, is the gain parameter, and is the expected deviation.
[0030] Finally, in step S28, the processor 10 corrects the slave timing data at the first time point based on the time deviation. Specifically, after estimating the time deviation, the processor 10 knows the deviation between the master timer 22 and the slave timer 24 at the first time point. Therefore, the time deviation can be directly used to correct the time deviation of the slave timer 24.
[0031] In addition, the time deviation estimated by the processor 10 can also be used to correct the offset value estimated by the Precision Time Protocol Daemon (PTPd) program.
[0032] In this embodiment, the processor 10 can first estimate the time deviation of the timer 24 at the first time point through the PTPd program. After the processor 10 estimates the time deviation of the timer 24 at the first time point through the method of this embodiment, the time deviation can be used to correct the time deviation value estimated by the PTPd program. The correction equation is as follows: ΔF = X - , where ΔF is the deviation adjustment range, X is the time deviation calculated by the method of this embodiment, and X is the time deviation calculated by PTP.
[0033] When the time deviation X) is greater than the time deviation calculated by PTP, the deviation adjustment magnitude ΔF is positive. When the time deviation X) is less than the time deviation calculated by PTP, the deviation adjustment magnitude ΔF is negative. When the time deviation X) is equal to the time deviation calculated by PTP, the deviation adjustment magnitude ΔF is zero.
[0034] For example, the time deviation X at the first time point is estimated to be 22ns using the method of this embodiment, and the PTP time deviation at the first time point is calculated to be 25ns using the PTPd program. The processor 10 then calculates ΔF=22-25=-3ns through the correction equation. That is, at the first time point, the processor 10 needs to adjust the time deviation estimated by the PTPd program downward by 3ns to obtain a more accurate deviation value. By adjusting the error estimated by the PTPd program through the above means, the slave timer 24 can get closer to the master timer 22, improving the synchronization between the slave timer 24 and the master timer 22, and making the slave timer 24 more stable and accurate.
[0035] As described above, the present invention can select the most accurate master timer and accurately predict the magnitude of correction required by the slave timer, thereby improving the synchronization, stability and accuracy of the slave timer and the master timer.
[0036] In summary, the present invention meets the requirements for an invention patent, and therefore a patent application is filed in accordance with the law. However, the above description is only a preferred embodiment of the present invention, and the scope of the present invention is not limited to the described embodiments. All equivalent modifications or variations made by those skilled in the art in accordance with the spirit of the present invention should be covered within the scope of the following patent application. [Simplified Explanation of the Diagram]
[0037] Figure 1 is a schematic diagram of the conventional PTP protocol time synchronization process. Figure 2 is an architectural diagram of the correction device according to the first embodiment of the present invention. Figure 3 is a flowchart of the steps for selecting the master timer according to the first embodiment of the present invention. Figure 4 is an architectural diagram of the correction device according to the second embodiment of the present invention. Figure 5 is a flowchart of the steps for correcting the slave timer according to the first embodiment of the present invention. [Biomaterial Storage]
[0039] None
Claims
1. A method for correcting master-slave timing synchronization, comprising: The initial squared error between the master timing data and the slave timing data in the estimated initial time point; Based on the sum of the initial error square and the noise variance, the expected deviation at the first time point is estimated; based on the expected deviation and the ratio of the sum of the expected deviation and the variance, the gain parameter is estimated; based on the initial deviation between the master timing data and the slave timing data at the initial time point, and the change of the initial deviation and the expected deviation, the gain parameter is applied to estimate the time deviation; and based on the time deviation, the slave timing data at the first time point is corrected.
2. The master-slave timing synchronization correction method as described in claim 1, wherein the master timing data is generated by selecting the timer with the smallest time variance.
3. The master-slave timing synchronization correction method as described in claim 2, wherein the time variance calculation step further includes: Estimate the average value of the time offset data for each of these timers; And estimate the variance of each of these average values as the time variance.
4. The master-slave timing synchronization correction method as described in claim 1, wherein the initial error square is estimated using the following initial error square equation, as follows: , where is the initial error square, the estimated offset value is the difference between the estimated master timing data and the slave timing data, and the measurement offset value is the difference between the actual measured master timing data and the slave timing data.
5. A master-slave timing synchronization correction device, which acquires master timing data generated by a master timer and slave timing data generated by a slave timer, the correction device comprising: A processor for executing computer programs to implement a correction method for master-slave timing synchronization, as requested in item 1.
6. The master-slave timing synchronization correction device as described in claim 5, wherein the master timing data is generated by selecting the timer with the smallest time variance.
7. The master-slave timing synchronization correction device as described in claim 6, wherein the time variance calculation step further includes: Estimate the average value of the time offset data for each of these timers; And estimate the variance of each of these average values as the time variance.
8. The master-slave timing synchronization correction device as described in claim 5, wherein the initial error square is estimated using the following initial error square equation, as follows: , where is the initial error square, the estimated offset value is the difference between the estimated master timing data and the slave timing data, and the measurement offset value is the difference between the actual measured master timing data and the slave timing data.
