RB Particle Filter Time Synchronization Algorithm Based on the DPM Model

Time synchronization is essential for node localization, target tracking, data fusion, and various other Wireless Sensor Network (WSN) applications. To improve the estimation accuracy of continuous clock offset and skew of mobile nodes in WSNs, we propose a novel time synchronization algorithm, the Rao-Blackwellised (RB) particle filter time synchronization algorithm based on the Dirichlet process mixture (DPM) model. In a state-space equation with a linear substructure, state variables are divided into linear and non-linear variables by the RB particle filter algorithm. These two variables can be estimated using Kalman filter and particle filter, respectively, which improves the computational efficiency more so than if only the particle filter was used. In addition, the DPM model is used to describe the distribution of non-deterministic delays and to automatically adjust the number of Gaussian mixture model components based on the observational data. This improves the estimation accuracy of clock offset and skew, which allows achieving the time synchronization. The time synchronization performance of this algorithm is also validated by computer simulations and experimental measurements. The results show that the proposed algorithm has a higher time synchronization precision than traditional time synchronization algorithms.

To solve the lack of the adaptive regulation method in modeling the delay distribution based on GMM, we conducted work on two fronts. First, we improve estimation accuracy of delay distributions based on the non-parametric Bayesian model. Next, we reduce the amount of computation in tracking non-Gaussian clock offset and skew based on the Rao-Blackwellised particle filter (RBPF). In order to overcome the limitations of the Gaussian mixture model, the Dirichlet process mixture (DPM) model is used to estimate the delay distribution, which can adjust the number of Gaussian models automatically based on the observational data. Subsequently, the DPM-based Rao-Blackwellised particle filter (DPM-RBPF) algorithm is proposed [21,22], where the system model is divided into linear and non-linear parts-it uses the particle filter and the Kalman filter to estimate the non-linear and the linear parts, respectively. Hence, the DPM-RBPF algorithm can efficiently track clock offset and skew in the non-Gaussian dynamic model. Time synchronization is achieved by improving the efficiency and accuracy of the continuous clock offset and skew estimation process.
The rest of this paper is organized as follows. In Section 2, the DPM-RBPF algorithm is stated in detail-it includes the two-way timing message exchange model, the DPM model description of the observation noise, and the RBPF algorithm. In Section 3, we compare the proposed algorithm with the other algorithms, and verify time synchronization performance of our algorithm. In Section 4, we draw conclusions and look ahead to the development direction of this research.

RBPF Time Synchronization Algorithm Based on the DPM Model
The time synchronization is the continuous clock offset and skew estimation, but it is crucial to deal with non-deterministic delay and packet loss. Therefore, this paper proposes a DPM-RBPF algorithm, which introduces a DPM model description of the observation noise and RBPF algorithm based on two-way timing message exchange. Consequently, the clock offset and skew tracking is achieved with the improved computational efficiency and accuracy.

State-Space Equation of Two-Way Timing Message Exchange
The two-way timing message exchange method is commonly employed in time synchronization. The specific exchange process of this method is illustrated in Figure 1. In Figure 1, the kth time set of message departure and arrival 1 The observation model can be derived from Equation (1) as follows: If the clock skew cannot be ignored (i.e., , 0 B k φ ≠ ), then the clock offset continue to change with time, as shown in Figure 1. Therefore, the clock offset and skew should be continuously estimated to improve the accuracy and reliability of synchronization. Here, we adopt the constant clock skew model as follows.
where t Δ is the time interval of two-way timing message exchange, i.e., where 1 k v − is the Gaussian state noise with zero mean and covariance Q , which reflects the effects of environmental temperature, crystal ageing, power supply voltage fluctuation, etc.
If the clock skew can be ignored (i.e., , 0 B k φ = ), the initial clock offset is the only parameter to be estimated. Assuming the clock offset as the state variables, the state-space equation of the two-way timing message exchange can be described as follows [18]: is the observation noise.

