# Reference Broadcast-Based Secure Time Synchronization for Industrial Wireless Sensor Networks
## 4 RSTS Protocol
### RSTS Synchronization  
From Equations (2) and (4), under security attacks, the safe nodes use an invalid timestamp \(\tau_{A}^{j}(t)\) for relative clock skew and offset updating, that is to say, the timestamps from attackers directly act on the estimation of compensation values. By analyzing Equation (1), the clock offset between two nodes \(i\) and \(j\) at time \(t\) is  
\[\Delta\tau_{ij}(t)=\tau_{j}(t)-\tau_{i}(t)=(\alpha_{j}-\alpha_{i})t+(\beta_{j}- \beta_{i}). \tag{5}\]  
Note that \(t=(\tau_{i}(t)-\beta_{i})/\alpha_{i}\), which yields  
\[ \begin{array}{ll}\Delta\tau_{ij}(t)&=\left(\alpha_{j}-\alpha_{i}\right)\frac {\tau_{i}(t)-\beta_{i}}{\alpha_{i}}+\left(\beta_{j}-\beta_{i}\right)\\ &=\left(\alpha_{ij}-1\right)\tau_{i}(t)+\left(\beta_{j}-\alpha_{ij}\beta_{i} \right)\\ &=\left(\alpha_{ij}-1\right)\tau_{i}(t)+\beta_{ij}\end{array} . \tag{6}\]  
Hence, based on messages \(<\!\tau_{i}(k),\Delta\tau_{ij}(t)\!\succ\!,\,k=1,2,\cdots,n\), the estimation of \(\alpha_{ij}\) and \(\beta_{ij}\) are rewritten as  
\[\left\{ \begin{array}{ll}\hat{\alpha}_{ij}=1+\frac{\sum_{k=1}^{n}\left( \Delta\tau_{ij}(k)-\overline{\Delta\tau_{ij}}\right)(\tau_{i}(k)-\overline{ \tau_{i}})}{\sum_{k=1}^{n}(\tau_{i}(k)-\overline{\tau_{i}})^{2}}\\ \hat{\beta}_{ij}=\overline{\Delta\tau_{ij}}-\left(\hat{\alpha}_{ij}-1\right) \overline{\tau_{i}}\end{array} \right.. \tag{7}\]  
Comparing Equations (4) and (7), presumably, we ask whether there are any reliable methods to obtain the valid \(\Delta\tau_{ij}(t)\) under attacks. Classic reference broadcast synchronization (RBS) protocol [24; 26] exchanges receiving timestamps of messages from a common reference node between two receivers. Each receiver computes its time offset to any other receiver as the average of the time offsets. Finally, synchronization is achieved among receivers rather than synchronizing with the reference node. Inspired by RBS, we design the RSTS protocol. The key insight of RSTS is to exploit the public neighbor forwarding mechanism so that the illegal timestamps can be filtered. We summarize the RSTS process in Algorithm 1, where \(G\) denotes the topology graph of an IWSN, \(V\) is the set of nodes, \(e_{ij}\) indicates that node \(i\) and \(j\) can communicate, and \(N_{i}\) is the neighbor set of node \(i\). In RSTS's synchronization process, the public reference neighbor \(j\) of two non-adjacent nodes \(l\) and \(i\), i.e., the slave node \(l\) and the master node \(i\), broadcasts its local time \(\tau_{j}(t)\) marked by a preset sequence number \(seq_{j}(t)\) periodically. The two nodes record the times based on their clocks once receiving the broadcast messages, i.e., \(<\!\tau_{i}(t),\,seq_{j}(t)\!\succ\!\) and \(<\!\tau_{l}(t),\,seq_{j}(t)\!\succ\!\). Subsequently, if the master node \(i\) is in the sync state, it immediately sends the timestamp \(<\!\hat{\tau}_{i0}(t),\,seq_{j}(t)\!\succ\!\), where \(\hat{\tau}_{i0}(t)\) is the estimated clock source time, to the slave node through public neighbor forwarding. Based on the \(n\) records \(<\!\Delta\tau_{i0}(t),\,\tau_{i}(t)\!\succ\!\), where \(\Delta\tau_{i0}(t)\) is the time difference of \(\hat{\tau}_{i0}(t)\) and \(\tau_{l}(t)\!\succ\!\), the slaver \(l\) estimates the clock compensation \(<\!\hat{\alpha}_{i0},\,\hat{\beta}_{i0}\!\succ\!\) in Equation (7). Meanwhile, node \(l\) achieves synchronization with the time source and denotes it as the sync state. From the above, detailed analysis of RSTS, it has a time complexity with \(O(n)\). Since no node can manipulate the information received from its neighbors with information checking in medium access control protocol [16], the receiving timestamps from the master node can be safely forwarded through the public neighbor. We use an example to illustrate how RSTS works. Consider a simple network scenario in Figure 3, where node \(m\) is the reference master node, node \(s\) is the slave node, node \(r\) is the shared neighbor node, and node \(A_{i}\) is the attacker.