# Cluster-Based Routing Protocol with Static Hub (CRPSH) for WSN-Assisted IoT Networks
## 4 Proposed Protocol
### Cluster Head Selection and Cluster Formation
The CH utilizes Time Division Multiple Access (TDMA) to create a time-slot schedule for the cluster members and distributes it to them to alleviate congestion. This TDMA slot can be used to maintain collision-free communication among the CHs and CMs. **
```
1:CH sends \(CH_{info}\) packet packet to the CMs. 2:CH sends \(Cluster_{membr}(CH)\) to the hub and TDMA slots to each CM. 3:Device \(\alpha\) receives the \(CH_{info}\) packet from the Device \(\beta\), where \(\beta\in CH\)
4:\(CH_{info}:<CH_{info}\), \(ID_{\beta}>\)
5:Device \(\alpha\) selects the CH with the maximum received signal intensity as its CH after receiving all \(CH_{info}\) packets. 6:Device \(\alpha\) sends the \(CH_{join}\) packet to the selected CH. 7:Device \(\alpha\) receives the \(CH_{join}\) packet from the Device \(\beta\), where \(\alpha\in CH\)
8:\(CH_{join}:<CH_{join}\), \(ID_{\beta}\), \(ID_{CH}>\)
9:if (\(ID_{\alpha}==ID_{CH}\)) then
10:\(Cluster_{member}(\alpha)\leftarrow Cluster_{member}(\alpha)\cup\beta\);
11:Device \(\alpha\) sends the \(Cluster_{member}(\alpha)\) to the hub after receiving all the \(CH_{join}\) packets. 12:Device \(\alpha\) sends the TDMA slots to each CM. 13:else
14:Discard the packet. 15:endif
```

**Algorithm 3** Cluster Formation

**Lemma 1**: _The clustering process needs the transmission of \(\mathcal{O}(\alpha)\) control messages, where \(\alpha\) is the number of sensor devices in the network._

Proof. : Each device begins the cluster formation process by broadcasting a \(P_{z}D_{control}\) packet. Thus, the network contains \(\alpha\) messages. Each device communicates information about its peers to the hub, which accepts \(\alpha\) messages again. To join the cluster head, every cluster member broadcasts a \(CH_{join}\) packet. Assume that the number of cluster heads created is \(\beta\). Thus, the total number of join requests is \((\alpha-\beta)\), and the cluster heads require \(\beta\) messages for each time slot. Thus, in cluster formation, the total number of control messages required is \(\alpha+(\alpha-\beta)+\beta+\beta=2\alpha+\beta\). As a result, the overall complexity of the control message throughout the cluster formation network is O(\(\alpha\)). **Lemma 2**: _The network's total energy usage is \(E_{Total}=\sum((E_{ch}\times\beta+E_{cm}\times(\alpha-\beta)))\)._

Proof. : Each device in CRPSH is classified as a cluster head or a cluster member. Cluster members transmit data to the CH, which collects and delivers the data to the hub. The transmission, receipt, and aggregation of data by the each cluster head requires\(E_{ch}\) energy. Each cluster member uses \(E_{cm}\) energy during transmission, reception, and sleep. If the number of CHs in the network is \(\beta\), then the network's total energy usage is \(E_{Total}=\sum((E_{ch}\times\beta+E_{cm}\times(\alpha-\beta)))\). ### Data Transmission

Within the specified time, the cluster member transmits the sensed data to the CH and then enters sleep mode. In the subsequent time slot, the sensor device reactivates to transmit the data. As a result, the protocol optimizes the energy efficiency of the sensor devices. The CH collects data and transmits it to the hub via the specified path. The CH receives an acknowledgment packet when the data arrives at the hub. The data is re-transmitted if the CH does not receive confirmation from the hub. Because the hub contains all of the network's topological information, it continuously monitors each device's remaining energy. If the hub detects that a device's residual energy is less than the predefined threshold, it redirects the CH to another available path. ### Re-Clustering and Renouting

The hub continually monitors each device's remaining energy to ensure that the load is distributed evenly among the devices. If a device's energy level falls below the threshold, the hub begins re-clustering or rerouting according to the role of the device. If the device is a relay device for any path, the hub chooses another way to bypass it. If the device is a CH, the hub switches to a different CH and path.