## 4 Methods
### Stable Operation Phase  
When the DCK-LEACH algorithm runs, each node sends its information (location and remaining energy) to the base station in each round, which performs the cluster splitting and cluster-head selection. All nodes communicate with the base station, which consumes a lot of energy. In fact, sometimes it is not useful to re-cluster and change cluster-heads in every round.  
Therefore, in order to reduce this unnecessary energy consumption, we propose a concept to control the frequency of the re-clustering operation, which is similar to the LEACH algorithm in cluster-head selection (r mod \((1/p)\)).  
The clustering and cluster-head selection operations are only performed in a few rounds in an adaptive manner. This is represented here by Cluster, as shown in Equation (15):  
\[Cluster=\left\{\begin{aligned} & 1,\ r=1\\ & 1,\ r\ mod\left(\frac{1}{p}\right)=0\\ & 0,\ Otherwise\end{aligned}\right. \tag{15}\]  
where \(r\) is the current round, and \(p\) is a parameter that controls the frequency of the re-clustering operation. \(p\) value is taken as 0.05 to reduce the communication time with the base station, thus saving energy. When Cluster is equal to 1, it means that re-clustering and cluster-head selection is performed in that round; when Cluster is 0, no clustering operation is performed in the network. Figure 2 illustrates the overall workflow of the proposed algorithm--Algorithm 3 (DCK-LEACH).  
Figure 2: The workflow of proposed protocol.  
After electing the primary and vice cluster-heads from nodes, each node is allocated a cluster based on its position in the network. It sends a message to its primary cluster-head within a cluster. This message includes the node's residual energy, the distance from its primary cluster-head to itself, and the node's own ID.  
According to the number of member nodes in the cluster, the primary cluster-head divides the time slots and uses the TDMA (Time Division Multiple Access) mechanism to assign the corresponding time slots to each member node in the cluster [37]. Each node collects and sends data to the primary cluster-head according to the allocated time slots. During non-self-time slots, it remains asleep to save energy.  
The primary cluster-head receives the data collected by the member nodes and performs data fusion to delete the redundant data. Then, the fused packets are sent to the vice cluster-head in the cluster, the latter forwards them to the base station. The CSMA MAC (Carrier Sense Multiple Access) [38] mechanism is used to send messages among nodes.
```
(1) Initializing network parameters (2) For each round (3) If it is the first round (r = 1) (4) Run Canopy optimized K-means algorithm to get each cluster (5) For each cluster (6) Select the primary cluster-head (7) Select the vice cluster-head (8) Broadcast the formed cluster information to all nodes via the base station (9) For nodes in the network { (10) Nodes send data to their primary cluster-heads in that cluster (11) The primary cluster-head fuses data and then sends the data to the vice cluster-head. (12) The vice cluster-head forwards the data to the base station] (13) Else (14) If r mod (1/\(p\)) == 0 (15) All nodes send their positions and residual energy to the base station. (16) Run again (4) to (12). (17) Else (18) The network runs without re-clustering (19) All nodes are dead. (20) End
```  
**Algorithm 3**DCK-LEACH algorithm