# ERCP: Energy-Efficient and Reliable-Aware Clustering Protocol for Wireless Sensor Networks
## 4 Proposed ERCP Clustering Algorithm
### Inter-Cluster Routing Protocol  
After clustering, the cluster heads have to deliver their collected data to the sink node; thus, the inter-cluster routing protocol is invoked.  
Actually, communication energy is considered the major source of energy consumed in WSNs. Since it mainly depends on the communication distance, the shortest path substantially minimizes the consumed energy. However, it may result that the shortest path approach does not prolong the network's lifetime. The network's energy usage must be balanced for energy-efficient routing.  
Relying entirely on sensor nodes' residual energy is not the ideal way to establish network energy balance. To achieve a better energy balance, the routing protocol must refrain from using low-energy, high-traffic nodes as next hops. Using the recommended new function, the energy load function, it is feasible to include the remaining energy and traffic load of sensor nodes and let them significantly impact choosing the next hop.  
The total number of messages sent by each cluster head should match that of the node. This should contain the number of messages from each cluster head member and other cluster heads to relay. That is to say, the cluster head with higher energy and less load is preferable to be chosen as a relay node. Equation (9) presents the proposed relay energy metric of cluster head \(y\) at time \(t\).  
\[REM_{y}(t)=\mathbf{exp}\Bigg{(}\frac{RE_{y}(t)-\big{(}NDR_{y}(t)*HE_{xy} \big{)}}{IE_{y}}\Bigg{)} \tag{9}\]  
where is the traffic load of cluster head \(y\) and \(HE_{xy}\) is the single-hop transmission energy from \(x\) to \(y\).  
Equation (9) suggested the new energy consumption load function expresses cluster head \(y\)'s energy use after sending all messages. Any tiny change in the exponential function input causes a huge output change. Through an exponential function, a slight change in nodes' energy leads to the selection of the most energy-efficient relay node [30].  
In ERCP, after collecting the data from its member nodes, every cluster head looks at the cluster heads of its neighbors and unicasts the data to the best one using the cost function. The data are then routed via this neighbor, which has chosen the best cluster head among its neighbors until it reaches the sink node. Several parameters, such as the link quality, energy metric, and distance to the sink node, are used to compute the cost function. To achieve an energy consumption balance, the node with the maximum energy metric value should be treated as a relay node. Furthermore, the node with the minimum distance should be chosen as a relay node to minimize energy consumption and delivery delay. In addition, the node that achieves the best link quality should be chosen as a relay node to avoid unreliable links. The cost of cluster head \(x\) selecting cluster head \(y\) as a relay node is defined as follows:  
\[RCost_{xy}(t)=\Bigg{(}REM_{y}(t)+\frac{1}{ED_{(y,sink)}}\Bigg{)}*PRR_{xy}(t) \tag{10}\]  
According to Equation (10), the cluster head with the maximum cost value will be selected as a relay node. The pseudo-code of the ERCP inter-cluster routing algorithm is given as Algorithm 2.