# Markov Chain Model-Based Optimal Cluster Heads Selection for Wireless Sensor Networks
## 4 The Proposed Clustering Protocol
### Settling Phase
#### 4.4.2 Optimal Number of CH Selection  
Proper and careful utilization of the available resources can also help in increasing the lifetime of the network. The first step in this way is that the selection of CHs should be proper. An uneven number of CHs in every round can be a waste of resources. As defined earlier, the CH is responsible for collecting, fusing, and sending data of \(C_{MNs}\). So, each step in the cluster formation consumes the power of the nodes. After the random selection of the CHs, it is essential to check whether the selected number of CHs are meeting the optimality criteria or not. In this step, the BS is involved to verify the number of CHs selected in the random selection process as demonstrated in Figure 6. The selection of CHs through a random selection process is not optimal because the CHs are selected through the distributed algorithm. So, there is a need to optimize the resources of the network. It is necessary to check if the resources are consumed in a balanced way or not. To supervise all this CH selection and cluster formation process, we engage the BS to supervise and to certify all these selection procedures. The decisions of BS are more reliable, as the BS is enriched with high-speed processors and storage capabilities as compared to root nodes [9]. The BS is not just following a single criterion, it also takes into account the distance, remaining energy, the average energy of the network, and member nodes for CH selection. Before proceeding to the next phase, the BS makes sure that the selected CHs in a random process are optimized or not. The BS calculates the optimal number of CHs through the Markov model [26] using Equation (4) according to the number of sensor nodes in the network. The BS is the central entity; it can reject an already selected CH in the random selection process as revealed in Figure 6. After that, there are three cases for finalizing the optimal number of CHs as discussed below:  
**Case 1**: \((|R_{CHs}|>|O_{CHs}|)\): The BS discards some \(R_{CHs}\) and all the waiting \(W_{CHs}\) to achieve the optimal value. Figure 5: The random CH selection, and waiting for CH selection in the network on the basis of threshold. 2. \((|R_{CHs}|<|O_{CHs}|)\): The BS selects some new \(O_{CHs}\) from the waiting CHs (\(W_{CHs}\)) equal to the optimal value. If the \(W_{CHs}\) are not enough, then the BS can also select some new CHs equal to the optimal number from the root nodes. 3. \((|R_{CHs}|=|O_{CHs}|)\): The BS allows the process to move to the next phase. where, \(O_{CHs}\) represent optimal CHs, \(R_{CHs}\) express the randomly selected CHs, and \(W_{CHs}\) express the waiting CHs. According to the first order radio energy model [11], to attain a suitable Signal to Noise Ratio (SNR) in transmitting a \(l\)-bit message over a distance \(d\), the energy spent by the radio is given as:  
\[E_{TX}(l,d)= \begin{cases}E_{elec}l+l\varepsilon_{fs}d^{2}&\quad\text{if}\ \ \ d<d_{0}\\ E_{elec}l+l\varepsilon_{amp}d^{4}&\quad\text{if}\ \ \ d\geq d_{0}\end{cases}  \tag{12}\]  
Where, \(E_{elec}\) is the energy consumed per bit to run the transmitter or the receiver circuit, \(\varepsilon_{fs}\) and \(\varepsilon_{amp}\) depend on the transmitter amplifier model we use, and \(d\) is the distance between the sender and the receiver. We assume that the radio channel is symmetric such that the energy required to transmit a message from node A to node B is the same as the energy required to transmit a message from node B to node A for a given SNR. The energy consumed by a CH for aggregating and sending data to the BS is computed as:  
\[E_{CH}=lE_{elec}\big{(}\frac{N}{K}-1\big{)}+l\varepsilon_{amp}d^{4}_{(CH,BS)} +l\varepsilon_{fs}d^{2}_{(N,CH)} \tag{13}\]  
where, \(K\) is the number of clusters in a network of \(N\) nodes. As we discuss earlier, that the BS has unlimited resources. Therefore, these calculations and computations cannot affect the network lifetime.