# Data Collection Based on Opportunistic Node Connections in Wireless Sensor Networks
## 4 Data Collection Scheme Based on Opportunistic Node Connections
### The Optimal Path Calculation Based on the Opportunistic Connection Random Graph
Figure 7: The process of constructing the spanning tree step by step, in which a node with max value of PC in set U will be transferred to set K, (**a**) an OCRG with seven nodes; (**b**) initialization; (**c**) step 1: transferring \(v_{1}\); (**d**) step 2: transferring \(v_{2}\); (**e**) step 3: transferring \(v_{6}\); (**f**) step 4: transferring \(v_{3}\); (**g**) step 5: transferring \(v_{5}\); (**h**) step 6: transferring \(v_{4}\); (**i**) a spanning tree with \(v_{\text{sink}}\) as the root node. to the energy efficient probe message forwarding mechanism. Moreover, recalling that the mobile sink can choose to re-broadcast the tag message randomly during the current data collection period, the nodes that have not received this tag message will also send their probe messages to the mobile sink. On receiving these probe messages, the mobile sink could re-construct an OCRG, then re-calculate the optimal path from itself to each node in this OCRG and update the spanning tree accordingly. In fact, for a node, its optimal path on the spanning tree is the most reliable path for it to forward its sensing data to the mobile sink. However, due to using the asynchronous working-sleeping cycle strategy for nodes, so during data transmission process along this path, any forwarder on the path may be in sleeping status which could lead to the failed link connection, it further causes the failure of data transmission. To solve this problem, a routing protocol that adapts to different nodes operating statuses is proposed to improve the reliability of data transmission and Algorithm 3 gives the detailed routing protocol. In this routing protocol, assuming that the sensing data from node \(v_{s}\) is being forwarded along its optimal path on the spanning tree to the mobile sink. When an intermediate node \(v_{m}\) receives the data, it should forward it to its father node \(v_{n}\) only if \(v_{n}\) is in working status, otherwise, \(v_{m}\) should select other forwarder from its neighbors to continue this data forwarding. This kind of forwarder selection method is described as follows. For each neighbor \(v_{i}\) of \(v_{m}\) that is on the spanning tree, \(v_{m}\) calculates the link connectivity \(P_{v_{m}v_{i}}\) between them according to Equation (14), by obtaining the value of PC (\(PC_{path(v_{i}v_{\text{sink},*})}\)) stored in \(v_{i}\) locally it then can calculate (\(P_{v_{m}v_{i}}\times PC_{path(v_{i}v_{\text{sink},*})}\)) to get the PC of the path \(v_{m}\)-\(v_{i}\)-\(v_{\text{sink}}\), accordingly, \(v_{m}\) selects the neighbor on path \(v_{m}\)-\(v_{i}\)-\(v_{\text{sink}}\) with a max value of PC as the forwarder. ```
1. Assuming that the sensing data from node \(v_{s}\) is forwarded along its optimal path on the spanning tree to the mobile sink;
2. When an intermediate node \(v_{m}\) receives the sensing data:
3. if (its father node \(v_{n}\) is in working status)
4. Forward the sensing data to \(v_{n}\);
5. \(v_{n}\) employs this routing protocol to forward the data;
6. else\(//v_{n}\) is in sleeping status
7. if (\(v_{m}\) has neighbors on the spanning tree)
8. for each neighbor \(v_{i}\)do
9. Calculate \(P_{v_{m}v_{i}}\) according to Equation (14);
10. Calculate the PC of the path \(v_{m}\)-\(v_{i}\)-\(v_{\text{sink}}\);
11. endfor
12. Select the neighbor that on a path with a max value of PC as the forwarder;
13. Forward the sensing data to this forwarder;
14. The forwarder employs this routing protocol to forward the data;
15. else
16. Stop forwarding this data;
17. endif
18. endif
```  
**Algorithm 3** The routing protocol  
Figure 8 depicts the detailed process of a source node \(v_{s}\) forwards its sensing data to \(v_{\text{sink}}\). Node \(v_{s}\) forwards the data to its father node \(v_{1}\), and then \(v_{1}\) forwards it to its father node \(v_{2}\). Since the father node \(v_{3}\) of \(v_{2}\) is in sleeping status, \(v_{2}\) needs to find other forwarder.