An Effective Frequency Drift and Phase Offset Estimation Based on Two-Way Message Exchange for WSNs Time Synchronization

Time synchronization is one of the key technologies of wireless sensor networks. At present, most studies assume that the transmission delay is a xed value, and there is no eective processing of historical clock data. erefore, this paper proposes a clock frequency drift and phase oset estimation scheme which is considering variable transmission delay and historical clock data.is paper has claried the eectiveness of the Gaussian delay model in the calculation of time synchronization error. On this basis, this paper calculated the maximum likelihood estimations of frequency drift and phase oset and the corresponding Cramer-Rao lower bound. Meanwhile, the transmission delay is optimized by comparing the chi-square distance between measured and standard data. Also, this paper conducts autonomous training on historical data to provide services for improving the accuracy of tting estimation. Simulation results validate the performance of the proposed scheme.


Introduction
As the key technology of the Internet of ings and 5G, wireless sensor networks (WSNs) have signi cant advantages in data collection, signal transmission, and information processing [1]. In WSNs designing, many factors need to be considered, such as hardware constraints, network tolerance in the event of node failure, dynamic network topology, and network energy consumption. Meanwhile, time synchronization technology is the top priority for majority of the WSNs applications. On one hand, the e cient time synchronization is conducive to adapting to dynamic topology changes and reducing energy consumption. On the other hand, it can improve performance indicators and ensure system reliability for applications such as data fusion, energy management, positioning, and target tracking [2]. erefore, many researchers have studied the time synchronization in WSNs. An energy-e cient coe cient exchange synchronization protocol was proposed in [3]. e protocol achieves high synchronization accuracy without requiring packet-level time-stamping but with a signi cant reduction on communication overhead to achieve low power consumption. Reference [4] proposed an asymmetric high-precision time synchronization scheme. e study proposed time synchronization scheme can avoid time synchronization errors resulting from the single-precision oating-point arithmetic of the resource-constrained sensor nodes and achieve microsecond-level time synchronization accuracy in multihop WSNs. Reference [5] introduced an e ective energy-saving method to jointly estimate the phase o set and frequency skew. e study proposed time synchronization method only requires two data samples and obtains a suitable estimator by using linear programming. In [6], a beaconless energy-e cient time synchronization protocol has been proposed based on reverse one-way message dissemination. ese studies improve the time synchronization mechanism from the perspective of network protocols and focus on the exchange method and quantity of synchronization packets. Nevertheless, there is no speci c analysis and implementation for the estimation methods of phase o set and frequency drift. In [7], based on the reverse asymmetric time synchronization framework, the study has introduced the idea of compensating for the processing delays at packet-relaying gateways to address the cumulative end-to-end synchronization error as an energy-efficient way of multihop extension of WSN time synchronization schemes. In [8], a fusion method of time synchronization with periodical data transmission and acknowledgment is proposed for WSNs. e maximum likelihood estimators (MLE) of clock skew and fixed delay and the simplified MLE of clock skew under the Gaussian random delay are derived. Novel clock skew and offset estimators were designed assuming different delay environments to achieve energy-efficient network-wide synchronization for WSNs [9]. It also derived the Cramer-Rao lower bounds (CRLB) and the maximum likelihood estimators under different delay models and assumptions.
is type of research improves network synchronization accuracy from the perspective of phase offset and frequency drift estimation. However, the study treats the transmission delay as a fixed value. e maximum likelihood estimators of the clock skew and the corresponding CRLB were derived assuming Gaussian delays in [10]. e method clarifies a time delay model for certain estimation, but it does not do any processing on the empirical data after the estimation is completed, which is a defect of the modern wireless sensor network synchronization technology.
is paper presents a frequency drift and phase offset estimation scheme based on two-way message exchange. e contributions of this paper are listed as follows. First, we prove the effectiveness of the Gaussian delay model in the calculation of time synchronization error through simulation. us, we calculate the maximum likelihood estimations of frequency drift and phase offset and the corresponding CRLB. Second, the transmission delay is optimized by comparing the chi-square distance between measured and standard data.
ird, we conduct autonomous training on historical clock data to provide services for improving the accuracy of fitting estimation.

