# Kalman Filter Algorithm for Security of Network Clock Synchronization in Wireless Sensor Networks

Authors: Xinggang Xuan; Jingsha He; Peng Zhai; Alireza Ebrahimi Basabi; Gongzheng Liu
Journal: Mobile Information Systems
 (2022)

---

## Abstract

Wireless sensor networks are a significant subfield of distributed systems, and a large number of their applications require time synchronization. Sensor nodes are powered by batteries. In order to reduce the interference of the peripheral environment on the node as much as possible, the size of the node is relatively small and the circuit design, storage, and calculation are relatively simple. Therefore, wireless sensor network nodes have limited energy, low computing power, and low communication capacity. In addition, the clock of the wireless sensor network node is usually realized through the local crystal oscillator and CPU interrupt mechanism, which is obviously affected by manufacturing errors, temperature changes, and CPU processing delays. Therefore, this research reviews and analyzes the development and current situation of time synchronization and puts forward the challenges faced by time synchronization-related research institutes. From the perspective of dynamic cybernetics, the feasibility of optimization based on Kalman filtering is analyzed. Finally, the article describes the system modeling process, including the clock model and the state equation and observation equation of Kalman filter and uses Matlab platform to carry out experimental simulation and analysis on the precise time synchronization protocol based on Kalman filter in the wireless sensor network environment.


---

## Body

## 1. Introduction

After the 1990s, computer communication and network technology have developed rapidly, especially represented by the internet. These developments have caused many changes in society, economy, industrial production, and media and have changed people’s lifestyles. The internet has become an indispensable part of many people’s daily lives.In a wireless sensor network, multiple sensor nodes in a certain area communicate with each other via wireless communication. Wireless sensor network has information integration and information processing capabilities and integrates computer technology, sensor technology, microelectronic technology, embedded technology, wireless communication technology, and many other technical fields. A wide range of industries and applications have also taken advantage of wireless sensor networks [1–5].Each network node in wireless sensor network has different attributes, and all sensor nodes have their own local clocks. In today’s high-precision industrial wireless local area networks, time synchronization is a critical technology for distributed systems [6]. It is essential for many wireless network applications to be time-synchronized, such as data fusion and TDMA scheduling. In data fusion applications, it is generally necessary to fuse target data collected by sensor nodes in the data transmission process to reduce network communication and reduce energy consumption [7, 8]. The nodes in the network have the same time standard to ensure data consistency is the primary condition for data fusion. In the design process of some media access layer (MAC layer) protocols, the time division multiple access (TDMA) scheduling algorithm is usually used in order to reduce energy consumption. Time synchronization is also his primary condition, which requires the two parties involved in communication to achieve time synchronization first. In wireless sensor network node positioning, the transmission time of signals such as sound waves is usually used to determine the distance between nodes, and it also depends on the time synchronization of the nodes. The higher the accuracy of time synchronization, the lower the energy consumption of all aspects of the node [9].In wireless sensor networks, there are differences between sensor nodes. The frequency of the crystal oscillator inside the node cannot be exactly the same; in addition to external influences, the node is impacted, such as temperature and pressure. The clocks between nodes will have time deviations. Time synchronization is a key support technology for wireless sensor network systems. Many applications in wireless sensor networks that cooperate with each other to complete applications require time synchronization as a prerequisite. For example, the aforementioned data fusion technology and TDMA scheduling need to be different.In traditional networks, time synchronization mechanisms have been widely used, and many different clock synchronization protocols have been proposed, such as the network time protocol for internet time synchronization [10]. In addition to some special protocols, technologies such as GPS can also achieve global time synchronization in the network. However, the high requirements of NTP for network stability and the high cost of GPS are difficult to meet for wireless sensor networks, so they cannot be directly transplanted and operated.Wireless sensor networks generally adopt the method of exchanging message packets containing time information between nodes to achieve time synchronization. The main factor affecting the accuracy of time synchronization is the time delay in the process of message packet exchange. Restricted by energy, the time synchronization design of sensor nodes in wireless sensor networks will face some of the following problems: (1) Wireless sensor networks usually have many nodes. The deployment of nodes is dense and the scale of the network is generally very large, resulting in a delay in synchronization messages between nodes, which increases the difficulty of realizing time synchronization. (2) Due to node movement, energy exhaustion, and the influence of surrounding environmental factors, the topology of wireless sensor networks changes frequently. It is difficult to predetermine the path for the node to obtain the reference time, which also increases the difficulty of realizing time synchronization. (3) In order to reduce the energy consumption of nodes, wireless sensor network protocols often make nodes dormant for most of the time when they do not need to work together. When a node is in a sleep state, it will stop operating, and the time synchronization state with the entire system cannot be maintained. When a node needs to work, it must quickly synchronize with other nodes and systems in the network after waking up, which also increases the difficulty of achieving time synchronization in wireless sensor networks.


## 2. Related Work

