A digital clock remote measurement method based on network delay suppression
By building a hierarchical synchronization architecture and a hybrid delay compensation algorithm, combined with Kalman filtering and LSTM neural network, the time deviation problem of digital clocks during verification or calibration is solved, high-precision and stable time synchronization are achieved, adapting to complex network environments, and the security and reliability of the system are improved.
Patent Information
- Application Number
- CN202510788449.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-06-13
- Publication Date
- 2025-08-22
- Estimated Expiration
- 2045-06-13
AI Technical Summary
The existing digital clock cannot effectively solve the time deviation between the current time display value and the standard time during verification or calibration, and the traditional time-based method has limitations, which leads to the system being unable to perform data analysis on a unified time benchmark, and there are hidden dangers of data synchronization.
Build a hierarchical synchronization architecture, adopt a hybrid delay compensation algorithm, combines Kalman filtering and LSTM neural network, obtains RTT data through bidirectional timestamp interaction, filters reliable messages, uses atomic clocks or satellite timing systems to provide reference time, and combines hardware collaboration and blockchain security verification to achieve high-precision time synchronization.
It improves the accuracy and stability of time synchronization, can effectively deal with the uncertainty and nonlinear changes in network delay in complex network environments, ensures the stable operation of the system in various network environments, and provides a reliable basis for time synchronization.
Smart Images

