## 4 the Proposed Secure Multicast Routing Protocol: DLSMR
### The Proposed Clustering Protocol: Top-down Particle Swarm Optimization (TD-PSO)
#### 4.2.3 Top-Down Particle Swarm Optimization Model  
This subsection will explain in detail the particle swarm optimization model used in the clustering protocol.  
In the TD-PSO algorithm, each individual node in the population is called a particle and moves in the search space. Particles have memory and, thus, they retain part of their previous state. Each particle's movement is the composition of a velocity and two randomly weighted influences. The two randomly weighted influences are individual and have the tendency to return to their best previous positions and sociality, or the tendency to move towards their neighborhood's best previous position. As briefly mentioned above, clustering involves gathering similar objects that must first be defined.  
Let us assume the objective function \(\mathcal{C}_{i}\) where \(i\in\{\mathsf{FN},\mathsf{GN}\}\) is the global optima \(\mathcal{C}_{i}^{*}\) of optimization with optimal value \(x_{l}\), \(l\in\{1,2,3,4\}\). The proposed TD-PSO algorithm to find the optimal values, i.e., \(x_{1},x_{2},x_{3},x_{4}\), can be summarized as Algorithm 1, where \(p\) represents the number of parameters, \(q\) denotes the number of particles, \(x_{pq}\) represents the position of particle \(q\) for parameter \(p\), \(v_{pq}\) represents the velocity of particle \(q\) for parameter \(p\), \(r_{1}\) and \(r_{2}\) are random values with range \([0,1]\) to avoid premature convergence, \(w\) denotes the weight of a particle with range \([0.4,0.9]\), \(c_{1}\) and \(c_{2}\) are acceleration factors, and \(t\) is the number of iterations.  
```
0: Optimal solution \(\mathcal{C}^{*}\) and \(x_{l}^{*}\)
1:Initialization :
2: Set \(p\gets 4\). \(\leftarrow\) number of parameters
3: Set \(q\gets 50\). \(\leftarrow\) number of particles
4: Set \((x_{pq},v_{pq})\)\(\leftarrow\) randomly with constraint.
5: Set \(w\leftarrow\) randomly with range \([0.4,0.9]\).
6: Set \((r_{1},r_{2})\leftarrow\) randomly with range \([0,1]\).
7: Set \((c_{1},c_{2})\gets 2\).
8:for\(x=0,1,2,\cdots\)do
9: calculate problem, find \(\mathcal{C}^{*},x_{l}^{*}\);
10:if\(\mathcal{C}^{*}<\mathcal{C}^{(t)}\)then
11:\(\mathcal{C}^{*}\leftarrow\mathcal{C}^{(t)}\)
12:\(x_{p}^{*}\gets x_{p}^{(t)}\)
13:endif
14:\(v_{pq}^{(t+1)}=w.v_{pq}^{(t)}+c_{1}.r_{1}(x_{kl}^{(t)}-x_{pq}^{(k)})+c_{1}.r_{1} (g_{bl}^{t}-x_{N}^{(t)})\)
15:\(x_{pq}^{(t+1)}=x_{pq}^{(t)}+v_{lj}^{(t)}\)
16:endfor
```  
**Algorithm 1** The TD-PSO algorithm to find global optimal points in problems (4) and (13)  
\begin{table}
\begin{tabular}{c c c} \hline \hline \(\mathsf{CM}_{\text{ID}}\) & \(\mathsf{CH}_{\text{ID}}\) & \(\mathsf{U}_{\text{type}}\) \\ \hline \hline \end{tabular}
\end{table}
Table 1: Cluster member table of the proposed TD-PSO-based clustering protocol.  
\begin{table}
\begin{tabular}{c c c} \hline \hline
**Packet Name** & **Full Name** & **Field Information** \\ \hline INFO & Information & \(\mathsf{Type},\mathsf{S}_{\text{ID}},\mathsf{D}_{\text{ID}},\mathsf{E},\mathsf{ U}_{\text{type}}\) \\ \hline CHI & Cluster Head Information & \(\mathsf{Type},\mathsf{S}_{\text{ID}},\mathsf{D}_{\text{ID}},\mathsf{Pos}, \text{Dir},\mathsf{S},\mathsf{E},\mathsf{U}_{\text{type}}\) \\ \hline JC & Join Cluster & \(\mathsf{Type},\mathsf{S}_{\text{ID}},\mathsf{D}_{\text{ID}},\mathsf{U}_{\text{ type}}\) \\ \hline AC & Accept Cluster & \(\mathsf{Type},\mathsf{S}_{\text{ID}},\mathsf{D}_{\text{ID}}\) \\ \hline \hline \end{tabular}
\end{table}
Table 3: List of packets for the TD-PSO clustering protocol.