## 4 The Proposed QoS-Aware Routing
### Reliability Control  
Link quality degradation, congestion, node mobility, link failure(s), node failure(s), _etc._ may cause packet losses, which affect the reliable data delivery to the destination(s). It has been shown in the literature that the probability of successful packet delivery to the destination can be increased by sending duplicate packets over multiple spatially separated routes [11; 12; 15; 16]. However, choosing the most appropriate next-hop nodes (\(NH_{r}\)) of multiple routes toward different sinks to assure end-to-end required reliability as well as determining the optimized number of such next-hop nodes (\(NH_{r,opt}\)) are challenging problems.  
In our reliability control algorithm (see Algorithm 1), we use greedy approach to solve the above problems. At first, each node \(i\), for each sink \(s\in\mathcal{S}\), identifies a candidate downstream node \(j\) that produces the maximum link reliability \(\hat{r}_{i,j}\) and stores it in the variable \(NH_{r}\) (lines 1-3); the estimation method of the parameter \(\hat{r}_{i,j}\) will be discussed in Section 4.5. If \(|NH_{r}|\) returns a NULL, the packet is dropped immediately; and, if it returns only one node, the packet is forwarded toward that next-hop node (lines 4-9) provided that its offered reliability is greater than the required reliability \(R\); otherwise, the packet is dropped due to unavailability of feasible path. In the case \(|NH_{r}|\) returns multiple nodes, the nodes from the list \(NH_{r}\) are chosen one after another (in descending order of their \(\hat{r}_{i,j}\) values) until their aggregate reliability becomes greater than or equal to the required reliability, \(R\) (lines 11-17). Since the reliability is a multiplicative metric, we calculate the failure probability \(F=F\times(1-\hat{r}_{i,j})\), as presented in line 16. In fact, the above operation produces the optimal number of next-hop nodes \(|NH_{r,opt}|\) that determines the degree of packet duplication for the reliability control. Note also that the value of \(|NH_{r,opt|}\) ranges between 1 (best case) and the maximum number of sinks in the network (worst case). Therefore, our reliability control algorithm uses only the adequate number of duplicate packets, which in turn minimizes the routing and energy overheads compared to those of other approaches.  
INPUT: RP or CP packets, required reliability \(R\) and \(i\)'s single hop neighbor nodes \(\mathcal{N}_{i,s},\ \forall s\in\mathcal{S}\)  
1. **for** each \(s\in\mathcal{S}\)**do**
2. \(NH_{r}=\{j\in\mathcal{N}_{i,s}:\hat{r}_{i,j}=\max_{j\in\mathcal{N}_{i,s}}(\hat {r}_{i,j})\}\)
3. **end for**
4. **if**(\(|NH_{r}|==\) Null) **then**
5. Drop the packet immediately;
6. **else**
7. **if**(\(|NH_{r}|==1\)) **then**
8. **if**(\(\hat{r}_{i,j}\geq R,\quad j\in NH_{r}\)) **then**
9. \(j\in NH_{r}\) is the desired next hop node and send the packet to the outgoing queue;
10. **else**
11. Drop the packet immediately;
12. **endif**
13. **else**
14. Sort \(NH_{r}\) in descending order of \(\hat{r}_{i,j}\)
15. \(NH_{r,opt}\) = first \(j\in NH_{r}\)
16. \(F=(1-\hat{r}_{i,j})\),  first \(j\in NH_{r}\)
17. **while**\((1-F<R)\) **do**
18. Add next \(j\in NH_{r}\) to the set \(NH_{r,opt}\);
19. \(F=F\times(1-\hat{r}_{i,j})\)
20. **end while**
21. Call EAGF with \(NH_{r,opt}\) as input instead of \(\mathcal{N}_{i,s}\);
22. **endif**
23. **endif**  
**Algorithm 1** Reliability Control Algorithm, _at each source node \(i\)._