Observation Noise DPM Model
For the unknown observation noise, the DPM model [23] is used to estimate its probability density function. The DPM model, as a non-parametric Bayesian model, has been widely used in the probability density estimation, data clustering [24], which can flexibly adjust model parameters and the component number. The graphical model of DPM model is shown in Figure 2.
where α is the concentration parameter of the Dirichlet distribution. K is the dimensional number of Dirichlet distribution. M is the number of the posterior component. In this work, the likelihood function ( ) F ⋅ is selected to be the Gaussian distribution, and the conjugate prior 0 G is described as the product of a Gaussian distribution and an inverse chi-squared distribution: If the observation noise l n is randomly selected, the indicator l c and the parameter of the which is a gamma distribution with parameters a m s normal components in the mixture model, after given α , the w , s and m may be sampled from the following distribution is given by: where w and s obey beta and binomial distributions, respectively. The ( , ) s L m and ( ) Γ ⋅ are unsigned Stirling numbers of the first kind and gamma function, respectively. The number of normal components m can be calculate based on the concentration parameter α and the number of observations L , it means that the DPM model can flexibly adjust the number of gaussian components using the observation data.

State Tracking Based on DPM-RBFPF
For the non-Gaussian observation noise in the state-space equation of clock offset or skew, the DPM-RBPF algorithm is used for time synchronization. The DPM model is used to describe the observation noise. RBPF is used to track clock offset or skew. RBPF is widely used in visual tracking, simultaneous localization and mapping (SLAM), and other fields [26,27]. It divides the state variables into linear and non-linear parts based on the Rao-Blackwell statistical theory, and improves the computational efficiency of the particle filter by integrating the Kalman filter.
As shown in Equation (4), by exchanging the times information between Node A and B for L times, we get the entire observation data Thus, the estimation of the unknown variables is divided into the estimation of the linear and non-linear variables independently through the marginalization of the probability density function. The Kalman filter is used to estimate the linear variable, and the particle filter is used to calculate the non-linear variable. Since the variable dimension of , the DPM-RBPF algorithm needs fewer particles than the standard particle filter, which can effectively improve the computational efficiency of this algorithm [28]. The following section describes linear and non-linear estimation, respectively. The posterior probability density of the non-linear hidden variable k c can be approximated by a set of random particles with certain importance weight, such that the posterior can be approximated as follows: Initially, the particle i k c is sampled according to the Equation (8), and its importance weight i k w is calculated using the sequential Monte Carlo sampling as follows: In order to simplify the calculation of the importance weight i k w , the proposal distribution is usually chosen to be equal to the conditional posterior Therefore, the posterior probability density function is approximately expressed by using a mixture of densities shown as follows: Finally, the minimum mean squared error (MMSE) estimation of linear state variable and noise covariance matrix can be written as follows:

Algorithmic Process
We propose the DPM-RBPF algorithm to improve the accuracy and efficiency of continuous clock offset and skew estimation in TPSN. It includes three key steps. First, the state-space equation is initialized and the DPM model is trained based on the approximate observation noise in Equation (5). Next, the particles of the indicator are re-sampled based on the updated weights. Furthermore, the DPM model is continuously retrained based on the new obtained observations and state values. Finally, the particles of the state variable are calculated using the Kalman filter and the state variable is estimated to complete time synchronization between two nodes. The process of DPM-RBPF algorithm is listed as shown below in Algorithm 1: Step (1) Initialize the DPM model and the state-space equation.
• Set the concentration parameter α and the base distribution 0 G . According to the approximate observation noise data set, the DPM model is trained using Equations (7)-(11). • Set the initial state variable 0ˆML x x = .
• Sample the N initial particles of the model component indicator from DPM model. • Initialize the importance weight of particles uniformly.
Step (2) Resample the particles and update the DPM model.
• Calculate and normalize the importance weights using Equation (14). Step (3) Estimate the state variable.
• According to Equation (15), the state variables of all particles are updated. According to the Equation (17), the state variables are calculated. • If the online calculation is not complete, return to Step (2).

