# ERCP: Energy-Efficient and Reliable-Aware Clustering Protocol for Wireless Sensor Networks
## 4 Proposed ERCP Clustering Algorithm
### Cluster Head Selection  
This section discusses an energy-efficient and reliable clustering design. For each node \(x\), its candidate neighbor set \(NEB_{x}\) nodes not covered by cluster heads are added to the final candidate member set. This is formally represented in Equation (1),  
\[NM_{x}=\left\{y|y\in NEB_{x},\Gamma_{y}=1\right\} \tag{1}\]  
where  
\[\Gamma_{y}= \begin{cases}1&\text{if node $y$ is not covered by any cluster head}\\ 0&\text{otherwise}\end{cases}  \tag{2}\]  
where \(NM_{x}\) is the neighbor set of sensor node \(x\) that is not covered by any cluster head. As reliable data transfer is the premise to guarantee the network's normal operation and is the basis for optimizing WSN performance, reliable wireless links would be needed for the successful delivery of data from the member nodes to their cluster heads. However, in WSN, packet losses are rather inevitable since it is deployed in harsh environmental conditions. Retransmitting missing packets takes additional time and energy, reducing data delivery and network lifetime [24; 25; 26; 27]. The proposed clustering technique integrates the link quality into the selection decision of the cluster heads to overcome such problems and improve the network throughput. Moreover, the retransmission reduction decreases consumed energy, which enhances the network's lifetime. Equation (3) presents the proposed new link quality metric of candidate cluster head \(x\) at time \(t\). \[QM_{x}(t)=\sum_{l\in NM_{x}}(1-PRR_{xl}(t)) \tag{3}\]  
where \(PRR_{xl}\) is the packet reception ratio for the link (\(x\), \(l\)). According to Equation (3), the new quality metric function is designed to evaluate the quality of links between the candidate cluster head \(x\) and its neighbor nodes \(NEB_{x}\). Moreover, this is designed by the fact that the maximum link quality value is one. Hence, through the quality metric function, the closer the link quality value is to one, the lower the resulting value for the metric function, leading to choosing the cluster head that can provide more reliable links for data transfer from its members. In the hierarchical clustering approach, every cluster assigns a cluster head that receives and aggregates the data from its members and forwards it to sink thereafter. Thus, cluster heads may lose energy faster than conventional sensor nodes. Therefore, to balance energy consumption across all nodes and extend the network's lifetime, the clustering must avoid low-residual-energy nodes. The clustering strategy needs to avoid nodes with small residual energy. Therefore, the candidate cluster head's energy is used as an energy metric, which is represented by Equation (4). \[EM_{x}(t)=RE_{x}(t) \tag{4}\]  
where \(RE_{x}(t)\) is the residual energy of node \(x\). To optimize delivery delay, the average intra-cluster distance is assessed in the election decision of cluster head nodes. This is defined for sensor node \(x\) by Equation (5) as follows:  
\[ICD_{x}=\sum_{y\in NM_{x}}ED_{xy}\hskip-14.226378 pt\Bigg{/}NM_{x}\Bigg{|} \tag{5}\]  
where 1.1 denotes the size of a set and \(ED_{xy}\) is the Euclidian distance between nodes \(x\) and \(y\). In addition to energy balancing, the clustering process should evenly distribute the load associated with being a cluster head among the nodes to achieve a balanced load distribution [12]. Hence, the cluster head nodes should be carefully chosen to construct well-balanced clusters. Therefore, load balancing is another factor that has to be consideredin the cluster head election. In this paper, the load balancing is decided by the cluster load metric. Equation (6) gives the cluster load metric of node \(y\) at time interval \(t\) as follows:  
\[CL_{x}(t)=\sum_{n=1}^{t-1}\eta_{x}^{n} \tag{6}\]  
where  
\[\eta_{x}^{n}= \begin{cases}1&if\ node\ x\ is\ chosen\ as\ a\ cluster\ head\ during\ time\ interval,\ n\\ 0&otherwise\end{cases}