# Trust-Aware Routing Mechanism through an Edge Node for IoT-Enabled Sensor Networks
## 4 Proposed Trust-Aware Routing Mechanism
### Trust-Value-Based Route Path Selection
#### 4.2.1 Trust Values Evaluation
The new solution by selecting a decision variable from the first chosen solution can be generated using Equation (27) \[F_{ij}^{new}=F_{ij}\times rand(0,1)+(F_{ij}-F_{kj})\varphi_{ij}+\] (27) \[(z_{ij}-F_{ij})(\theta_{ij}-0.5)^{2}\] where \((z_{ij}-F_{ij})(\theta_{ij}-0.5)^{2}\) is the global best solution that produces optimal convergence efficiently and \(\theta_{ij}\) is the new step size given by \(\theta_{ij}=1-\frac{itr_{i}}{1}\). The above Equation (26) enables the CHs to quickly relay the data to the nearest trustworthy CH or node. 5. The next phase is the onlooker bee phase; these onlooker bees are managed by the CH nodes. It searches for the relay CH depending on the following probability for each solution: \[p_{i}=\frac{o_{i}}{\sum_{Ch\in RCG_{CH_{(}\alpha_{ij})}}o_{i}}\] (28) where \(o_{i}=\frac{w_{j}}{\sum_{Ch\in RCG_{CH_{(}\alpha_{ij})}}w_{j}}\times\frac{DD_ {i}}{\sum_{h\in RCG_{CH_{(}\alpha_{ij})}}DD_{i}}\). Once all the probabilities associated with every solution are obtained, the onlooker bees select the initial \(S\) and compare its probability with the random number \(x\in[0,1]\). 1. If \(x>p_{i}\), the onlooker bees repeat the same process and do not generate new \(S\). 2. If \(x<p_{i}\), the onlookers generate new \(S\) by choosing an arbitrary decision variable in current \(S\) using Equation (26). 6. The scout bees use a trail vector to keep track of the failures when they fail to generate a better solution. Here, the new solutions are generated using Equation (23). The best fitness value among the previous and newly generated solutions based on the fitness function is stored in the trail vector. 7. If the mobile edge node receives the data from CH, it acknowledges CH intimating delivery. The delivery update equation is determined by Equation (29): \[DD(CH_{m})^{\prime}=\frac{DD(CH_{l})+DD(CH_{m})}{2}\] (29) where \(l\) and \(m\) are the two nodes in a cluster. 8. Based on the optimized path, the nearest CH transmits its data to the MEN. The pseudo-code for the trust evaluation scheme based on the ABC routing approach for mobile edge node is provided in Algorithm 1. Figure 5 portrays a visualization of the proposed TARM that focuses on the clustered network wherein clustering is performed by the modified GWO. This clustered network then undergoes a trust evaluation mechanism at MEN to identify trustworthy nodes. Routing through the trustworthy nodes via the CH is then performed using the ABC algorithm explained in Section 4.2.2. It initially evaluates the trust values of the nodes and classifies them as trustworthy and untrustworthy nodes. Then, it applies the ABC approach proposed in this section on the MEN and enables the optimal route discovery for MEN through the trusted nodes and, finally, to the base station. The edge node is used because of its properties such as storage capability, processing ability, and location near the base station. The mobility of the MEN is restricted to its transmission radius. Nevertheless, the CHs are able to relay the information to other CH nodes in order to make the information reach the CH nearer to the MEN. ### Complexity Analysis

In general, the GWO algorithm starts with the initialization of parameters with a complexity of \(O(n_{w})\) where \(n_{w}\) is the number of packs. An outer for loop runs until maximum rounds are reached computing the complexity of \(O(n_{w})\). Now, the inner three for loops run until the number of packs are reached and they count the complexity of \(O(maxit,n_{w},s)\), where \(maxit\) is the maximum iterations and \(s\) is the size of the pack. Thus, the total complexity for the worst case is determined by \(O(n_{w})+O(n_{w})+O(maxit,n_{w},s)\). ABC does not depend on the problem dimension; thus, time complexity for it is scaled to \(O(n)\) where \(n\) is the size of the bee population. The search complexity (depending on onlooker bee population) of ABC is given by \(2\times LB\times maxcy\), where \(LB\) is the number of onlooker bees and \(maxcy\) indicates maximum cycles.