# Performance Analysis of Time Synchronization Protocols in Wireless Sensor Networks
## 4 Simulation Setup  
The performance of time synchronization can vary even when implemented on the same hardware platform [32]. For example, with the same Berkeley notes platform, researchers that proposed Reference Broadcast Synchronization (RBS) [38] protocol reported 11 us precision, while another study [39] reported 29 us precision for RBS. It is difficult to conclude that the latter evaluation is incorrect because the difference in precision may have been caused by different conditions in the evaluation (e.g., network topology, message delays, clock drift). Therefore, to ensure fairness and repeatability in the comparison of time synchronization protocols, a simulation-based approach is more appropriate for this study.  
The Riverbed Modeler (OPNET) [40] is used to evaluate the performance of FTSP and GTSP. The implementations of FTSP ([[https://github.com/tinyos/tinyos-main/tree/master/tos/lib/ftsp](https://github.com/tinyos/tinyos-main/tree/master/tos/lib/ftsp)]([https://github.com/tinyos/tinyos-main/tree/master/tos/lib/ftsp](https://github.com/tinyos/tinyos-main/tree/master/tos/lib/ftsp))) and GTSP ([[https://github.com/phsommer/sinalgo-timesync](https://github.com/phsommer/sinalgo-timesync)]([https://github.com/phsommer/sinalgo-timesync](https://github.com/phsommer/sinalgo-timesync))) are referred from original implementation used to simulate these protocols. The MAC layer timestamp is implemented for both protocols. Figure 1 describes the node model in our simulation. A node model includes basic layers of a sensor node such as the application layer, MAC layer, and physical layer. The functions of time synchronization protocols are implemented at the application layer. However, the timestamp in the message is captured at the moment it is transmitted or received by the physical layer. Because GTSP does not require a reference node, it is unfair to compare its convergence time with that of FTSP which includes a leader election process. Hence, the first node (with ID = 1) is predefined as the reference node in FTSP so that the network can start the synchronization process immediately after the nodes are turned on. Each node in the network is set to a uniform random clock drift of \(\pm\) 30-100 ppm. This clock drift range is reasonable because a sensor node typically uses inexpensive oscillators, and this is assumed in most studies [7; 16; 18; 41].  
Figure 1: Node model in OPNET used to implement protocols in the evaluation.  
The network size is 600 m \(\times\) 600 m and the transmission range is set to 100 m, which allows distances of up to 12 hops in the network (grid topology 7 \(\times\) 7) similarly to the evaluation of FTSP [1] and GTSP [1]. In a random topology, the positions of all nodes are uniformly and randomly distributed in the network. Noted that the following assumptions are made about the network: (1) the network is connected and (2) the connection link between nodes is symmetric. To support microsecond resolutions, the oscillator frequency is set to 1 MHz, implying that it generates one tick every microsecond. The settings of FTSP and GTSP are derived from the original studies of [1] and [1], respectively.  
Each simulation execution is run for 2 hours (7200 seconds) and repeated 10 times. Different seeds are used in different executions to ensure that the random values are varied. However, it is important to note that in each particular simulation run, the simulation conditions (e.g., network topology, message delays, and clock drift) of each protocol are identical. The measurement data are collected after each synchronization round (30 s as default). Table 1 summarizes the default settings of the protocols and network, and a few settings are changed to evaluate the effects of different aspects on the protocols in each scenario. The simulation results are explained in the next section.