# Bio-Inspired Algorithms for Efficient Clustering and Routing in Flying Ad Hoc Networks
## 4 HMAO Algorithms
### Routing Phase
```
1:Input: Positions of UAVs \(P_{i}=(x,y_{i},z_{i})\), velocity of UAVs \((Vx_{i},Vy_{i},Vz_{i})\), residual energy level of UAVs \(E(i)\), congestion data from ferry nodes, queue length \(QL_{i}\), packet rate \(PR_{i}\), and neighbor table \(NT\). Output: Primary path and secondary path. 2:# Step 1: Initialize UAV parameters
3:for each UAV \(i\) do:
4:\(P_{i}=(x_{i},y_{i},z_{i})\), \(V_{i}=(Vx_{i},Vy_{i},Vz_{i})\), \(E(i)=E_{i}\), \(QL_{i}=0\), \(PR_{i}=0\), and \(NT_{i}=\{\}\)
5:\(\;\)
6:\(\;\)
7:end for
8:\(\;\)
9:\(\;\)
10:for each UAV \(i\) do:
11:for each UAV \(i\) do:
12:\(\;\)
13:end for
14:\(\;\)
15:\(\;\)
16:end for
17:for each UAV \(i\) do:
18: Receive Hello Message from neighbor \(j\)
19: Update \(NT_{i}=\{P_{i},\,V_{i},\,E_{j},\,QL_{i},\,PR_{j}\}\)
20:end for
21:\(\;\)
22:\(\;\)
23:\(\;\)
24:\(\;\)
25:\(\;\)
26:end for
27:for each UAV \(i\) do:
28: Receive Hello Message from neighbor \(j\)
29: Update \(NT_{i}=\{P_{i},\,V_{i},\,E_{j},\,QL_{i},\,PR_{j}\}\)
30:end for
31:\(\;\)
32:\(\;\)
33:\(\;\)
34:\(\;\)
35:\(\;\)
36:\(\;\)
37:end for
38: Receive Hello Message from neighbor \(j\)
39: Update \(NT_{i}=\{P_{i},\,V_{i},\,E_{j},\,QL_{i},\,PR_{j}\}\)
40:end for
41:\(\;\)
42:\(\;\)
43:\(\;\)
44:\(\;\)
45:\(\;\)
46:\(\;\)
47:end for
48: Receive Hello Message from neighbor \(j\)
49: Update \(NT_{i}=\{P_{i},\,V_{i},\,E_{j},\,QL_{i},\,PR_{j}\}\)
50:end for
51:\(\;\)
52:\(\;\)
53:\(\;\)
54:\(\;\)
55:\(\;\)
56:\(\;\)
57:\(\;\)
58: Receive Hello Message from neighbor \(j\)
69: Update \(NT_{i}=\{P_{i},\,V_{i},\,E_{j},\,QL_{i},\,PR_{j}\}\)
70:end for
60:\(\;\)
61:end for
62:\(\;\)
63:\(\;\)
64:\(\;\)
65:\(\;\)
66:\(\;\)
67:\(\;\)
68: Receive Hello Message from neighbor \(j\)
69: Update \(NT_{i}=\{P_{i},\,V_{i},\,E_{j},\,QL_{i},\,PR_{j}\}\)
71:end for
63:\(\;\)
64:\(\;\)
65:\(\;\)
66:\(\;\)
67:\(\;\)
68: Receive Hello Message from neighbor \(j\)
79: Update \(NT_{i}=\{P_{i},\,V_{i},\,E_{j},\,QL_{i},\,PR_{j}\}\)
80:end for
81:\(\;\)
82:\(\;\)
83:\(\;\)
84:\(\;\)
85:\(\;\)
86: Receive Hello Message from neighbor \(j\)
90: Update \(NT_{i}=\{P_{i},\,V_{i},\,E_{j},\,QL_{i},\,PR_{j}\}\)
91:end for
92:\(\;\)
93:\(\;\)
94:\(\;\)
95:\(\;\)
96:\(\;\)
97:\(\;\)
98: Receive Hello Message from neighbor \(j\)
99: Update \(NT_{i}=\{P_{i},\,V_{i},\,E_{j},\,QL_{i},\,PR_{j}\}\)
10:end for
93:\(\;\)
94:\(\;\)
95:\(\;\)
96:\(\;\)
97:\(\;\)
98: Receive Hello Message from neighbor \(j\)
99: Update \(NT_{i}=\{P_{i},\,V_{i},\,E_{j},\,QL_{i},\,PR_{j}\}\)
10:end for
94:\(\;\)
95:\(\;\)
96:\(\



### Computational Complexity

The computational or time complexity of proposed HMAO is represented as \(O(\mathcal{W}*d*t_{max})\), where \(\mathcal{W}\) is the size of the population, \(d\) the dimension of the optimization problem, and \(t_{max}\) the maximum number of iterations. In the initialization phase, the algorithm requires \(O(\mathcal{W}*d)\) time to calculate the control parameters. After that, the algorithm requires \(O(\mathcal{W}*d)\) to update three best solutions in each iteration. For the maximum number of iterations, the total time complexity is \(O(\mathcal{W}*d*t_{max})\). ## 5 Performance Evaluation

In this section, the performance of the proposed HMAO clustering and routing protocol is analyzed in comparison with other routing protocols such as MFO-based clustering [9], MWCRSF [27], DCFH [28], DCM [31], and HMGOC (MGO-JAYA) [33]. This analysis is performed by using Network Simulator 3 (NS-3.35), which is an event-driven wireless

Figure 3: Algorithm flow of proposed HMAO scheme. network simulator that is well suited for simulating UAV networks because of its ability to accurately process events and model a wide variety of networks. In this study, we compared our proposed HMAO with five other existing schemes in terms of cluster stability, PDR, overhead, delay, and energy consumption. Detailed definitions of these performance metrics can be found in [17; 24]. ### Simulation Environment

The simulations were conducted on NS-3.35, operating on a system equipped with an Intel Core i7 processor and 16 GB RAM.