## 4 Proposed Routing Scheme
### Distributed Detour Routing Scheme
```
Input : link failure ISL direction \(e_{\text{fail}}\), latitude of link failure node \(\text{lat}_{f}\), latitude of current node \(\text{lat}_{\text{c}}\), latitude of destination node \(\text{lat}_{\text{dst}}\), routing table of current node \(\text{RT}\), minimum hop region of original packet \(\text{MHR}^{k}\) Output : rapid detour direction \(\text{next}_{\text{dir}}\)
1 if\(e_{\text{fail}}=\text{up}\)then
2 if\(\text{lat}_{\text{c}}\geq 0\)then
3\(next_{\text{dir}}\gets RT_{\text{sec}}\)
4 else
5\(next_{\text{dir}}\gets RT_{\text{ffr}}\)
6 end if
7 elseif\(e_{\text{fail}}=\text{down}\)then
8 if\(\text{lat}_{\text{c}}\geq 0\)then
9\(next_{\text{dir}}\gets RT_{\text{sec}}\)
10 else
11\(next_{\text{dir}}\gets RT_{\text{ffr}}\)
12 end if
13 elseif\(e_{\text{fail}}=\text{left}\) or \(e_{\text{fail}}=\text{right}\)then
14\(next_{\text{dir}}\gets RT_{\text{sec}}\)
15 if\(\text{lat}_{\text{c}}>\text{lat}_{\text{dst}}\)then
16\(next_{\text{dir}}\gets RT_{\text{ffr}}\)
17 end if
18
19 end if
20 if\(\text{MHR}^{k}_{H}=0\) or \(\text{MHR}^{k}_{W}=0\)then
21 if\(|\text{lat}_{\text{c}}|>|\text{lat}_{f}|\)then
22\(next_{\text{dir}}\gets RT_{\text{ffr}}\)
23 else
24\(next_{\text{dir}}\gets RT_{\text{sec}}\)
25 end if
26
27 end if
28
29 end if
30
31 end if
```  
**Algorithm 1**Calculating rapid detour direction  
```
Input : link failure ISL direction \(e_{\text{fail}}\), latitude of link failure node \(\text{lat}_{f}\), latitude of current node \(\text{lat}_{\text{c}}\), latitude of destination node \(\text{lat}_{\text{dst}}\), routing table of current node \(\text{RT}\), minimum hop region of original packet \(\text{MHR}^{k}\) Output : rapid detour direction \(\text{next}_{\text{dir}}\)
1 if\(e_{\text{fail}}=\text{up}\)then
20 if\(\text{lat}_{\text{c}}\geq 0\)then
21\(next_{\text{dir}}\gets RT_{\text{sec}}\)
22 else
23\(next_{\text{dir}}\gets RT_{\text{ffr}}\)



44 end for
```  
**Algorithm 2** Calculate the original packet \(\text{lat}_{\text{c}}\)  
```
Input : link failure ISL direction \(e_{\text{fail}}\), latitude of link failure node \(\text{lat}_{f}\), latitude of current node \(\text{lat}_{\text{c}}\), latitude of destination node \(\text{lat}_{\text{dst}}\), routing table of current node \(\text{RT}\), minimum hop region of original packet \(\text{MHR}^{k}\) Output : rapid detour direction \(\text{next}_{\text{dir}}\)
10 if\(e_{\text{fail}}=\text{up}\)then
45 if\(\text{lat}_{\text{c}}\geq 0\)then
46\(next_{\text{dir}}\gets RT_{\text{sec}}\)
47 end if
58
59 end if
60
61 end if
62
63 end if
64
65 end if
66
67 end if
68
69 end for
```  
**Algorithm 3** Calculate the original packet \(\text{lat}_{\text{c}}\)  
```
Input : link failure ISL direction \(e_{\text{fail}}\), latitude of link failure node \(\text{lat}_{\text{c}}\), latitude of current node \(\text{lat}_{\text{c}}\), latitude of destination node \(\text{lat}_{\text{dst}}\), routing table of current node \(\text{RT}\), minimum hop region of original packet \(\text{MHR}^{k}\) Output : rapid detour direction \(\text{next}_{\text{dir}}\)
11 if\(e_{\text{fail}}=\text{up}\)then
70 if\(\text{lat
```
Input : original packet \(\text{pkt}^{k}\), detour direction \(\text{DT}_{\text{dir}}\), minimum hop region of original packet \(\text{MHR}^{k}\) Output : selective flooding packet \(\text{pkt}^{\prime}_{\text{fd}}\)
1 Generating selective flooding packet \(\text{pkt}^{\prime}_{\text{fd}}\)
2 Next direction of \(\text{pkt}^{\prime}_{\text{fd}}\) is reverse of \(\text{DT}_{\text{dir}}\)
3 if\(\text{MHR}^{k}_{H}=0\)\(\text{MHR}^{k}_{W}=0\)then
4\(\text{pkt}^{\prime}_{\text{fd}}\) destination set to source of \(\text{pkt}^{k}\)
5 else
6 if\(\text{next}_{\text{dir}}=\text{up}\)\(\text{next}_{\text{dir}}=\text{down}\)then
7\(x_{\text{dst}}\gets x_{\text{cur}}\)
8\(y_{\text{dst}}\leftarrow\text{MHR}^{k}_{y_{\text{src}}}\)
9 else if\(\text{next}_{\text{dir}}=\text{leftnext}_{\text{dir}}=\text{right}\)then
10\(x_{\text{dst}}\leftarrow\text{MHR}^{k}_{x_{\text{src}}}\)
11\(y_{\text{dst}}\gets y_{\text{cur}}\)
12 end if
13
14
15 Destination of \(\text{pkt}^{\prime}_{\text{fd}}\) set to \([x_{\text{dst}},y_{\text{dst}}]\)
```

**Algorithm 2**Calculating selective flooding path

### Rapid Detour Routing

Packets that encounter a failed link are rerouted without additional path computation through rapid detour routing.