The Performance and the Analysis
In this section, the estimation accuracy and computational efficiency of the DPM-RBPF algorithm are compared with the Maximum Likelihood Estimation (MLE) [15,16], the Advanced Self-Correcting Time Synchronization (ASCTS) [29] and the Iterative Gaussian Mixture Kalman Particle Filter (IGMKPF) algorithm [20]. The performance of the proposed algorithm is verified via computer simulations and experimental measurements, and the influence of the number of observations, particles, and other parameters is analyzed in detail. Unless otherwise specified in the following experiments, it is assumed that the variance Q of state noise is equal to set to 500, and the concentration parameter α is followed by gamma prior with the shape 1 a = and the scale 1 b = .

Simulations' Comparison
Assuming that the non-deterministic delay model obeys Gaussian distribution and Laplace  As shown in Figure 3, with an increase in the number of observations, there is a gradual reduction in MSE. A smaller MSE implies that there is a higher precision of time synchronization. Comparing the four algorithms-MLE, ASCTS, IGMKPF and DPM-RBPF-DPM-RBPF is better than MLE, ASCTS and IGMKPF in MSE of the clock offset estimation. This indicates that the DPM model describes the observation noise more accurately. The hypothetical observation noise distribution model used by MLE is probably different from the actual observation noise distribution model. Therefore, the performance of MLE is worse than the other two algorithms, which implement an adaptive observation noise model.
Gaussian distribution and Laplace distribution are symmetrical, but the delay noise is often asymmetric. As a result, the performances of the algorithms are compared under conditions of asymmetric delay noise, and the computational efficiency of DPM-RBPF and IGMKPF are tested. Assuming the non-deterministic delay model obeys an asymmetric distribution, k R is the Gaussian distribution with zero mean and 0.01 variance, and k M is the exponential distribution with 0.01 rate parameter. Figure 4a shows the comparison of the estimation results of different algorithms. Since the hypothetical noise distribution is inconsistent with the actual noise distribution, the performance of MLE under conditions of symmetrical Gaussian distribution or symmetrical exponential distribution (Laplace distribution) becomes worse. The performance of DPM-RBPF remains superior to the four comparative algorithms. Figure 4b shows the number of particles needed by DPM-RBPF, DPM-PF and IGMKPF under different MSE. For the same MSE, DPM-RBPF requires fewer particles than DPM-PF and IGMKPF. The calculation extent of DPM-RBPF is less than the other algorithms to achieve the same accuracy. This means that the RBPF can improve the computational efficiency.

Parameters' Analysis
The impact of the relevant parameters on the DPM-RBPF algorithm is discussed in this section. Since sensor nodes are energy-constrained, the number of the time message exchanges between the nodes is limited, and the number of particles for the RBPF algorithm is also limited. In order to minimize energy consumption for a given synchronization accuracy, we evaluate the impart of the number of observations and the number of particles on the DPM-RBPF algorithm. Figure 5a shows the relationship between the number of observations L and the MSE of the clock offset when the numbers of particles are 100, 200, 300, 400, and 500, respectively. As can be seen from the figure, with fewer particles (N = 100 or N = 200), MSE only changes slightly with an increase in the number of observations. In other words, when the number of particles is too small, the DPM-RBPF algorithm cannot fully exploit the time information of observations. However, when the number of particles is greater than 300, we find that the MSE becomes smaller with an increase in the number observations. In order to guarantee that MSE is less than -5 7e , and to minimize energy consumption of nodes, we select 20 L = and 400 N ≥ .

