# A Robust Routing Protocol in Cognitive Unmanned Aerial Vehicular Networks
## 4 Proposed Routing Protocol
### Cluster Formation
#### 4.4.1 Node Move-In
Otherwise, \(CN_{j}\) rejects the joining request from \(UN_{j}\) and tries to join with other \(CN\)s. However, if \(CN_{j}\) fails to join any cluster it makes its cluster and states CN. ```
START:  UN_, Starts Span Scanning; \(UN_{j}\), Prepares \(ACL_{j}\); \(UN_{j}\), Prepares \(IN_{n}\); \(UN_{j}\), Broadcast \(ACL_{j}\) and \(IN_{n}\); \(UN_{j}\), Constructs \(G_{ci}\) based on \(G_{pi}\); \(UN_{j}\), Calculates \(CNRF_{j}\); \(UN_{j}\), shares \(CNRF_{j}\) to \(UN_{n}\); if(\(UN_{j}\) in \(UN_{n}\))then if(\(i>1\))then if(\(i<1\))then if(\(i<2\))then if(\(i<3\))then if(\(i<4\))then if(\(i<5\))then if(\(i<6\))then if(\(i<7\))then if(\(i<8\))then if(\(i<8\))then if(\(i<9\))then if(\(i<10\))then if(\(i<11\))then if(\(i<12\))then if(\(i<If the value of \(CNRF_{j}\) is greater than the value of \(CNRF_{C}N\), it checks if \(UN_{n}\) is the neighboring CN or not. \(UN_{j}\) then becomes the new CN and \(CH_{j}\) becomes the Secondary Central Node (SCN). Again if the neighboring cluster head is a proper sub-set of the neighboring UAV Nodes, then the \(UN_{j}\) calculates new CNRF for \(UN_{new}\) which is the neighboring cluster head (\(CN_{n}\)). Then it checks if the value of \(CNRF_{new}\) is greater than \(CNRF_{CN}\) then it follows the same procedure from the algorithm from line 25. If the \(UN_{n}\) is not equal to \(CN_{n}\); then it follows the algorithm procedure from line 13. Also, it looks the same if \(CNRF_{j}\) is less than \(CNRF_{CN}\) and if the channel list is not a maximum biclique edge graph. When joining the nearest node (\(NN_{j}\)) belongs to (\(UN_{n}\)) then it check if the joining node number is more than one, it then selects the \(NN_{j}\) with the highest CNRF and \(UN_{j}\) forms a new cluster and becomes cluster's Central node. Otherwise, the result remains the same as before and \(UN_{j}\) joins the cluster if the \(NN\) does not belong to the set of \(UN_{n}\). \(UN_{j}\) then joins new cluster with new \(CN\) and selects \(CN\) with highest \(CNRF\) and \(SCN\) with second highest \(CNRF\) value. #### 4.4.2 Node Move-Out

The Node Move-Out protocol governs the process of nodes leaving the network, including Central Node (CN), Nearest Nodes (NN), and Cluster Members (CM). Here is how it aligns with our clustering mechanism:

**Leaving Process Initiation:** When a node detects a decrease in beacon signal strength, indicating movement, it initiates the leaving process. Depending on its role as a CN, NN, or CM, different leaving scenarios are considered. **Leaving Message Broadcast:** The leaving node, denoted as \(UN_{l}\), broadcasts a leaving message to its neighbors (\(UN_{n}\)). \(UN_{l}\) first checks its neighbor list to determine its role and potential connections with other nodes. **CH Departure Handling:** If \(UN_{l}\) is a CN, it informs neighboring CMs about the departure and assigns the Secondary CN (SCN) as the new CN. The SCN selects a new CNR based on CNRF values, ensuring continuity in cluster leadership. **NN Departure Handling:** If \(UN_{l}\) is an NN, it informs the parent CN (\(CN_{k}\)) and neighboring clusters about the movement. If direct connection with a neighboring cluster is not possible, \(CN_{k}\) requests a CM to act as an NN or selects a new NN based on CNRF values. **CM Departure Handling:** If \(UN_{l}\) is a CM, it informs \(CN_{k}\) about the departure. \(CN_{k}\) selects a new SCN from the CMs and adjusts intra-cluster communication accordingly. The neighboring cluster is informed about the departure and potential joining scenarios. **Inter-Cluster Connectivity:** In all leaving scenarios, efforts are made to maintain inter-cluster connectivity. Nodes are assigned new roles or connections based on CNRF values, ensuring network stability and continuity of communication. This protocol ensures smooth transitions when nodes leave the network, maintaining connectivity and stability within and between clusters. From Algorithm 4, initially, the leaving UAV (\(UAV_{l}\)) broadcasts a leaving decision to the neighboring UAVs.