In 1999, the wireless sensor network was selected by “Business Week” as one of the 21 most important technologies in the 21st century. In 2003, the wireless sensor network was selected by the MIT Technology Review magazine as one of the top ten emerging pull techniques that will change human life in the future. As a result of the rapid development and widespread use of wireless sensor networks, industrial structures have been dramatically restructured and human lifestyles have been profoundly influenced. Countries in the world have launched researches on wireless sensor networks. In 2006, our country planned the two frontier directions of information technology by issuing the “Outline of the National Medium and Long-term Science and Technology Development Plan (2006–2020)” [11]. Among them, “Window organization network technology” and “Intelligent perception invitation technology” are directly related to wireless sensor networks. Major domestic universities and research institutes have successively launched a lot of research work in the field of wireless sensor networks.There are numerous applications of wireless sensor networks that rely largely on synchronization of time [12], such as TDMA scheduling [13], data fusion [14], beamforming-oriented multinode collaboration technology [15], and positioning technology based on TOF [16]. Therefore, realizing high-precision and high-performance time synchronization is a research hotspot and difficulty that has always existed in the related fields of wireless sensor networks.In the data packet switching network, the current existing research on time synchronization algorithms is widely used to improve the accuracy of the clock through time information exchange technology, such as the network time protocol [10] widely used on the internet and IEEE1588 precision time synchronization protocol [17] proposed for industrial ethernet. A variety of time synchronization protocols have also emerged for wireless sensor networks, such as FTSP (flooding time synchronization protocol) algorithm [18], DMTS (delay measurement time synchronization) algorithm [19], TPSN (timing-sync protocol for sensor networks) algorithm [20], and RBS (reference broadcast synchronization) algorithm [21]. However, these algorithms are not fully optimized in terms of accuracy and energy efficiency [22].It faces many application environments of wireless sensor networks, especially in industrial fields that require high-precision time synchronization. How to obtain high-precision time synchronization and improve time synchronization performance through optimization measures is still an arduous challenge and the key to time synchronization research. At present, the research on time synchronization of wireless sensor networks is mainly driven by application, and most of them are studied from the perspective of communication protocol and then the protocol is proposed. There is a lack of research on multihop precise time synchronization from the perspective of dynamic system cybernetics, and this rarely involves the construction of time synchronization system models. Research on this aspect at home and abroad is in its infancy, and it is worthy of further discussion.Traditional internet network time synchronization solutions, such as GPS system and NTP protocol, all realize the time synchronization of nodes in the network by synchronizing the time of the nodes in the network with the UTC (Universal Time Coordinated) time source outside the network. In wireless sensor networks, it is usually not required that all node times be synchronized to UTC time. Generally, it is only necessary to synchronize the reference time in the network with the UTC time source at the connection point of the wireless sensor network and other communication networks, that is, the base station node. Therefore, most of the current time synchronization algorithms of wireless sensor networks pay more attention to achieving intranetwork time synchronization. The time synchronization model in the network can be divided into three different levels according to the requirements for time synchronization: sorting, relative synchronization, and absolute synchronization. The first-level network synchronization model is the simplest. It only needs to determine the sequence of occurrence of each node event and does not need to calibrate the time of the node. Therefore, this type of synchronization model is not suitable for applications where it is necessary to know the node time. The second-level model realizes relative time synchronization by establishing the conversion relationship between the local time of different nodes. Compared with absolute synchronization, absolute synchronization does not uniformly synchronize the time of all nodes to the same time base, but only achieves time synchronization between two nodes. The third level of absolute synchronization model is to keep the time of all nodes in the network and the time of the selected reference clock node to maintain time transplantation, which is an absolute synchronization for the entire network. The current research on time synchronization of wireless sensor networks is mainly the latter two-layer model.IEEE1588 precision time synchronization protocol 9 is proposed for industrial wired packet switching networks. Under certain conditions, the time synchronization accuracy of IEEE1588PTP can be controlled at the microsecond level, which is much higher than that of the NTP protocol. At the same time, compared with time protocols such as FTSP and TPSN, IEEE1588PTP has simpler operations and relatively low bandwidth requirements. Therefore, IEEE1588PTP can better balance synchronization accuracy and energy consumption and is more suitable for running on wireless sensor network devices with limited energy and communication bandwidth [23].Based on this, this research attempts to start from the perspective of dynamic system cybernetics and break through the traditional framework of communication protocols as the main body of research [24]. The state-space model is used to describe the dynamic process of time synchronization, and theoretical analysis is closely combined with software simulation. Use uniform sampling and filtering techniques to suppress observation noise and improve the accuracy of time synchronization. At the same time, it can better achieve the consistency of time synchronization data and the robustness of the system, as well as a better compromise between energy consumption and accuracy. Accordingly, this research proposes a precise time synchronization protocol based on Kalman filter optimization in a wireless sensor network environment.


## 3. Method

The essence of time synchronization is to use communication bandwidth and calculation power consumption to exchange time accuracy, which is heavily influenced by the jitter and precision of the time stamps. The time synchronization procedure based on the exchange of time information packets has two components: the deviating physical clock and the protocol for exchanging time information. Therefore, it is necessary to model the physical clock and time information exchange separately.This chapter attempts to introduce the precision time synchronization protocol into the wireless sensor network to study the quantitative relationship between the accuracy of precise time synchronization and the uncertainty and delay jitter of the clock stamp. The AR model is used to construct the state transition equation of the clock, and the precision time synchronization protocol process is modeled as a set of observation equations. As a result, the precision time synchronization protocol’s synchronization performance in the wireless sensor network environment can be improved using the Kalman filter to track the clock offset and clock skew rates.


### 3.1. The Concept of Clock

Before modeling the system clock, it is necessary to understand the mechanism and changing laws of the clock. A counting register and an oscillator with a predetermined frequency are used to time the nodes in the wireless sensor network. The value of the counter register is increased by 1 every time an oscillation pulse appears, and the current clock value can be obtained by reading the value of the counter register. When using a crystal oscillator with a rated frequency, the oscillation pulse output is typically periodic and cannot be modified. This oscillating output is sometimes referred to as local physical time. The counter register holds the local software time, which can be read and modified. In the article that follows, the node’s local clock is adjusted by modifying the software clock on the node itself.


#### 3.1.1. Clock Characteristics

The crystal oscillator periodically generates pulse output at a certain frequency. The evaluation of its performance is mainly manifested in the following two aspects: (1) Frequency stability is the change in the rated frequency of the crystal oscillator. In general, we assume that the rated frequency of oscillation is relatively stable. (2) Frequency accuracy is the difference between the actual frequency and the rated frequency. Relative to frequency accuracy, frequency stability is more important. The stability is determined by the crystal oscillator itself and cannot be compensated or changed. If the frequency accuracy is low, an external compensation method can be used to obtain a clock with a higher frequency accuracy.Under normal circumstances, due to factors such as external temperature, humidity, and crystal impurity, there is a deviation between the operating frequency of the crystal oscillator and the rated frequency, which is called the clock drift rate. In addition, the initialization of nodes is random. Before correction, the initial value of the clock is inconsistent. There is a difference between the initial phases of each node, which is called a clock offset. Even if there is no clock skew, due to the accumulation of the node clock skew rate, after a period of time, it will cause a large clock skew between the node and the node. Therefore, it is necessary to periodically check the clock of the node and keep track of the frequency of the crystal oscillator to ensure that the time synchronization error is within an acceptable range.


#### 3.1.2. Clock Modeling

Clock modeling uses a system of state transition equations to describe the changing law of the local clock of the network node itself. Normally, the local clocks of wireless sensor network nodes have clock skew and are not accurate. In the following discussion, useTPt=t to represent the precise clock, that is, the master clock or the global clock. The clock offset δ is used to describe the difference between the local clock Lt and the global clock TPt, that is, δ=TPt−Lt. The clock skew rate ϕ=1−dLt/dt is used to describe the difference between the local clock frequency and the global clock frequency. The local software clock model mainly describes the relationship between the software clock and the physical clock. The commonly used model is as follows: the software clock performs affine transformation on the hardware clock value. The hardware clock is read-only; that is, the hardware clock rate cannot be changed. Different software and hardware configurations have different software clock models. The value of the software clock in this article is obtained after correcting the value of the physical clock according to δ and ϕ. Because the clock skew rate ϕ is usually affected by environmental factors such as temperature, it changes slowly. It can usually be assumed that, in a small-time interval, ϕ is constant. Therefore, through discretization, the continuous clock model can be transformed into a set of state transition equations in the discrete time domain:(1)δk=∑i=0k−1ϕiλi+δ0+φδk,where δ0 is the initial clock offset (that is, the clock offset value at t = 0), ϕi is the clock offset rate in the time period λi0≤i≤k−1, and φδk is the instantaneous cumulative sum of the clock offset fluctuation μδk, and the expression is: φδk+1=φδk+μδk. Write (1) in recursive form, and the state transition equation of clock offset is(2)δk+1=δk+ϕkλk+μδk.The change of clock skew rate can be described by an AR model; that is, the state transition equation ofϕ is(3)ϕk+1=ϕk+μϕk.Among them,λk is the time synchronization interval. In this article, it is assumed to be fixed, that is, λk=ΔT; μδk represents the white noise of the clock offset, and μϕk represents the noise of the clock offset rate. It is generally considered that μδk and μϕk are two uncorrelated Gaussian white noise processes, with variances σδ2 and σϕ2, respectively.


