## 4 the Proposed Secure Multicast Routing Protocol: DLSMR
### The Proposed Clustering Protocol: Top-down Particle Swarm Optimization (TD-PSO)
#### 4.2.2 The Proposed Clustering Protocol: TD-PSO
The objective is to maximize the cost value by considering weight value under node degree, cosine similarity, cosine distance, and energy, which can be formulated as \[\max_{\{x_{1},x_{2},x_{3},x_{4}\}} \mathbb{C}_{l}=x_{1}\Delta_{l}+x_{2}\texttt{Cosim}_{l}+x_{3} \texttt{Dist}_{l}+x_{4}\mathbb{E}_{i},\] (4a) s.t \[x_{1}+x_{2}+x_{3}+x_{4}=1,\] (4b) \[\Delta_{l}\leq\texttt{d}_{\text{ch}},\] (4c) \[\texttt{Cosim}_{l}\geq\texttt{Cosim}_{\text{ch}},\] (4d) Figure 2:0 (4e) Figure 2:1 (4f)  
where (4b) denotes that the total weight of the particle must be equal to one, (4c) denotes that the node degree difference must be lower than or equal to the node degree threshold, (4d) denotes that the cosine similarity between two nodes must be greater than or equal to the cosine similarity threshold, (4e) denotes that the cosine distance between nodes must be lower than or equal to the cosine distance threshold, and (4f) denotes that the energy of the cluster head must be greater than or equal to the energy threshold. We consider four factors which consist of the node degree difference, cosine similarity, the cosine distance between two nodes, and the remaining energy of its node. The node degree of its nodes can be written as  
Figure 2:2Figure 2:3  
where \(\mathtt{dist}(i,j)\) can be defined as  
Figure 2:4  
\(\mathtt{D}_{i}\) stands for the node degree of the node \(f_{i}\), \(\mathtt{R}_{i}\) stands for the communication range of the node \(i\), and \(\mathtt{dist}(i,j)\) stands for distance between node \(i\) and \(j\). Then, the average node degree can be expressed as  
Figure 2:5  
The self-adaptive node degree variance is calculated by subtracting the node measure from its average measure, which can be expressed as:  
Figure 2:6  
The second factor is cosine similarity between two nodes which can be defined as [29; 37]  
Figure 2:7  
where \(\overrightarrow{V}_{i}\) and \(\overrightarrow{V}_{j}\) are the \(i\)-th and \(j\)-th nodes' vector information, respectively. Each node \(\overrightarrow{V}_{i}\) is related with a mobility vector information metric value (i.e., speed, direction, and position) \(\overrightarrow{V}_{i}=(\overrightarrow{V}_{1},\overrightarrow{V}_{2}, \cdots,\overrightarrow{V}_{j})\), where \(\overrightarrow{V}_{i}\) constitutes the vector values which indicate link information between nodes. Under a constrained communication distance, we can control the cluster member by considering the maximum cosine similarity. Afterwards, the third factor is the cosine distance of the node, which is used to find the distance between two nodes and can be formulated by [38]  
Figure 2:8  
Thus, the selected cluster member can be mathematically formulated as  
Figure 2:9  
where \(\mathtt{C}_{i}\) represents the cost of the node \(i\) and \(\mathtt{C}_{j}\) represents the the cost of the neighbor cluster heads near node \(j\). After that, \(g_{l}\) sends the join cluster (JC) packet to the CH. The JC packet contains the following fields:  
\[\langle\texttt{Type},\texttt{S}_{\texttt{ID}},\texttt{D}_{\texttt{ID}}, \texttt{E},\texttt{U}_{\texttt{type}}\rangle\]0  
where Type represents packet type, \(\mathtt{S}_{\mathtt{ID}}\) represents source node ID, \(\mathtt{D}_{\mathtt{ID}}\) represents destination node ID, and \(\mathtt{U}_{\mathtt{type}}\) represents the type of node. Then, go to **step 5**. * Otherwise, when \(g_{l}\) only receives one CHI packet, then sends the JC packet to the CH and go to **step 6**. * **Step 5: Decision of Gateway Node** The flying node \(f_{k^{\prime}}\in\mathcal{F}\backslash\{f_{k}\}\) receives two or more CHI packets and become a gateway node. Similar to the ground nodes, the flying node \(f_{k^{\prime}}\) will decide which cluster head follows by calculating the cost function of the cluster head candidate.