# An Energy-Distance-Balanced Cluster Routing Protocol for Smart Microgrid IoT Sensing Networks
## 4 Algorithm Simulation and Analysis  
To thoroughly assess LEAD-RP's performance and confirm its capability in minimizing energy use while extending the lifespan of a static-node network within the IoT sensing layer, simulation testing is carried out using MATLAB R2023b (MathWorks Inc., Natick, MA, USA). platform is utilized to create the simulation framework, with parameters derived from consultations [8,9]. To ensure clarity in the simulation process, the following details are included:  
1. Placement of the Base Station (BS): The base station is strategically placed at the coordinates (50 m, 150 m) to optimize network performance and energy efficiency. 2. Number of Clusters Formed: The number of clusters is dynamically determined based on node density and energy levels, ensuring optimal cluster formation. 3. Method for Cluster Members (CMs) to Select Cluster Heads (CHs): The selection of cluster heads is based on a combination of the residual energy and distance to the base station. Cluster members select the nearest cluster head within their calculated radius, ensuring efficient and balanced energy consumption. LEAD-RP's CH count scales as \(\sqrt{N}\), versus LEACH's linear growth. This explains 23% lower control overhead at \(N=300\) (Algorithm 2). A dynamic radius prevents CH overload in dense regions. The critical simulation parameters, including the placement of BS, are detailed in Table 4. This study stipulates that simulations will conclude once the proportion of non-functional nodes hits 95%, allowing for a more precise comparison of the effectiveness of various routing protocols. Each configuration was executed 30 times with randomized topologies, reporting mean values with 95% confidence intervals. Within this research, we examine and contrast several specific protocols--LEACH, hybrid energy-efficient distributed clustering (HEED), the stable election protocol (SEP), distributed energy-efficient clustering (DEEC), and the newly introduced LEAD-RP--based on metrics such as overall energy usage, the lifespan of the network, and aggregate data transmission. This inclusion of more recent algorithms ensures a comprehensive evaluation of our proposed method in the context of both traditional and modern clustering protocols. Parameters align with EDsHEED's empirical measurements [21] from actual microgrid sensor deployments. To address the potential issues of LEACH under high-node-density conditions mentioned in the problem analysis, the proposed algorithm incorporates adaptive mechanisms for cluster head selection and cluster formation. These enhancements are designed to maintain network efficiency and prolong node lifespans even as node density increases. ```
1 Initialization: Position nodes and base station. Set initial parameters. 2 for each node \(i\)do
3 Compute cluster radius \(R_{i}\) using Equation (16). 4 Compute ideal cluster head proportion \(p\) using Equation (18). 5 end for
6 Cluster Head Selection:
7 for each node \(i\)do
8 Calculate threshold \(T(S_{i})\) considering:
9 Distance factor \(D_{f}\)
10 Energy factor \(E_{f}\)
11 Generate a random number rand. 12 if\(rand<T(S_{i})\)then
13 Node \(i\) becomes a cluster head. 14 end if
15 Refresh the set \(G\) of potential cluster heads. 16
17
18
19
20 Data Transmission Phase: for each cluster head \(i\)do
21 Broadcast status as cluster head. 22
23 end for
24 for each non-cluster head node \(i\)
25 Join the nearest cluster head within radius \(R_{i}\). 26
27 end for
28 Data Transmission Phase: for each node \(i\)do
29 Transmit data to cluster head according to TDMA schedule(Each CH serves \(\pi R_{i}^{2}\rho\) nodes (\(\approx\)15-20 at \(N\) = 300), with \(O(1)\) per-node complexity. Global knowledge avoidance enables linear scaling.). 30 Switch to low-power state when not transmitting. 31 end for
32 Check for Termination:
33 if all nodes depleted or maximum cycles reached then
34 Terminate the algorithm. 35
36 end for
37 else
38 Recalculate \(R_{i}\) and other parameters for a new round.