### 3.2. Time Synchronization Modeling Based on the Kalman Filter

It is assumed that the time stamp obtained based on the synchronization information packet exchange between the master and slave nodes is absolutely accurate and reliable. The calculated observed values of clock skew and clock skew rate can be directly used to correct the local clock to achieve synchronization with the master node. However, due to various uncertain factors in the exchange of synchronization information packets between the master and slave nodes, the time stamp obtained during the period is usually inaccurate and unreliable. Therefore, it needs to be preprocessed by filter technology. On the basis of the established recursive clock model and synchronization protocol model, the Kalman filter equation can be used to implement the recursive estimator. For this purpose, the following observation equation can be obtained:(4)δPk=δk+νδMk,ϕPk=ϕk+νϕPk.Write the state transition equation and the observation equation in matrix form to establish a state space model of clock synchronization:(5)xk=Sxk−1+μk,yk=Mxk+νk.Equations (5) are the clock state equation and observation equation, respectively. xk is the k-th round of clock state vector, yk is the k-th round of clock observation vector, S is the state transition matrix, and M is the parameter matrix of the measurement system, which maps the real state space to the observation space. μk and νk represent process noise and observation noise, respectively. Their expressions are as follows:(6)xk=δkϕk,yk=δPkϕMk,S=1ΔT0R,M=1001,μk=μδkμϕk,νk=νθPkνϕPk.Based on the foregoing analysis, it can be assumed thatμk obeys N0,U normal distribution, νk obeys N0,W normal distribution, and the samples of the two noises are independent of each other. Among them, U and W are the covariance matrices of state noise and observation noise, respectively, and the values are as follows:(7)U=σδ200σϕ2,W=σδP2=12ΔT2ΔT2ΔT2.It should be pointed out that the zero-mean hypothesis ofvk is not necessarily true in the actual system. The mean value of vk is also a variable related to the sending node and the receiving node. Nevertheless, the assumption of zero mean value of vk when the mean value of vk is unknown is necessary to carry out Kalman filtering. The error introduced by the assumption of zero mean will eventually be reflected in the mean value of the time synchronization error. Therefore, the iterative algorithm process of the Kalman filter can be described as the following form: (8) is the prediction process:(8)x˜k|k−1=Sxk−1.Minimum prediction mean square error is(9)Rk|k−1=SRk−1ST+U.Gain matrix is G(k)=(10)Rk|k−1MTMRk|k−1MT+W−1.State correction is(11)x˜k=x˜k|k−1+Gkyk−x˜k|k−1.Least mean square matrix is(12)Rk=1−GkRk|k−1.


## 3.1. The Concept of Clock

Before modeling the system clock, it is necessary to understand the mechanism and changing laws of the clock. A counting register and an oscillator with a predetermined frequency are used to time the nodes in the wireless sensor network. The value of the counter register is increased by 1 every time an oscillation pulse appears, and the current clock value can be obtained by reading the value of the counter register. When using a crystal oscillator with a rated frequency, the oscillation pulse output is typically periodic and cannot be modified. This oscillating output is sometimes referred to as local physical time. The counter register holds the local software time, which can be read and modified. In the article that follows, the node’s local clock is adjusted by modifying the software clock on the node itself.


### 3.1.1. Clock Characteristics

The crystal oscillator periodically generates pulse output at a certain frequency. The evaluation of its performance is mainly manifested in the following two aspects: (1) Frequency stability is the change in the rated frequency of the crystal oscillator. In general, we assume that the rated frequency of oscillation is relatively stable. (2) Frequency accuracy is the difference between the actual frequency and the rated frequency. Relative to frequency accuracy, frequency stability is more important. The stability is determined by the crystal oscillator itself and cannot be compensated or changed. If the frequency accuracy is low, an external compensation method can be used to obtain a clock with a higher frequency accuracy.Under normal circumstances, due to factors such as external temperature, humidity, and crystal impurity, there is a deviation between the operating frequency of the crystal oscillator and the rated frequency, which is called the clock drift rate. In addition, the initialization of nodes is random. Before correction, the initial value of the clock is inconsistent. There is a difference between the initial phases of each node, which is called a clock offset. Even if there is no clock skew, due to the accumulation of the node clock skew rate, after a period of time, it will cause a large clock skew between the node and the node. Therefore, it is necessary to periodically check the clock of the node and keep track of the frequency of the crystal oscillator to ensure that the time synchronization error is within an acceptable range.


### 3.1.2. Clock Modeling

Clock modeling uses a system of state transition equations to describe the changing law of the local clock of the network node itself. Normally, the local clocks of wireless sensor network nodes have clock skew and are not accurate. In the following discussion, useTPt=t to represent the precise clock, that is, the master clock or the global clock. The clock offset δ is used to describe the difference between the local clock Lt and the global clock TPt, that is, δ=TPt−Lt. The clock skew rate ϕ=1−dLt/dt is used to describe the difference between the local clock frequency and the global clock frequency. The local software clock model mainly describes the relationship between the software clock and the physical clock. The commonly used model is as follows: the software clock performs affine transformation on the hardware clock value. The hardware clock is read-only; that is, the hardware clock rate cannot be changed. Different software and hardware configurations have different software clock models. The value of the software clock in this article is obtained after correcting the value of the physical clock according to δ and ϕ. Because the clock skew rate ϕ is usually affected by environmental factors such as temperature, it changes slowly. It can usually be assumed that, in a small-time interval, ϕ is constant. Therefore, through discretization, the continuous clock model can be transformed into a set of state transition equations in the discrete time domain:(1)δk=∑i=0k−1ϕiλi+δ0+φδk,where δ0 is the initial clock offset (that is, the clock offset value at t = 0), ϕi is the clock offset rate in the time period λi0≤i≤k−1, and φδk is the instantaneous cumulative sum of the clock offset fluctuation μδk, and the expression is: φδk+1=φδk+μδk. Write (1) in recursive form, and the state transition equation of clock offset is(2)δk+1=δk+ϕkλk+μδk.The change of clock skew rate can be described by an AR model; that is, the state transition equation ofϕ is(3)ϕk+1=ϕk+μϕk.Among them,λk is the time synchronization interval. In this article, it is assumed to be fixed, that is, λk=ΔT; μδk represents the white noise of the clock offset, and μϕk represents the noise of the clock offset rate. It is generally considered that μδk and μϕk are two uncorrelated Gaussian white noise processes, with variances σδ2 and σϕ2, respectively.


