# An Energy Balance Clustering Routing Protocol for Intra-Body Wireless Nanosensor Networks
## 3 Clustering Routing Framework
### Clustering and Cluster Head Updating  
After all nano-nodes are assigned to their respective layers, the initial cluster head node is selected based on their remaining energy. In this election process, firstly, the candidate nodes compete for the ability to become the cluster head CH by multicasting their weights to neighbor nodes of the same layer, and the nano-nodes ignore the weights sent by their neighboring layer. In this process, the cluster head node reduces its transmit power to half of the original transmit power to ensure that the diameter of the formed cluster is less than r, thereby ensuring that the node can reach any other nodes in the cluster in one hop. The weight is represented by \(\zeta_{k}\). Its calculation is as follows:  
\[\zeta_{k}=\frac{E_{res\_k}}{E_{max}} \tag{13}\]  
where \(E_{res\_k}\) is the residual energy of nanonode \(v_{k}\), and \(E_{max}\) is the maximum energy. If a given nanonode does not find another nanonode with a larger \(\zeta_{k}\), it declares itself to be the CH. After the CH is selected, clustering begins. The CH multicasts short-range messages (messages that declare itself as the cluster head) to all unclustered nano-nodes within the same layer. Furthermore, each non-member nanonode compares multiple short-range messages it receives, sends a join request to the CH corresponding to the strongest RSSI (Received Signal Strength Indication) short-range message it receives and registers itself as a cluster member CM. This process continues until clusters are formed and all nodes have been assigned to their respective CHs. In order to reduce the clustering overhead, the entire network is only clustered once. After each round of data transmission, only the CHs are updated. The cluster formation algorithm (Nano Cluster Formation, NCF) is shown in Algorithm 2. ```
Notations: \(v_{k}\) = No. of deployed nanosensors \(\zeta_{k}\) = normalized residual energy of sensor \(v_{k}\) \(k_{max}(\zeta)\) = Nanosensor with maximum \(\zeta\)GN = General Node Data:\(L(v_{k})\), \(E_{res\_k}\), \(E_{max}\) Result: Clusters foreach \(v_{k}\)do  Calculate \(\zeta_{k}\) with equation (13);  Multicast \(\zeta_{k}\) within associated \(L(v_{k})\); if\(k_{max}(\zeta)\)then  Status\(\bullet\)\(\bullet\)



linear combination of residual energy and node position, and the node with the largest score becomes the cluster head. The scoring function is:

\[S_{k}=w(m)\frac{E_{res\_k}}{E_{max}}+\left[1-w(m)\times\frac{d_{\sum}\ -d(v_{k},h(v_{k}))}{d_{\sum}}\right] \tag{14}\]

where \(S_{k}\) is the score of node \(v_{k}\), \(E_{res\_k}\) represents the residual energy of node \(v_{k}\) and \(E_{max}\) represents the maximum energy of node, assuming the initial energy of node is the maximum energy. \(h(v_{k})\) represents the cluster head node of node \(v_{k}\), \(d_{\sum}\) indicates the sum of the distances from all nodes in the cluster to the cluster head node and \(d(v_{k},h(v_{k}))\) is the distance from the node \(v_{k}\) to the cluster head node, \(w(m)\) is the weight coefficient. The cluster head selection formula is:

\[h^{\prime}=argmax(S_{k}) \tag{15}\]

where, \(h^{\prime}\) is the updated cluster head node. Considering that the energy of the nodes in the network is decreasing over time, at this time, the chance that the node closer to the original cluster head becomes a cluster head should be increased. Therefore, the weight in (14) is an adaptive weight. As the dead node increases, the weight for the remaining energy is reduced, and the weight for the node position is increased. The mathematical expression is as follows:

\[w(m)=1-\frac{1}{e^{-\kappa m}} \tag{16}\]

where \(\kappa\) is an adjustable parameter and \(m\) is the number of dead nodes in the cluster. It can be seen from (14), the cluster head update rule expressed is that, the node with greater residual energy and closer the original cluster head node has greater probability to become cluster head. After the candidate node becomes the cluster head, it needs to broadcast the information that becomes the cluster head immediately.