## 4 EMOR Protocol Design for WSN in NAN
### Optimal Multi-Disjoint Path Selection for Real-Time and Non-Real-Time Traffic
Formation of data set \(D\)(\(S\),\(N_{s}\),\(W\)/\(S\),\(F_{ST}\),\(R_{E}\),\(B_{S}\),\(S\)/\(N\)) Output:
2. Optimal multi-disjoint paths for delay-sensitive and delay-tolerant traffic Begin:
3. for each awake node \(V_{i}\) and \(V_{j}\) in network, do
4. Determine \(L_{V|V_{i}}\) in terms of \(TF\), \(R_{E}\), \(B_{S}\), \(S\)/\(N\) for first and second best hop decision criteria
5. if (delay sensitive traffic is needed), then //real-time data
6. \(L_{V|V_{i}}^{RT}=\max\limits_{V\
ot\in N}\{\alpha TF_{V|V_{i}}+\beta R_{E,V_{i} }+\gamma B_{S},\gamma_{i}+\sigma(S/N)_{VIV_{j}}\}\)
7. elseif (delay tolerant traffic is needed), then //non-real-time data
8. \(L_{V|V_{i}}^{NT}=2 nd\max\limits_{V\
ot\in N}\{\alpha TF_{V|V_{i}}+\beta R_{E,V _{i}}+\gamma B_{S,V_{i}}+\sigma(S/N)_{VIV_{j}}\}\)
9. else Link connectivity cannot be established due to status transition (i.e., node sleeping)
10. end if
11. Determine the path connectivity for both delay-sensitive and delay-tolerant traffic
12. if (delay-sensitive traffic is needed), then //real-time data
13. \(PC_{V_{SINK}V_{j}}^{RT}=PC_{V_{SINK}V_{i}}^{RT}\times\prod\limits_{k=0}^{t-2}L_ {V_{i+k}V_{i+(k+1)}}^{RT}\times L_{V_{i+t-1}V_{i+t}}^{RT}\)
14. elseif (delay tolerant traffic is needed), then //non-real-time data
15. \(PC_{V_{SINK}V_{j}}^{NT}=PC_{V_{SINK}V_{i}}^{NT}\times\prod\limits_{k=0}^{t-2}L_ {V_{i+k}V_{i+(k+1)}}^{NT}\times L_{V_{i+t-1}V_{i+t}}^{NT}\)
16. else link and path connectivity failed (i.e., path is no longer available)
17. end if
18. Formulate real-time and non-real-time paths from total paths \(\mu\) if (delay sensitive traffic is needed), then //real-time data
20. total real-time paths will be \(\tau*PATH(V_{SINK},V_{j},*)=\tau*\{V_{SINK},V_{i}^{RT},\ldots V_{i+t-1}^{RT},V_ {j}\}\)
21. else total non-real-time paths will be \(\varepsilon*PATH(V_{SINK},V_{j},*)=\varepsilon*\{V_{SINK},V_{i}^{NT},\ldots V _{i+t-1}^{NT},V_{j}\}\);
22. end if
23. Select the optimal path using following expressions
24. \(\max\{PC_{V_{SINK}V_{j}}^{RT},PC_{V_{SINK}V_{i}}^{RT}\times\prod\limits_{k=0}^ {t-2}L_{V_{i+k}V_{i+(k+1)}}^{RT}\times L_{V_{i+t+1}V_{i+t}}^{RT}\}\)
25. \(\max\{PC_{V_{SINK}V_{j}}^{NT},V_{j}^{RT}\times\prod\limits_{k=0}^{t-2}L_{V_{ i+k}V_{i+(k+1)}}^{NT}\times L_{V_{i+t+1}V_{i+t}}^{NT}\}\)
26. end for
```  
**Algorithm 3**Optimal Multi-Disjoint Paths Selection for Real-Time and Non-Real-Time Traffic  
After the selection of optimal paths for real-time and non-real-time traffic, we need to define our routing strategy for data transmission and reception. The traditional opportunistic node connection routing only includes asynchronous working-sleeping cycle of sensor nodes which could lead to failed link connection sometimes, due to the sleeping mode of any forwarder node. Also, it does not support different type of data requirements in SGs, so in order to resolve this ambiguity, we need energy-efficient multi-disjoint path supporting opportunistic connection routing protocol. Algorithm 4 provide details about our routing strategy for delay sensitive and delay tolerant traffic in EMOR. ```
1. OCRG, spanning tree formation, optimal path connectivity for distinguishable service
2. Energy efficient routing protocol based on optimal path connectivity for distinguishable service Begin:
3. Assuming that NAN sensing data from node \(V_{m}\) is forwarded to \(V_{\text{SINK}}\) using optimal path
4. When an intermediate node \(V_{r}\) receives the sensing data in NAN:
5. _if_ (the successor node \(V_{s}\) of node \(V_{r}\) is in working mode), _then_
6. Forward the sensing data to \(V_{s}\)
7. _if_ (\(V_{s}\) knows optimal path towards \(V_{\text{SINK}}\) in its routing table), _then_
8. \(V_{s}\) receives the sensing data from \(V_{r}\) and forwards the data on optimal path;
9. _elseif_ (\(V_{s}\) does not know optimal path towards \(V_{\text{SINK}}\) in its routing table), _then_
10. _if_ (\(V_{s}\) has neighbors on the spanning tree), _then_
11. _for_ (each working neighbor \(V_{i}\) of \(V_{s}\) node), _do_
12. _if_ (delay sensitive traffic is needed), _then_
13.