# A Design of a Time Synchronization Protocol Based on Dynamic Route and Forwarding Certification
## 4 Realization of DRFC-TSP on an Embedded Linux Platform
### Realization Process
#### 4.2.2 Synchronization Process of the Non-Root Node  
The synchronization flow chart of the non-root node is shown in Figure 4.  
1. All of the non-root nodes keep the UDP server online to monitor the synchronization packet.
2. When the node detects a packet, go to step (_d_); otherwise, go to step (_c_).
3. If the timer for \(T_{wait}\) is up, the node should send a request for synchronization to its neighbors because a void appears. After the packets from neighbors are received, go to step (_h_); otherwise, go to step (_a_).
4. When the node to be synchronized detects a synchronization packet, it should determine whether the current message is a time synchronization packet or forwarding certification. If a time synchronization packet is received, then go to step (_e_); otherwise, it is a forwarding certification packet, so go to step (_k_).
5. The timer of synchronization is turned on to count down \(T_{ref}\).
6. The node to be synchronized records several parameters in the received packet, such as the current round number, the hop count, _Std_, the sending time, etc. Furthermore, it needs to record the local time when the current packet is received. These parameters are tentatively set as the reference node information for the node. The node to be synchronized keeps on receiving other packets and compares synchronization information with its record. If the performance of the newly received synchronization message is better than the current record, the record about candidate reference nodes is updated; otherwise, the record remains unchanged.
7. If the timer for \(T_{ref}\) is up, go to step (_h_); otherwise, go to step (_a_).  
Figure 4: Synchronization flow chart of the non-root node.  
* Turn off UDP monitoring. The node is synchronized according to the records and caching information in this round.
* If the node is forwarding certificated, go to step (_j_); otherwise, the node does nothing, so go step (_n_).
* Generate the time synchronization packet and forward it to the next hop. The current round of synchronization is finished, so go to step (_n_).
* The timer for certification is turned on.
* The number of neighbors is marked as My_Neighbor plus 1 when a node receives a certification packet. If the Std of the neighbor node is smaller than that of the current node, it is considered that the neighbor performs better, and the ranking parameter marked as My_Place of the current node is increased by 1; otherwise, it is considered that the neighbor performs worse, and My_Place remains unchanged.
* Determine whether the timer for certification has expired, if not, continue to step (_l_); otherwise, turn off UDP monitoring, and then compare the two parameters My_Place and My_Neighbor. If My_Place \(\leq\) R\({}_{\rm cer}\times\) My_neighbor, then the node's performance is considered to be better than the threshold, so it is authorized with forwarding certification and set as Flag_QA = 1. If not, this node is not certificated and marked as Flag_QA with 0. Then, go to step (_i_).
* Restart the UDP monitor for packets of the next round, and then go to step (_a_).