# Bio-Inspired Algorithms for Efficient Clustering and Routing in Flying Ad Hoc Networks
## 4 HMAO Algorithms
### Routing Phase  
Ferry nodes in the AO phase have become global explorers. They systematically collect network-wide data, including network density, congestion, and mobility patterns, to improve the CH selection and optimal positioning of nodes. These ferry nodes do not employ random levy flight exploration, but have a structured trajectory, crossing the network to collect detailed data from UAVs in their communication range. Levy flight, a type of random walk typically implemented for broad search capacity, is modified to leverage its search capability to combine short exploratory steps with long ones. The aggregation of such information by ferry nodes allows other UAVs to make good decisions regarding routing issues. Ferry nodes distribute real-time global data throughout the network, thereby providing UAVs with the information needed to optimize Cluster Head selection and adaptively change routing paths to improve network performance and resilience. Algorithm 3 illustrates the function of the ferry nodes in a UAV network for gathering and diffusing global data. Given that ferry nodes move on a set path, they collect information from all UAVs within their communication range, including their position and load. This is comparable to levy flight exploration, in which ferry nodes methodically scan the network by gathering and summarizing essential metrics instead of depending on random motion. Once a UAV receives a control packet from its ferry node, it reports its updated status and the ferry node gathers this into a comprehensive global dataset of up-to-date network states. As the ferry nodes move along their path, they share the gathered information with neighboring UAVs, maintaining a fresh and dynamic view of the global network. Continuous packet exchange for control ensures that the network state is always updated, which aids in effective and adaptive decisions regarding clustering and routing within a FANET. HMAO uses both intra- and inter-cluster routing phases. Intra-cluster routing allows for efficient data aggregation because information is transmitted from UAVs in one cluster to the CH, which integrates information from its members. In inter-cluster routing, CHs are responsible for sending collected data from CMs to neighboring CHs. The energy-level constraints must be met before any UAV is considered for routing. Each UAV \(j\) must have a residual energy level greater than the \(E_{th}\) to be eligible for selection in either the primary or the secondary path. If the residual energy is below this threshold, the UAV is excluded from the selection process. The residual energy of node \(E_{j}\) is measured as follows:  
\[E_{j}=\frac{E_{remaging,j}}{E_{initial,j}}, \tag{17}\]  
where \(E_{remaging,j}\) is a remaining energy of node \(j\) and \(E_{initial,j}\) is the initial energy level of UAV node \(j\). After passing the energy checks, the UAV determines its fitness based on three critical parameters: the mobility, load, and congestion level. Predictive mobility-based routing aims to forward data towards the destination at high speed in a UAV that is moving toward the destination and at the same time has sufficient connectivity and is not moving in the opposite direction to the sender. This process enhances data delivery by selecting a suitable next-hop UAV based on predictions of future mobility, ensuring that the chosen UAV remains an efficient part of the communication chain. The future position of each neighboring UAV is predicted based on its current position and velocity. The predicted future position of UAV \(j\) after time interval \(\Delta t\) is given by  
\[P_{j}^{future}=(x_{i},y_{i},z_{i})+(Vx_{i},Vy_{i},Vz_{i})\times\Delta t. \tag{18}\]  
Using the predicted future position, the distance between the UAV's future position and the destination is calculated as follows:  
\[d_{dest,\ j}^{future}=\Big{\|}P_{j}^{future}-P_{dest}\Big{\|}, \tag{19}\]  
where \(P_{j}^{future}\) is the UAV future position and \(P_{dest}\) is the UAV destination.