# An Energy Balance Clustering Routing Protocol for Intra-Body Wireless Nanosensor Networks
## 3 Clustering Routing Framework
### Clustering and Cluster Head Updating
Layer 1 has three clusters, Layer 2 has five clusters and Layer 3 has seven clusters. Each cluster of Layer 1 has four active nodes ADTN for data transmission, and Layer 2 and Layer 3 for each cluster head have two active nodes. Since the cluster heads between layers need to transmit data, it is necessary to optimize the slot scheduling. For example, the third layer (\(T_{1}^{3}\)) divides one time slot for each of the seven clusters, and the corresponding time slot numbers are \(T_{1,1}^{3}\), \(T_{1,2}^{3}\), \(T_{1,3}^{3}\), \(T_{1,4}^{3}\), \(T_{1,5}^{3}\), \(T_{1,6}^{3}\), \(T_{1,7}^{3}\)

Figure 4: RTS packet format of cluster head node (CH). Figure 3: RTS (Request To Send) packet format of cluster member node (CM). Figure 2: Frame structure. respectively. Considering that the inter-layer cluster head needs communication, three sub-time slots \(T^{3}_{1,1,1}\), \(T^{3}_{1,1,2}\), \(T^{3}_{1,1,CH}\) are divided. The first two time slots are used for data transmission of the active node ADTN, but \(T^{3}_{1,1,CH}\), the shaded part in the Figure 5 is used for data transmission between the cluster heads. This process is repeated for all clusters and layers. This slot scheduling scheme makes optimal use of the large bandwidth provided by the THz band and avoids transmission collisions at the CH and NC. ```
Notations: \(LL=\) List of order of layers \(p=1,2,\cdots n\) \(T^{l}_{p}=\) Time slot for layer L \(T^{l}_{p,c}=\) Time slot for cluster \(c\) of layer \(L\) \(T^{l}_{p,c,p}=\) Time slot for Active Data Transmission Node (ADTN) \(\
u\) of cluster \(c\) of Layer \(L\) \(T^{l}_{p,c,CH}=\) Time slot for CH of cluster \(c\) Data: Transmission request message Result: Variable length time slots for all ADTNs and all CHs  NC relays message to CMs requesting transmission;  ADTNs send RTS message to CH;  CHs send RTS message to NC;  Calculate total time \(T\) for a complete cycle;  Create the order list \(LL\) in the order of outer layer to inner layer; for each \(LL\)do  Calculate layer time \(T^{l}_{p}\); for each \(T^{l}_{p}\)do  Calculate each cluster time \(T^{l}_{p,c}\); for each \(T^{l}_{p,c}\)do  Calculate ADTN time \(T^{l}_{p,c,p}\);  Calculate CH time \(T^{l}_{p,c,CH}\);  Allocate time slots accordingly;  end end  end
```
**Algorithm 3** TSA Algorithm

In the initial stage, all nano-nodes are in data acquisition mode except for the cluster head node CH. After the time slot allocation is completed, the control node NC sends a wake-up code to activate the outermost layer, thereby activating all ADTNs of the layer for transmission. After receiving all ADTN data, the cluster head node fuses all data and sends it to the next hop node in the time slot allocated to it. \[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}\]0 Example of slot scheduling for a three-layer network. ### Inter-Cluster Routing

A major problem in iWNSNs is the high probability of link breakdown due to low transmission power and high transmission loss (e.g., path loss). This problem can be successfully solved using collaborative communication between cluster head nodes. When the cluster head choosing next hop to establish a routing, it is always desirable that the next hop node is closer to the nano control node, but this also means that the transmission distance between the cluster head node and the next cluster head node increases. Considering the transmission characteristics of the THz channel, the path loss becomes larger with the increase of the transmission distance and the channel quality deteriorates. Therefore, the link cost function is established as the selection basis of the next hop node, and the candidate path is evaluated. The distance and channel capacity are taken as important factors in the calculation, so that the transmission distance and the channel capacity are compromised.