Network Time Synchronization Optimization Method, System, Readable Storage Medium and Computer
By applying Kalman filtering technology under the AUTOSAR architecture, the time deviation of the master clock and slave clock is optimized, and the synchronization accuracy problem of traditional methods under complex network conditions is solved, and high-precision time synchronization and collaborative work of the vehicle internal system is achieved.
Patent Information
- Application Number
- CN202411397222.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-09
- Publication Date
- 2025-07-25
- Estimated Expiration
- 2044-10-09
AI Technical Summary
Traditional time synchronization methods cannot meet the high-precision requirements under complex network conditions, especially when there is network jitter or instability, the synchronization accuracy under the AUTOSAR architecture is low and cannot meet the needs of real-time communication.
Using Kalman filtering technology, by constructing observation models and state space algorithms, the time deviation between the master clock and the slave clock is optimized, the Kalman filter is used to estimate the state of the slave clock and compensate for the clock deviation, optimize the clock model and reduce the time deviation.
It improves the accuracy and stability of time synchronization, realizes the collaborative work of the intelligent system inside the vehicle, and meets the high standard requirements of real-time communication.
Smart Images

Figure CN118890685B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of vehicle communication, and particularly relates to a method and system for optimizing network time synchronization, a readable storage medium, and a computer. Background Art
[0002] With the rapid development of the automotive industry and industrial control, the deep integration of computer network technology and automatic control technology has brought innovative products to emerging technical fields. Among them, in-vehicle networks are gradually becoming an expanding field. While the automotive industry is continuously moving towards intelligent development, various advanced in-vehicle applications such as navigation systems, safety systems, multimedia entertainment, and driverless driving are emerging in an endless stream, posing more complex and high-standard requirements for network reliability, bandwidth, and synchronization performance.
[0003] The rapid development of automotive electronic systems has brought increasingly complex software requirements and interconnectivity challenges. To meet this challenge, the automotive industry has quickly realized the need for an open and standardized software architecture to achieve the reusability and interoperability of automotive electronic systems. Against this background, the Automotive Open System Architecture (AUTOSAR) emerged.
[0004] The introduction of AUTOSAR has brought about a revolution in the development and integration of automotive electronic systems. By providing consistent standards and specifications, the AUTOSAR architecture enables automotive manufacturers and electronic system suppliers to more effectively design, deploy, and update software functions in vehicles. This standardized approach helps reduce development costs, improve software maintainability, and support the seamless integration of software components from different suppliers.
[0005] With the rapid development of the automotive industry and industrial control, the deep integration of computer network technology and automatic control technology has brought innovative products to emerging technical fields. Among them, in-vehicle networks are gradually becoming an expanding field. While the automotive industry is continuously moving towards intelligent development, various advanced in-vehicle applications such as navigation systems, safety systems, multimedia entertainment, and driverless driving are emerging in an endless stream, posing more complex and high-standard requirements for network reliability, bandwidth, and synchronization performance. Along with the continuous emergence of these innovative applications, the demand for key indicators such as data transmission, latency, and packet loss in real-time data transmission applications (such as multi-axis synchronization, transportation industry, etc.) is also becoming increasingly urgent. To improve the interoperability, configuration flexibility, and monitoring capabilities of real-time Ethernet to better meet these demands, Time-Sensitive Networking (TSN) emerged and is continuously evolving in rapid development.
[0006] Time-Sensitive Networking (TSN) is an extension of Ethernet standards, aiming to support real-time and time-sensitive applications, especially in the industrial and automotive fields. TSN provides precise clock synchronization, low latency, and high reliability for network communication by introducing a series of standards and mechanisms, thus meeting the requirements of real-time communication.
[0007] In this dynamic automotive electronics environment, the introduction of Time-Sensitive Networking (TSN) has become an important part of ensuring precise communication between various subsystems. The AUTOSAR architecture provides an ideal platform, making it possible to integrate the TSN time synchronization system and providing a more efficient and precise time synchronization solution for automotive electronic systems.
[0008] Traditional time synchronization methods, such as some mechanisms in the network protocol stack, may face the problem of not meeting high-precision requirements under complex network conditions. For example, in the presence of network jitter or instability, traditional methods may not provide sufficient synchronization accuracy. The main reasons for the low synchronization accuracy under the AUTOSAR architecture lie in the multi-layer calls and interactions between modules, fixed scheduling and execution order, standardized limiting conditions, and the complexity of the clock synchronization mechanism. Summary of the Invention
[0009] Based on this, the object of the present invention is to provide a network time synchronization optimization method, system, readable storage medium, and computer to at least solve the deficiencies in the above technologies.
[0010] The present invention proposes a network time synchronization optimization method applied to a time-sensitive network, where the time-sensitive network includes a master clock and a slave clock. The method includes:
[0011] Obtain the sampling time of the time deviation between the master clock and the slave clock, as well as the true value and the measured value of the clock deviation at the sampling moments within the sampling time, and construct a corresponding observation model according to the true value and the measured value of the clock deviation;
[0012] Obtain the clock frequency of the master clock and the clock frequency of the slave clock at the sampling moments, and calculate the time frequency drift rate of the slave clock according to the clock frequency of the master clock;
[0013] Construct a data relationship between the true value of the clock deviation, the clock frequency of the slave clock, and the time frequency drift rate of the slave clock according to the observation model and the time frequency drift rate of the slave clock;
[0014] Define the true value of the clock deviation and the frequency drift rate at the moment after the sampling moment, and construct a Kalman standard state space algorithm according to the true value of the clock deviation and the frequency drift rate at the moment after the sampling moment and the data relationship;
[0015] Filter the time deviation according to the state space algorithm, and update the state at the moment after the sampling moment based on the filtering result to reduce the time deviation between the master clock and the slave clock.
[0016] Further, the steps of obtaining the sampling time of the time deviation between the master clock and the slave clock, the true value and the measured value of the clock deviation at the sampling moment within the sampling time, and constructing a corresponding observation model according to the true value and the measured value of the clock deviation include:
[0017] Define the sampling time of the time deviation between the master clock and the slave clock as , so as to represent the true value of the clock deviation at the sampling moment within the sampling time , and use to represent the measured value of the time deviation at the sampling moment . Construct an observation model according to the true value of the clock deviation and the measured value :
[0018] ;
[0019] In the formula, represents the measurement error. If the measurement error conforms to a normal distribution, its mean is 0 and the variance is white noise.
[0020] Further, the calculation formula for the time frequency drift rate of the slave clock is:
[0021] ;
[0022] In the formula, represents the normal drift of the clock frequency of the slave clock at the sampling moment, and is the random drift of the clock frequency , with a variance of white noise.
[0023] Further, the expression of the data relationship between the true value of the clock deviation, the clock frequency of the slave clock, and the time frequency drift rate of the slave clock is:
[0024] Formula (1): ;
[0025] Formula (2): ;
[0026] In the formula, is the initial value of the clock deviation, is the initial value of the frequency;
[0027] Discretize the formula (1) and formula (2) to obtain the following expressions:
[0028] .
[0029] Furthermore, the calculation formula of the Kalman standard state space algorithm is:
[0030] ;
[0031] Wherein, ;
[0032] In the formula, is the true value of the clock deviation and the frequency drift at the next moment after the sampling moment , is the observation signal corresponding to the state, and the state transition matrix is , the control matrix and the noise drive matrix are , , and the observation matrix is .
[0033] Furthermore, the steps of filtering the time deviation according to the state space algorithm and updating the state at the next moment after the sampling moment based on the filtering result to reduce the time deviation between the master clock and the slave clock include:
[0034] Predict the state at the sampling moment :
[0035] ;
[0036] In the formula, is the prior state prediction at the next moment after the sampling moment ; is the prior estimation covariance; is the posterior state prediction at the sampling moment ; is the posterior estimation covariance, which is calculated according to the posterior state prediction at the next moment after the sampling moment , the posterior estimation covariance and the prior state prediction and prior estimation covariance at the sampling moment , and is the optimal solution at the sampling moment ; is the control quantity at the sampling moment , ; is the process noise covariance matrix, ;
[0037] Update the state at the sampling moment :
[0038] ;
[0039] ;
[0040] In the formula, represents the Kalman gain at the next moment after the sampling moment , which depends on the measurement noise covariance related to the measurement device ; ; represents the posterior state prediction at the next moment after the sampling moment , represents the posterior estimation covariance, which is the optimal prediction at the next moment after the sampling moment .
[0041] The present invention also proposes a network time synchronization optimization system, which is applied to a time-sensitive network. The time-sensitive network includes a master clock and a slave clock. The system includes:
[0042] A model construction module, configured to obtain the sampling time of the time deviation between the master clock and the slave clock, and the true value and the measured value of the clock deviation at the sampling moment within the sampling time, and construct a corresponding observation model according to the true value of the clock deviation and the measured value;
[0043] A drift rate calculation module, configured to obtain the clock frequency of the master clock and the clock frequency of the slave clock at the sampling moment, and calculate the time frequency drift rate of the slave clock according to the clock frequency of the master clock;
[0044] A relationship construction module, configured to construct a data relationship between the true value of the clock deviation, the clock frequency of the slave clock, and the time frequency drift rate of the slave clock according to the observation model and the time frequency drift rate of the slave clock;
[0045] An algorithm construction module, configured to define the true value of the clock deviation and the frequency drift rate at the next moment of the sampling moment, and construct a state space algorithm of the Kalman standard according to the true value of the clock deviation and the frequency drift rate at the next moment of the sampling moment and the data relationship;
[0046] A status update module, configured to filter the time deviation according to the status space algorithm, and update the status at the moment after the sampling moment based on the result of the filtering process, so as to reduce the time deviation between the master clock and the slave clock.
[0047] The present invention also provides a readable storage medium, on which a computer program is stored, and when the program is executed by a processor, the above-mentioned network time synchronization optimization method is implemented.
[0048] The present invention also provides a computer, including a memory, a processor, and a computer program stored on the memory and executable on the processor, and when the processor executes the computer program, the above-mentioned network time synchronization optimization method is implemented.
[0049] In the network time synchronization optimization method, system, readable storage medium and computer of the present invention, by using Kalman filtering for estimation, in the context of clock synchronization, the Kalman filter compares the observed values of the master clock and the slave clock, accurately estimates the state of the slave clock, compensates for the clock deviation by optimizing the clock model, and at the same time optimizes the clock model, reduces the time deviation between the master clock and the slave clock, thereby improving the drift behavior of the slave clock. By utilizing the application of each node in the TSN network in the AUTOSAR architecture, a unified time synchronization scheme can be provided for in-vehicle electronic systems, so as to realize the collaborative work between various intelligent systems inside the vehicle. Description of the Drawings
[0050] Figure 1 It is a flowchart of the network time synchronization optimization method in the first embodiment of the present invention;
[0051] Figure 2 It is a schematic diagram of the AUTOSAR hierarchical architecture and the time synchronization protocol stack principle in the first embodiment of the present invention;
[0052] Figure 3 It is a schematic diagram of the time synchronization process principle in the first embodiment of the present invention;
[0053] Figure 4 It is a schematic diagram of the path link delay measurement principle in the first embodiment of the present invention;
[0054] Figure 5 It is a schematic diagram of the Kalman filtering process principle in the first embodiment of the present invention;
[0055] Figure 6 It is a comparison diagram of the Kalman filtering test results in the first embodiment of the present invention;
[0056] Figure 7 It is a structural block diagram of the network time synchronization optimization system in the second embodiment of the present invention;
[0057] Figure 8 The structural block diagram of the computer in the third embodiment of the present invention.
[0058] The following specific embodiments will further illustrate the present invention in conjunction with the above-mentioned drawings. Specific Embodiments
[0059] To facilitate the understanding of the present invention, the present invention will be described more comprehensively below with reference to the relevant drawings. Several embodiments of the present invention are given in the drawings. However, the present invention can be implemented in many different forms and is not limited to the embodiments described herein. On the contrary, these embodiments are provided to make the disclosure of the present invention more thorough and comprehensive.
[0060] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by those of ordinary skill in the technical field to which the present invention belongs. The terms used herein in the specification of the present invention are only for the purpose of describing specific embodiments and are not intended to limit the present invention. The term "and / or" used herein includes any and all combinations of one or more of the related listed items.
[0061] Embodiment 1
[0062] Please refer to Figure 1 , which shows the network time synchronization optimization method in the first embodiment of the present invention, applied to a time-sensitive network. The time-sensitive network includes a master clock and a slave clock. The method specifically includes steps S101 to S105:
[0063] S101, obtain the sampling time of the time deviation between the master clock and the slave clock, and the true value and the measured value of the clock deviation at the sampling moment within the sampling time, and construct a corresponding observation model according to the true value and the measured value of the clock deviation;
[0064] In specific implementation, due to the aging problem of the crystal oscillator and the influence of the ambient temperature, the clock drift is not constant. The main reasons for clock errors are clock stamps and delay jitters, that is, time offsets and time offset rates.
[0065] To improve the timestamp accuracy of TSN time synchronization nodes and reduce delay jitters, and to adjust the node clocks to make the clocks of each node as consistent as possible, a time synchronization scheme based on Kalman filtering is adopted. By performing Kalman filtering on the clock offset and the clock offset rate, the local clock is adjusted to make its clock synchronization more accurate.
[0066] Define the sampling time of the time deviation between the master clock and the slave clock as , with representing the sampling moment within the sampling time The true value of the clock deviation at is denoted as, at the sampling moment the measured value of the time deviation at According to the true value of the clock deviation and the measured value
[0067] ;
[0068] In the formula, represents the measurement error. If the measurement error follows a normal distribution, its mean is 0 and the variance is white noise, and this variance can be obtained from test data using statistical principles.
[0069] S102. Obtain the clock frequency of the master clock and the clock frequency of the slave clock at the sampling moment, and calculate the time frequency drift rate of the slave clock according to the clock frequency of the master clock;
[0070] In specific implementation, define the clock frequency of the master clock as and there is no noise influence, that is, the clock frequency of the master clock remains unchanged. Denote as the clock frequency of the slave node at moment, as the frequency drift rate of the slave node. The calculation formula for the time frequency drift rate of the slave clock is:
[0071] ;
[0072] In the formula, represents the normal drift of the clock frequency of the slave clock at the sampling moment , affected by external environments such as temperature and crystal oscillator aging, is the random drift of the clock frequency which is white noise with zero mean and variance in this embodiment. Under normal working conditions, within a certain similar period of time, can be regarded as a constant value.
[0073] S103. Construct the data relationship among the true value of the clock deviation, the clock frequency of the slave clock, and the time frequency drift rate of the slave clock according to the observation model and the time frequency drift rate of the slave clock;
[0074] In specific implementation, based on the above analysis, the expression of the data relationship among the true value of the clock deviation, the clock frequency of the slave clock, and the time frequency drift rate of the slave clock is:
[0075] Formula (1): ;
[0076] Formula (2): ;
[0077] Wherein, is the initial value of the clock deviation, is the initial value of the frequency;
[0078] Discretize the said Formula (1) and Formula (2) to obtain the following expressions:
[0079] .
[0080] S104. Define the true value of the clock deviation and the frequency drift rate at the moment after the sampling moment, and construct a Kalman standard state space algorithm according to the true value of the clock deviation and the frequency drift rate at the moment after the sampling moment and the said data relationship;
[0081] In specific implementation, define at the moment after the sampling moment the system state at is the true value of the clock deviation and the frequency drift, is the observation signal corresponding to the state, the state transition matrix is , the control quantity matrix and the noise drive matrix are , , the observation matrix is , and the Kalman standard state space equation can be deduced according to the discrete expression as follows:
[0082] ;
[0083] Wherein, .
[0084] S105. Filter the time deviation according to the said state space algorithm, and update the state at the moment after the sampling moment based on the filtering result to reduce the time deviation between the master clock and the slave clock.
[0085] In specific implementation, according to the above state space equation, the time deviation can be filtered. The filtering is mainly divided into two steps. The first step is to predict the state at the above sampling moment :
[0086] ;
[0087] Wherein, is the prior state prediction at the moment after the sampling moment ; It is the a priori estimated covariance, which is an unreliable prediction based on the results of the previous iteration and is the input of the subsequent state update equation; is the sampling time Moment posterior state prediction; is the posterior estimated covariance, which is based on the moment after the sampling moment The posterior state prediction, posterior estimated covariance and sampling time The prior state prediction and prior estimate covariance at the time are calculated to be the sampling time The optimal solution of
[0088] In this embodiment, the initial value of the state space equation is not 0. is the sampling time The control amount, and ; is the process noise covariance matrix, and ;
[0089] The second step is to sample the above time The status is updated:
[0090] ;
[0091] ;
[0092] In the formula, Indicates the sampling time The next moment The Kalman gain, Depends on the measurement noise covariance associated with the measurement device ; Indicates the sampling time The next moment The posterior state prediction of represents the posterior estimated covariance, which is the sampling time The next moment The best prediction of .
[0093] It can be understood that the Kalman filter algorithm significantly reduces the time deviation between the master clock and the slave clock. By using Kalman filtering for estimation, the state of the clock can be accurately estimated, the clock deviation can be compensated, and the clock model can be optimized.
[0094] On the other hand, the effect of this embodiment can be further illustrated by the following hardware test results:
[0095] Experimental conditions: The DaVinci toolchain of Vector company is used to configure each module of the AUTOSAR project. The AUTOSAR-side IEEE802.1AS protocol stack runs as a slave node on the TC397 Triboard development board. The main port is configured on the SJA1110 switch, and a synchronization message is sent to the TC397 every 125 ms.
[0096] Experimental content: Test the time synchronization accuracy with and without the Kalman filter algorithm. After adding the corresponding code, use the UAD2 debugger to integrate and compile the project to generate an executable file, and obtain the master-slave time deviation by printing. The detailed experimental steps are as follows:
[0097] 1. Configure the time synchronization node project, using the Infineon Aurix2G TC397 development board and the NXP SJA1110 switch as the hardware platform. The Infineon Aurix2G TC397 development board serves as the slave node of the experiment and is suitable for real-time embedded systems compliant with the AUTOSAR standard. The NXP SJA1110 switch serves as the time synchronization master node, which supports time-sensitive networking (TSN) and time synchronization functions.
[0098] 2. The hierarchical architecture of the AUTOSAR standard is as Figure 2 shown. From top to bottom, it is the application layer, runtime environment layer, basic software layer, and microcontroller layer. The time synchronization protocol stack mainly includes several modules: EthDriver, EthIf, EthTSyn, and StbM.
[0099] Among them, the EthDriver module is mainly responsible for the sending and receiving of time synchronization messages, as well as recording the timestamps of message sending and receiving;
[0100] The EthIf module is mainly responsible for the abstraction and management of the Ethernet interface, realizing the decoupling of software and hardware. Specifically, the EthIf module provides an abstraction layer, enabling upper-layer applications and other AUTOSAR modules to communicate with the Ethernet driver without caring about the details of the underlying hardware and driver, providing consistent interfaces and services, and making the system more flexible in adapting to different hardware and network configurations;
[0101] The EthTSyn module implements the IEEE 802.1 AS protocol, including the management of master and slave nodes, the processing of synchronization messages, clock filtering and calibration, and event and status management;
[0102] EthTSyn maintains a local clock, while the StbM module can share and maintain a global time, ensuring that upper-layer applications can operate on the same time basis, which is very important for system components that require cooperative operations, real-time applications, and scenarios that require accurate timestamps;
[0103] The synchronization process of the TSN time synchronization node is specifically as Figure 3 , and the IEEE 802.1AS protocol uses a peer-to-peer method to transmit time synchronization information, separating the link delay measurement and the time synchronization process, thereby improving the stability and accuracy of synchronization.
[0104] 3. In this protocol, it is clearly stipulated that only a two-step mode is adopted, that is, the timestamp of the Sync message is carried by the Follow_Up message, so two types of messages, Sync and Follow_Up, are required to complete;
[0105] The master node (MasterClock) periodically sends Sync messages to slave nodes in the network. The Sync message contains the current timestamp of the master node, which is used to indicate the current time of the master node;
[0106] After the Sync message, the master node usually sends a Follow-Up message, which contains the timestamp when the Sync message was sent , which helps the slave node adjust its clock more accurately. The slave node (Slave Clock) receives the Sync message sent by the master node and records the timestamp when the Sync message was received , which is usually done by using multicast or unicast methods.
[0107] The slave node calculates the transmission delay between the master node sending the Sync message and the slave node receiving the Sync message. This transmission delay is caused by network transmission and includes the time for the message to propagate in the network and the time for the device to process the message;
[0108] The slave node uses information such as the master node's timestamp and transmission delay to calculate the clock deviation between the master node and the slave node. This deviation represents the difference between the master node's clock and the slave node's clock.
[0109] The slave node adjusts its own clock to reduce the clock difference between the master node and the slave node. This adjustment can be gradual or carried out according to the requirements of the PTP specification. The entire synchronization process is periodic, with the master node periodically sending Sync messages and the slave node periodically receiving and adjusting its clock.
[0110] The PTP specifies the synchronization interval, usually at the millisecond level. This process ensures that the slave node devices in the network can be synchronized according to the master node's clock to achieve high-precision clock synchronization. This is crucial for real-time and time-sensitive applications such as audio-video synchronization and industrial automation.
[0111] 4. The path delay measurement process is as follows Figure 4 , during the time synchronization process, it is necessary to know the link delay between the master node and the slave node. The specific process of measuring the link delay is as follows:
[0112] The slave node sends a Pdelay_req message to the master node. This message contains the timestamp when the slave node sends it . The master node receives the Pdelay_req message sent by the slave node. The master node records the current master node timestamp when receiving the message .
[0113] The master node sends a Pdelay_resp message to the slave node. This message contains the timestamp when the master node receives the Pdelay_req message . The slave node receives the Pdelay_resp message sent by the master node. The slave node records the current slave node timestamp when receiving the message .
[0114] The slave node uses the received timestamp information to calculate the link delay. Usually, the link delay (Pdelay) can be calculated by the following formula:
[0115] ;
[0116] This calculation process takes into account the transmission delays in both directions from the slave node to the master node and from the master node to the slave node. The slave node uses the calculated link delay information to adjust its own clock to minimize the clock deviation between the master node and the slave node.
[0117] 5. The whole process of Kalman filtering is as Figure 5 shown. The specific steps of Kalman filtering are to first give the initial state, that is, the clock deviation, frequency drift value and covariance at a certain moment, and the initial values can be given arbitrarily;
[0118] Then, from the recurrence formula, obtain the prior state prediction and prior estimation covariance at a certain moment; then update the Kalman gain at a certain moment. The Kalman gain determines the weights of the prior state prediction at a certain moment and the posterior state prediction at a certain moment;
[0119] Finally, update the state equation to obtain the Predict the posterior state and the posterior estimation covariance at a moment to complete a filtering process.
[0120] Experimental results: There is an exponentially weighted moving average filtering algorithm in the code package of Vector for filtering. The advantage of this algorithm is that it is simple and easy to implement. However, the EWMA algorithm performs poorly on data with outliers and sudden changes.
[0121] It can be understood that the Kalman filtering algorithm compared with the exponentially weighted moving average algorithm lies in that the Kalman filtering algorithm can obtain the optimal estimated value of the state by minimizing the variance of the estimation error according to the dynamic model of the system and the observed data. Therefore, it can provide a more accurate state estimation result. And the Kalman filtering algorithm can adaptively adjust the weights to balance the trade-off between the latest observed data and the system dynamic model, so as to better adapt to different system dynamic characteristics and noise distributions. The specific comparison results are as Figure 6 shown.
[0122] In summary, in the network time synchronization optimization method in the above embodiments of the present invention, by using Kalman filtering for estimation, in the context of clock synchronization, the Kalman filter compares the observed values of the master clock and the slave clock, accurately estimates the state of the slave clock, compensates for the clock deviation by optimizing the clock model, and at the same time optimizes the clock model, reduces the time deviation between the master clock and the slave clock, thereby improving the drift behavior of the slave clock. By using the application of each node in the TSN network in the AUTOSAR architecture, a unified time synchronization scheme can be provided for in - vehicle electronic systems, thus realizing the collaborative work between various intelligent systems inside the vehicle.
[0123] Embodiment 2
[0124] On the other hand, the present invention also proposes a network time synchronization optimization system. Please refer to Figure 7 , which shows the network time synchronization optimization system in the second embodiment of the present invention, applied to a time - sensitive network. The time - sensitive network includes a master clock and a slave clock. The system includes:
[0125] A model construction module 11, configured to obtain the sampling time of the time deviation between the master clock and the slave clock and the true value and the measured value of the clock deviation at the sampling moments within the sampling time, and construct a corresponding observation model according to the true value of the clock deviation and the measured value;
[0126] A drift rate calculation module 12, configured to obtain the clock frequency of the master clock and the clock frequency of the slave clock at the sampling moments, and calculate the time frequency drift rate of the slave clock according to the clock frequency of the master clock;
[0127] The relationship construction module 13 is configured to construct a data relationship among the true value of the clock deviation, the clock frequency of the slave clock, and the time-frequency drift rate of the slave clock according to the observation model and the time-frequency drift rate of the slave clock;
[0128] The algorithm construction module 14 is configured to define the true value of the clock deviation and the frequency drift rate at the moment after the sampling moment, and construct a Kalman standard state space algorithm according to the true value of the clock deviation and the frequency drift rate at the moment after the sampling moment and the data relationship;
[0129] The state update module 15 is configured to perform filtering processing on the time deviation according to the state space algorithm, and update the state at the moment after the sampling moment based on the filtering processing result, so as to reduce the time deviation between the master clock and the slave clock.
[0130] The functions or operation steps implemented when the above-mentioned modules and units are executed are substantially the same as those in the above method embodiment, and will not be elaborated here.
[0131] The network time synchronization optimization system provided by the embodiment of the present invention has the same implementation principle and technical effects as those in the foregoing method embodiment. For the sake of brief description, for the parts not mentioned in the system embodiment, reference may be made to the corresponding content in the foregoing method embodiment.
[0132] Embodiment III
[0133] The present invention also proposes a computer. Please refer to Figure 8 , which shows the computer in the third embodiment of the present invention, including a memory 10, a processor 20, and a computer program 30 stored on the memory 10 and executable on the processor 20. When the processor 20 executes the computer program 30, the above-mentioned network time synchronization optimization method is implemented.
[0134] Among them, the memory 10 includes at least one type of readable storage medium. The readable storage medium includes flash memory, hard disk, multimedia card, card-type memory (for example, SD or DX memory, etc.), magnetic memory, magnetic disk, optical disc, etc. The memory 10 may be an internal storage unit of the computer in some embodiments, such as the hard disk of the computer. The memory 10 may also be an external storage device in other embodiments, such as a plug-in hard disk, a Smart Media Card (SMC), a Secure Digital (SD) card, a Flash Card, etc. Further, the memory 10 may also include both an internal storage unit and an external storage device of the computer. The memory 10 can be used not only to store application software installed on the computer and various types of data, but also to temporarily store data that has been output or will be output.
[0135] Among them, the processor 20 may be an electronic control unit (ECU, also known as a vehicle computer), a central processing unit (CPU), a controller, a microcontroller, a microprocessor, or other data processing chips in some embodiments, and is used to run the program code stored in the memory 10 or process data, such as executing an access restriction program and the like.
[0136] It should be noted that Figure 8 The structure shown does not constitute a limitation on the computer. In other embodiments, the computer may include fewer or more components than shown in the figure, or combine certain components, or have a different component arrangement.
[0137] An embodiment of the present invention also provides a readable storage medium, on which a computer program is stored, and when the program is executed by a processor, it implements the network time synchronization optimization method as described above.
[0138] Those skilled in the art can understand that the logic and / or steps represented in the flowchart or described in other ways herein, for example, can be considered as a fixed sequence list of executable instructions for implementing logical functions, and can be specifically implemented in any computer-readable medium for use by an instruction execution system, apparatus, or device (such as a computer-based system, a system including a processor, or other systems that can fetch instructions from the instruction execution system, apparatus, or device and execute the instructions), or in combination with these instruction execution systems, apparatus, or devices. For the purposes of this specification, a "computer-readable medium" can be any device that can contain, store, communicate, propagate, or transport a program for use by or in connection with an instruction execution system, apparatus, or device.
[0139] More specific examples (non-exhaustive list) of computer-readable media include the following: an electrical connection part (electronic device) having one or more wirings, a portable computer disk cartridge (magnetic device), a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber device, and a portable compact disc read-only memory (CDROM). Additionally, the computer-readable medium can even be paper or other suitable media on which the program can be printed, because the program can be obtained electronically, for example, by optically scanning the paper or other media, followed by editing, interpretation, or other suitable processing as necessary, and then stored in a computer memory.
[0140] It should be understood that the various parts of the present invention can be implemented by hardware, software, firmware or a combination thereof. In the above embodiments, multiple steps or methods can be implemented by software or firmware stored in a memory and executed by a suitable instruction execution system. For example, if implemented by hardware, as in another embodiment, any one or a combination of the following techniques well known in the art can be used: discrete logic circuits having logic gate circuits for implementing logic functions on data signals, application specific integrated circuits having appropriate combinational logic gate circuits, programmable gate arrays (PGAs), field programmable gate arrays (FPGAs), etc.
[0141] The technical features of the above-described embodiments can be combined arbitrarily. For the sake of brevity of description, not all possible combinations of the various technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, it should be considered as falling within the scope described in this specification.
[0142] The above-described embodiments merely represent several implementation manners of the present application. The description thereof is relatively specific and detailed, but it should not be construed as a limitation on the scope of the invention patent. It should be noted that for those of ordinary skill in the art, without departing from the concept of the present application, several modifications and improvements can still be made, and these all belong to the protection scope of the present application. Therefore, the protection scope of the patent of the present application shall be subject to the appended claims.
Claims
1. A network time synchronization optimization method is applied to a time-sensitive network. The time-sensitive network includes a master clock and a slave clock, and is characterized in that, The method includes: Obtaining the sampling time of the time deviation between the master clock and the slave clock, and the true value and the measured value of the clock deviation at the sampling moments within the sampling time, and constructing a corresponding observation model according to the true value of the clock deviation and the measured value; Obtaining the clock frequency of the master clock and the clock frequency of the slave clock at the sampling moments, and calculating the time frequency drift rate of the slave clock according to the clock frequency of the master clock; Constructing a data relationship among the true value of the clock deviation, the clock frequency of the slave clock, and the time frequency drift rate of the slave clock according to the observation model and the time frequency drift rate of the slave clock; Defining the true value of the clock deviation and the frequency drift rate at the moment after the sampling moment, and constructing a Kalman standard state space algorithm according to the true value of the clock deviation and the frequency drift rate at the moment after the sampling moment and the data relationship, and the calculation formula of the Kalman standard state space algorithm is: ; Among them, ; wherein, is the true value of the clock deviation and the frequency drift at the moment after the sampling moment , and the observation signal corresponding to the state, and the state transition matrix is , the control quantity matrix and the noise driving matrix are , , , and the observation matrix is ; Performing filtering processing on the time deviation according to the state space algorithm, and updating the state at the moment after the sampling moment based on the filtering processing result to reduce the time deviation between the master clock and the slave clock; The steps of obtaining the sampling time of the time deviation between the master clock and the slave clock, and the true value and the measured value of the clock deviation at the sampling moments within the sampling time, and constructing a corresponding observation model according to the true value of the clock deviation and the measured value include: The sampling time of the time deviation between the master clock and the slave clock is defined as ,by Indicates the sampling time The sampling time within The true value of the clock deviation is Indicates that at the sampling time The measured value of the time deviation is based on the actual value of the clock deviation and measured values Constructing the observation model: ; In the formula, represents the measurement error. If the measurement error follows a normal distribution, its mean is 0 and the variance is white noise; The calculation formula of the time frequency drift rate of the slave clock is: ; In the formula, represents the normal drift of the slave clock at the sampling moment of the clock frequency ; is the random drift of the clock frequency with a white noise variance of . The expression of the data relationship among the true value of the clock deviation, the clock frequency of the slave clock, and the time frequency drift rate of the slave clock is: Formula (1): ; Formula (2): ; In the formula, represents the clock frequency of the master clock, is the initial value of the clock deviation, is the initial value of the frequency; Discretizing the formula (1) and the formula (2) to obtain the following expressions: ; Among them, the steps of performing filtering processing on the time deviation according to the state space algorithm, and updating the state at the moment after the sampling moment based on the filtering processing result to reduce the time deviation between the master clock and the slave clock include: Predict the state of the sampling moment : ; In the formula, is the sampling time and the next moment is the prior state prediction; is the prior estimation covariance; is the sampling time and the posterior state prediction at that moment; is the posterior estimation covariance, which is calculated based on the posterior state prediction at the next moment of the sampling time, the posterior estimation covariance, and the prior state prediction and prior estimation covariance at the sampling time at that moment, and is the optimal solution at the sampling time ; is the control quantity at the sampling time ; ; is the process noise covariance matrix, ; Update the state of the sampling moment : ; ; wherein, represents the subsequent moment of the sampling moment and the Kalman gain, which depends on the measurement noise covariance related to the measurement device ; represents the subsequent moment of the sampling moment and the predicted posterior state, represents the posterior estimation covariance, which is the optimal prediction of the subsequent moment of the sampling moment ; 2. A network time synchronization optimization system is applied to a time-sensitive network, and the time-sensitive network includes a master clock and slave clocks, characterized in that, The system includes: A model construction module, configured to obtain the sampling time of the time deviation between the master clock and the slave clock, and the true value and the measured value of the clock deviation at the sampling moments within the sampling time, and construct a corresponding observation model according to the true value of the clock deviation and the measured value; A drift rate calculation module, configured to obtain the clock frequency of the master clock and the clock frequency of the slave clock at the sampling moments, and calculate the time frequency drift rate of the slave clock according to the clock frequency of the master clock; A relationship construction module, configured to construct a data relationship among the true value of the clock deviation, the clock frequency of the slave clock, and the time frequency drift rate of the slave clock according to the observation model and the time frequency drift rate of the slave clock; An algorithm construction module, configured to define the true value of the clock deviation and the frequency drift rate at the moment after the sampling moment, and construct a Kalman standard state space algorithm according to the true value of the clock deviation and the frequency drift rate at the moment after the sampling moment and the data relationship. The calculation formula of the Kalman standard state space algorithm is as follows: ; Among them, ; Wherein, is the true value of the clock deviation and the frequency drift at the moment after the sampling moment , the observation signal corresponding to the state, and the state transition matrix is , the control quantity matrix and the noise driving matrix are , , , and the observation matrix is ; A state update module, configured to perform filtering processing on the time deviation according to the state space algorithm, and update the state at the moment after the sampling moment based on the filtering processing result, so as to reduce the time deviation between the master clock and the slave clock; The steps of obtaining the sampling time of the time deviation between the master clock and the slave clock and the true value and the measured value of the clock deviation at the sampling moment within the sampling time, and constructing a corresponding observation model according to the true value of the clock deviation and the measured value include: The sampling time of the time deviation between the master clock and the slave clock is defined as ,by Indicates the sampling time The sampling time within The true value of the clock deviation is Indicates that at the sampling time The measured value of the time deviation is based on the actual value of the clock deviation and measured values Constructing the observation model: ; wherein, represents a measurement error. If the measurement error follows a normal distribution, its mean is 0 and the variance is white noise; The calculation formula of the time frequency drift rate of the slave clock is: ; In the formula, represents the normal drift of the slave clock at the sampling moment of the clock frequency ; is the random drift of the clock frequency with a white noise variance of . The expression of the data relationship among the true value of the clock deviation, the clock frequency of the slave clock, and the time frequency drift rate of the slave clock is: Formula (1): ; Formula (2): ; In the formula, represents the clock frequency of the master clock, is the initial value of the clock deviation, is the initial value of the frequency; Discretize the formula (1) and formula (2) to obtain the following expressions: ; Among them, the state update module includes: Predict the state of the sampling moment : ; In the formula, is the sampling time of the next moment of the prior state prediction; is the prior estimation covariance; is the sampling time of the posterior state prediction at the moment; is the posterior estimation covariance, which is calculated according to the posterior state prediction, the posterior estimation covariance at the next moment of the sampling time , the prior state prediction and the prior estimation covariance at the moment of the sampling time , and is the optimal solution at the sampling time ; is the control quantity at the sampling time , ; is the process noise covariance matrix, ; Update the state of the sampling moment : ; ; In the formula, represents the next moment after the sampling moment is the Kalman gain, which depends on the measurement noise covariance related to the measurement device ; represents the next moment after the sampling moment is the a posteriori state prediction, represents the a posteriori estimation covariance, which is the optimal prediction at the next moment after the sampling moment 3. A readable storage medium, on which a computer program is stored, characterized in that, When the program is executed by a processor, it implements the network time synchronization optimization method as described in claim 1.
4. A computer, comprising a memory, a processor, and a computer program stored on the memory and executable on the processor, characterized in that, When the processor executes the computer program, it implements the network time synchronization optimization method as described in claim 1.