## 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
When the value of the cost function is larger, the relationship between the cluster head and node is better than other relationships which can be mathematically expressed as  
\[\langle\texttt{Type},\texttt{S}_{\texttt{ID}},\texttt{D}_{\texttt{ID}}, \texttt{E},\texttt{U}_{\texttt{type}}\rangle\]1 (13a) s.t \[\langle\texttt{Type},\texttt{S}_{\texttt{ID}},\texttt{D}_{\texttt{ID}}, \texttt{E},\texttt{U}_{\texttt{type}}\rangle\]2 \[\langle\texttt{Type},\texttt{S}_{\texttt{ID}},\texttt{D}_{\texttt{ID}}, \texttt{E},\texttt{U}_{\texttt{type}}\rangle\]3 (13c) \[\langle\texttt{Type},\texttt{S}_{\texttt{ID}},\texttt{D}_{\texttt{ID}}, \texttt{E},\texttt{U}_{\texttt{type}}\rangle\]4 (13d) \[\langle\texttt{Type},\texttt{S}_{\texttt{ID}},\texttt{D}_{\texttt{ID}}, \texttt{E},\texttt{U}_{\texttt{type}}\rangle\]5 (13e) \[\langle\texttt{Type},\texttt{S}_{\texttt{ID}},\texttt{D}_{\texttt{ID}}, \texttt{E},\texttt{U}_{\texttt{type}}\rangle\]6  
where (13b) denotes that the total weight of the particle must be equal to one, (13c) that denotes the node degree difference must be lower than or equal to the node degree threshold, (13d) denotes that the cosine similarity between two nodes must be greater than or equal to the cosine similarity threshold, (13e) denotes that the cosine distance between nodes must be lower than or equal to the cosine distance threshold, and (13f) denotes that the energy of the cluster head must be greater than or equal to the energy threshold. Thus, the selected cluster member can be mathematically formulated as  
\[\langle\texttt{Type},\texttt{S}_{\texttt{ID}},\texttt{D}_{\texttt{ID}}, \texttt{E},\texttt{U}_{\texttt{type}}\rangle\]7  
where \(C_{k}\) represents the cost of the node \(k\) and \(C_{j}\) represents the cost of the neighbor cluster heads near node \(j\). Then, \(f_{k^{\prime}}\) sends the JC packet to the CH; go to **step 6**. * Otherwise, when \(f_{k^{\prime}}\) only receives one CHI packet, then it sends the JC packet to the CH; go to **step 6**. * **Step 6: Cluster Member Table Updates** When node \(f^{\prime}_{k}\) and \(g_{l}\) choose the CH, they update the cluster member (CM) table as shown in Table 1 where \(\text{CM}_{\text{ID}}\) is a unique identifier assigned to each node within the cluster, \(\text{CH}_{\text{ID}}\) represents the identifier of the cluster head that the cluster member belongs to, and \(\text{U}_{\text{type}}\) represents the type of user. Then, go to **step 7**. * **Step 7: Cluster Head Table Updates** When \(f_{k}\) receives a JC packet, \(f_{k}\) replies with an accept packet (AC) to the transmitted node, and updates the cluster head table as shown in Table 2 where \(\text{CH}_{\text{ID}}\) is a unique identifier assigned to each cluster head in the network, \(\text{CM}_{\text{ID}}\) represents the identifier of the cluster member that belongs to the cluster managed by the cluster head, and \(\text{U}_{\text{type}}\) represents the type of user. Finally, the cluster has been formed. The AC packet contains the following fields: \[\langle\texttt{Type},\texttt{S}_{\texttt{ID}},\texttt{D}_{\texttt{ID}}, \texttt{E},\texttt{U}_{\texttt{type}}\rangle\]8 where \(\texttt{Type},\texttt{S}_{\texttt{ID}},\texttt{and}\texttt{D}_{\texttt{ID}}\) represent the packet type, source node ID, and destination node ID, respectively. * Otherwise, the **AC** packet will be dropped. In the end, the clustering process is finished. When the source node needs to send a data transmission to multiple destination nodes, the network will start the routing process based on the routing protocol algorithm. The list of packets for the proposed TD-PSO clustering protocol is summarized in \[\langle\texttt{Type},\texttt{S}_{\texttt{ID}},\texttt{D}_{\texttt{ID}}, \texttt{E},\texttt{U}_{\texttt{type}}\rangle\]9