# Bio-Inspired Energy-Efficient Cluster-Based Routing Protocol for the IoT in Disaster Scenarios
## 5 Routing Protocol  
The cluster head (CH) collects data from the cluster member and sends the data to the BS. We assume that the CH maintains a list for the BS route. The main objective of this routing algorithm is to minimise the overall distance travelled from the source to the destination, as the distance is proportionally related to the energy decay and network lifetime. The fitness function evaluates the quality of the routing protocol. In this study, we consider an improved PSO algorithm for the routing protocol. The PSO algorithm [28] is a bio-inspired method based on a swarm of birds or fish moving in a multidimensional space to search for food. Each CH node considers each of the particles, and each CH is initialised with a random velocity and position. Let \(P_{i}=P_{i,1},P_{i,2},P_{i,3},\)\(\ldots\ldots P_{i,D}\), where \(D\) is the optimal number of CHs. The particles update their positions based on the intensity of movement and the deviation. Particles observe \((L_{best})\) and \((g_{best})\) and then adjust their positions and velocities as follows [28]:  
\[V_{i}^{t+1}=\omega*V_{i}^{t}+C1*rand1*(L_{best}-P_{i}^{t})+C2*rand2*(g_{best}-P_ {i}^{t}) \tag{14}\]  
\[P_{i}^{t+1}=P_{i}^{t}+V^{t+1} \tag{15}\]  
where \(t\) is the current iteration, \(\omega\) is the inertia weight with \(\omega^{max}=0.9\) and \(\omega_{min}=0.2\). rand1 and rand2 are random numbers in the range \([0,1]\). Each CH is assigned a random number in \([0,1]\) from a uniform random distribution. This number is then used to connect the CH with a random destination, known as the nearest relay node. We assume that each CH is connected within the range of either another CH or the BS. The \(P_{i},D\) is assigned to the final destination node \(CH_{D}\), which is connected with the BS. This process ensures that the data sent from the source CH \(CH_{S}\) are routed to the BS via \(CH_{D}\), thereby optimising the routing process. The improved fitness function for the PSO algorithm considers the residual energy, the distance between the source and the destination, and the total number of relay nodes. The fitness function is as follows:  
\[\mathit{FitnesspSO}=\beta 1*\sum_{i=1}^{D}\mathit{Distance}(CH_{S},CH_{d})+ \beta 2*\frac{\sum_{i=1}^{D}E_{r}}{avgE}+\beta 3*\sum_{i=1}^{D} relay(CH_{S},Dest_{d}) \tag{16}\]  
where \(E_{r}\) is the residual energy, \(AvgE\) is the average energy of all alive nodes, and \(\mathit{Distance}(CH_{S},CH_{d})\) is the distance between the source and destination nodes. Let us consider the network shown in Figure 4, where graph \(G(V,E)\) shows the vertices, with each CH acting as a gateway, and \(E\) represents the edges. Table 2 shows nodes within the range of a particular CH and the total number of relay nodes. According to Figure 4, there are seven CHs \((CH1,CH2,CH3,\ldots,CH7)\) connected with each other within the communication range. We assign each CH a random number \(P(i,d)\)\(\epsilon\)\([0,1]\), which maps to a random relay node destination. Some of the CHs are connected to the BS. When CH1 wants to send data to the BS, it can route the data through \(CH2,CH3,orCH5\). After the optimisation process is completed with the fitness function, the CHs have information about their members and the different routes to communicate with other CHs. The TDMA scheduler is used to address congestion and collision issues. Each node has a dedicated slot to send data to the CHs. The cluster members send their data according to the specific time slot assigned by the CHs. The collected data are aggregated by the CHs and sent along the optimised route to the BS according to the proposed model. After every iteration, according to Equations (14) and (15), the particle positions and velocities update with respect to \(P_{best}\) and \(G_{best}\). The updated position values might fall be \(\leq\)0 or \(\geq\)1 because of algebraic addition and subtraction. To address this issue, we regulate the positions as follows [47]:  
\[P(i,d)= \begin{cases}1&\text{if }P(i,d)>1\\ min(\vec{r})&\text{if }P(i,d)<0\end{cases}