## 3.1.1. Clock Characteristics

The crystal oscillator periodically generates pulse output at a certain frequency. The evaluation of its performance is mainly manifested in the following two aspects: (1) Frequency stability is the change in the rated frequency of the crystal oscillator. In general, we assume that the rated frequency of oscillation is relatively stable. (2) Frequency accuracy is the difference between the actual frequency and the rated frequency. Relative to frequency accuracy, frequency stability is more important. The stability is determined by the crystal oscillator itself and cannot be compensated or changed. If the frequency accuracy is low, an external compensation method can be used to obtain a clock with a higher frequency accuracy.Under normal circumstances, due to factors such as external temperature, humidity, and crystal impurity, there is a deviation between the operating frequency of the crystal oscillator and the rated frequency, which is called the clock drift rate. In addition, the initialization of nodes is random. Before correction, the initial value of the clock is inconsistent. There is a difference between the initial phases of each node, which is called a clock offset. Even if there is no clock skew, due to the accumulation of the node clock skew rate, after a period of time, it will cause a large clock skew between the node and the node. Therefore, it is necessary to periodically check the clock of the node and keep track of the frequency of the crystal oscillator to ensure that the time synchronization error is within an acceptable range.


## 3.1.2. Clock Modeling

Clock modeling uses a system of state transition equations to describe the changing law of the local clock of the network node itself. Normally, the local clocks of wireless sensor network nodes have clock skew and are not accurate. In the following discussion, useTPt=t to represent the precise clock, that is, the master clock or the global clock. The clock offset δ is used to describe the difference between the local clock Lt and the global clock TPt, that is, δ=TPt−Lt. The clock skew rate ϕ=1−dLt/dt is used to describe the difference between the local clock frequency and the global clock frequency. The local software clock model mainly describes the relationship between the software clock and the physical clock. The commonly used model is as follows: the software clock performs affine transformation on the hardware clock value. The hardware clock is read-only; that is, the hardware clock rate cannot be changed. Different software and hardware configurations have different software clock models. The value of the software clock in this article is obtained after correcting the value of the physical clock according to δ and ϕ. Because the clock skew rate ϕ is usually affected by environmental factors such as temperature, it changes slowly. It can usually be assumed that, in a small-time interval, ϕ is constant. Therefore, through discretization, the continuous clock model can be transformed into a set of state transition equations in the discrete time domain:(1)δk=∑i=0k−1ϕiλi+δ0+φδk,where δ0 is the initial clock offset (that is, the clock offset value at t = 0), ϕi is the clock offset rate in the time period λi0≤i≤k−1, and φδk is the instantaneous cumulative sum of the clock offset fluctuation μδk, and the expression is: φδk+1=φδk+μδk. Write (1) in recursive form, and the state transition equation of clock offset is(2)δk+1=δk+ϕkλk+μδk.The change of clock skew rate can be described by an AR model; that is, the state transition equation ofϕ is(3)ϕk+1=ϕk+μϕk.Among them,λk is the time synchronization interval. In this article, it is assumed to be fixed, that is, λk=ΔT; μδk represents the white noise of the clock offset, and μϕk represents the noise of the clock offset rate. It is generally considered that μδk and μϕk are two uncorrelated Gaussian white noise processes, with variances σδ2 and σϕ2, respectively.


## 3.2. Time Synchronization Modeling Based on the Kalman Filter

It is assumed that the time stamp obtained based on the synchronization information packet exchange between the master and slave nodes is absolutely accurate and reliable. The calculated observed values of clock skew and clock skew rate can be directly used to correct the local clock to achieve synchronization with the master node. However, due to various uncertain factors in the exchange of synchronization information packets between the master and slave nodes, the time stamp obtained during the period is usually inaccurate and unreliable. Therefore, it needs to be preprocessed by filter technology. On the basis of the established recursive clock model and synchronization protocol model, the Kalman filter equation can be used to implement the recursive estimator. For this purpose, the following observation equation can be obtained:(4)δPk=δk+νδMk,ϕPk=ϕk+νϕPk.Write the state transition equation and the observation equation in matrix form to establish a state space model of clock synchronization:(5)xk=Sxk−1+μk,yk=Mxk+νk.Equations (5) are the clock state equation and observation equation, respectively. xk is the k-th round of clock state vector, yk is the k-th round of clock observation vector, S is the state transition matrix, and M is the parameter matrix of the measurement system, which maps the real state space to the observation space. μk and νk represent process noise and observation noise, respectively. Their expressions are as follows:(6)xk=δkϕk,yk=δPkϕMk,S=1ΔT0R,M=1001,μk=μδkμϕk,νk=νθPkνϕPk.Based on the foregoing analysis, it can be assumed thatμk obeys N0,U normal distribution, νk obeys N0,W normal distribution, and the samples of the two noises are independent of each other. Among them, U and W are the covariance matrices of state noise and observation noise, respectively, and the values are as follows:(7)U=σδ200σϕ2,W=σδP2=12ΔT2ΔT2ΔT2.It should be pointed out that the zero-mean hypothesis ofvk is not necessarily true in the actual system. The mean value of vk is also a variable related to the sending node and the receiving node. Nevertheless, the assumption of zero mean value of vk when the mean value of vk is unknown is necessary to carry out Kalman filtering. The error introduced by the assumption of zero mean will eventually be reflected in the mean value of the time synchronization error. Therefore, the iterative algorithm process of the Kalman filter can be described as the following form: (8) is the prediction process:(8)x˜k|k−1=Sxk−1.Minimum prediction mean square error is(9)Rk|k−1=SRk−1ST+U.Gain matrix is G(k)=(10)Rk|k−1MTMRk|k−1MT+W−1.State correction is(11)x˜k=x˜k|k−1+Gkyk−x˜k|k−1.Least mean square matrix is(12)Rk=1−GkRk|k−1.


## 4. Experiment

As shown in Table1, this experiment is based on two different clock types: a relatively stable clock (Clock X) and a relatively unstable clock (Clock Y), where σϕ2 represents the variance of the clock skew rate noise and σδ2 represents the variance of clock offset noise.Table 1
Type of clock.
Clock nameParameter valueClock Xσβ2=10−16Clock Yσγ2=10−14Clock Xσβ2=10−12Clock Yσγ2=10−10The synchronization simulation experiment has two protocol modes: one is a precise time synchronization protocol without Kalman filter optimization and the other is a precise time synchronization protocol optimized based on Kalman filter. The experiment design is shown in Table2 for the four simultaneous experiment simulation schemes.Table 2
Experimental simulation program.
Project numberClock typeSynchronization protocol nameKalman filter optimization1Clock XPTPNo2Clock XPTPYes3Clock YPTPNo4Clock YPTPYesBy changing the size of the observation noise, based on the above four schemes, the trend of the mean and standard deviation of the synchronization estimation error from the node clock offset and the clock offset rate is analyzed, and the differences are compared.


