# Cross-Layer and Energy-Aware AODV Routing Protocol for Flying Ad-Hoc Networks
## 4 Materials and Methods
### GSO-Based Cluster Head Selection  
The grouping method takes into consideration the selection of the cluster head based on linkage with the GCS and objective functions that are dependent on the luciferin value as well as the UAV remaining energy level for effective access and data transfer. Algorithm 3 shows the selection of cluster head and formation of the cluster. The fitness functions are defined as follows:  
\[Fit\_fun=\alpha 1*f1+\alpha 2*f2\]  
where \(\alpha 1\) and \(\alpha 2=1\)  
\[f1=Res\_ener=(In\_ener(i)-Cuu\_ener(i))\]  
where \(Res\_ener\) indicates the remaining energy; \(In\_ener(i)\) indicates the initial energy; and \(Cuu\_ener(i)\) indicates the current energy of all UAVs. The objective function for luciferin values is represented as follows:  
\[F2-(Ai(t+1)).\]  
Explanation: Each node in the cluster formation process evaluates its fitness using Equation (6). Equations (7) and (8) are used to compute the fitness, which is based on the weighted sum of the luciferin value and remaining energy. Each UAV broadcasts HM together with its fitness after it has been calculated. When a UAV receives HM, it evaluates it to its own fitness. The UAV builds NTAB from unmanned aircraft entries, updates NTAB with each new HM, and sorts the NTAB in order of fitness. When a UAV connects to GCS, it announces itself to be a cluster head. If there is more than one UAV connected to the GCS or none at all, the UAV with the highest fitness broadcasts CFM and proclaims its cluster head. If the fitness of the UAV is lower than the others, it recognizes the UAV with the most increased fitness as CH and transmits CJM to the CH. If a UAV's fitness is lower than the others, it recognizes the UAV with the highest fitness as the cluster head and sends CJM to it. ```
Begin  X(m) = hello packet;  Y(tab) = table of neighbor;  T(tab) = table of topology; \(Clus\_form\) = cluster formation text; \(Clus\_join\) = cluster joinable text;  Select UAVs in the network;  Initially find the fitness function;  Do (transfer the X(m) with the support of fitness); While (UAV receives X(m):  Crosscheck in Y(tab);  Compare (fitness of UAVs);  Design the T(tab);  Sort out (T(tab) with fitness factor);  Update the entities in the table; End  Check again the fitness function; If (UAV has more fitness parameter)  Start the transmission process; Else  Wait for \(Clus\_form\);  Predict the UAV with the fitness value;  Transfer the data; End End
```  
**Algorithm 3**Selection of cluster head and formation of the cluster. When a UAV wants to convey information but is beyond the range of GCS, an ad-hoc coalition of the UAV is created. The UAV subsequently delivers data to the distant target via intermediate UAVs over numerous hops. The UAV that is connected to the GCS will proclaim its cluster head and send the cluster formation message to the other UAV. The remaining UAVs will join them as members. If no UAV has direct contact with the GCS, communication can take place through a relay UAV from another cluster. The cluster head is chosen based on the fitness value. The UAV with the best fitness is chosen as a cluster head, while the remaining UAVs will be cluster members. However, if more than one UAV is connected to the GCS, the cluster head is chosen based on fitness, which is determined by the luciferin value and remaining energy. That UAV is chosen as a cluster head because it has the best fitness among the other UAVs connected to the GCS. The cluster head selection and cluster development are explained in Algorithm 3. Cluster Management  
The GSO algorithm controls the clusters in the suggested network, as shown in Algorithm 4. The optimal solution and location are used to update the luciferin level of every glowworm. As stated in the second algorithm, the cluster members must track the movement of the cluster head and modify their positions accordingly. The cluster is managed by the cluster head, which constantly updates the routing tables with data from all of the UAVs in the cluster.