Experimental Measurement
To evaluate the time synchronization performance, we set up a testing system with four mobile nodes based on Arduino Uno boards, as shown in Figure 6. Arduino Uno is a microcontroller board based on the ATmega328 processor with 16 MHz crystal clock oscillator. The on-chip memory includes 32 KB of flash memory, 1 KB of EEPROM and 2 KB of SRAM. All Arduino Uno configured with CC3000 WiFi Shield establish the communication links to each other through a wireless router. The program of the proposed DPM-RBPF algorithm is running on the control computer with a 2.27 GHz CPU and 16 GB RAM. According to the two-way timing message exchange method, the control computer periodically sends the timestamps packet to four mobile nodes. When the mobile node receives a timestamps packet, it would read the clock at the time of receiving and sending the timestamps packet. These clocks are calibrated based on the clock offset in the timestamps packet, and fill back the timestamps packet. Then, the timestamps packet was immediately sent back to the control computer for the next clock skew tracking. The format of timestamps packet is {T0,k,T1,k,T2,k,T3,k,T4,k}, which includes the clock offset T0,k, the computer clock T1,k and T4,k at time of receiving and sending the timestamps packet, and the node clock T2,k and T3,k at the time of receiving and sending timestamps packet, where k is the number of two-way timing message exchanges. If there is no clock offset calibration (It means the T0,k in timestamp packet is set to 0), the clock in timestamps packet from k0 to k0 + 3 times is shown in the left section of Table 1. Due to the existence of the clock offset and skew between the control computer and the mobile node, T1,k, T4,k and T2,k , T3,k have a significant difference. If there is a clock offset calibration, as shown in the right section of Table 1, the clock values from T1,k to T4,k continue to increase, which is consistent with the chronological laws of the timestamps packet exchange. Using the build test system, the clock synchronization performances of ASCTS and DPM-RBPF algorithm were compared. The tracking curves of the clock offset and skew of four mobile nodes are shown in Figure 7. There is a certain clock offset and skew to every mobile node at the start time.
Through tracking the clock offset and skew, the clock offset gradually moves towards zero, which means the clock synchronization can be achieved. Compared with ASCTS, DPM-RBPF can quickly complete the clock synchronization, which calibrates the clock offset at 20, 22, 25, 39 steps, respectively, to four mobile nodes. The tracking curves of DPM-RBPF algorithm show a small fluctuation. This means that the proposed method has better tracking performance. Quantitative analysis of time synchronization is shown in Table 2. The mean and standard deviation of clock offset and skew in the steady state are listed. Since the observation noise is randomly distributed with nonzero mean, the estimation of clock offset in steady state has certain bias. This bias can usually be counteracted by system calibration. The standard deviation (STD) in Table 2 shows less tracking fluctuation in DPM-RBPF than ASCTS, which means that the time synchronization performance of DPM-RBPF is superior to ASCTS's. In order to reveal the effect of the DPM model updated in the experiment, different observation intervals L Δ are selected. It means the DPM model is updated after obtaining a different number of observation noises, which are calculated based on the observations and the estimated state variables. When two different time intervals 10 and 20 are selected, the tracking curves of the clock offset and skew on node A are shown in Figure 8. As shown in Figure 8, since the update of the observation noise model is inconsistent, the tracking curves appear different within the 10-40 observation point range. Despite ignoring the clock skew in the initialization of the observation noise model, the tracking curves soon become identical after more than 40 points. It means that the updating DPM model can better adapt to environmental change and the DPM model is able to describe the unknown observation noise, which ensures the accurate tracking of clock offset and skew.

Conclusions
In this paper, we propose a novel time synchronization algorithm, DPM-RBPF, to improve the accuracy and efficiency of continuous clock offset and skew estimation in a dynamic sensor network. In the proposed algorithm, a unified state-space equation is constructed to track the clock offset and skew, and a DPM model is used to describe the distribution of observation noise, which can flexibly adjust the number of Gaussian components to enhance the adaptability of the observation noise model. In addition, simulation experiments indicate the advantages of the proposed algorithm in terms of estimation precision and computational efficiency compared with the other algorithms-such as SGML, SEML, ASCTS and IGMKPF algorithms. We also discuss the parameters' selection process of the proposed algorithm. The results of computer simulations and test systems demonstrate that the proposed algorithm outperforms other algorithms in time synchronization accuracy.