# An Energy-Distance-Balanced Cluster Routing Protocol for Smart Microgrid IoT Sensing Networks
## 3 Framework Architectures
### Security Integration via RBAC-IoT
#### 3.4.1 Dynamic Cluster Head Proportion  
The LEACH protocol defines a static proportion \(p\) of cluster heads to total nodes; it is set prior to network activation based on three primary factors:  
1. Network density (\(\rho\)): Higher density requires larger \(p\) values to prevent cluster head overload, typically \(p\propto\sqrt{\rho}\) as per the original LEACH formulation.
2. Energy constraints: \(p\) is inversely related to the average transmission distance. For battery-limited nodes, lower \(p\) values (e.g., 0.05) extend network lifetime but increase intra-cluster distances.
3. Application requirements: Real-time monitoring demands higher \(p\) values for low latency, while periodic data collection allows lower \(p\) values for energy conservation. The original version of LEACH uses \(p=0.05\) as the default value for generic sensing.  
Despite constant re-evaluation during each clustering cycle, \(p\) remains fixed throughout network operations. This rigidity makes LEACH unsuitable for evolving network conditions, including base station repositioning, network scaling, and deployment changes.  
As the number of active nodes fluctuates, this study proposes a variable cluster head ratio \(p\) that is responsive to the surviving node count, ensuring the lowest total network energy consumption is achieved:  
\[K_{opt}=\sqrt{\frac{N}{2\pi}}\sqrt{\frac{\xi_{fs}}{\xi_{mp}}}\sqrt{\frac{M}{d_ {toBS}^{2}}} \tag{17}\]  
In the energy model, the key parameters are defined as follows: \(K_{\text{opt}}\) denotes the optimal number of cluster heads; \(N\) represents the current active node count; \(M\) indicates the network side length (in meters); \(d_{\text{toBS}}\) signifies the average distance to the base station (in meters); and \(\xi_{fs}\) and \(\xi_{mp}\) denote the energy model parameters for free-space and multipath propagation respectively.  
Definition of \(K_{\text{opt}}\): The variable \(K_{\text{opt}}\) represents the optimal number of cluster heads calculated for each round of network operation. It is derived from the following energy optimization principles:  
* Minimizes total network energy consumption by balancing the following:
* The intra-cluster communication cost (proportional to \(M/d_{\text{toBS}}\));
* The inter-cluster relay cost (captured by \(\sqrt{\xi_{fs}/\xi_{mp}}\)).
* Dynamically adjusted based on current node count \(N\) and network size \(M\)
* _not a constant_: Recalculated when \(N\) changes by \(\Delta N>5\%\) (Section 4.2).  
Thus, \(K_{\text{opt}}\) serves as the foundation for the dynamic cluster head proportion \(p=K_{\text{opt}}/N\) in Equation (12), replacing LEACH's static \(p\) value.  
Here, \(N\) represents the total node count within a \(M\times M\) area. \(\xi_{fs}\) and \(\xi_{mp}\) are energy model parameters associated with the LEACH protocol, and \(d_{t0 BS}^{2}\) is the squared distance from the cluster head to the base station. Thus, the ideal cluster head ratio \(p\) is  
\[p=\frac{K_{opt}}{N}=\sqrt{\frac{1}{2\pi N}}\sqrt{\frac{\xi_{fs}}{\xi_{mp}}} \frac{M}{d_{t0 BS}^{2}} \tag{18}\]  
As delineated in Equation (18), \(p\) dynamically adjusts with the changing number of nodes \(N\), better accommodating network variations. \(d_{t0 BS}^{2}\) signifies the squared distance to the cluster head from the base station, a factor necessitating recalibration in each cycle, thus adding algorithmic complexity. To simplify, this study approximates this distance squared as a parameter, thus updating \(N\) and recalculating the optimal cluster head ratio \(P\) whenever a node becomes non-functional. This \(O(1)\) recalculation (utilizing hardware node counters) consumes \(<0.1\), ensuring continual adaptation to network dynamics.