# Energy-Efficient Opportunistic Routing Algorithm for Post-Disaster Mine Internet of Things Networks
## 4 Proposed DEOR Algorithm
### Selection of Relay Node
In this article, the proposed relay node selection method based on routing quality evaluation determines the optimal relay node for packet forwarding, so that an energy-efficient routing path between the sender and the sink can be achieved. By utilizing the local metrics of forwarders to make routing decisions, DEOR reduces routing overhead and extends network lifetime. The schematic diagram of relay node selection is shown in \[\theta_{i,j}=\arccos\frac{\overrightarrow{a}\cdot\overrightarrow{c}}{ \left|\overrightarrow{a}\right|\left|\cdot\right|\left|\overrightarrow{c} \right|} \tag{10}\]2  
According to the routing quality \(\overline{Q}_{i,j}\) value, we sort the forwarders of \(n_{1}\) in descending order, denoted as \(C(\overline{Q}_{i})\). As we can see in Figure 5, for the current sender \(n_{1}\) carrying packets, \(C_{\text{up}}(1)\) is the candidate forwarding sets of \(n_{1}\), where \(C_{\text{up}}(1)=\{n_{2},n_{3},n_{4}\}\). When \(n_{1}\) needs to find the next-hop routing node, it will send a request message to all nodes in \(C_{\text{up}}(1)\). After receiving this message, these forwarders send a reply message about their own information to \(n_{1}\). Then, according to Formulas (12), (15) and (17), \(n_{1}\) calculates the three attribute values of nodes \(n_{2}\), \(n_{3}\), and \(n_{4}\), i.e., \((\widetilde{\theta}_{1,2},\widetilde{d}_{1,2},\widetilde{\varepsilon}_{1,2})\), \((\widetilde{\theta}_{1,3},\widetilde{d}_{1,3},\widetilde{\varepsilon}_{1,3})\), and \((\widetilde{\theta}_{1,4},\widetilde{d}_{1,4},\widetilde{\varepsilon}_{1,4})\). Next, \(n_{1}\) calculates the routing quality values of three forwarders based on Formula (19), i.e., \(\overline{Q}_{1,2}\), \(\overline{Q}_{1,3}\), and \(\overline{Q}_{1,4}\). Finally, the three routing quality values are compared. Assuming that \(\overline{Q}_{1,4}>\overline{Q}_{1,3}>\overline{Q}_{1,2}\), the forwarders' priority sorting set of the sender \(n_{1}\) can be denoted as \(C(\overline{Q}_{1})=\{n_{4},n_{3},n_{2}\}\). The sender \(n_{1}\) selects the candidate with the largest \(\overline{Q}_{i,j}\) value as the next hop, i.e., \(\overline{Q}_{1,4}\). The best relay node \(n_{4}\) forwards the packets, and if the transmission is successful, the other nodes \(n_{2}\) and \(n_{3}\) discard the packet copies. Since \(n_{4}\) is not the destination node, it becomes the new sender and continues to select the next hop through the above process until the packet is forwarded to the sink. Finally, a complete routing path is formed in the network, denoted as \((n_{1},\;n_{4},\;n_{6},\;n_{9},\;\text{Sink})\) in \[\theta_{i,j}=\arccos\frac{\overrightarrow{a}\cdot\overrightarrow{c}}{ \left|\overrightarrow{a}\right|\left|\cdot\right|\left|\overrightarrow{c} \right|} \tag{10}\]3 The pseudocode of the selection of relay nodes is shown in Algorithm 2. ```
Input : \(\overline{Q}_{i,j}=(\overline{Q}_{i,1},\overline{Q}_{i,2},\ldots,\overline{Q}_ {i,c_{i}})\) Output: The ID of the best relay nodes
1:for each node \(n_{j}\in C(i)\) do
2: node \(n_{j}\) receives the packets sent by node \(n_{i}\)
3: Get the \(\widetilde{\theta}_{i,j}\) using Equation (12)
4: Get the \(\widetilde{d}_{i,j}\) using Equation (15)
5: Get the \(\widetilde{e}_{i,j}\) using Equation (17)
6: Calculate \(\overline{Q}_{i,j}\) using Equation (19)
7: sort \(\left(\overline{Q}_{i,1},\overline{Q}_{i,2},\ldots,\overline{Q}_{i,c_{i}}\right)\) in descending order to \(C(\overline{Q}_{i})\)
8:endfor
9: select the node \(n_{j}\) from the highest--\(C(\overline{Q}_{i})\)
10:if\(n_{j}\) forwards the packet successfully
11:then other nodes in \(C(i)\) drop the packet
12:else
13: set the node \(n_{j}\;=\;n_{5}\) where \(n_{j}\) has lower--\(C(\overline{Q}_{i})\)
14:endif
15:until the timer expired
16:if packet is not delivered to Sink
17:then\(n_{\text{sender}}=n_{j}\)
18: switch to Algorithm 1
19:endif
```  
**Algorithm 2**Select the Best Relay Nodes