# An Energy Balance Clustering Routing Protocol for Intra-Body Wireless Nanosensor Networks
## 3 Clustering Routing Framework
### Clustering and Cluster Head Updating
With the location information of the cluster head, the remaining nodes can start data transmission. ### Communication Mechanism

The medium access layer uses a Carrier Sense Multiple Access with Collision Avoidance (CSMA/CA) and a Time Division Multiple Access (TDMA) hybrid MAC access mechanism. In a conventional wireless network, a node detects whether a channel is busy by means of carrier sensing. In the communication system based on the TS-OOK mechanism, the nodes in the network cannot perform carrier sensing because of the short duration of the pulse. In view of the above problems, the nano-nodes in this paper use the RTS/CTS (Request To Send/Clear To Send) mechanism in CSMA/CA (Carrier Sense Multiple Access/Collision Detection) to examine channel usage and reserve time slots. Since the time slot application packet is small, the probability of collision is relatively low, so the performance of this mechanism is better. In the data transmission phase, the control node NC allocates a total time for each cluster of a specific layer based on the amount of data to be transmitted in the cluster, the time includes the data transmission time of the nodes in the cluster and the time required for the cluster head node to forward the data to the next hop cluster head of the adjacent layer. This method can prevent TDMA-based intra-cluster transmissions from colliding with other clusters from neighboring layers. Based on this hybrid access method, the frame structure can be designed as shown in Figure 2.

In the slot application phase, all cluster member nodes send the slot request packet RTS to the cluster head node, and the format of the RTS packet of the cluster member node is as shown in Figure 3. The \(D_{amnt}\) of member node without the data transmission requirement is 0, and the node that needs to transmit data called Active Data Transmission Node (ADTN). If the cluster head node receives the request, it replies a CTS message. Furthermore, if the member node does not receive the CTS after waiting for a certain time, it resends the data request packet. After receiving the data request packet from all member nodes, the cluster head node calculates the total amount of the data that need to be transmitted in the cluster and then randomly selects a neighbor cluster head node from the next layer to forward the RTS packet to the nano control node. The structure of the RTS request packet sent by the cluster head node to the NC is as shown in Figure 4.

After receiving the RTS packets from all cluster head nodes, the NC estimates the total propagation delay required to complete the transmission and specifies the packet transmission order of the ADTN. Transmission time scheduling is divided into the following three phases:

Phase 1: The NC allocates variable length transmission slots for each layer. The length of the time slot depends on the transmission parameters (the total amount of data to be transmitted per layer and the total time required for data transmission). The order of the time slots is from the outermost layer to the innermost layer. Phase 2: The Control Node NC then allocates the total time for each cluster of a particular layer based on the amount of data that needs to be transmitted within the cluster, which prevents TDMA-based intra-cluster transmissions from colliding with other clusters from the same layer. Phase 3: Based on the time slots allocated for each cluster, each ADTN node and cluster head node within the cluster will be able to allocate new sub-time slots based on the mechanism shown in Algorithm 3. The specific time slot allocation algorithm (Time Slot Allocation, TSA) is shown in Algorithm 3. Figure 5 illustrates a time scheduling process for a three-layer network that requires T time to complete the transmission cycle. The time slots are arranged in the order from the outer layer to the inner layer. NC divides the time slot \(T_{1}^{3}\), \(T_{2}^{2}\) and \(T_{3}^{1}\) to Layer 3, Layer 2 and Layer 1 respectively.