### 4.1. Single-Hop Synchronization Simulation Experiment

The single-hop experiment studies the four schemes shown in Table2. The master node clock is absolutely accurate and reliable, and the slave node uses the clock types in Table 1.


#### 4.1.1. Mean Value Analysis of Synchronization Estimation Errors

Figures1 and 2 reflect the change with the observed noise (that is, the standard deviation of the uncertainty from the clock time mark, σsts) and the changing trend of the mean value of the synchronization estimation error of clock skew and clock skew rate reflects the changing law of clock reliability.Figure 1
Average value of the clock offset estimation error.Figure 2
Average value of the clock skew estimation error.It can be seen from Figure1 that as the observed noise increases, the mean value of the estimated error from the node clock offset shows an increasing trend in different protocol modes. The precision time synchronization protocol optimized based on the Kalman filter has a significantly smaller mean value of the clock offset estimation error than the precision time synchronization protocol optimized by the Kalman filter. For different clock types, when the slave node adopts a relatively stable clock, the average value of the estimated error of the slave node clock offset is much lower than that of the relatively unstable clock. When σsts>10−5, its value gradually approaches the use of a relatively unstable clock. When the precise time synchronization protocol without Kalman filter optimization uses the two clock types, clock X and clock Y, the change trend is almost the same. Therefore, it can be seen that when σsts increases to a certain value, clock stability is no longer the main reason that causes the synchronization estimation error to increase, and the main influencing factor is σsts. Whether in the precise time synchronization protocol mode optimized based on Kalman filter or in the precise time synchronization protocol mode optimized by Kalman filter below, the difference is not significant. It is mainly affected by clock offset and clock skew rate, and σsts is not obvious. However, as the observation noise increases, the advantage of the accurate time synchronization protocol based on Kalman filter optimization is very significant. This shows that when σsts is large, the use of filtering technology can reduce the synchronization estimation error.It can be seen from Figure2 that, with the increase of the observed noise, the estimated error average value from the clock skew rate of the node shows a significant increase trend in the precise time synchronization protocol mode without Kalman filter optimization. But in the precise time synchronization protocol mode based on Kalman filter optimization, it shows relative stability and is significantly better than the precise time synchronization protocol without Kalman filter optimization. In different clock types, when the slave node uses a relatively stable clock (Clock X), the average value of the estimated error of the clock skew rate is lower than that of the relatively unstable clock (Clock Y) in the two different protocol modes.


#### 4.1.2. Standard Deviation Analysis of Synchronization Estimation Errors

It can be seen from Figure3 that as the observed noise increases, the standard deviation of the estimated error of the slave node clock offset shows an increasing trend under different protocol modes. Based on the precise time synchronization protocol optimized by the Kalman filter, the standard deviation of the estimation error from the node clock offset is significantly smaller than that of the precise time synchronization protocol optimized by the Kalman filter. For different clock types, when the slave node uses a relatively stable clock (Clock X), in different protocol modes, the standard deviation of the clock offset estimation error is lower than that of the relatively unstable clock (Clock Y). For the same clock type, when the observed noise σsts>10−6 is small, the difference in the standard deviation of the estimated error of the clock offset from the node under different protocol modes is not significant. But as the observation noise σsts>10−6 increases, the precise time synchronization protocol based on Kalman filter optimization has significant advantages.Figure 3
Standard deviation of the clock offset estimation error.It can be seen from Figure4 that as the observed noise increases, the standard deviation of the estimated error from the node clock skew rate shows a significant increase in the precise time synchronization protocol mode without Kalman filter optimization. The optimized precise time synchronization protocol mode shows relative stability and is significantly smaller than the precise time synchronization protocol optimized by the Kalman filter. Under different clock types, when the node uses a relatively stable clock (Clock X), in different protocol modes, the standard deviation of the estimation error of the clock skew rate is lower than that of the relatively unstable clock (Clock Y).Figure 4
Standard deviation of the clock skew estimation error.


### 4.2. Multihop Synchronization Simulation Experiment

The multihop synchronization simulation experiment examines the synchronization performance of different protocol modes as the number of synchronization hops increases and compares their differences. In this experiment, we constructed a two-hop synchronization network composed of five nodes to verify the multihop synchronization performance under different protocol modes.


#### 4.2.1. Multihop Synchronization Experiment Analysis of Different Clock Types

Study the trend and difference of synchronization performance under different clock types and protocol modes as the number of synchronization hops increases. The experimental scheme is shown in Table3.Table 3
Multihop synchronization experiment scheme for different clock types.
Project numberClock typeSynchronization protocol nameKalman filter optimizationSynchronization hops1Clock XPTPNo32Clock XPTPYes33Clock YPTPNo34Clock YPTPYes3


#### 4.2.2. Mean Analysis of the Synchronization Estimation Error

It can be seen from Figure5 that as the observed noise increases, the average value of the estimated error of the clock offset of the two-hop synchronization subnode shows an increasing trend in different protocol modes. Based on the accurate time synchronization protocol optimized by the Kalman filter, the average value of the estimated error of the clock offset of the two-hop synchronization subnode is significantly smaller than that of the accurate time synchronization protocol without Kalman filter optimization. When the observation noise σsts>10−5 is small, there is no accurate time synchronization protocol optimized by the Kalman filter, and the average error of the clock offset estimation error of the two-hop synchronization subnode is not much different. Based on the precise time synchronization protocol optimized by the Kalman filter, the average value of the estimated error of the clock offset of the two-hop synchronization subnode is significantly smaller than that of the relatively unstable clock. When the observation noise σsts>10−5 increases, no matter in the precise time synchronization protocol mode optimized based on the Kalman filter or the precise time synchronization protocol mode optimized by the Kalman filter, the average value of the estimated error of the clock offset of the two-hop synchronization child node is not much different. Therefore, when σsts increases to a certain value, clock stability is no longer the main reason for the increase in synchronization estimation error, and the main influencing factor is σsts. For the same clock type, regardless of whether the slave node uses a relatively stable clock or a relatively unstable clock, compared to the precise time synchronization protocol optimized by the Kalman filter, the clock of the two-hop synchronization subnode is offset. Shift the mean value of estimation error, all have significant advantages.Figure 5
Average value of the clock offset estimation error.It can be seen from Figure6 that as the observed noise increases, the average value of the estimated error of the clock skew of its two-hop synchronization child node shows a significant increase. However, based on the accurate time synchronization protocol optimized by Kalman filter, the average value of the estimated error of the clock skew rate of its two-hop synchronization subnodes shows relative stability and is significantly less accurate than that without Kalman filter optimization. Under different clock types, when the slave node uses a relatively stable clock, the average value of the estimated error of the clock skew rate of the two-hop synchronization subnode is smaller than that of the relatively unstable clock.Figure 6
Average value of the clock skew estimation error.


