# Fuzzy Logic and Bio-Inspired Firefly Algorithm Based Routing Scheme in Intrabody Nanonetworks
## 3 Fuzzy Logic and Bio-Inspired Firefly Algorithm Based Routing Scheme
### Bio-Inspired Firefly Algorithm Based NBSs Selection
The simulation settings are further highlighted in the \[d(\widehat{FF}_{i},\widehat{FF}_{j})=\sqrt{(\widehat{FF}_{j}(x)-\widehat{FF}_{ i}(x))^{2}+(\widehat{FF}_{j}(y)-\widehat{FF}_{i}(y))^{2}+(\widehat{FF}_{j}(z)- \widehat{FF}_{j}(z))^{2}}, \tag{6}\]6

#### 4.1.1 Residual Energy

Residual energy is defined as the energy left in the network at the end of the simulation. We have evaluated remaining energy with respect to different request intervals to comprehend the influences of request rate on the energy resources of the network. In this work, we evaluate residual energy with different request rate intervals and increasing densities of NBSs. \begin{table}
\begin{tabular}{l l} \hline \hline
**Parameter** & **Value** \\ \hline Number of NBSs & 100, 200 \\ Number of nanorouter & 1 \\ TTL value & 100 \\ Tx Range of NBS (mm) & 10 \\ Request packet interval & 0.2, 0.3, 0.4, 0.5 \\ Pulse energy (pJ) & 100 \\ Pulse duration (fs) & 100 \\ Pulse interval time (ps) & 10 \\ Packet size \((P_{FB},P_{RQM})\) & 48 (bits) \\ Packet size \((P_{RM})\) & 176 (bits) \\ Simulation duration (s) & 3 \\ Total iteration & 10 \\ \hline \hline \end{tabular}
\end{table} 
Table 2: The values of parameters selected for the simulations. Residual Energy in the Network with the Density of 100 NBSs and Increasing Request Rate Intervals

Figure 7 demonstrates that the increasing rate of request generation leads to a fast depletion of energy resources. For the request rate interval 0.2, the maximum number of requests are generated in the network and to satisfy a large number of requests, a large number of answer messages are generated that cause high energy consumption. The detailed comparison in Figure 7a-d depict that employing a fuzzy logic and bio-inspired firefly algorithm in our proposed scheme maximum amount of energy is left at all intervals (i.e., 0.2,0.3,0.4 and 0.5). The reason behind the highest residual energy is due to data aggregation prevention from low enrichment value correlated region and optimum selection of NBSs with the highest fitness value that supports decreased energy consumption. While in scenarios A and B, the remaining energy is almost the same due to the selection of the optimal number of NBSs and information and energy enriched correlated regions. Both scenarios provide better remaining energy than the flooding scheme as in the flooding scheme, increased the number of packet generation and forwarding rate results in consuming all the energy in the network before the simulation ends. Residual Energy in the Network with the Density of 200 NBSs and Increasing Request Rate Intervals

The increase in the number of NBSs increases the probability of having active NBSs in the network. However, the rise in the request rate interval increases the number of packet transmission and reception rate. The Figure 8 shows that flooding scheme consumes its available energy resources at the highest rate at all intervals (see Figure 8a-d ). While our proposed scheme achieves the best result for an increasing number of NBSs due to the optimum selection of correlated region and NBSs. The scenario A and B, both witness high energy consumption as compared to our proposed scheme as selecting only the correlated region or only selection of optimum NBSs cannot solely overcome the vast consumption of energy resources. #### 4.1.2 Network Lifetime

Network lifetime is defined based on the number of alive NBSs (m-ink-of-n nodes) at the end of simulations. The number of alive NBSs are evaluated with respect to different request rate intervals and with increasing density of NBSs in the cluster. Figure 7: _Cont._

Figure 8: Residual energy comparison of our proposed scheme with flooding scheme and different scenarios (A and B) with respect to increasing request rate interval and NBSs density of 200. (**a**) Residual energy comparison at request rate interval 0.2. (**b**) Residual energy comparison at request rate interval 0.3. (**c**) Residual energy comparison at request rate interval 0.4. (**d**) Residual energy comparison at request rate interval 0.5.