## 5 Proposed Dynamic Cluster Head Election Algorithm
### Proposed Optimum Cluster Head Election Method
Moreover, the random election method is used only at the beginning of each round, and not over the length of the round time. (iii) The next new idea is that, after starting the beginning of the round by using the random method, the rest of the nodes are electing periodically, also checking the remaining energy to skip the dead/failed nodes and save energy and time. Moreover, using the periodic method during the rounds/cycles distribute the energy load equally among network sensors. Benefits of Random and Periodic Methods Combination  
After network creation is completed, the sink node elects the CH candidate randomly at the beginning of each round, to complicate the tracking of the CHs by attackers, who seek full control of the network and all the data collected in the CHs without the need to obtain any other nodes. Moreover, and after the first CH is elected by the SN, the rest of the CHs are elected periodically until the end of the first round, to achieve a good load balance for the network, which prolongs the node life and extends the network lifetime. Then, the CH is randomly elected at the beginning of the second round, and the process continues in  
Figure 5: The proposed Optimum Cluster Head Election method’s data flow diagram. the rest of the rounds. Thus this combined metric is a good way to overcome the limitation of each one, and at the same time maintain their strengths. The benefits of mixing the previous two methods (random and periodic) can be summarized as follows:  
* Strengthening the security side by electing the CH candidate randomly at the beginning of each round, which complicates the attackers' tasks and attempts as tracking CHs to obtain information;
* Distributing energy among the network nodes fairly, using a periodical election method during each round extending the network lifetime;
* The simplicity, ease, and lightness of the proposed model avoids the complexity burden due to more mathematical operations and messaging for accuracy, which drains the network energy that is supposed to be provided. ```
Input: ClusterNumber, DevicePower, Devicidal, SIZEOFCLUISTERS Output: Assigning the optimum Cluster Head fn_AssignClusterHead (ClusterNumber, DevicePower) //Function assign Cluster Heads randomly at the beginning of each cycle and periodically with the //rest BEGIN R = Generate a random number from [SIZEOFCLUSTERS] FOR each sensor i elected randomly R at the beginning of each cycle DO Devicel = ClusterElements [ClusterNumber][i] ClusterHeadPower = DevicePower [Devicel-1] ->&RemainingPower If the candidate CH is a live THEN ClusterHeadD = Devicel  EALL fn_DeleteLoadSensors (ClusterNumber, DevicePower) END IF RETURN ClusterHeadID END FOR END
```  
**Algorithm 1** Working of the proposed method in a single cluster  
To calculate the energy consumption of the whole network and the formula of its mathematical modeling, it is necessary to calculate the energy consumed for the two sensor points and the formula of its mathematical equation, then expand the equation to include the whole network. The environmental results sensed by the two sensor points should be sent to the central monitoring unit called the sink node (SN).