## 4 The Proposed Routing Protocol: HPA-SR
### The Proposed Clustering Protocol (ASCs): The Underlying Structure
#### 4.2.2 The Proposed Clustering Protocol: ASCS  
In this sub-subsection, we explain in detail the proposed clustering protocol, named ASCS. We consider two criteria to form the cluster, namely cosine similarity and cosine distance. The procedure for electing the cluster head and forming a cluster (to decide the cluster members) is as follows:  
* **Step 0: Initialization** When the clustering starts, each node turns on and operates independently. * **Step 1: Dissemination of Node Information** A node \(n_{i}\) estimates its information, such as speed, direction, and location, periodically. To advertise its node information with neighbor nodes, node \(n_{i}\) generates (**INFO**) packet and broadcasts the (**INFO**) packet to its neighbor nodes periodically, respectively. **INFO** packet contains the following fields: \[\langle\texttt{Type},\texttt{S}_{\texttt{ID}},\texttt{D}_{\texttt{ID}}, \texttt{S},\texttt{Dir}\rangle\] where Type represents packet type, \(\texttt{S}_{\texttt{ID}}\) represents source node ID, \(\texttt{D}_{\texttt{ID}}\) represents destination node ID, \(\texttt{S}\) represents \(i\)-th node's speed, and Dir represents its node direction (\(\theta_{i}\)), respectively. * **Step 2: Decision of Node Direction*
* When \(n_{i}\) receives **INFO*
* packet from the neighbor nodes as shown in Figure 2, the \(n_{i}\) checks whether the direction is less than the threshold of the neighbor nodes and if it will be cluster head (CH) or not, which is mathematically expressed as \[\texttt{NB}_{i}^{*}=|\theta_{NB_{i}}|<\theta_{th_{i}},\] (5) where \(\theta_{NB_{i}}\) is direction nodes and \(\theta_{th_{i}}\) is threshold direction of \(i\)-th node. The selected nodes means that they can move in the same direction. * If \(\texttt{NB}_{i}=\texttt{NB}_{i}^{*}\), go to **step 3**. * Otherwise, the packet will be dropped. * **Step 3: Election of Candidate Cluster Heads*
* The candidate cluster heads (CHs) are selected by the slowest node among the two or more neighbor nodes, which is mathematically expressed as \[i^{\star}=\arg\min_{i\in\texttt{NB}_{i}^{*}\cup\{i\}}\{s_{i}\}.\] (6) Since the cluster head is the smallest node speed in the similar direction, this node can provide strong connectivity between the cluster head and the cluster member nodes. * If \(i=i^{\star}\), the node \(n_{i}\) becomes cluster head, go to **step 4**. * Otherwise, go to **step 6**. * **Step 4: Dissemination of Cluster Head Information** If \(n_{i}\) becomes the cluster head, to announce to its neighbor nodes, \(n_{i}\) generates and broadcasts the cluster head information (**CHI**) packet to its neighbor nodes. The **CHI** packet contains the following fields: \[\langle\texttt{Type},\texttt{S}_{\texttt{ID}},\texttt{D}_{\texttt{ID}}, \texttt{S},\texttt{Loc},\texttt{Dir}\rangle\] where Type represents packet type, \(\texttt{S}_{\texttt{ID}}\) represents source node ID, \(\texttt{D}_{\texttt{ID}}\) represents destination node ID, \(\texttt{S}\) represents its node speed, Loc represents its node location (\(x_{i},y_{i}\)), Dir represents its node direction (\(\theta_{i}\)), respectively. Then, go to **step 7**. * **Step 5: Decision of Gateway** When \(n_{i}\) is between more than one cluster heads, \(n_{i}\) will receive more than one **CHI** packet from cluster heads neighbor. Next, \(n_{i}\) becomes the gateway node. Otherwise, \(n_{i}\) becomes member node, and go to **step 6**. * **Step 6: Decision of Cluster Members** Node \(n_{i}\) decides the cluster head among the candidates of the cluster head using link stability based on Cosine Similarity and Cosine Distance, as follows. The cosine similarity and cosine distance are used to calculate the link stability between \(n_{i}\) and neighbor nodes.