Network time synchronization optimization method and system, readable storage medium and computer
The clock model is optimized through Kalman filtering technology, which solves the problem of insufficient accuracy of the traditional time synchronization method under complex network conditions, and achieves higher accuracy and stable clock synchronization, supporting the coordinated work of on-board electronic systems.
Patent Information
- Application Number
- CN202411397222.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-09
- Publication Date
- 2024-11-01
- Estimated Expiration
- 2044-10-09
AI Technical Summary
Traditional time synchronization methods cannot meet high-precision requirements under complex network conditions, especially when there is network jitter or instability, the synchronization accuracy is low under the AUTOSAR architecture. The main reason is multi-layer calls and interactions between modules, fixed scheduling and execution. Sequence, standardized constraints, and the complexity of the clock synchronization mechanism.
Using Kalman filtering technology, by obtaining the time deviation and frequency drift rate between the master clock and the slave clock, constructing observation models and state space algorithms, performing filtering to reduce time deviation, optimizing clock model, compensating clock deviation, and improving clock synchronization Accuracy.
It improves the accuracy and stability of time synchronization, reduces the time deviation between the master clock and the slave clock, achieves more accurate clock synchronization, and supports the coordinated work of on-board electronic systems.
Smart Images

Figure CN118890685A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of vehicle-mounted communication technology, and in particular to a network time synchronization optimization method, system, readable storage medium and 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 the emerging technology field, among which in-vehicle network is gradually becoming a growing field. While the automotive industry is constantly moving towards intelligent development, various advanced in-vehicle applications such as navigation systems, safety systems, multimedia entertainment and unmanned driving are emerging in an endless stream, which puts forward 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. In order to meet this challenge, the automotive industry quickly realized the need for an open and standardized software architecture to achieve reusability and interoperability of automotive electronic systems. Against this background, the Automotive Open System Architecture (AUTOSAR) came into being.
[0004] The introduction of AUTOSAR has brought changes to the development and integration of automotive electronic systems. By providing consistent standards and specifications, the AUTOSAR architecture enables automakers and electronic system suppliers to more efficiently design, deploy and update software functions in vehicles. This standardized approach helps reduce development costs, improve software maintainability, and support seamless integration of software components between different suppliers.
[0005] The rapid development of the automotive industry and industrial control, and the deep integration of computer network technology and automatic control technology have brought innovative products to the field of emerging technologies, among which in-vehicle networks are gradually becoming a growing field. As the automotive industry continues to move towards intelligent development, various advanced in-vehicle applications such as navigation systems, safety systems, multimedia entertainment, and unmanned driving are emerging in an endless stream, which puts forward more complex and high-standard requirements for network reliability, bandwidth, and synchronization performance. With the continuous emergence of these innovative applications, real-time data transmission applications (such as multi-axis synchronization, transportation industry, etc.) have increasingly urgent needs for key indicators such as data transmission, delay, and packet loss. In order to improve the interoperability, configuration flexibility, and monitoring capabilities of real-time Ethernet to better meet these needs, Time-Sensitive Networking (TSN) came into being and continues to evolve in rapid development.
[0006] Time-Sensitive Networking (TSN) is an extension of the Ethernet standard designed to support real-time and time-sensitive applications, especially in the industrial and automotive fields. TSN introduces a series of standards and mechanisms to provide precise clock synchronization, low latency and high reliability for network communications, 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 accurate communication between various subsystems. The AUTOSAR architecture provides an ideal platform, making it possible to integrate the TSN time synchronization system, providing a more efficient and accurate 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 being able to meet 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 are the multi-layer calls and interactions between modules, fixed scheduling and execution order, standardized constraints, and the complexity of the clock synchronization mechanism. Summary of the invention
[0009] Based on this, an 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-mentioned technology.
[0010] The present invention proposes a network time synchronization optimization method, which is applied to a time-sensitive network, wherein the time-sensitive network includes a master clock and a slave clock, and the method includes: Obtaining a sampling time of the time deviation between the master clock and the slave clock and a true value and a measured value of the clock deviation at a 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; Acquire the clock frequency of the master clock and the clock frequency of the slave clock at the sampling time, and calculate the time frequency drift rate of the slave clock according to the clock frequency of the master clock; Constructing a data relationship between the real 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 a true value of the clock deviation and a frequency drift rate at a moment after the sampling moment, and constructing a state space algorithm of the Kalman standard according to the true value of the clock deviation and the frequency drift rate at a moment after the sampling moment and the data relationship; The time deviation is filtered according to the state space algorithm, and the state at a moment subsequent to the sampling moment is updated based on the filtering result, so as to reduce the time deviation between the master clock and the slave clock.
[0011] Further, the steps of obtaining the sampling time of the time deviation between the master clock and the slave clock and the real 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 real value and the measured value of the clock deviation 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 conforms to the normal distribution, its mean is 0 and its variance is of white noise.
[0012] Furthermore, the calculation formula of the time frequency drift rate of the slave clock is: ; In the formula, Indicates that the slave clock is at the sampling time Clock frequency The normal drift of is the clock frequency The random drift of of white noise.
[0013] Furthermore, the expression for the data relationship between the real 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, is the initial value of the clock deviation, is the initial value of frequency; Discretizing the formula (1) and formula (2), we get the following expression: .
[0014] Furthermore, the calculation formula of the state space algorithm of the Kalman standard is: ; in, ; In the formula, is the time after the sampling time The true value of the clock bias and frequency drift, is the observed signal of the corresponding state, and the state transfer matrix is , the control matrix and noise driving matrix are , , the observation matrix is .
[0015] Further, the step of filtering the time deviation according to the state space algorithm, and updating the state of 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 includes: The sampling time The state is predicted: ; In the formula, The sampling time The next moment A priori state predictions of is the a priori estimated covariance; 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 is the sampling time The amount of control, ; is the process noise covariance matrix, ; The sampling time The status is updated: ; ; 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 .
[0016] The present invention further proposes a network time synchronization optimization system, which is applied to a time-sensitive network, wherein the time-sensitive network includes a master clock and a slave clock, and the system includes: A model building module, used to obtain the sampling time of the time deviation between the master clock and the slave clock and the real value and measured value of the clock deviation at the sampling moment within the sampling time, and build a corresponding observation model according to the real value and the measured value of the clock deviation; A drift rate calculation module, used to obtain the clock frequency of the master clock and the clock frequency of the slave clock at the sampling time, and calculate the time frequency drift rate of the slave clock according to the clock frequency of the master clock; A relationship building module, used to build a data relationship between the real 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, used to define a true value of the clock deviation and a frequency drift rate at a moment after the sampling moment, and to construct a state space algorithm of the Kalman standard according to the true value of the clock deviation and the frequency drift rate at a moment after the sampling moment and the data relationship; A state updating module is used to filter the time deviation according to the state space algorithm, and update the state of 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.
[0017] The present invention also provides a readable storage medium on which a computer program is stored. When the program is executed by a processor, the above-mentioned network time synchronization optimization method is implemented.
[0018] The present invention also provides a computer, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the above-mentioned network time synchronization optimization method when executing the computer program.
[0019] The network time synchronization optimization method, system, readable storage medium and computer of the present invention use 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, and compensates for the clock deviation by optimizing the clock model. At the same time, the clock model is optimized to reduce 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 solution can be provided for the vehicle electronic system, thereby realizing the collaborative work between various intelligent systems inside the vehicle. BRIEF DESCRIPTION OF THE DRAWINGS
[0020] Figure 1 is a flow chart of a network time synchronization optimization method in a first embodiment of the present invention; Figure 2 AUTOSAR layered architecture and time synchronization protocol stack schematic diagram in the first embodiment of the present invention; Figure 3 This is a schematic diagram of the time synchronization process in the first embodiment of the present invention; Figure 4 This is a schematic diagram of the path link delay measurement principle in the first embodiment of the present invention; Figure 5 is a schematic diagram of the Kalman filtering process in the first embodiment of the present invention; Figure 6 This is a comparison diagram of Kalman filter test results in the first embodiment of the present invention; Figure 7 is a structural block diagram of a network time synchronization optimization system in a second embodiment of the present invention; Figure 8 FIG. 4 is a structural block diagram of a computer in a third embodiment of the present invention.
[0021] The following specific implementation manner will further illustrate the present invention in conjunction with the above-mentioned drawings. DETAILED DESCRIPTION
[0022] In order to facilitate the understanding of the present invention, the present invention will be described more fully 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, the purpose of providing these embodiments is to make the disclosure of the present invention more thorough and comprehensive.
[0023] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as those commonly understood by those skilled in the art 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.
[0024] Embodiment 1 See also Figure 1 , which shows a network time synchronization optimization method in a first embodiment of the present invention, applied to a time-sensitive network, wherein the time-sensitive network includes a master clock and a slave clock, and the method specifically includes steps S101 to S105: S101, obtaining a sampling time of the time deviation between the master clock and the slave clock and a true value and a measured value of the clock deviation at a 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; In specific implementation, due to the aging problem of the crystal oscillator and the influence of ambient temperature, the clock drift is not constant. The main causes of clock error are clock stamp and delay jitter, that is, time offset and time offset rate.
[0025] In order to improve the timestamp accuracy of TSN time synchronization nodes and reduce delay jitter, the node clocks are adjusted to make the clocks of each node as consistent as possible. A time synchronization solution based on Kalman filtering is adopted. By performing Kalman filtering on the clock offset and clock offset rate, the local clock is adjusted to make its clock synchronization more accurate.
[0026] 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 The observation model is constructed as follows: ; In the formula, Represents the measurement error. If the measurement error conforms to the normal distribution, its mean is 0 and its variance is The variance can be obtained from the test data using statistical principles.
[0027] S102, acquiring the clock frequency of the master clock and the clock frequency of the slave clock at the sampling time, and calculating the time frequency drift rate of the slave clock according to the clock frequency of the master clock; In the specific implementation, the clock frequency of the main clock is defined as And there is no noise influence, that is, the clock frequency of the main clock remains unchanged, record For slave nodes The clock frequency at the moment, is the slave node frequency drift rate, and the calculation formula of the time frequency drift rate of the slave clock is: ; In the formula, Indicates that the slave clock is at the sampling time Clock frequency The normal drift is affected by the external environment such as temperature and crystal aging. is the clock frequency The random drift of is zero mean in this embodiment, and the variance is White noise, under normal working conditions, within a certain period of time, can be Considered as a constant value.
[0028] S103, constructing a data relationship among the real 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; In a specific implementation, based on the above analysis, the expression for the data relationship between the real 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, is the initial value of the clock deviation, is the initial value of frequency; Discretizing the formula (1) and formula (2), we get the following expression: .
[0029] S104, defining a true value of the clock deviation and a frequency drift rate at a moment after the sampling moment, and constructing a state space algorithm of the Kalman standard according to the true value of the clock deviation and the frequency drift rate at a moment after the sampling moment and the data relationship; In the specific implementation, it is defined at the moment after the sampling moment System status at is the true value of the clock bias and the frequency drift, is the observed signal of the corresponding state, and the state transfer matrix is , the control matrix and noise driving matrix are , , the observation matrix is , the state space equation of the Kalman standard can be derived according to the discrete expression as follows: ; in, .
[0030] S105, filtering the time deviation according to the state space algorithm, and updating the state at a moment after the sampling moment based on the filtering result, so as to reduce the time deviation between the master clock and the slave clock.
[0031] 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 filter the above sampling time. The state is predicted: ; In the formula, The sampling time The next moment A priori state predictions of 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 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 ; The second step is to sample the above time The status is updated: ; ; 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 .
[0032] 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.
[0033] On the other hand, the effect of this embodiment can be further illustrated by the following hardware test results: Experimental conditions: Vector's DaVinci tool chain is used to configure the various modules of the AUTOSAR project. The AUTOSAR-side IEEE802.1AS protocol stack runs as a slave node on the TC397 Triboard development board. The master port is configured on the SJA1110 switch, which sends a synchronization message to the TC397 every 125ms.
[0034] 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, generate an executable file, and obtain the master-slave time deviation by printing. The detailed experimental steps are as follows: 1. Configure the time synchronization node project, using the Infineon Aurix2G TC397 development board and NXP SJA1110 switch as the hardware platform. The Infineon Aurix2G TC397 development board is used as the slave node of the experiment, which is suitable for real-time embedded systems of the AUTOSAR standard. The NXP SJA1110 switch is used as the time synchronization master node, which supports time-sensitive networking (TSN) and time synchronization functions.
[0035] 2. The layered architecture of the AUTOSAR standard is as follows Figure 2 As shown in the figure, from top to bottom are the application layer, runtime environment layer, basic software layer, and microcontroller layer. The time synchronization protocol stack mainly includes EthDriver, EthIf, EthTSyn, and StbM modules.
[0036] Among them, the EthDriver module is mainly responsible for sending and receiving time synchronization messages, and recording the timestamps of message sending and receiving; The EthIf module is mainly responsible for the abstraction and management of the Ethernet interface to achieve software and hardware decoupling. Specifically, the EthIf module provides an abstraction layer that enables upper-layer applications and other AUTOSAR modules to communicate with the Ethernet driver without having to worry about the details of the underlying hardware and driver. It provides consistent interfaces and services, allowing the system to adapt to different hardware and network configurations more flexibly. The EthTSyn module implements the IEEE 802.1 AS protocol, including the management of master and slave nodes, processing of synchronization messages, clock filtering and calibration, and event and status management; 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. This is very important for system components that need to operate in coordination, real-time applications, and scenarios that require accurate timestamps. The synchronization process of TSN time synchronization nodes is as follows: Figure 3 ,IEEE 802.1AS protocol uses a peer-to-peer method to transmit time synchronization information, separating the link delay measurement and time synchronization process, thereby improving the stability and accuracy of synchronization.
[0037] 3. In this protocol, it is clearly stipulated that only two-step mode is adopted, that is, the timestamp of the synchronization (Sync) message is carried by the Follow_Up message, so it is necessary to use two messages, Sync and Follow_Up, to complete; The master node (MasterClock) periodically sends Sync messages to the 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; After the Sync message, the master node usually sends a Follow-Up message, which contains the timestamp of when the Sync message was sent. This 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 of the received Sync message. This is usually done using multicast or unicast.
[0038] 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 it takes for the message to propagate in the network and the time it takes for the device to process the message. The slave node uses the master node's timestamp, transmission delay and other information to calculate the clock deviation between the master node and the slave node. This deviation represents the difference between the master node and the slave node clock.
[0039] 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 according to the requirements of the PTP specification. The entire synchronization process is periodic, the master node sends Sync messages regularly, and the slave node receives and adjusts the clock regularly.
[0040] PTP specifies the synchronization interval, which is usually in milliseconds. This process ensures that the slave node devices in the network can synchronize according to the clock of the master node to achieve high-precision clock synchronization. This is critical for real-time and time-sensitive applications, such as audio and video synchronization, industrial automation, etc.
[0041] 4. The path delay measurement process is as follows Figure 4 In the process of time synchronization, it is necessary to know the link delay between the master node and the slave node. The link delay measurement process is as follows: 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. .
[0042] 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. .
[0043] 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: ; This calculation process takes into account the transmission delay 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 skew between the master node and the slave node.
[0044] 5. The whole process of Kalman filtering is as follows Figure 5 As 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 the moment, and the initial value can be given arbitrarily; Then, by the recursive formula, we can get The prior state prediction and prior estimated covariance at the moment are then updated based on the prior estimated covariance. The Kalman gain at the moment, the Kalman gain determines The weight of the prior state prediction at time t and the posterior state prediction at time t; Finally, update the state equation to obtain The posterior state prediction and posterior estimated covariance at the moment complete a filtering process.
[0045] Experimental results: The Vector code package contains an exponentially weighted moving average filtering algorithm that can be used for filtering. The advantage of this algorithm is that it is simple and easy to implement. However, the EWMA algorithm performs poorly for data with outliers and sudden changes.
[0046] It can be understood that the Kalman filter algorithm is superior to the exponentially weighted moving average algorithm in that the Kalman filter algorithm can obtain the optimal estimate of the state by minimizing the variance of the estimation error based on the system's dynamic model and observation data, and thus can provide a more accurate state estimation result. In addition, the Kalman filter algorithm can adaptively adjust the weights to balance the trade-off between the latest observation data and the system's dynamic model, thereby better adapting to different system dynamic characteristics and noise distributions. The specific comparison results are as follows: Figure 6 shown.
[0047] In summary, the network time synchronization optimization method in the above-mentioned embodiment of the present invention uses 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, and compensates for the clock deviation by optimizing the clock model. At the same time, the clock model is optimized to reduce 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 solution can be provided for the vehicle-mounted electronic system, thereby realizing the collaborative work between various intelligent systems inside the vehicle.
[0048] Embodiment 2 Another aspect of the present invention is to provide a network time synchronization optimization system. Figure 7 , which shows a network time synchronization optimization system in a second embodiment of the present invention, applied to a time-sensitive network, wherein the time-sensitive network includes a master clock and a slave clock, and the system includes: A model building module 11 is used to obtain the sampling time of the time deviation between the master clock and the slave clock and the real value and measured value of the clock deviation at the sampling moment within the sampling time, and to build a corresponding observation model according to the real value and the measured value of the clock deviation; A drift rate calculation module 12, used to obtain the clock frequency of the master clock and the clock frequency of the slave clock at the sampling time, and calculate the time frequency drift rate of the slave clock according to the clock frequency of the master clock; A relationship building module 13, configured to build 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; An algorithm construction module 14, used to define the true value of the clock deviation and the frequency drift rate at a moment after the sampling moment, and to construct a state space algorithm of the Kalman standard according to the true value of the clock deviation and the frequency drift rate at a moment after the sampling moment and the data relationship; The state updating module 15 is used to filter the time deviation according to the state space algorithm, and update the state of 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.
[0049] The functions or operation steps implemented when the above modules and units are executed are generally the same as those in the above method embodiments, and will not be repeated here.
[0050] The network time synchronization optimization system provided in the embodiment of the present invention has the same implementation principle and technical effects as those of the aforementioned method embodiment. For the sake of brief description, for matters not mentioned in the system embodiment, reference may be made to the corresponding contents in the aforementioned method embodiment.
[0051] Embodiment 3 The present invention also provides a computer, see Figure 8 , shown is a computer in the third embodiment of the present invention, including a memory 10, a processor 20, and a computer program 30 stored in 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.
[0052] The memory 10 includes at least one type of readable storage medium, which includes a flash memory, a hard disk, a multimedia card, a card-type memory (e.g., an SD or DX memory, etc.), a magnetic memory, a magnetic disk, an optical disk, etc. In some embodiments, the memory 10 may be an internal storage unit of a computer, such as a hard disk of the computer. In other embodiments, the memory 10 may also be an external storage device, such as a plug-in hard disk, a smart memory card (Smart Media Card, SMC), a secure digital (Secure Digital, SD) card, a flash card, etc. Further, the memory 10 may also include both an internal storage unit of the computer and an external storage device. The memory 10 may be used not only to store application software and various types of data installed in the computer, but also to temporarily store data that has been output or is to be output.
[0053] Among them, in some embodiments, the processor 20 can be an electronic control unit (Electronic Control Unit, abbreviated as ECU, also known as a vehicle computer), a central processing unit (Central Processing Unit, CPU), a controller, a microcontroller, a microprocessor or other data processing chip, used to run the program code stored in the memory 10 or process data, such as executing access restriction programs, etc.
[0054] It should be pointed out 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 arrange the components differently.
[0055] The embodiment of the present invention further provides a readable storage medium on which a computer program is stored. When the program is executed by a processor, the network time synchronization optimization method as described above is implemented.
[0056] Those skilled in the art will appreciate that the logic and / or steps represented in the flowchart or otherwise described herein, for example, may be considered as an ordered list of executable instructions for implementing logical functions, and may be specifically implemented in any computer-readable medium for use by an instruction execution system, device or apparatus (such as a computer-based system, a system including a processor, or other system that can fetch instructions from an instruction execution system, device or apparatus and execute instructions), or in conjunction with such instruction execution systems, devices or apparatuses. For purposes of this specification, "computer-readable medium" may be any device that can contain, store, communicate, propagate or transmit a program for use by an instruction execution system, device or apparatus, or in conjunction with such instruction execution systems, devices or apparatuses.
[0057] More specific examples of computer-readable media (a non-exhaustive list) include the following: an electrical connection with one or more wires (electronic device), a portable computer disk case (magnetic device), a random access memory (RAM), a read-only memory (ROM), an erasable and programmable read-only memory (EPROM or flash memory), an optical fiber device, and a portable compact disk read-only memory (CDROM). In addition, the computer-readable medium may even be a paper or other suitable medium on which the program is printed, since the program may be obtained electronically, for example, by optically scanning the paper or other medium, followed by editing, deciphering or, if necessary, processing in another suitable manner, and then stored in a computer memory.
[0058] 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-mentioned 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, it can be implemented by any one of the following technologies known in the art or a combination thereof: a discrete logic circuit having a logic gate circuit for implementing a logic function for a data signal, a dedicated integrated circuit having a suitable combination of logic gate circuits, a programmable gate array (PGA), a field programmable gate array (FPGA), etc.
[0059] The technical features of the above-described embodiments may be arbitrarily combined. To make the description concise, not all possible combinations of the technical features in the above-described embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0060] The above-mentioned embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the invention patent. It should be pointed out that, for a person of ordinary skill in the art, several variations and improvements can be made without departing from the concept of the present application, 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 attached claims.
Claims
1. A network time synchronization optimization method, applied to a time-sensitive network, wherein the time-sensitive network includes a master clock and a slave clock, characterized in that: The method comprises: Obtaining a sampling time of the time deviation between the master clock and the slave clock and a true value and a measured value of the clock deviation at a 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; Acquire the clock frequency of the master clock and the clock frequency of the slave clock at the sampling time, and calculate the time frequency drift rate of the slave clock according to the clock frequency of the master clock; Constructing a data relationship among the real 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 a true value of the clock deviation and a frequency drift rate at a moment after the sampling moment, and constructing a state space algorithm of the Kalman standard according to the true value of the clock deviation and the frequency drift rate at a moment after the sampling moment and the data relationship; The time deviation is filtered according to the state space algorithm, and the state at a moment subsequent to the sampling moment is updated based on the filtering result, so as to reduce the time deviation between the master clock and the slave clock.
2. The network time synchronization optimization method according to claim 1, characterized in that: The steps of obtaining the sampling time of the time deviation between the master clock and the slave clock and the real 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 real value and the measured value of the clock deviation 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 conforms to the normal distribution, its mean is 0 and its variance is of white noise.
3. The network time synchronization optimization method according to claim 2, characterized in that: The calculation formula of the time frequency drift rate of the slave clock is: ; In the formula, Indicates that the slave clock is at the sampling time Clock frequency The normal drift of is the clock frequency The random drift of of white noise.
4. The network time synchronization optimization method according to claim 3, characterized in that: The expression for the data relationship between the real 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, is the initial value of the clock deviation, is the initial value of frequency; Discretizing the formula (1) and formula (2), we get the following expression: 。 5. The network time synchronization optimization method according to claim 4, characterized in that: The calculation formula of the state space algorithm of Kalman standard is: ; in, ; In the formula, is the time after the sampling time The true value of the clock bias and frequency drift, is the observed signal of the corresponding state, and the state transfer matrix is , the control matrix and noise driving matrix are , , the observation matrix is .
6. The network time synchronization optimization method according to claim 5, characterized in that: The step of filtering the time deviation according to the state space algorithm and updating the state of 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 includes: The sampling time The state is predicted: ; In the formula, The sampling time The next moment A priori state predictions of is the a priori estimated covariance; 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 is the sampling time The amount of control, ; is the process noise covariance matrix, ; The sampling time The status is updated: ; ; 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 .
7. A network time synchronization optimization system, applied to a time-sensitive network, wherein the time-sensitive network includes a master clock and a slave clock, characterized in that: The system comprises: A model building module, used to obtain the sampling time of the time deviation between the master clock and the slave clock and the real value and measured value of the clock deviation at the sampling moment within the sampling time, and build a corresponding observation model according to the real value and the measured value of the clock deviation; A drift rate calculation module, used to obtain the clock frequency of the master clock and the clock frequency of the slave clock at the sampling time, and calculate the time frequency drift rate of the slave clock according to the clock frequency of the master clock; A relationship building module, used to build a data relationship between the real 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, used to define a true value of the clock deviation and a frequency drift rate at a moment after the sampling moment, and to construct a state space algorithm of the Kalman standard according to the true value of the clock deviation and the frequency drift rate at a moment after the sampling moment and the data relationship; A state updating module is used to filter the time deviation according to the state space algorithm, and update the state of 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.
8. A readable storage medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the network time synchronization optimization method as described in any one of claims 1 to 6 is implemented.
9. A computer comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the network time synchronization optimization method as described in any one of claims 1 to 6 is implemented.
Citation Information
Patent Citations
Clock frequency indirect compensation method of train communication network
CN103812591A
Method and device for synchronizing frequencies of PTP master clock and slave clock
CN105207767A
IEEE1588 clock synchronization method based on disturbance observation control technology
CN106160914A
RRU high-precision clock synchronization method based on Kalman sliding window filtering
CN114584248A
Filtering method and system for precision clock synchronization
CN114710252A
Cited By
Mutual inductor waveform real-time synchronous acquisition and analysis method and device and electronic equipment
CN121454434A