Figure CN120320891B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of digital clock measurement, and in particular to a digital clock remote measurement method based on network delay suppression. Background Art
[0002] In modern society, digital clocks are widely used in various fields, such as healthcare, finance, and high-speed rail. These fields require extremely high time precision, making accurate timekeeping by digital clocks crucial. However, current digital clock verification and calibration methods present numerous challenges. Current methods for measuring standard digital clocks fail to effectively address the issue of time deviations between the current time indicated by a digital clock and the standard time.
[0003] At the same time, traditional digital clock synchronization methods also have shortcomings. For example, hard synchronization, soft synchronization, coded synchronization, and NTP network synchronization all have their own limitations. Hard synchronization is limited by transmission distance and accuracy, soft synchronization is limited by serial port transmission distance and has limited accuracy, coded time signals have limited application scenarios, and NTP network synchronization has shortcomings in handling network latency.
[0004] Furthermore, in the past, equipment providers mostly used independent digital clocks without synchronization and calibration. This resulted in data analysis and comparison being unable to be performed on a unified time basis across the entire system or region, posing significant risks to information and data analysis and judgment. Therefore, a new network delay suppression and time algorithm for a digital clock remote metering platform is urgently needed to improve calibration and synchronization accuracy. Summary of the Invention
[0005] The technical problem to be solved by the present invention is to provide a digital clock remote measurement method based on network delay suppression to solve the time deviation problem between the current indication of the digital clock and the standard time and the data synchronization analysis problem.
[0006] The problem of the present invention is achieved as follows: A digital clock remote measurement method based on network delay suppression includes the following steps:
[0007] S1. Build a hierarchical synchronization architecture, deploying a master clock source, multiple regional clock servers, and multiple terminal devices. The multiple regional clock servers are connected to the master clock source via dedicated fiber lines to obtain reference time. Each regional clock server is connected to multiple terminal devices via 5G / Industrial Ethernet, forming a three-level synchronization network. The 5G and Industrial Ethernet access methods adapt to the connection requirements of terminal devices in different environments, improving the time synchronization efficiency and accuracy of the entire system and laying a solid foundation for subsequent time synchronization work.
[0008] S2. Obtain RTT data between the terminal device and a regional server through two-way timestamp interaction, filter messages according to preset rules, and retain reliable RTT data as historical data;
[0009] S3, use the hybrid delay compensation algorithm to calculate the final delay compensation value, process the historical RTT data through the Kalman filter module, and output the short-term compensation value , and predict the long-term compensation value by learning the historical 24-hour delay sequence, network state parameters and Kalman residual terms through the LSTM neural network module , then dynamically assigning weights of the two compensation values according to the real-time network status through fuzzy logic to obtain a final delay compensation value, and using the final delay compensation value to calibrate the terminal clock;
[0010] S4. Use time selection algorithm to obtain the optimal reference source for data synchronization analysis.
[0011] Furthermore, the master clock source uses an atomic clock or satellite timing system to provide a reference time. A hierarchical synchronization architecture is constructed, utilizing atomic clocks, satellite timing systems, and dedicated optical fiber lines to ensure high-precision and stable transmission of the reference time.
[0012] Furthermore, the step S2 further includes:
[0013] S21. The terminal device sends an NTP request message to the regional clock server connected to it, carrying the local timestamp. ;
[0014] S22. After receiving the request, the regional clock server generates a response message including the reference time and appends the network status parameters;
[0015] S23. The terminal device receives the response message and records the local time , calculate the round trip delay , filter packets according to the following rules: If the RTT of a group of packets exceeds the average , they are eliminated, and the three groups of messages with the smallest RTT standard deviation are selected. Then, the RTT of the three filtered groups of messages is averaged and used as the final reliable RTT data.
[0016] By using two-way timestamp interaction to obtain round-trip delay, the message filtering rules can remove abnormal data and select stable and reliable messages to calculate the average RTT, providing more accurate data support for subsequent precise time synchronization calculations, effectively reducing the impact of network fluctuations on time synchronization, and improving the accuracy of time synchronization.
[0017] Furthermore, the step S3 specifically includes:
[0018] Step S31: Set the state transition equation of the Kalman filter module to: ; The observation equation is: ;
[0019] In network delay prediction, X(k) is the delay state vector at time k, expressed as [delay value, delay change rate], F(k) is the state transition matrix, and , is the time interval, which is consistent with the time resolution of data acquisition. This matrix indicates that the delay at the current moment is equal to the delay at the previous moment plus the delay change rate multiplied by the time interval; is the control input matrix, is the control input vector, which will be Set to zero matrix, Set to zero vector, is the process noise vector, which is used to represent the unpredictable noise interference in the system. Its mean is zero and its covariance matrix is ; yes The observation vector at time t, that is, the round-trip delay RTT actually measured, is the observation matrix, and , this matrix indicates that the observation vector is equal to the delay value in the system state vector, is the observation noise vector, whose mean is zero and whose covariance matrix is ;
[0020] Dynamically adjust the Q / R matrix, where the process noise covariance matrix The adjustment method is: ,in is the initial process noise covariance matrix, and its value is determined according to the prior knowledge of the network. is the current packet loss rate; the observation noise covariance matrix The adjustment method is: ,in is the initial observation noise covariance matrix, is the current jitter;
[0021] Through the iterative Kalman filter algorithm, the system state is predicted and updated using the state transfer equation and observation equation, and finally the short-term delay compensation value is obtained. ;
[0022] Clarifying the state transition equation and observation equation provides a precise mathematical model for the Kalman filter algorithm, enabling it to more accurately estimate and predict network delay states, thereby improving the accuracy and stability of the hybrid delay compensation algorithm and further enhancing the accuracy of time synchronization.
[0023] Step S32: Set the input layer, hidden layer, and output layer of the LSTM neural network module; the input layer is used to receive input data, including the historical 24-hour delay sequence, the current network status information, and the Kalman filter residual term, to fully reflect the network status and historical delay information; the hidden layer is used to capture the long-term dependencies in the time series data, and predict and control the information output based on the long-term rules; the output layer is used to predict the delay changes in the future period based on the output results of the hidden layer, and output the long-term delay compensation value , used to reflect the long-term trend of network latency;
[0024] By enriching the input data of the LSTM neural network, it can integrate historical delay information, current network status, and Kalman filter residuals to more comprehensively capture the changing patterns of network delay. This improves the accuracy of the LSTM neural network in predicting long-term delay compensation values, thereby improving the performance of the entire hybrid delay compensation algorithm.
[0025] Step S33: Dynamically adjust the short-term delay compensation value according to the real-time status of the network and long-term delay compensation value Weight in delay compensation:
[0026] Real-time monitoring of network status: Obtain the network packet loss rate in real time through network monitoring tools , bandwidth utilization and jitter parameter;
[0027] Formulate fuzzy logic rules: When When setting the weights of the LSTM neural network , the weight of the Kalman filter algorithm ;when When setting the weight of the Kalman filter algorithm , the weights of the LSTM neural network ; When the above two conditions are not met, the linear interpolation method is used to dynamically adjust and The value of
[0028] Calculate the final delay compensation value based on the dynamically adjusted weight: ;
[0029] The terminal clock is calibrated using the final delay compensation value.
[0030] Furthermore, the step S4 specifically includes the following:
[0031] Step S41: Calculate the filtering deviation and synchronization distance of different time reference sources:
[0032] Filter dispersion It is used to measure the discreteness of the time reference source. Its calculation formula is: ,in, Representative The time of the time reference source, is the average of all time reference source times, Indicates the number of time reference sources;
[0033] Synchronous distance It is used to intuitively represent the degree of difference between each time reference source and the average time. The calculation formula is: ;
[0034] Step S42: Filter the time reference source:
[0035] Setting the Crossing Threshold
[0036] Eliminate abnormal time reference source: synchronize the distance Time reference source elimination;
[0037] Select the best time reference source: select the top three best sources from the remaining time reference sources;
[0038] Calculate the final time reference value: Take the weighted average of the times of the three optimal sources to obtain the final time reference value for data synchronization analysis.
[0039] The time selection algorithm filters the time reference source by calculating the filtering deviation and synchronization distance. It can select the more reliable and accurate time from multiple time reference sources, provide a more accurate time reference for the digital clock remote measurement platform, and improve the reliability and accuracy of time synchronization.
[0040] Furthermore, the method further includes: S5, further improving time synchronization accuracy and data reliability through hardware collaboration and blockchain security verification:
[0041] The terminal device uses a dedicated timestamp chip, which includes a counter driven by a 100MHz temperature-compensated crystal oscillator, a hardware timestamp marking unit for inserting timestamps into IEEE802.3 frame headers, and an on-chip cache. The on-chip cache stores the most recent 100 timestamp data for Kalman filter preprocessing.
[0042] The specific process of blockchain security verification includes: generating a new block on the master clock: the master clock generates a new block every 10 seconds, and the new block contains the hash value of the current timestamp and the hash value of the previous block. The hash value of the current timestamp is used to ensure the integrity of the timestamp data, and the hash value of the previous block connects each block into a chain structure to form a blockchain; regional server verification and resynchronization mechanism: the regional server verifies the height continuity of the blockchain through a smart contract. If it is found that the deviation of the blockchain height exceeds 5 blocks, the resynchronization mechanism is triggered to obtain the correct blockchain data from other nodes to ensure the consistency of the blockchain recorded by itself with the entire network.
[0043] Blockchain verification ensures the integrity and non-tamperability of timestamp data. Regional servers verify the high continuity of the blockchain through smart contracts to ensure the consistency of time data. The use of blockchain verification and smart contracts enhances the security and credibility of timestamp data, prevents data from being tampered with, ensures the consistency of time data, ensures the accuracy and reliability of time synchronization of each device in the system, and improves the security and stability of the entire system.
[0044] Furthermore, the method further comprises:
[0045] S6, Adaptive synchronization cycle adjustment: including: S61, real-time monitoring of local crystal oscillator frequency deviation ; S62, when When the synchronization period is shortened from 1 hour to 10 minutes; S63, when the synchronization error is 10 times in a row When the time is set to zero, the synchronization period is extended to 2 hours; the adaptive synchronization period adjustment mechanism can dynamically adjust the synchronization period according to the local crystal oscillator frequency deviation and time synchronization accuracy, while ensuring time synchronization accuracy, effectively reducing network overhead, improving network resource utilization, and enhancing overall system performance.
[0046] S7. Perform load balancing adjustments on regional clock servers: This includes: S71. When the number of connected terminals exceeds a preset limit, the regional clock server automatically assigns new terminals to adjacent, less-loaded servers; S72. Regional clock servers regularly exchange load status information and dynamically adjust terminal affiliations. This regional clock server load balancing strategy ensures even server load, preventing excessive load on a single server from impacting performance, improving system stability and reliability, and ensuring that a large number of terminal devices can access time synchronization services stably and efficiently.
[0047] Furthermore, the Kalman filter module in step S3 adopts the square root unscented transform (SRUT) algorithm, processes the nonlinear network delay model based on the UT transform, selects the Sigma point to approximate the nonlinear system probability distribution, and maintains the positive definiteness of the covariance matrix through square root decomposition to ensure the stable operation of the Kalman filter algorithm, as follows:
[0048] The probability distribution of the nonlinear system is approximated by a set of deterministic sampling points Sigma. dimensional state vector , first according to the mean of the state vector and covariance matrix To determine the Sigma point set , where the Sigma point selection method is as follows: ;
[0049] in, , Determines the distribution range of Sigma points around the mean, and the value is a positive number. is a secondary scaling parameter, Representation matrix No. column vector;
[0050] After determining the Sigma point set through the above formula, these Sigma points are passed through the nonlinear network delay model. Propagate and obtain the Sigma point set after nonlinear transformation : ;
[0051] Then, the mean of the state vector is estimated by these transformed Sigma points and covariance matrix :
[0052] ;
[0053] ;
[0054] in, and are the weights used to calculate the mean and covariance, respectively. The calculation formulas are as follows: ; ; ;
[0055] in, is a parameter used to exploit the second-order statistical information of the state variables;
[0056] The square root unscented transform (SRUT) maintains the positive definiteness of the covariance matrix by performing a square root decomposition on the covariance matrix: In the process, the square root of the covariance matrix is directly operated, assuming is the covariance matrix The square root matrix of Perform corresponding transformations instead of directly To perform the operation, specifically, to calculate the transformed covariance matrix When the square root matrix The operation is used to update the square root representation of the covariance matrix , thereby ensuring It always maintains positive definiteness to avoid the non-positive definiteness problem of the covariance matrix that may occur in traditional Kalman filtering, thereby improving the stability and accuracy of the algorithm.
[0057] Furthermore, the method also includes: fault diagnosis and recovery: quickly locating the fault location and performing corresponding fault recovery through layered fault monitoring and diagnosis.
[0058] Furthermore, the method also includes: performance evaluation and optimization: including monitoring performance indicators, comparing performance indicators with traditional time synchronization systems under the same network environment and application scenarios, and building a simulated network environment for simulation testing to evaluate platform performance under different conditions; and providing corresponding performance optimization strategies based on the evaluation results.
[0059] The advantages of the present invention are:
[0060] 1. High time synchronization accuracy: The layered synchronization architecture constructed by this invention leverages the high-precision reference time provided by atomic clocks or satellite timing systems, combined with the low-latency transmission characteristics of fiber-optic dedicated lines, 5G, and industrial Ethernet, to achieve extremely high-precision time synchronization between terminal devices and the master clock source. By establishing a three-level synchronization network architecture (master clock source - regional clock server - terminal device), the time synchronization tasks are rationally distributed in a layered manner, effectively reducing the impact of network latency and improving the accuracy of time synchronization. In complex network environments, time synchronization errors can be controlled to the microsecond level, which is several times more accurate than traditional time synchronization systems. This accuracy can meet the strict requirements for transaction timestamp accuracy in financial transactions, ensuring the accuracy and fairness of transaction records and avoiding transaction disputes caused by time errors. In the medical field, high-precision time synchronization facilitates the precise coordination of medical devices. For example, in telemedicine surgery, the accuracy of time synchronization between devices is directly related to the success rate of the surgery and the safety of the patient.
[0061] 2. Strong resistance to network interference: The hybrid delay compensation algorithm combines the advantages of the Kalman filter and the LSTM neural network. The Kalman filter's ability to quickly track short-term delay changes, combined with the LSTM neural network's ability to accurately predict long-term delay trends, enables the system to effectively cope with the uncertainty and nonlinearity of network delay in complex and changing network environments. Furthermore, fuzzy logic rules that dynamically adjust the weights of the two based on real-time network status further optimize the delay compensation effect. Even under harsh network conditions with packet loss rates as high as 5% and jitter reaching 5ms, the algorithm maintains stable time synchronization performance, effectively reducing time synchronization errors caused by network fluctuations and ensuring stable system operation in various network environments.
[0062] 3. Reliable time source screening and data security: The time selection algorithm accurately selects the most reliable time source from multiple time reference sources by calculating filtering deviation and synchronization distance, providing a more solid foundation for time synchronization. Furthermore, hardware coordination and security verification mechanisms provide dual guarantees for system security and data reliability. The dedicated timestamp chip integrated into the terminal device automatically inserts a hardware timestamp with nanosecond precision at the MAC layer, reducing software processing delays and improving timestamp accuracy. The application of blockchain technology ensures the integrity and immutability of timestamp data. Regional servers verify the high degree of continuity of the blockchain through smart contracts, effectively preventing malicious data tampering and enhancing the security and credibility of the system. In scenarios such as financial data recording and industrial production data traceability, this data security mechanism can ensure the authenticity and reliability of data, providing a reliable basis for subsequent data analysis and decision-making.
[0063] 4. Intelligent and efficient system optimization: The adaptive synchronization cycle adjustment mechanism automatically optimizes the synchronization cycle based on the local crystal oscillator frequency deviation and time synchronization accuracy. When the crystal oscillator frequency deviation is large, the synchronization cycle is shortened to ensure time synchronization accuracy; when the synchronization accuracy is high, the synchronization cycle is extended to reduce network overhead, achieving a balance between time synchronization accuracy and network resource utilization efficiency. The load balancing strategy of the regional clock server can automatically assign new terminals to adjacent low-load servers when the number of connected terminals exceeds a certain threshold, and regularly exchange load status information to dynamically adjust terminal affiliation, ensuring uniform server load and improving system stability and reliability. The fault diagnosis and recovery mechanism can monitor the operating status of each device in the system in real time, quickly detect and diagnose faults, and take appropriate recovery measures in a timely manner, reducing system downtime caused by faults and improving system availability. BRIEF DESCRIPTION OF THE DRAWINGS
[0064] The present invention will be further described below with reference to the accompanying drawings and embodiments.
[0065] Figure 1This is an execution flow chart of a digital clock remote measurement method based on network delay suppression according to the present invention;
[0066] Figure 2 This is a principle block diagram of building a hierarchical synchronization architecture in a digital clock remote measurement method based on network delay suppression according to the present invention;
[0067] Figure 3 This is a principle block diagram of bidirectional timestamp interaction and message screening in a digital clock remote metering method based on network delay suppression according to the present invention;
[0068] Figure 4 This is a principle block diagram of a hybrid delay compensation algorithm in a digital clock remote measurement method based on network delay suppression. DETAILED DESCRIPTION
[0069] The embodiments of the present application provide a digital clock remote measurement method based on network delay suppression, which can effectively improve the efficiency of digital clock synchronization.
[0070] The technical solution in the embodiment of the present application has the following overall idea: by building a hierarchical synchronization architecture, deploying a high-precision master clock source, obtaining precise reference time with the help of atomic clocks or satellite timing systems, and utilizing the low latency, high bandwidth and high stability of optical fiber dedicated lines, the reference time is efficiently transmitted to the regional clock server; the terminal equipment accesses the regional clock server through 5G or industrial Ethernet to form a stable three-level synchronization network, breaking the limitations of traditional time synchronization methods and providing solid support for high-precision time synchronization from a basic level. In terms of the core algorithm of time synchronization, a two-way timestamp interaction and message screening mechanism is adopted, combined with the NTP protocol, so that the terminal device and the regional clock server can exchange time information efficiently. Through screening, abnormal data can be effectively removed, and a more accurate round-trip delay can be obtained, providing a reliable data basis for subsequent time synchronization calculations, and significantly improving the accuracy of time synchronization. Using a hybrid delay compensation algorithm, the Kalman filter and the LSTM neural network are integrated. The Kalman filter dynamically adjusts the Q / R matrix based on historical RTT data to accurately track short-term delay changes; the LSTM neural network learns the historical 24-hour delay sequence, network status parameters and Kalman residual terms to predict long-term delay trends. Fuzzy logic is then used to dynamically assign weights to the two based on real-time network status, calculating the final delay compensation value. This allows for accurate prediction and compensation of network delays, effectively addressing the uncertainty and nonlinearity of network delays in complex network environments, and significantly improving time synchronization accuracy.
[0071] To make the present invention more clearly understood, a preferred embodiment is now described in detail below with reference to the accompanying drawings.
[0072] like Figure 1As shown, a digital clock remote measurement method based on network delay suppression of the present invention includes the following steps:
[0073] S1. Build a hierarchical synchronization architecture, deploy a master clock source, multiple regional clock servers, and multiple terminal devices. Multiple regional clock servers are connected to the master clock source via optical fiber dedicated lines to obtain reference time. Each regional clock server is connected to multiple terminal devices via 5G / Industrial Ethernet to form a three-level synchronization network. Figure 2 As shown in the figure, since fiber-optic dedicated lines are dedicated network lines based on fiber-optic communication technology, they offer advantages such as low latency, high bandwidth, and high stability. Compared to other communication methods (such as wireless communication), fiber-optic dedicated lines provide a more stable and reliable communication connection, ensuring that reference time information is not lost or erroneous during transmission. Terminal devices, the end users of the digital clock remote metering platform, are geographically distributed and connect to regional clock servers in their area via 5G networks or Industrial Ethernet for accurate time synchronization. For example, in industrial automation scenarios with extremely high real-time requirements, such as sensors and actuators on automated assembly lines, terminal devices can quickly receive time synchronization information from regional clock servers via 5G networks and perform precise time calibration. In factory automation production lines, such as CNC machine tools, Industrial Ethernet ensures time synchronization between individual production equipment (such as robots and sensors) and regional clock servers, enabling precise coordination of the production process.
[0074] Example description: Suppose we want to build a digital clock remote metering platform covering a large industrial park. There are multiple production workshops distributed in the park, and each workshop has a large number of production equipment (such as CNC machine tools, automated assembly lines, etc.) as terminal equipment, which require high-precision time synchronization. A high-precision cesium atomic clock can be deployed in the park's management center as the main clock source, and multiple regional clock servers can be set up in different areas of the park. Each regional clock server is responsible for providing time synchronization services for terminal equipment in the area. For example, a regional clock server is set up in the south, north and west areas of the park. The frequency stability of the atomic clock is , providing extremely precise reference time. Furthermore, dedicated fiber optic lines connect the atomic clocks to regional clock servers in various areas of the park. Production equipment within the park acts as a terminal device, connecting to the corresponding regional clock server based on its location.
[0075] This hierarchical synchronization architecture enables highly accurate time synchronization across all production equipment within the park, ensuring precise coordination and efficient operation of the production process. For example, on an automated assembly line, equipment at all stages can start and stop at the same time, avoiding production failures and quality issues caused by time asynchrony.
[0076] S2. Obtain RTT data between the terminal device and a regional server through two-way timestamp interaction, filter messages according to preset rules, and retain reliable RTT data as historical data;
[0077] S3, using the hybrid delay compensation algorithm to calculate the final delay compensation value, such as Figure 4 As shown, the Kalman filter module processes historical RTT data and outputs short-term compensation values. , and predict the long-term compensation value by learning the historical 24-hour delay sequence, network state parameters and Kalman residual terms through the LSTM neural network module , then dynamically assigning weights of the two compensation values according to the real-time network status through fuzzy logic to obtain a final delay compensation value, and using the final delay compensation value to calibrate the terminal clock;
[0078] S4. Use time selection algorithm to obtain the optimal reference source for data synchronization analysis.
[0079] In a preferred embodiment, the master clock source uses an atomic clock or a satellite timing system to provide a reference time. This master clock source is the foundation for achieving high-precision time synchronization across the entire digital clock remote metering platform. The reference time it provides acts as the "heartbeat" of the entire system, providing a reliable basis for time calibration of subsequent devices at all levels. Atomic clocks use the stability of atomic transition frequencies to keep time. Common atomic clocks include cesium and rubidium clocks. Atomic clocks have extremely low timing errors. Satellite timing systems calibrate local time by receiving time signals transmitted by satellites. Currently, widely used satellite timing systems include the United States' Global Positioning System (GPS) and China's Beidou system. Satellite timing systems can achieve microsecond accuracy, but this accuracy is affected by various factors, such as satellite signal propagation delay, interference from the ionosphere and troposphere, and multipath effects.
[0080] In a preferred embodiment, if Figure 3 As shown, the step S2 further includes:
[0081] S21. The terminal device sends an NTP request message to the regional clock server connected to it, carrying the local timestamp. As the requester of time synchronization, the terminal device needs to actively initiate a time synchronization request to the regional clock server. During this process, the terminal device constructs and sends a request message based on the Network Time Protocol (NTP). When sending the request message, the terminal device will embed a local timestamp in the message. This timestamp accurately records the moment when the terminal device sends the message. Its accuracy depends on the accuracy of the terminal device's internal clock. For example, if the terminal device uses an ordinary clock with an accuracy of 1 millisecond, then The error range may be between ±1 millisecond.
[0082] S22: After receiving the request, the regional clock server generates a The regional clock server will immediately record the time of receiving the request message from the terminal device and mark it as This time record depends on the clock system of the regional clock server itself. Since the regional clock server is connected to the master clock source through a high-precision optical fiber line, its own clock will be constantly calibrated according to the reference time provided by the master clock source. The accuracy can be effectively guaranteed, usually reaching the microsecond level. The time it takes for the server to send a response is recorded as ;
[0083] S23. The terminal device receives the response message and records the local time , calculate the round-trip time (RTT) , which represents the total time it takes for a message to be sent from the terminal device to the regional clock server and then returned to the terminal device. To obtain more accurate and reliable round-trip delay data, the terminal device will filter and process multiple groups of received messages. Messages are filtered according to the following rules:
[0084] 1. Calculate the average and standard deviation: The terminal device first calculates the average RTT of all received messages and standard deviation .average value The calculation formula is , where n represents the number of received message groups, Indicates the round trip delay of the i-th group of messages. Standard deviation The calculation formula is , which reflects the degree of dispersion of RTT data. The smaller the standard deviation, the more concentrated the data is and the higher the stability of network delay is.
[0085] 2. Eliminate abnormal messages: If the RTT of a group of messages exceeds , then the group of messages will be regarded as abnormal messages and will be removed. This is because under normal circumstances, the RTT of most messages should be concentrated around the average value, and those exceeding The message is likely to be affected by sudden network interference, routing anomalies and other factors, resulting in an abnormal increase in its round-trip delay, which cannot represent the normal network delay situation.
[0086] 3. Select stable packets: From the remaining packets, select the three groups of packets with the smallest RTT standard deviations. The RTT data of these three groups of packets is relatively stable, less affected by network fluctuations, and more accurately reflects the actual network latency.
[0087] 4. Calculate the final estimate: Average the RTTs of the three filtered groups of messages to obtain the final reliable round-trip delay estimate (i.e., RTT data). Example: Suppose a terminal device receives five response messages from a regional clock server during time synchronization, with corresponding round-trip delays (RTTs) of 20ms, 22ms, 30ms, 21ms, and 23ms. After calculation, select the three groups with the smallest standard deviations, assuming they are 20ms, 21ms, and 22ms. The final estimate is 21ms.
[0088] Through this two-way timestamp interaction and message screening process, the terminal device can obtain the round-trip delay more accurately, providing more reliable data support for subsequent time synchronization calculations, thereby improving the accuracy of time synchronization.
[0089] Preferably, the step S3 specifically includes:
[0090] Step S31: Set the state transition equation of the Kalman filter module to: ; The observation equation is:
[0091] In network delay prediction, The delay state vector at time k may contain information such as the current delay value and the delay change rate. For example, X(k) can be expressed as [delay value, delay change rate]. These two elements constitute the description of the system state at time k. F(k) is the state transition matrix, which describes the transition relationship between the system state from time k-1 to time k. The design of F(k) needs to be determined based on the dynamic characteristics of the network. Assuming that network delay has a certain degree of inertia, that is, the delay at the current moment is related to the delay and delay change rate at the previous moment, then F(k) can be designed as:
[0092] in is the time interval, which is consistent with the time resolution of data acquisition. For example, when the time resolution is 1 second, This matrix indicates that the delay at the current moment is equal to the delay at the previous moment plus the delay change rate multiplied by the time interval, while the delay change rate remains unchanged;
[0093] is the control input matrix, is the control input vector. In network delay prediction, these two elements may be used to introduce the influence of external control factors on the system state. If there is no external control factor, Set to zero matrix, Set to zero vector;
[0094] Is the process noise vector, which is used to represent the unpredictable noise interference in the system. In the network environment, this noise may come from the hardware noise of the network equipment, sudden changes in network traffic, etc. Process noise vector It is usually assumed to be Gaussian white noise with a mean of zero and a covariance matrix of ;
[0095] is the observation vector at time k. In network delay prediction, it can be the actual measured round-trip delay (RTT). For example, the RTT value obtained through two-way timestamp interaction can be used as the observation vector;
[0096] is the observation matrix, which transforms the system state vector Mapped to the observation space. Since the observation vector is the actual measured round trip delay, and the system state vector contains the delay value, so the observation matrix It can be simply set as: , this matrix indicates that the observation vector (round-trip delay) is equal to the delay value in the system state vector;
[0097] Is the observation noise vector, which is used to represent the noise introduced during the measurement process. In the actual measurement of round-trip delay, it may be affected by factors such as network jitter and clock accuracy, resulting in certain errors in the measurement results. These errors can be expressed as the observation noise vector The observation noise vector It is also usually assumed to be Gaussian white noise with zero mean and covariance matrix ;
[0098] Dynamically adjust the Q / R matrix:
[0099] In the Kalman filtering process, the process noise covariance matrix and the observation noise covariance matrix It has a significant impact on the filtering effect. In order to adapt to the dynamic changes of the network environment, these two matrices need to be dynamically adjusted;
[0100] Among them, the process noise covariance matrix The adjustment method is: ,in is the initial process noise covariance matrix, and its value needs to be determined based on the prior knowledge of the network. For example, in a relatively stable network environment, Can be set to a smaller value, such as (Here we assume is a two-dimensional vector, represents a diagonal matrix). The current packet loss rate. The higher the packet loss rate, the more unstable the network environment is and the greater the process noise is. Therefore, it is necessary to increase For example, when the packet loss rate When, if , then
[0101] Observation noise covariance matrix The adjustment method is: ,in is the initial observation noise covariance matrix, which also needs to be determined according to the actual situation. Assuming that under ideal conditions, the error in measuring the round-trip delay is small, Can be set to . is the current jitter. The greater the jitter, the greater the measurement error. The observation noise covariance matrix Also needs to be increased accordingly. For example, when the jitter hour, ;
[0102] By continuously iterating the Kalman filter algorithm, the system state is predicted and updated using the state transfer equation and observation equation, and finally the short-term delay compensation value can be obtained. ;
[0103] Kalman filtering is a commonly used optimal estimation method. In the network delay prediction of the present invention, it can effectively use historical data to accurately estimate the current delay state and predict future delay trends.
[0104] Step S32: setting the input layer, hidden layer, and output layer of the LSTM neural network module;
[0105] The input layer receives input data, including the historical 24-hour delay series, current network status information, and Kalman filter residuals, to fully reflect the network status and historical delay information.
[0106] Historical 24-hour latency series: With a time resolution of 1 second, the input layer receives latency data for every second over the past 24 hours. This historical data captures long-term trends and periodic characteristics of network latency. For example, during certain times of the day, network traffic is high, leading to increased latency. By analyzing this historical data, the LSTM neural network can learn these patterns.
[0107] Current network state vector :in is the packet loss rate, which reflects the reliability of the network; It is the bandwidth utilization, which reflects the load of the network; is jitter, which describes the stability of network delay; is the average round trip delay, which comprehensively reflects the current network delay level. These network status parameters can reflect the current status of the network in real time and help the LSTM neural network to more accurately predict future delay changes. For example, when the packet loss rate A sudden increase may indicate that the network is about to be congested and the latency will increase.
[0108] Kalman filter residual term This residual term contains the difference between the Kalman filter's predictions at the current moment and the previous moment, reflecting the Kalman filter's ability to track delay variations. Using it as input to the LSTM neural network allows it to better incorporate Kalman filter information, improving prediction accuracy.
[0109] The hidden layer captures long-term dependencies in time series data, making predictions and controlling information output based on long-term patterns. The hidden layer consists of multiple LSTM cells, each of which controls the flow of information through a forget gate, an input gate, and an output gate. The forget gate determines which information is discarded from the cell state, the input gate determines which new information is added to the cell state, and the output gate determines the final output information. This mechanism enables LSTM cells to effectively capture long-term dependencies in time series data. When processing historical delay data, LSTM cells can memorize delay trends over time, enabling predictions based on long-term patterns even when there are short-term fluctuations.
[0110] The output layer predicts the delay changes in the future based on the output results of the hidden layer and outputs the long-term delay compensation value. This value is obtained based on the LSTM neural network's learning and analysis of historical data and current network status, and is used to reflect the long-term trend of network latency.
[0111] The LSTM (Long Short-Term Memory) neural network is a deep learning model specifically designed for processing time series data. It effectively captures long-term dependencies in data and offers unique advantages in network latency prediction. Its input layer receives a variety of data to comprehensively reflect network status and historical latency information:
[0112] Step S33: In order to give full play to the advantages of Kalman filtering and LSTM neural network, the short-term delay compensation value is dynamically adjusted according to the real-time status of the network. and long-term delay compensation value Weight in delay compensation:
[0113] Real-time monitoring of network status: Obtain the network packet loss rate in real time through network monitoring tools , bandwidth utilization and jitter These parameters can be obtained through the management interface of network devices (such as routers and switches) or special network monitoring software.
[0114] Formulate fuzzy logic rules:
[0115] when When , it means that the network packet loss is serious and the network status is unstable. At this time, increase the weight of the LSTM neural network , reduce the weight of the Kalman filter algorithm This is because LSTM neural networks can better handle complex and unstable network environments and use their learning ability of historical data and network status to predict delay changes. The specific values are pre-defined according to the specific situation. For example, when the packet loss rate reaches 5%, set .
[0116] when and When , it indicates that the network jitter is small and the bandwidth utilization is high, and the network status is relatively stable. In this case, increase the weight of the Kalman filter algorithm , reduce the weight of the LSTM neural network Because Kalman filtering can track delay changes more accurately in a stable network environment and provide reliable short-term predictions. The specific values are pre-defined according to the specific situation. For example, when the jitter is And the bandwidth utilization is When you can set .
[0117] When the above two conditions are not met, the linear interpolation method is used to dynamically adjust and The value of The linear interpolation formula is:
[0118] in, and It is the Kalman filter weight value pre-set according to different network states. and is the corresponding packet loss rate threshold, is the current packet loss rate. For example, when hour, ;when hour, If the current packet loss rate ,but:
[0119] Calculate the final delay compensation value based on the dynamically adjusted weight: ;
[0120] Assume that in a certain network environment, we test the digital clock remote measurement platform. Over a period of time, the network packet loss rate is , jitter and bandwidth utilization Constantly changing. In the initial stage, the network is relatively stable and the packet loss rate , jitter , bandwidth utilization According to the fuzzy logic rules, set Through the Kalman filter module, the short-term delay compensation value is obtained. The LSTM neural network module predicts the long-term delay compensation value The final delay compensation value is corrected to: ;
[0121] As time goes by, the network becomes congested and the packet loss rate rises to 3%. At this time, according to the fuzzy logic rules, the weight is adjusted to . Recalculate the delay compensation value, assuming that ,but:
[0122] The terminal clock is calibrated using the final delay compensation value.
[0123] This example shows that the hybrid delay compensation algorithm can dynamically adjust the weights of the Kalman filter and LSTM neural network based on changes in network status, thereby more accurately compensating for network delays and improving time synchronization accuracy.
[0124] Preferably, the step S4 specifically includes the following:
[0125] Step S41: Calculate the filtering deviation and synchronization distance of different time reference sources:
[0126] Filter dispersion It is used to measure the discreteness of the time reference source. Its calculation formula is: ,in, Representative The time of the time reference source, is the average of all time reference source times, Indicates the number of time reference sources; assuming the terminal device receives the time from 5 time reference sources, 、 、 、 、 First calculate the average ;
[0127] Then calculate the sum of squared deviations: ;
[0128] Finally, calculate the filter deviation: ;
[0129] Synchronous distance It is used to intuitively represent the degree of difference between each time reference source and the average time. The calculation formula is: ; For example, for the above , its synchronization distance ;
[0130] Synchronous distance , and so on.
[0131] During the time synchronization process, the terminal device often receives time information from multiple time reference sources. In order to determine the reliability of these time reference sources, it is necessary to calculate two key indicators: filtering deviation and synchronization distance; filtering deviation ( ) is used to measure the dispersion of the time reference source and reflects its stability. After calculating the filtering deviation and synchronization distance, time reference sources can be screened based on these indicators.
[0132] Step S42: Filter the time reference source:
[0133] Setting the Crossing Threshold ; Crossing threshold It is an important basis for screening time reference sources. In the above example, ;
[0134] Eliminate abnormal time reference source: synchronize distance The time reference source is eliminated; assuming that according to the calculation, Synchronous distance , then Eliminate.
[0135] Select the optimal time reference source: The top three optimal sources are selected from the remaining time reference sources. "Optimal" can be determined based on various factors, such as the reliability and accuracy of the time reference source. For example, if the time reference sources come from different servers, where Server A is known for its high-precision clock and Server B has good network stability, the time reference sources from Servers A and B might be prioritized. Assume that based on the reliability and accuracy evaluation, the first, second, and fifth sources are selected as the optimal sources.
[0136] Calculate the final time reference value: The weighted average of the time of the three optimal sources is used to obtain the final time reference value for data synchronization analysis. The weight setting can be determined according to the priority of the time reference source. For example, if the first one comes from a high-precision master clock source, give it a weight of The second and fifth are from relatively reliable backup clock sources, with weights The final time reference value is for: ;
[0137] Through such a time selection algorithm, more reliable and accurate time can be screened out from multiple time reference sources, providing strong support for the time synchronization of digital clock remote measurement platforms.
[0138] Preferably, in a digital clock remote metering platform, hardware collaboration and security verification are key steps to ensure time synchronization accuracy and data security. The specific content, principles, and functions of these two steps will be elaborated below. The method also includes: S5, further improving time synchronization accuracy and data reliability through hardware collaboration and blockchain security verification:
[0139] Terminal device hardware collaboration: The terminal device hardware collaboration improves the accuracy and processing efficiency of timestamps from the bottom up by integrating dedicated chips and related functional modules, providing a reliable data foundation for subsequent time synchronization algorithms. The terminal device uses a dedicated timestamp chip, which includes a counter driven by a 100MHz temperature-compensated crystal oscillator, a hardware timestamp marking unit that inserts timestamps into the IEEE802.3 frame header, and an on-chip cache that stores the most recent 100 timestamp data for Kalman filter preprocessing.
[0140] The terminal device integrates a dedicated timestamp chip, which provides precise timing using a counter driven by a 100MHz temperature-compensated crystal oscillator. The temperature-compensated crystal oscillator (TCXO) automatically adjusts the crystal's oscillation frequency based on temperature fluctuations, ensuring clock stability. A 100MHz oscillation frequency means the counter can perform 100 million counts per second, enabling extremely high-precision time measurement. For example, if a 1ms event is to be measured, at a 100MHz counting frequency, the event can theoretically be measured with an accuracy of 10 nanoseconds. A hardware timestamp unit automatically inserts hardware timestamps at the MAC (Media Access Control) layer, supporting nanosecond accuracy. The MAC layer is part of the network's data link layer and is responsible for sending and receiving data frames. Inserting timestamps at this layer allows accurate recording of the time the data frame enters the network, eliminating delays introduced by software processing. Software processing requires multiple steps, such as operating system scheduling and data copying, which can introduce unpredictable delays. The hardware timestamp unit operates directly at the hardware level, significantly improving timestamp accuracy. For example, in a high-speed data transmission network, data frames are transmitted at very high speeds. If software is used to record timestamps, software processing delays may cause significant discrepancies between the timestamps and the actual transmission or reception time. Hardware timestamps, however, can limit this discrepancy to nanoseconds. On-chip buffering and Kalman filter preprocessing: The on-chip buffer stores the most recent 100 timestamps, which are used for Kalman filter preprocessing. The Kalman filter is a commonly used filtering algorithm used to estimate and predict noisy measurement data. Storing a certain amount of timestamp data in the on-chip buffer provides the Kalman filter with more historical information, thereby improving its efficiency and accuracy. For example, in a time synchronization system, measured timestamps may have certain errors due to factors such as network delays. The Kalman filter can use historical timestamp data and current measurements to more accurately estimate the actual time. The 100 timestamps stored in the on-chip buffer allow the Kalman filter algorithm to better capture temporal trends and reduce the impact of errors.
[0141] The specific process of blockchain security verification includes: generating a new block on the master clock: the master clock generates a new block every 10 seconds. The new block contains the hash value of the current timestamp and the hash value of the previous block. The hash value is a fixed-length string obtained by calculating the data through a hash function. It is unique and irreversible. The hash value of the current timestamp is used to ensure the integrity of the timestamp data, because once the timestamp data is tampered with, its hash value will change. The hash value of the previous block connects each block into a chain structure to form a blockchain. This chain structure makes any attempt to tamper with a block data will cause the hash value of all subsequent blocks to change, making it easy to detect. For example, suppose the master clock generates a new block at the 10th second, which contains a current timestamp of 10:00:10, the hash value calculated by the hash function is "H1", and the hash value of the previous block is "H0", then the information of this new block can be expressed as .
[0142] Regional Server Verification and Resynchronization Mechanism: Regional servers use smart contracts to verify the consistency of the blockchain height. The blockchain height represents the number of blocks from the genesis block to the current block. Regional servers periodically check the blockchain height. If the height deviates by more than five blocks, a resynchronization mechanism is triggered to obtain the correct blockchain data from other nodes to ensure consistency between their recorded blockchain and the entire network. This is because a deviation in the blockchain height may indicate an error in data transmission or a malicious attack. To ensure the accuracy and consistency of time data, resynchronization is necessary. For example, suppose regional server A records a blockchain height of 100, while regional server B records a blockchain height of 106. The height deviation is six blocks, exceeding the five-block threshold. At this point, regional server B will trigger a resynchronization mechanism to obtain the correct blockchain data from other reliable nodes to ensure consistency between its recorded blockchain and the entire network.
[0143] Through this hardware collaboration and blockchain security verification mechanism, distributed industrial control systems can achieve high-precision time synchronization and reliable data security. The introduction of blockchain technology provides a reliable solution for the security verification of timestamp data, ensuring the integrity, immutability, and consistency of time data.
[0144] Preferably, the method further comprises:
[0145] S6, Adaptive synchronization cycle adjustment: including: S61, real-time monitoring of local crystal oscillator frequency deviation ; S62, when When the synchronization period is shortened from 1 hour to 10 minutes; S63, when the synchronization error is 10 times in a row When , the synchronization period is extended to 2 hours;
[0146] S7. Perform load balancing adjustment on regional clock servers: including: S71. When the number of connected terminals exceeds the preset number, the regional clock server automatically distributes the new terminal to the adjacent low-load server; S72. The regional clock servers regularly exchange load status information and dynamically adjust the terminal ownership relationship.
[0147] Preferably, the method further comprises: the Kalman filter module in step S3 adopts a square root unscented transform (SRUT) algorithm, comprising:
[0148] Based on UT transformation to process nonlinear network delay model, Sigma point is selected to approximate the probability distribution of nonlinear system;
[0149] The positive definiteness of the covariance matrix is maintained through square root decomposition, ensuring the stable operation of the Kalman filter algorithm.
[0150] The following is a detailed description:
[0151] The Kalman filter module uses the square root unscented transform (SRUT) algorithm:
[0152] In the digital clock remote metering platform, in order to more accurately handle the uncertainty and nonlinear characteristics of network delay, the Kalman filter module adopts the square root unscented transform (SRUT) algorithm, which has significant advantages in processing delay prediction in complex network environments.
[0153] Processing nonlinear network delay model based on UT transformation:
[0154] Network latency is affected by numerous factors, such as changes in network topology, fluctuations in data traffic, and signal interference, resulting in complex nonlinear characteristics. Traditional linear Kalman filtering methods struggle to accurately handle these nonlinear relationships, but the unscented transform (UT) provides an effective approach to address this problem.
[0155] The core idea of UT transformation is to approximate the probability distribution of nonlinear systems through a set of carefully selected deterministic sampling points (called Sigma points). For an n-dimensional state vector X, first, according to the mean of the state vector and covariance matrix To determine the Sigma point set The commonly used Sigma point selection methods are as follows:
[0156] in, Determines the distribution range of Sigma points around the mean (usually a small positive value such as 0.001), and k is a secondary scaling parameter (usually set to 0). Representation matrix No. Column vector.
[0157] In network delay prediction, it is assumed that the network delay state vector X contains the current delay value and delay variation rate ,Right now Here T represents the transposed symbol. For the convenience of calculation, the state vector is represented as a column vector in the Kalman filter model. The covariance matrix P reflects the uncertainty of each element of the state vector and the correlation between them. After the Sigma point set is determined by the above formula, these Sigma points are passed through the nonlinear network delay model. To spread: ;
[0158] To the Sigma point set after nonlinear transformation Then, the mean of the state vector is estimated by these transformed Sigma points and covariance matrix : ; ;
[0159] in, and are the weights used to calculate the mean and covariance, respectively. The calculation formulas are as follows:
[0160] here, is a parameter used to exploit the second-order statistics of the state variable (for Gaussian distribution, is the best choice).
[0161] Through UT transformation, the nonlinear changes of network delay can be captured more accurately. Compared with traditional linear approximation methods, the processing ability of complex network delay models is greatly improved.
[0162] The square root decomposition preserves the positive definiteness of the covariance matrix:
[0163] In the Kalman filtering process, the covariance matrix P is used to describe the uncertainty of the state estimate. The positive definiteness of the covariance matrix is a key factor in ensuring the stable operation of the Kalman filtering algorithm. If the covariance matrix loses positive definiteness, the filtering results may diverge, and the state estimate may not be accurate.
[0164] The square root unscented transform (SRUT) solves this problem by performing a square root decomposition on the covariance matrix. In the process, the square root of the covariance matrix is directly operated. Assume that S is the square root matrix of the covariance matrix P (that is, ), during the calculation of the UT transform, S is transformed accordingly instead of directly operating on P. In this way, the square root of the covariance matrix is always tracked throughout the calculation process, ensuring that the covariance matrix remains positive definite in each step of the calculation.
[0165] Specifically, when calculating the transformed covariance matrix When the square root matrix The operation is used to update the square root representation of the covariance matrix , thereby ensuring This method effectively avoids the non-positive definiteness problem of the covariance matrix that may occur in traditional Kalman filtering, and improves the stability and accuracy of the algorithm.
[0166] Example: In a large-scale smart factory scenario, a large number of terminal devices synchronize time with regional clock servers. The network environment is complex and changeable, and network latency exhibits obvious nonlinear characteristics.
[0167] Assume that the network delay state vector of one of the terminal devices at a certain moment is , mean (Unit: milliseconds and milliseconds / second, representing the current delay value and delay change rate respectively), covariance matrix .
[0168] First, calculate the Sigma point set according to the UT transformation. , calculated .
[0169]
[0170] Assume that the nonlinear network delay model is , propagate the Sigma point set through the model:
[0171] Compute the mean and covariance:
[0172] ;
[0173]
[0174]
[0175]
[0176] ;
[0177] In this process, the positive definiteness of the covariance matrix is maintained through square root decomposition, ensuring that the Kalman filter algorithm can operate stably under complex nonlinear network delay models, accurately predict network delays, and provide strong support for high-precision time synchronization between terminal devices and regional clock servers.
[0178] Preferably, the method further includes: fault diagnosis and recovery: quickly locating the fault location and performing corresponding fault recovery through hierarchical fault monitoring and diagnosis.
[0179] Terminal device fault monitoring: Terminal devices monitor their operating status in real time, including clock oscillator frequency stability, network connection status, and time synchronization error. Built-in sensors and monitoring programs collect relevant data at regular intervals (e.g., 1 minute). The time synchronization error is calculated as the difference between the terminal device's local time and the reference time obtained through the synchronization algorithm. If this error exceeds a set threshold (e.g., 50 μs) multiple times (e.g., five times) in a row, the device is flagged as a possible fault.
[0180] Regional clock server fault monitoring: A regional clock server monitors its own load, network bandwidth utilization, and connection status with the master clock source. For example, it monitors CPU usage and memory utilization to determine whether the server load is excessive. It also checks the time synchronization accuracy with the master clock source. If the time deviation from the master clock source exceeds a certain range (e.g., 100 μs), there may be a connection failure with the master clock source or a problem with its own clock calibration.
[0181] Master clock source fault monitoring: Master clock source monitoring primarily focuses on the operating status of atomic clocks or satellite timing systems. For atomic clocks, frequency stability and output signal strength are monitored; for satellite timing systems, satellite signal reception quality and the number of satellites are monitored. If the atomic clock's frequency deviation exceeds a certain percentage of its nominal accuracy (e.g., 10%), or if the satellite timing system loses signals from multiple satellites (e.g., three or more) for a period exceeding a certain duration (e.g., five minutes), the master clock source may be faulty.
[0182] Troubleshooting:
[0183] Terminal device fault diagnosis: When a terminal device detects a possible fault, it first performs a self-test. It checks whether the clock oscillator is functioning properly by comparing the current frequency with the nominal frequency. It also checks whether the network connection is stable by sending and receiving test packets to measure the packet loss rate and round-trip latency. If the packet loss rate is excessively high (e.g., exceeding 10%) or the round-trip latency is abnormally high (e.g., exceeding twice the normal average), a network connection failure may be the cause. If the self-test finds no issues, but the time synchronization error remains significant, a fault report is sent to the regional clock server for further diagnosis.
[0184] Regional clock server fault diagnosis: When a regional clock server detects a potential fault, first check the connection line and communication protocol to the master clock source. Check the status of the network interface to see if there are any line interruptions or communication protocol misconfigurations. Analyze its load. If the load is too high, check for abnormal processes or services that are consuming a large amount of resources. Use system monitoring tools to view the CPU and memory usage of each process. For communication issues with terminal devices, check the terminal device's connection history and time synchronization data to determine whether it is a problem with a specific terminal device or a widespread communication failure.
[0185] Master clock source fault diagnosis: If the master clock source shows signs of failure, first check the atomic clock or satellite timing system hardware. For atomic clocks, check hardware parameters such as power supply and temperature control. For satellite timing systems, check the correct antenna installation position and orientation. Analyze the satellite timing system log files to check for abnormal satellite signal reception, such as frequent signal loss or abnormal signal strength.
[0186] Fault recovery:
[0187] Terminal device fault recovery: If the clock oscillator fails, the terminal device automatically adjusts the clock frequency. By adjusting the oscillator's control voltage or other parameters, the frequency returns to near the nominal value. If the network connection fails, the terminal device attempts to reconnect to the network. This can be achieved by switching the network interface (for example, from 5G to Industrial Ethernet) or reconfiguring network parameters. If the fault persists, the terminal device sends a fault recovery request to the regional clock server, which can provide further configuration guidance or reassign the terminal device's synchronization source.
[0188] Regional clock server failure recovery: If the connection to the master clock source fails, the regional clock server attempts to reestablish the connection. This can be done by restarting the network interface, reconfiguring the communication protocol, or other means. If the failure is caused by excessive load, the regional clock server can shut down unnecessary processes or services to free up system resources. Simultaneously, it can migrate some terminal devices to other, less-loaded regional clock servers. If the failure is severe and cannot be self-recovered, the regional clock server sends an alert to the system administrator, awaiting manual intervention.
[0189] Master clock source failure recovery: If the atomic clock is faulty, try restarting the atomic clock. After restarting, perform calibration to restore its frequency to its correct value. If the satellite timing system is faulty, adjust the antenna's position and orientation to improve satellite signal reception. If this still doesn't resolve the issue, switch to a backup satellite timing system or other time reference source.
[0190] Preferably, in the construction and application of a digital clock remote metering platform, performance evaluation and optimization are key steps to ensure efficient and stable system operation and achieve high-precision time synchronization. Through comprehensive monitoring, scientific evaluation, and targeted optimization of platform performance, the system's performance can be continuously improved to meet the needs of different application scenarios. The method also includes: performance evaluation and optimization: This includes monitoring performance indicators, comparing performance indicators with traditional time synchronization systems in the same network environment and application scenarios, and building a simulated network environment for simulation testing to evaluate platform performance under different conditions; and providing corresponding performance optimization strategies based on the evaluation results.
[0191] The performance indicators include time synchronization accuracy, network latency, and system throughput:
[0192] Time synchronization accuracy measurement method: Regularly measuring the time synchronization error between the terminal device and the master clock source is an important means of evaluating the system time synchronization performance. The specific operation is to record the timestamp of a specific event on the terminal device and the master clock source at the same time. For example, at a certain moment, a precise pulse signal is triggered, and the terminal device and the master clock source simultaneously record the time when the pulse signal arrives, which are recorded as and , then the time synchronization error .
[0193] In order to have a more comprehensive understanding of the stability and accuracy of time synchronization, it is necessary to count the time synchronization errors in different time periods. Assuming that in one day, the time synchronization error data is measured every hour, and a total of 24 time periods are obtained. By calculating the average value of these data , maximum value and minimum value , can be used to quantitatively evaluate the time synchronization performance. Average value (n is the number of measurements, here ) reflects the overall level of time synchronization error; the maximum Can reveal the time synchronization deviation under the most unfavorable conditions; minimum This demonstrates the time synchronization accuracy of the system under optimal conditions.
[0194] Network delay measurement method: Network delay is one of the key factors affecting time synchronization accuracy. It is necessary to monitor the network delay between the terminal device and the regional clock server, and between the regional clock server and the master clock source. The network delay is measured by sending a test data packet and recording the round-trip time. Assume that the terminal device sends a test data packet to the regional clock server at the time of sending. , the time of the data packet returned by the receiving regional clock server is , the round-trip delay between the terminal device and the regional clock server is .
[0195] Analyzing the changing trend of network delay is crucial for evaluating network stability. In addition to calculating the average delay , we also need to calculate the standard deviation and jitter. Average value (m is the number of measurements) reflects the average level of network delay; standard deviation It is used to measure the dispersion of network delay. The larger the standard deviation, the greater the fluctuation of network delay. Jitter refers to the maximum absolute value of the delay difference between two adjacent measurements. The larger the jitter, the worse the network stability.
[0196] System throughput monitoring indicators: System throughput is used to evaluate the processing capacity and load of regional clock servers and master clock sources. System throughput is measured by counting the number of time synchronization requests and data transmission volume processed by regional clock servers and master clock sources per unit time. For example, in one hour, the number of time synchronization requests received and processed by the regional clock server is The total amount of data transmitted is (unit is bytes), the throughput of the regional clock server in that hour can be expressed as the request processing rate (Unit: times / second) and data transmission rate (Unit: bytes / second).
[0197] Comparative test:
[0198] Testing Process: Comparing this digital clock remote metering platform with other traditional time synchronization systems is an effective way to evaluate the platform's performance strengths and weaknesses. This platform and a traditional time synchronization system were run simultaneously under the same network environment (e.g., network topology, bandwidth limitations, packet loss rate, etc.) and application scenario (e.g., the time synchronization requirements for production equipment in a large smart factory). Performance indicators such as time synchronization accuracy, network latency, and system throughput were measured and recorded for each. Simulation Test:
[0199] Environment Construction: Building a simulated network environment can simulate different network conditions and load scenarios, allowing for a comprehensive evaluation of the platform's performance under various complex scenarios. For example, network simulation software can be used to set different bandwidths (e.g., 10Mbps, 100Mbps, 1000Mbps), packet loss rates (e.g., 1%, 5%, 10%), and jitter (e.g., 1ms, 5ms, 10ms), as well as different numbers of terminal devices (e.g., 100, 500, 1000) connected to the regional clock server.
[0200] Example: In a large smart factory, a digital clock remote measurement platform was deployed for time synchronization of production equipment. During the performance indicator monitoring phase, 100 representative terminal production equipment were selected and their time synchronization errors with the master clock source were measured every 15 minutes. After one day of monitoring, the average synchronization error was calculated to be , the maximum value is , the minimum value is At the same time, by sending test data packets, the network delay between the terminal device and the regional clock server was measured. In 100 measurements, the average round-trip delay was 11ms, the standard deviation was 3ms, and the maximum jitter was 5ms. Within one hour, the regional clock server processed a total of 36,000 time synchronization requests, with a data transmission volume of 180MB. The calculated request processing rate was 10 times / second and the data transmission rate was 500KB / s. During the performance evaluation phase, a comparative test was conducted. This platform and the traditional time synchronization system previously used by the factory were run simultaneously in the same production workshop network environment. The results showed that the average synchronization error of the traditional system was , the maximum value is The average round-trip delay is 18ms, with a standard deviation of 7ms. The regional clock server processes 700 time synchronization requests per second, with a data transmission rate of 350KB / s. During the simulation test, a simulation environment with a network bandwidth of 50Mbps, a packet loss rate of 8%, and a jitter of 8ms was built, with 800 terminal devices connected. In this environment, the average time synchronization error of this platform increased to The average round-trip delay is 15ms, the regional clock server can process 850 time synchronization requests per second, and the data transmission rate is 420KB / s.
[0201] Based on the performance evaluation results, the performance is optimized. For example, the parameters of the Kalman filter algorithm can be adjusted according to the results, such as The matrix is adjusted to , The value is adjusted to 0.003, the number of neurons in the hidden layer of the LSTM neural network is increased to 200, and the learning rate is adjusted to 0.0008.
[0202] The terminal devices were replaced with higher-precision clock oscillators, and the regional clock servers were upgraded to 16GB of memory and eight-core CPUs. The regional clock servers were also relocated, reducing network hops. Flow control and the RED congestion avoidance algorithm were implemented, significantly improving system performance.
[0203] In summary, the advantages of the present invention are as follows:
[0204] The architecture utilizes a layered synchronization structure, where regional clock servers serve as intermediate nodes, receiving the reference time from the master clock source and forwarding it to the end devices. Furthermore, these servers process and manage time synchronization requests from end devices, reducing the burden on the master clock source. End devices only need to communicate with the regional clock server in their area, significantly reducing communication distance and latency, and improving the efficiency and accuracy of time synchronization.
[0205] In terms of the core time synchronization algorithm, a two-way timestamp interaction and message filtering mechanism, combined with the NTP protocol, enables efficient time information exchange between terminal devices and regional clock servers. By filtering three groups of messages with the minimum RTT and performing an average calculation, anomalies are effectively removed, resulting in a more accurate round-trip delay. This provides a reliable data foundation for subsequent time synchronization calculations, significantly improving time synchronization accuracy.
[0206] The hybrid delay compensation algorithm is one of the key points of the present invention. It integrates Kalman filtering and LSTM neural network. The Kalman filter dynamically adjusts the Q / R matrix based on historical RTT data to accurately track short-term delay changes; the LSTM neural network learns the historical 24-hour delay sequence, network status parameters and Kalman residual terms to predict long-term delay trends. Fuzzy logic is then used to dynamically allocate the weights of the two according to the real-time network status to calculate the final delay compensation value. This algorithm can accurately predict and compensate for network delays. In complex network environments, it can effectively deal with the uncertainty and nonlinearity of network delays, greatly improve time synchronization accuracy, and meet application scenarios with demanding requirements for time accuracy.
[0207] The time selection algorithm calculates the filtering deviation and synchronization distance, selects the top three optimal sources from multiple time reference sources, and performs weighted averaging to ensure a reliable time reference for time synchronization, further enhancing the reliability and stability of the system.
[0208] In terms of hardware and security, the terminal device integrates a dedicated timestamp chip. A 100MHz temperature-compensated crystal oscillator drives a counter to provide precise timing. A nanosecond-level precision hardware timestamp is automatically inserted at the MAC layer to reduce software processing latency. An on-chip cache stores timestamp data for Kalman filter preprocessing, improving filtering efficiency and accuracy. Furthermore, leveraging blockchain technology, the master clock writes the timestamp hash value to the blockchain. Regional servers verify data integrity and blockchain continuity through Merkle proofs and smart contracts, effectively preventing data tampering and ensuring the security and reliability of time data.
[0209] In addition, the present invention also features mechanisms such as adaptive synchronization period adjustment, regional clock server load balancing, fault diagnosis and recovery, and performance evaluation and optimization. Adaptive synchronization period adjustment dynamically optimizes the synchronization period based on the local crystal oscillator frequency deviation and time synchronization accuracy, balancing time synchronization accuracy with network resource consumption. Regional clock server load balancing ensures uniform server load and improves system stability. The fault diagnosis and recovery mechanism monitors device status in real time, quickly discovers and resolves faults, and reduces system downtime. The performance evaluation and optimization mechanism continuously improves overall system performance by monitoring performance indicators and optimizing algorithms, hardware, and networks.
[0210] Although the specific embodiments of the present invention are described above, those skilled in the art should understand that the specific embodiments described are merely illustrative and are not intended to limit the scope of the present invention. Equivalent modifications and changes made by those skilled in the art in accordance with the spirit of the present invention should be included within the scope of protection of the claims of the present invention.
Claims
1. A digital clock remote measurement method based on network delay suppression, characterized by: The following steps are involved: S1. Build a hierarchical synchronization architecture, deploying a master clock source, multiple regional clock servers, and multiple terminal devices. The multiple regional clock servers are connected to the master clock source via dedicated optical fiber lines to obtain reference time. Each regional clock server is connected to multiple terminal devices via 5G / Industrial Ethernet, forming a three-level synchronization network. S2. Obtain RTT data between the terminal device and a regional server through two-way timestamp interaction, filter messages according to preset rules, and retain reliable RTT data as historical data; S3, use the hybrid delay compensation algorithm to calculate the final delay compensation value, process the historical RTT data through the Kalman filter module, and output the short-term compensation value , and predict the long-term compensation value by learning the historical 24-hour delay sequence, network state parameters and Kalman residual terms through the LSTM neural network module , then dynamically assigning weights of the two compensation values according to the real-time network status through fuzzy logic to obtain a final delay compensation value, and using the final delay compensation value to calibrate the terminal clock; S4, using a time selection algorithm to obtain the optimal reference source for data synchronization analysis; The method further includes: S5, the terminal device uses a dedicated timestamp chip, the dedicated timestamp chip includes a counter driven by a 100 MHz temperature-compensated crystal oscillator, a hardware timestamp marking unit for inserting a timestamp into an IEEE802.3 frame header, and an on-chip cache, the on-chip cache storing the most recent 100 timestamp data for Kalman filter preprocessing; The specific process of blockchain security verification includes: generating a new block on the master clock: the master clock generates a new block every 10 seconds. The new block contains the hash value of the current timestamp and the hash value of the previous block. The hash value of the current timestamp is used to ensure the integrity of the timestamp data, and the hash value of the previous block connects each block into a chain structure to form a blockchain; regional server verification and resynchronization mechanism: the regional server verifies the height continuity of the blockchain through smart contracts. If the deviation of the blockchain height exceeds 5 blocks, the resynchronization mechanism is triggered to obtain the correct blockchain data from other nodes to ensure the consistency of the blockchain recorded by itself with the entire network; S6, Adaptive synchronization cycle adjustment: including: S61, real-time monitoring of local crystal oscillator frequency deviation ; S62, when When the synchronization period is shortened from 1 hour to 10 minutes; S63, when the synchronization error is 10 times in a row When , the synchronization period is extended to 2 hours; S7. Perform load balancing adjustment on regional clock servers: including: S71. When the number of connected terminals exceeds the preset number, the regional clock server automatically distributes the new terminal to the adjacent low-load server; S72. The regional clock servers regularly exchange load status information and dynamically adjust the terminal ownership relationship.
2. A digital clock remote measurement method based on network delay suppression according to claim 1, characterized in that: The master clock source adopts an atomic clock or a satellite timing system to provide a reference time.
3. The digital clock remote measurement method based on network delay suppression according to claim 1, characterized in that: The step S2 further comprises: S21. The terminal device sends an NTP request message to the regional clock server connected to it, carrying the local timestamp. ; S22. After receiving the request, the regional clock server generates a response message including the reference time and appends network status parameters; S23. The terminal device receives the response message and records the local time , calculate the round trip delay , filter packets according to the following rules: If the RTT of a group of packets exceeds the average , then it will be eliminated, and the three groups of messages with the smallest RTT standard deviation will be selected, and then the RTT of the three filtered groups of messages will be averaged as the final reliable RTT data; , standard deviation m is the number of measurements.
4. The digital clock remote measurement method based on network delay suppression according to claim 1, characterized in that: The step S3 specifically includes: Step S31: Set the state transition equation of the Kalman filter module to: ; The observation equation is: ; In network delay prediction, X(k) is the delay state vector at time k, expressed as [delay value, delay change rate], F(k) is the state transition matrix, and , is the time interval, which is consistent with the time resolution of data acquisition. This matrix indicates that the delay at the current moment is equal to the delay at the previous moment plus the delay change rate multiplied by the time interval; B(k) is the control input matrix, U(k) is the control input vector, and when there is no external control factor, B(k) is set to a zero matrix and U(k) is set to a zero vector. W(k) is the process noise vector, which is used to represent the unpredictable noise interference in the system. Its mean is zero and its covariance matrix is Q(k); Z(k) is the observation vector at time k, that is, the round-trip delay RTT actually measured, and H(k) is the observation matrix, and , this matrix indicates that the observation vector is equal to the time delay value in the system state vector, V(k) is the observation noise vector, its mean is zero, and its covariance matrix is R(k); Dynamically adjust the Q / R matrix, where the process noise covariance matrix The adjustment method is: ,in is the initial process noise covariance matrix, and its value is determined according to the prior knowledge of the network. is the current packet loss rate; the observation noise covariance matrix The adjustment method is: ,in is the initial observation noise covariance matrix, is the current jitter; Through the iterative Kalman filter algorithm, the system state is predicted and updated using the state transfer equation and observation equation, and finally the short-term delay compensation value is obtained. ; Step S32: Set the input layer, hidden layer, and output layer of the LSTM neural network module; the input layer is used to receive input data, including the historical 24-hour delay sequence, the current network status information, and the Kalman filter residual term, to fully reflect the network status and historical delay information; the hidden layer is used to capture the long-term dependencies in the time series data, and predict and control the information output based on the long-term rules; the output layer is used to predict the delay changes in the future period based on the output results of the hidden layer, and output the long-term delay compensation value , used to reflect the long-term trend of network latency; Step S33: Dynamically adjust the short-term delay compensation value according to the real-time status of the network and long-term delay compensation value Weight in delay compensation: Real-time monitoring of network status: Obtain network packet loss rate in real time through network monitoring tools , bandwidth utilization and jitter parameter; Formulate fuzzy logic rules: When When setting the weights of the LSTM neural network , reduce the weight of the Kalman filter algorithm ;when and When setting the weight of the Kalman filter algorithm , reduce the weight of the LSTM neural network ; When the above two conditions are not met, the linear interpolation method is used to dynamically adjust and The value of Calculate the final delay compensation value based on the dynamically adjusted weight: ; The terminal clock is calibrated using the final delay compensation value.
5. The digital clock remote measurement method based on network delay suppression according to claim 1, characterized in that: The step S4 specifically includes the following: Step S41: Calculate the filtering deviation and synchronization distance of different time reference sources: Filter dispersion It is used to measure the discreteness of the time reference source. Its calculation formula is: ,in, Representative The time of the time reference source, is the average of all time reference source times, Indicates the number of time reference sources; Synchronous distance It is used to intuitively represent the degree of difference between each time reference source and the average time. The calculation formula is: ; Step S42: Filter the time reference source: Setting the Crossing Threshold ; Eliminate abnormal time reference source: synchronize distance Time reference source elimination; Select the best time reference source: select the top three best sources from the remaining time reference sources; Calculate the final time reference value: Take the weighted average of the times of the three optimal sources to obtain the final time reference value for data synchronization analysis.
6. The digital clock remote measurement method based on network delay suppression according to claim 1, characterized in that: The Kalman filter module in step S3 adopts the square root unscented transform (SRUT) algorithm, processes the nonlinear network delay model based on the UT transform, selects the Sigma point to approximate the nonlinear system probability distribution, and maintains the positive definiteness of the covariance matrix through square root decomposition to ensure the stable operation of the Kalman filter algorithm, as follows: The probability distribution of the nonlinear system is approximated by a set of deterministic sampling points Sigma. For an n-dimensional state vector X, first, the mean of the state vector is And covariance matrix P to determine the Sigma point set , where the Sigma point selection method is as follows: ; in, , Determines the distribution range of Sigma points around the mean, takes a positive value, and k is a secondary scaling parameter. Representation matrix No. column vector; After determining the Sigma point set through the above formula, these Sigma points are passed through the nonlinear network delay model. Propagate and obtain the Sigma point set after nonlinear transformation : ; Then, the mean of the state vector is estimated by these transformed Sigma points and covariance matrix : ; ; in, and are the weights used to calculate the mean and covariance, respectively. The calculation formulas are as follows: ; ; ; in, is a parameter used to exploit the second-order statistical information of the state variables; Calculate the covariance matrix in UT transformation In the process of , the square root of the covariance matrix is directly operated. Assuming that S is the square root matrix of the covariance matrix P, in the calculation process of UT transformation, S is transformed accordingly instead of directly operating P. Specifically, in the calculation of the transformed covariance matrix When , the square root representation of the covariance matrix is updated by operating the square root matrix S , thereby ensuring It always maintains positive definiteness to avoid the non-positive definiteness problem of the covariance matrix that may occur in traditional Kalman filtering, thereby improving the stability and accuracy of the algorithm.
7. The digital clock remote measurement method based on network delay suppression according to claim 1, characterized in that: The method further includes: fault diagnosis and recovery: quickly locating the fault location and performing corresponding fault recovery through hierarchical fault monitoring and diagnosis.
8. The digital clock remote measurement method based on network delay suppression according to claim 1, characterized in that: The method also includes: performance evaluation and optimization: including monitoring performance indicators, comparing performance indicators with traditional time synchronization systems under the same network environment and application scenarios, and building a simulated network environment for simulation testing to evaluate platform performance under different conditions; and providing corresponding performance optimization strategies based on the evaluation results.
Citation Information
Patent Citations
Accurate clock synchronization parameter tracking method based on augmented Kalman neural network
CN119254373A
Timestamp-free synchronization clock parameter tracking method based on extended kalman filter
US20240201728A1