## 4 EMOR Protocol Design for WSN in NAN
### Optimal Paths Calculation and Spanning Tree Design  
After the construction of OCRG, we need to find the optimal path in EMOR for our sensor node's data to reach the sink node successfully. In order to establish the optimal path, we need to design a spanning tree algorithm which will help us in determining the maximum value of path connectivity from any sensor node to mobile sink node. Using this algorithm, we will select the optimal multi-disjoint paths for real-time and non-real-time traffic towards mobile sink (NAN gateway) in Section 4.5. Path connectivity (PC) depends on the link connectivity of adjacent sensor nodes and is calculated as the product of individual link connectivity values between sensor nodes along the path towards the sink node. The reliability of the data delivery depends on the link connectivity between adjacent sensor nodes and optimal path selection. PC for a path (\(V_{i}\), \(V_{i+t}\), t) according to Figure 4 can be formulated in Equation (9) as:  
\[PC_{V_{i}V_{j}}=PC_{V_{i}V_{i}+t}\ =\prod_{k=0}^{t-1}L_{V_{i+k},V_{i+(k+1)}} \tag{9}\]  
Similarly, the PC for neighboring nodes \(V_{i}\) of mobile sink node \(V_{SINK}\) will be:  
\[PC_{V_{SINK}V_{i}}\ =L_{V_{SINK}V_{i}} \tag{10}\]  
During the construction of the spanning tree, it is pertinent to mention that the nodes whose optimal path are formed already, since they were the neighbors of mobile sink, can help the mobile sink node in getting the optimal paths of intermediate and far-end nodes. Equations (8), (9) and (10) help us in determining the PC of node \(V_{j}\) to mobile sink. The PC from mobile sink node to an unknown sensor node \(V_{j}\) depends on 2 factors: (i) PC between mobile sink and its neighboring nodes and (ii) link connectivity between mobile sink's neighboring node \(V_{i}\) and unknown sensor node \(V_{j}\). \[PC_{V_{SINK}V_{j}}\ =PC_{V_{SINK}Vi}\times\prod_{k=0}^{t-1}L_{V_{i+k},V_{i+(k+1)}} \tag{11}\]  
\[PATH(V_{SINK},V_{j},\star)=\left\{V_{SINK},V_{j},t+1\right\}=\left\{V_{SINK}, V_{i},\dots V_{i+t-1},V_{j}\right\} \tag{12}\]  
where \(PC_{V_{SINK}Vi}\) is the path connectivity from the mobile sink to neighboring node \(V_{i}\). Here we have assumed that \(V_{j}=V_{i+t}\) for which \(t\) is the number of hops on the path from \(V_{i}\) to \(V_{j}\) and it satisfies the criteria \(1\leq t\leq N-1\). In every round of communication (iteration), the mobile sink acquires the updated path connectivity values of intermediate and far-end sensor nodes deployed in the NAN, compares it with the previous PC values, and selects the max PC value. The same process is repeated  
Figure 4: Representation of opportunistic connection random graph (OCRG) based on the link connectivity. until mobile sink node receives the updated path and max PC information of all the nodes present in the network. \[PC_{V_{SINK}V_{j}}^{updated}=\max\{PC_{V_{SINK}V_{j}},PC_{V_{SINK}V_{i}}\times \prod_{k=0}^{t-1}L_{V_{i+k}V_{i+(k+1)}}^{updated}\} \tag{13}\]  
\[PATH(V_{SINK},V_{j},*)=\left\{V_{SINK},V_{j},t+1_{updated}\right\}=\left\{V_{ SINK},V_{i},\ldots V_{i+t-1(updated)},V_{j}\right\} \tag{14}\]  
This spanning tree formation is useful in reducing the overall delay in the network as if the mobile sink needed to explore all the possible paths before selecting the optimal path and determining which one has maximum PC value would have resulted in more delay and a less efficient spanning tree design. The formation of a spanning tree and optimal path calculation after construction of OCRG can be seen in Figure 5 and Table 2. It can be depicted from Figure 5b that after construction of OCRG, the mobile sink starts the initialization phase by connecting to its immediate neighbors. Figure 5c shows the path connectivity between the mobile sink and neighbors of the neighbors of mobile sink (i.e., node V\({}_{4}\) and V\({}_{5}\)). The process of spanning tree formation continues from Figure 5d-i based on the optimal path connectivity rule in Algorithm 2.