System Model
Assuming that the local clock of node z is t z and t is the ideal reference time, the time model can be defined as where α drift is the frequency drift, and β offset is the phase offset [11]. Frequency drift and phase offset are two important parameters that affect the accuracy of pairwise node synchronization errors. e frequency drift is mainly affected by the crystal oscillator of the node microcontroller, and the phase offset is mainly determined by various delays and frequency changes. e central limit theorem asserts the probability density function of the sum of a large number of independent and identically distributed random variable approaches that of Gaussian random variables. If the delay is considered as the addition of numerous independent random processes, this model will be appropriate [9]. In this paper, we use the simulation environment proposed by Elson et al. [12] to prove that the local time difference between the two nodes conforms to the Gaussian distribution. e best parameter result of simulation fitting by our simulation is μ � 0.048, σ � 11.2 μs, and it is very close to the conclusion drawn in [12]. As shown in Figure 1, we estimate the frequency drift and phase offset by the two-way timing message exchange model based on the sender-receiver synchronization mechanism.
e two nodes are defined as the master node M and slave node S. In the i-th round of packet exchange, node S sends a synchronization packet to node M at T S 1,i which needs to synchronize with node M. After node M receives the packet, it records the current time T M 2,i and returns a message to node S at T M 3,i . en, node S receives the replied message and records arrival time at T S 4,i . According to (1) and two-way timing message exchange model from Figure where φ (SM) delay and φ (MS) delay denote the transmission delay in the bidirectional synchronization packet transmission, ε (SM) and ε (MS) denote uncertain delay caused by random noise during bidirectional synchronization packet transmission, α i drift is the frequency drift of the i-th round packets exchange, and β i initial is the initial phase offset. erefore, it can be seen that the time delay, nondeterministic random noise, and initial phase offset in the transmission process determine the local time of each node at each moment. Meanwhile, on the basis of two-way timing message exchange theory, the time synchronization deviation Δ i between node S and node M can be calculated by en, substituting (2) and (3) into (4), Δ i can be calculated by Node M Node S

Mobile Information Systems
Let en, Δ i can be rewritten by (7) Δ e following sections will estimate α drift and β offset after N rounds of data exchange, so as to achieve the purpose of improving the accuracy of time synchronization.

Frequency Drift Estimation.
In time synchronization, each node oscillator has its unique clock frequency, which will cause clock difference among nodes as time goes. In this section, we consider that the frequency drift is only affected by a single factor of the crystal change. erefore, the goal of this part is to estimate frequency drift α drift and the corresponding CRLB on the observation of [1, N] based on Gaussian delay model.
From (4) and (5), we can get the following equation: Let en, (8) can be expressed as In (10), initial phase offset β i offset in T i is the phase offset of the previous round information exchange. We will give the estimation method of this item in the next section, which is considered to be a known condition here. e effect of transmission delay Φ i will be discussed in Section 4, which is also considered to be a known term. Assuming that N times of information exchange is a period, and E i is distributed as Gaussian random variables as shown in Section 2. us, the likelihood function with respect to frequency drift α dr ift and the variance σ 2 is given by Maximizing a likelihood function is equivalent to maximize its natural logarithm. erefore, we derivate α dr ift with respect to L as us, estimated frequency drift can be calculated as Next, we calculate the CRLB to evaluate the estimated effect of frequency drift. e second-order derivative of the log-likelihood function with respect to α drift is e expectations of (14) can be expressed as en, the CRLB of α dr ift can be obtained as follows:

Phase Offset Estimation.
e phase offset is not only related to the initial phase offset but also related to the frequency drift. Adding (2) and (3) to get the expression of initial phase offset, it can be shown as Substituting (20) into the expression of phase offset, we can obtain where T M i � T M 2,i + T M 3,i , and the equation (21) can be rewritten as us, the likelihood function with respect to phase offset β offset and the variance σ 2 for Gaussian delay model is given by (20) en, the derivative of β offset corresponding to L can be expressed as (21) erefore, the phase offset is estimated by We also calculate the CRLB to evaluate the estimated effect of phase offset. e second-order derivative of the loglikelihood function with respect to β offset is e expectations of (23) can be expressed as en the CRLB of β offset can be obtained as follows: (25)

Transmission Delay Optimization and Clock Data Update
After the estimation of frequency drift and phase offset, this section focuses on the uncertain transmission delay optimization in time synchronization estimation. Meanwhile, most synchronization algorithms do not deal with the local time-stamp historical data, which makes the synchronization algorithm to lack the ability of adaptive evaluation, so this section also uses autonomous training methods to update the clock data.