#### 4.2.3. Standard Deviation Analysis of the Synchronization Estimation Error

It can be seen from Figure7 that as the observed noise increases, the standard deviation of the estimated error of the two-hop synchronization subnode clock offset shows a significant increase. The precision time synchronization protocol is optimized based on the Kalman filter, and the standard deviation of the estimated error of the two-hop synchronization subnode clock offset is significantly smaller than that of the precision time synchronization protocol without Kalman filter optimization. For different clock types, whether it is under the precise time synchronization protocol or under the precise time synchronization protocol, the estimated error of the clock offset of its two-hop synchronization subnode is all lower than those of the relatively unstable clock. For the same clock type, when the observed noise σsts>10−5 is small, the standard deviation of the estimated error of the two-hop synchronization subnode clock offset is not significant. As the observation noise σsts>10−5 increases, compared to the precise time synchronization protocol without Kalman filter optimization, the standard deviation of the synchronization estimation error of the clock offset of the two-hop synchronization subnode is superior significantly.Figure 7
Standard deviation of the clock offset estimation error.It can be seen from Figure8 that as the observed noise increases, the standard deviation of the skew estimation error of the two-hop synchronization subnode shows a significant increase in the precise time synchronization protocol mode without Kalman filter optimization. In the precise time synchronization protocol mode, it shows relative stability and is significantly smaller than the precise time synchronization protocol. For different clock types, when the slave node adopts a relatively stable clock, whether in the precise time synchronization protocol mode or in the precise time synchronization protocol mode, its standard deviation of the estimated error of the clock skew rate of the two-hop synchronization child node is lower than that of the relatively unstable clock.Figure 8
Standard deviation of the clock skew estimation error.


## 4.1. Single-Hop Synchronization Simulation Experiment

The single-hop experiment studies the four schemes shown in Table2. The master node clock is absolutely accurate and reliable, and the slave node uses the clock types in Table 1.


### 4.1.1. Mean Value Analysis of Synchronization Estimation Errors

Figures1 and 2 reflect the change with the observed noise (that is, the standard deviation of the uncertainty from the clock time mark, σsts) and the changing trend of the mean value of the synchronization estimation error of clock skew and clock skew rate reflects the changing law of clock reliability.Figure 1
Average value of the clock offset estimation error.Figure 2
Average value of the clock skew estimation error.It can be seen from Figure1 that as the observed noise increases, the mean value of the estimated error from the node clock offset shows an increasing trend in different protocol modes. The precision time synchronization protocol optimized based on the Kalman filter has a significantly smaller mean value of the clock offset estimation error than the precision time synchronization protocol optimized by the Kalman filter. For different clock types, when the slave node adopts a relatively stable clock, the average value of the estimated error of the slave node clock offset is much lower than that of the relatively unstable clock. When σsts>10−5, its value gradually approaches the use of a relatively unstable clock. When the precise time synchronization protocol without Kalman filter optimization uses the two clock types, clock X and clock Y, the change trend is almost the same. Therefore, it can be seen that when σsts increases to a certain value, clock stability is no longer the main reason that causes the synchronization estimation error to increase, and the main influencing factor is σsts. Whether in the precise time synchronization protocol mode optimized based on Kalman filter or in the precise time synchronization protocol mode optimized by Kalman filter below, the difference is not significant. It is mainly affected by clock offset and clock skew rate, and σsts is not obvious. However, as the observation noise increases, the advantage of the accurate time synchronization protocol based on Kalman filter optimization is very significant. This shows that when σsts is large, the use of filtering technology can reduce the synchronization estimation error.It can be seen from Figure2 that, with the increase of the observed noise, the estimated error average value from the clock skew rate of the node shows a significant increase trend in the precise time synchronization protocol mode without Kalman filter optimization. But in the precise time synchronization protocol mode based on Kalman filter optimization, it shows relative stability and is significantly better than the precise time synchronization protocol without Kalman filter optimization. In different clock types, when the slave node uses a relatively stable clock (Clock X), the average value of the estimated error of the clock skew rate is lower than that of the relatively unstable clock (Clock Y) in the two different protocol modes.


### 4.1.2. Standard Deviation Analysis of Synchronization Estimation Errors

It can be seen from Figure3 that as the observed noise increases, the standard deviation of the estimated error of the slave node clock offset shows an increasing trend under different protocol modes. Based on the precise time synchronization protocol optimized by the Kalman filter, the standard deviation of the estimation error from the node clock offset is significantly smaller than that of the precise time synchronization protocol optimized by the Kalman filter. For different clock types, when the slave node uses a relatively stable clock (Clock X), in different protocol modes, the standard deviation of the clock offset estimation error is lower than that of the relatively unstable clock (Clock Y). For the same clock type, when the observed noise σsts>10−6 is small, the difference in the standard deviation of the estimated error of the clock offset from the node under different protocol modes is not significant. But as the observation noise σsts>10−6 increases, the precise time synchronization protocol based on Kalman filter optimization has significant advantages.Figure 3
Standard deviation of the clock offset estimation error.It can be seen from Figure4 that as the observed noise increases, the standard deviation of the estimated error from the node clock skew rate shows a significant increase in the precise time synchronization protocol mode without Kalman filter optimization. The optimized precise time synchronization protocol mode shows relative stability and is significantly smaller than the precise time synchronization protocol optimized by the Kalman filter. Under different clock types, when the node uses a relatively stable clock (Clock X), in different protocol modes, the standard deviation of the estimation error of the clock skew rate is lower than that of the relatively unstable clock (Clock Y).Figure 4
Standard deviation of the clock skew estimation error.


## 4.1.1. Mean Value Analysis of Synchronization Estimation Errors

Figures1 and 2 reflect the change with the observed noise (that is, the standard deviation of the uncertainty from the clock time mark, σsts) and the changing trend of the mean value of the synchronization estimation error of clock skew and clock skew rate reflects the changing law of clock reliability.Figure 1
Average value of the clock offset estimation error.Figure 2
Average value of the clock skew estimation error.It can be seen from Figure1 that as the observed noise increases, the mean value of the estimated error from the node clock offset shows an increasing trend in different protocol modes. The precision time synchronization protocol optimized based on the Kalman filter has a significantly smaller mean value of the clock offset estimation error than the precision time synchronization protocol optimized by the Kalman filter. For different clock types, when the slave node adopts a relatively stable clock, the average value of the estimated error of the slave node clock offset is much lower than that of the relatively unstable clock. When σsts>10−5, its value gradually approaches the use of a relatively unstable clock. When the precise time synchronization protocol without Kalman filter optimization uses the two clock types, clock X and clock Y, the change trend is almost the same. Therefore, it can be seen that when σsts increases to a certain value, clock stability is no longer the main reason that causes the synchronization estimation error to increase, and the main influencing factor is σsts. Whether in the precise time synchronization protocol mode optimized based on Kalman filter or in the precise time synchronization protocol mode optimized by Kalman filter below, the difference is not significant. It is mainly affected by clock offset and clock skew rate, and σsts is not obvious. However, as the observation noise increases, the advantage of the accurate time synchronization protocol based on Kalman filter optimization is very significant. This shows that when σsts is large, the use of filtering technology can reduce the synchronization estimation error.It can be seen from Figure2 that, with the increase of the observed noise, the estimated error average value from the clock skew rate of the node shows a significant increase trend in the precise time synchronization protocol mode without Kalman filter optimization. But in the precise time synchronization protocol mode based on Kalman filter optimization, it shows relative stability and is significantly better than the precise time synchronization protocol without Kalman filter optimization. In different clock types, when the slave node uses a relatively stable clock (Clock X), the average value of the estimated error of the clock skew rate is lower than that of the relatively unstable clock (Clock Y) in the two different protocol modes.