Transmission Delay Optimization.
e various delays present in message delivery in WSNs include the following components: (1)Send Time-the time it takes to prepare the message and pass it to lower layers (nondeterministic). (2) Access Time-delay incurred by waiting for access to the transmit channel up to the point when transmission begins (non-deterministic). (3) Transmission Time-the time it takes for the sender to transmit the message. is time is in the order of tens of milliseconds depending on the length of the message and the speed of the radio (deterministic). (4) Propagation Time-the time it takes for the message to transmit from sender to receiver once it has left the sender (negligible, as it is below 1μs for 300 meters ). (5) Reception Time-the time it takes for the receiver to receive the message (deterministic). (6) Receive Time-time to construct and send the received message to the application layer at the receiver. e delay components can also be divided into two categories: fixed portion and variable portion. e transmission delay is often recognized as fixed [13]. But due to the mobility of the node or channel fading changes, the transmission delay often varies greatly. erefore, the optimization of the transmission delay is an important measure to ensure the estimation accuracy. Assuming that Φ N � φ 1 , φ 2 , · · · , φ i , · · · , φ N denotes the set of transmission delay after N rounds of data exchange. We use the vector transformation as shown below to normalize the transmission delay (26) en, Φ N can be rewritten as Φ N � φ 1 , φ 2 , · · · , φ i , · · · , φ N }. Assuming that standard transmission delay is φ s , we compare the chi-square distance of transmission delay between Φ N and φ s by where D i denotes the difference between the observation data Φ N and the standard data. Let D th represent the difference threshold, and then, the transmission delay can be determined by

Clock Data Update.
In order to make the local timestamp data empirical value gradually approach the ideal value, we perform data update scheme. It mainly conducts autonomous training on historical data to provide services for improving the accuracy of fitting estimation. Let T M I � T M 1 , T M 2 , · · · , T M i , · · · , T M N , T S I � T S 1 , T S 2 , · · · , T S i , · · · , T S N }, for the purpose of ensuring the accuracy of the data during the fitting process, the two sets need to satisfy

Numerical Results
e simulations are carried out to evaluate the frequency drift and phase offset on the basis of the Gaussian delay model. We first compare the mean square error (MSE) of frequency drift and phase offset and corresponding CRLB.
en, we apply the estimation method, transmission delay optimization strategy, and clock data update scheme proposed in this paper to the time synchronization algorithm in [14] and compare the synchronization error with the enhanced precision time synchronization (E-PTS) algorithm [15] and the enhanced flooding time synchronization protocol (E-FTSP) algorithm [16]. e simulation parameters are shown in Table 1. Figure 2 shows the simulation result of MSE and the corresponding CRLB of frequency drift with different transmission delays. It can be seen that the curve of MLE with optimized transmission delay performs close to the CRLB, and its variance goes to zero as the number of observations increases. erefore, the performance of frequency drift estimation is effective. Also, the CRLB can predict this value well also. Note that the estimation with delay optimization works better than fixed transmission delay. Figure 3 compares the performance of the proposed phase offset estimation method considering the optimized transmission delay with the fixed transmission delay. It can be seen that the MLE of optimized transmission delay outperforms the fixed delay due to the help of delay data screening and identification. We can also conclude that the MLE of phase offset with optimized transmission delay performs close to the CRLB, and its variance goes to zero as the number of observations increases. erefore, the performance of phase offset estimation is effective. e proposed algorithm uses a Gaussian delay model to estimate frequency drift and phase deviation. By optimizing the transmission delay and realizing the clock data update, the cumulative time synchronization error is minimized. In Figure 4, with the increase in the number of observations, the average synchronization error of the proposed algorithm is between 10 and 20 μs, and the average synchronization error of the E-PTS algorithm and E-FTSP algorithm is between 42-60 μs and 48-78 μs, respectively. erefore, the proposed algorithm in this paper has better time synchronization accuracy when paired nodes carry out time synchronization.

Conclusion
In this paper, we have proposed a clock frequency drift and phase offset estimation scheme for WSNs' time synchronization. Based on the Gaussian delay model, this scheme calculates the maximum likelihood estimations of frequency drift and phase offset and the corresponding CRLB. At the same time, this paper also optimizes the transmission delay and updates historical clock data. Simulation results show that the scheme proposed in this paper improves the estimation accuracy and reduces the time synchronization error.

Data Availability
No data were used in this study.       Mobile Information Systems