## 4.1.2. Standard Deviation Analysis of Synchronization Estimation Errors

It can be seen from Figure3 that as the observed noise increases, the standard deviation of the estimated error of the slave node clock offset shows an increasing trend under different protocol modes. Based on the precise time synchronization protocol optimized by the Kalman filter, the standard deviation of the estimation error from the node clock offset is significantly smaller than that of the precise time synchronization protocol optimized by the Kalman filter. For different clock types, when the slave node uses a relatively stable clock (Clock X), in different protocol modes, the standard deviation of the clock offset estimation error is lower than that of the relatively unstable clock (Clock Y). For the same clock type, when the observed noise σsts>10−6 is small, the difference in the standard deviation of the estimated error of the clock offset from the node under different protocol modes is not significant. But as the observation noise σsts>10−6 increases, the precise time synchronization protocol based on Kalman filter optimization has significant advantages.Figure 3
Standard deviation of the clock offset estimation error.It can be seen from Figure4 that as the observed noise increases, the standard deviation of the estimated error from the node clock skew rate shows a significant increase in the precise time synchronization protocol mode without Kalman filter optimization. The optimized precise time synchronization protocol mode shows relative stability and is significantly smaller than the precise time synchronization protocol optimized by the Kalman filter. Under different clock types, when the node uses a relatively stable clock (Clock X), in different protocol modes, the standard deviation of the estimation error of the clock skew rate is lower than that of the relatively unstable clock (Clock Y).Figure 4
Standard deviation of the clock skew estimation error.


## 4.2. Multihop Synchronization Simulation Experiment

The multihop synchronization simulation experiment examines the synchronization performance of different protocol modes as the number of synchronization hops increases and compares their differences. In this experiment, we constructed a two-hop synchronization network composed of five nodes to verify the multihop synchronization performance under different protocol modes.


### 4.2.1. Multihop Synchronization Experiment Analysis of Different Clock Types

Study the trend and difference of synchronization performance under different clock types and protocol modes as the number of synchronization hops increases. The experimental scheme is shown in Table3.Table 3
Multihop synchronization experiment scheme for different clock types.
Project numberClock typeSynchronization protocol nameKalman filter optimizationSynchronization hops1Clock XPTPNo32Clock XPTPYes33Clock YPTPNo34Clock YPTPYes3


### 4.2.2. Mean Analysis of the Synchronization Estimation Error

It can be seen from Figure5 that as the observed noise increases, the average value of the estimated error of the clock offset of the two-hop synchronization subnode shows an increasing trend in different protocol modes. Based on the accurate time synchronization protocol optimized by the Kalman filter, the average value of the estimated error of the clock offset of the two-hop synchronization subnode is significantly smaller than that of the accurate time synchronization protocol without Kalman filter optimization. When the observation noise σsts>10−5 is small, there is no accurate time synchronization protocol optimized by the Kalman filter, and the average error of the clock offset estimation error of the two-hop synchronization subnode is not much different. Based on the precise time synchronization protocol optimized by the Kalman filter, the average value of the estimated error of the clock offset of the two-hop synchronization subnode is significantly smaller than that of the relatively unstable clock. When the observation noise σsts>10−5 increases, no matter in the precise time synchronization protocol mode optimized based on the Kalman filter or the precise time synchronization protocol mode optimized by the Kalman filter, the average value of the estimated error of the clock offset of the two-hop synchronization child node is not much different. Therefore, when σsts increases to a certain value, clock stability is no longer the main reason for the increase in synchronization estimation error, and the main influencing factor is σsts. For the same clock type, regardless of whether the slave node uses a relatively stable clock or a relatively unstable clock, compared to the precise time synchronization protocol optimized by the Kalman filter, the clock of the two-hop synchronization subnode is offset. Shift the mean value of estimation error, all have significant advantages.Figure 5
Average value of the clock offset estimation error.It can be seen from Figure6 that as the observed noise increases, the average value of the estimated error of the clock skew of its two-hop synchronization child node shows a significant increase. However, based on the accurate time synchronization protocol optimized by Kalman filter, the average value of the estimated error of the clock skew rate of its two-hop synchronization subnodes shows relative stability and is significantly less accurate than that without Kalman filter optimization. Under different clock types, when the slave node uses a relatively stable clock, the average value of the estimated error of the clock skew rate of the two-hop synchronization subnode is smaller than that of the relatively unstable clock.Figure 6
Average value of the clock skew estimation error.


### 4.2.3. Standard Deviation Analysis of the Synchronization Estimation Error

It can be seen from Figure7 that as the observed noise increases, the standard deviation of the estimated error of the two-hop synchronization subnode clock offset shows a significant increase. The precision time synchronization protocol is optimized based on the Kalman filter, and the standard deviation of the estimated error of the two-hop synchronization subnode clock offset is significantly smaller than that of the precision time synchronization protocol without Kalman filter optimization. For different clock types, whether it is under the precise time synchronization protocol or under the precise time synchronization protocol, the estimated error of the clock offset of its two-hop synchronization subnode is all lower than those of the relatively unstable clock. For the same clock type, when the observed noise σsts>10−5 is small, the standard deviation of the estimated error of the two-hop synchronization subnode clock offset is not significant. As the observation noise σsts>10−5 increases, compared to the precise time synchronization protocol without Kalman filter optimization, the standard deviation of the synchronization estimation error of the clock offset of the two-hop synchronization subnode is superior significantly.Figure 7
Standard deviation of the clock offset estimation error.It can be seen from Figure8 that as the observed noise increases, the standard deviation of the skew estimation error of the two-hop synchronization subnode shows a significant increase in the precise time synchronization protocol mode without Kalman filter optimization. In the precise time synchronization protocol mode, it shows relative stability and is significantly smaller than the precise time synchronization protocol. For different clock types, when the slave node adopts a relatively stable clock, whether in the precise time synchronization protocol mode or in the precise time synchronization protocol mode, its standard deviation of the estimated error of the clock skew rate of the two-hop synchronization child node is lower than that of the relatively unstable clock.Figure 8
Standard deviation of the clock skew estimation error.


## 4.2.1. Multihop Synchronization Experiment Analysis of Different Clock Types

Study the trend and difference of synchronization performance under different clock types and protocol modes as the number of synchronization hops increases. The experimental scheme is shown in Table3.Table 3
Multihop synchronization experiment scheme for different clock types.
Project numberClock typeSynchronization protocol nameKalman filter optimizationSynchronization hops1Clock XPTPNo32Clock XPTPYes33Clock YPTPNo34Clock YPTPYes3


## 4.2.2. Mean Analysis of the Synchronization Estimation Error

It can be seen from Figure5 that as the observed noise increases, the average value of the estimated error of the clock offset of the two-hop synchronization subnode shows an increasing trend in different protocol modes. Based on the accurate time synchronization protocol optimized by the Kalman filter, the average value of the estimated error of the clock offset of the two-hop synchronization subnode is significantly smaller than that of the accurate time synchronization protocol without Kalman filter optimization. When the observation noise σsts>10−5 is small, there is no accurate time synchronization protocol optimized by the Kalman filter, and the average error of the clock offset estimation error of the two-hop synchronization subnode is not much different. Based on the precise time synchronization protocol optimized by the Kalman filter, the average value of the estimated error of the clock offset of the two-hop synchronization subnode is significantly smaller than that of the relatively unstable clock. When the observation noise σsts>10−5 increases, no matter in the precise time synchronization protocol mode optimized based on the Kalman filter or the precise time synchronization protocol mode optimized by the Kalman filter, the average value of the estimated error of the clock offset of the two-hop synchronization child node is not much different. Therefore, when σsts increases to a certain value, clock stability is no longer the main reason for the increase in synchronization estimation error, and the main influencing factor is σsts. For the same clock type, regardless of whether the slave node uses a relatively stable clock or a relatively unstable clock, compared to the precise time synchronization protocol optimized by the Kalman filter, the clock of the two-hop synchronization subnode is offset. Shift the mean value of estimation error, all have significant advantages.Figure 5
Average value of the clock offset estimation error.It can be seen from Figure6 that as the observed noise increases, the average value of the estimated error of the clock skew of its two-hop synchronization child node shows a significant increase. However, based on the accurate time synchronization protocol optimized by Kalman filter, the average value of the estimated error of the clock skew rate of its two-hop synchronization subnodes shows relative stability and is significantly less accurate than that without Kalman filter optimization. Under different clock types, when the slave node uses a relatively stable clock, the average value of the estimated error of the clock skew rate of the two-hop synchronization subnode is smaller than that of the relatively unstable clock.Figure 6
Average value of the clock skew estimation error.


## 4.2.3. Standard Deviation Analysis of the Synchronization Estimation Error

It can be seen from Figure7 that as the observed noise increases, the standard deviation of the estimated error of the two-hop synchronization subnode clock offset shows a significant increase. The precision time synchronization protocol is optimized based on the Kalman filter, and the standard deviation of the estimated error of the two-hop synchronization subnode clock offset is significantly smaller than that of the precision time synchronization protocol without Kalman filter optimization. For different clock types, whether it is under the precise time synchronization protocol or under the precise time synchronization protocol, the estimated error of the clock offset of its two-hop synchronization subnode is all lower than those of the relatively unstable clock. For the same clock type, when the observed noise σsts>10−5 is small, the standard deviation of the estimated error of the two-hop synchronization subnode clock offset is not significant. As the observation noise σsts>10−5 increases, compared to the precise time synchronization protocol without Kalman filter optimization, the standard deviation of the synchronization estimation error of the clock offset of the two-hop synchronization subnode is superior significantly.Figure 7
Standard deviation of the clock offset estimation error.It can be seen from Figure8 that as the observed noise increases, the standard deviation of the skew estimation error of the two-hop synchronization subnode shows a significant increase in the precise time synchronization protocol mode without Kalman filter optimization. In the precise time synchronization protocol mode, it shows relative stability and is significantly smaller than the precise time synchronization protocol. For different clock types, when the slave node adopts a relatively stable clock, whether in the precise time synchronization protocol mode or in the precise time synchronization protocol mode, its standard deviation of the estimated error of the clock skew rate of the two-hop synchronization child node is lower than that of the relatively unstable clock.Figure 8
Standard deviation of the clock skew estimation error.


## 5. Conclusion

Wireless sensor network is an important branch of distributed system, and time synchronization is one of its important supporting technologies. Due to the limited energy of wireless sensor network nodes, low computing power, low communication capacity, and other factors, as well as the unique attributes and design requirements of wireless communication channels and self-organizing networks, it is difficult for traditional time synchronization techniques to be directly applied to wireless sensors internet. Therefore, how to obtain high-precision time synchronization is still a huge challenge for the applications of wireless sensor networks, especially in industrial fields sensitive to time synchronization accuracy. Taking optimization measures to improve synchronization performance is a key research issue. At present, in the data packet switching network, the widely used time synchronization algorithm mainly adopts the time information packet switching technology, and its research content is mainly how to improve the accuracy of the clock through the exchange of time information. How to apply PTP to wireless sensor networks and improve the accuracy of time synchronization is a challenge topic in current related research. In this study, from the perspective of dynamics, the Kalman filter is used to optimize the precise time synchronization protocol, which is applied to wireless sensor networks, and its performance is verified based on simulation experiments.The experimental results show that the precise time synchronization protocol optimized based on the Kalman filter is compared to the precise time synchronization protocol optimized without the Kalman filter. Whether the slave node uses a relatively stable clock or a relatively unstable clock and single-hop synchronization and multihop synchronization, the accuracy and stability of the estimation error of the clock offset and the clock skew rate are excellent, and it has obvious advantages and can show better synchronization performance. When the observation noise is relatively small, for single-hop time synchronization, the advantage of the accurate time synchronization protocol based on Kalman filter optimization is not significant, but for multihop time synchronization, the advantage is significant; as the observation noise gradually increases, based on Kalman filter precise time synchronization protocol optimized by the controller, whether it is single-hop synchronization or multihop synchronization, it has significant advantages. Therefore, the precise time synchronization protocol optimized based on the Kalman filter can show excellent synchronization performance in synchronization networks with large observation noise or a large number of synchronization hops. This shows that the Kalman filter can better filter out the synchronization noise and suppress the transmission of synchronization errors, which is beneficial to the expansion of the synchronization network.In summary, this research starts from the perspective of dynamics, breaks through the traditional framework of communication protocol as the main research body, uses state-space model to describe the dynamic process of time synchronization, closely combines theoretical analysis and software simulation, and uses them uniformly. Sampling and filtering techniques suppress observation noise, improve the accuracy of time synchronization, and are applied to wireless sensor networks.



---

*Source: 2766796-2022-02-27.xml*