# 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 trusted routing path based on the optimized ABC approach, utilized to transfer data from all trusted nodes to all CHs and then to the MEN, can be achieved with Algorithm 3. Figure 2 represents the flow of the proposed methodology. ```
1:Input: W, \(CH_{i}\), MEN, R
2:Output: Trustworthy nodes with trust values for each cluster, optimized inter- and intra-cluster route paths
3:for all nodes in \(c\) cluster do
4:if\(dist(currentnodeA,CH)<R\)then
5: the node is directly communicated and compute direct trust value using Equations (13)-(17)
6:else
7: The node is not directly communicated
8:for\(A\) node do
9:if\(dist(Atox+xtoCH)<R\)then
10: Mark \(x\) as the neighbor of \(A\) and compute indirect trust values using Equation (19)
11:else
12: node \(x\) is not the neighbor of \(A\)
13:endif
14:endif
15:endfor
```
1:The scout bee (cluster member) searches for food resources
2:Initiating food source \((F_{ij})\)
3:Finding optimized solutions (relay CH) for food sites by employee bees using Equation (19)
4:The CH transmits \"PATH_MESSAGE\" (which includes energy, node ID, length of queue, etc.) to the nodes in its cluster. 5:New food source by employee bee is generated using Equation (26)
6:Employee bee shares all best solutions with onlooker bees
7:The onlooker bee chooses the best solution using the probability \(p_{i}\) elucidated in Equation (28)
8:if MEN receive the data packets then
9:It acknowledges the CH intending the delivery probability. The upgrade in delivery can be achieved using Equation (29)
10:endif
11:for All paths in the network do
12:if the present source exceeds the limit of the search then
13:it is not considered as an optimized solution and is discarded. 14:else
15:CHs transmit their data to the MEN using the optimized path
16:endif
17:endfor
```

**Algorithm 3** ABC routing on trusted paths for all trusted neighboring nodes

#### 4.2.2 Routing

The artificial bee colony algorithm [32] is a search-based probabilistic evolutionary approach of optimization. It works in three stages: (i) food sources; (ii) foraging for food by employer bees; (iii) observing and random searching by scout and onlooker bees to know the food source, which is the solution set. Although the search time of this algorithm is longer, it is beneficial in preventing premature convergence. To combat the problem of search time, we have modified the fitness function and developed the ABC approach, which is inspired by [24] to enhance its accuracy. The following steps can be followed to easily understand the proposed ABC approach:

1. Initialize the swarm size, food source, employer bees, and onlooker bees such that \(S=Emp=Onl=\frac{W}{2}\). The scout bee (cluster member) searches for food resources \(CH_{i},\;\;r=f_{i},\;1,f_{i},\;2,\ldots f_{i},R\)
2. Initialize the random solutions using the equation below: \[F_{ij}=F_{j}^{min}+rand(0,1)\times(F_{j}^{max}-F_{j}^{min})\] (23)
3. Find optimized solutions (relay CH) for food sites by employee bees using the equation below: \[ \begin{split} RG_{CH}\big{(}ch_{j}\big{)}&=ch_{i} |dist(ch_{j},ch_{i})\leq\min RG\big{(}ch_{j}\big{)}\\ &;dist(ch_{i},MEN)<dist\big{(}ch_{j},MEN\big{)}\end{split} \] (24)

The expression for objective function is given as

\[f_{i}()=(1-t)O_{3}+(t-y)\times\;O_{4} \tag{25}\]

where \(O_{3}\) and \(O_{4}\) are the same as shown in Equation (4) and Equation (5), respectively. The fitness for every solution is calculated using

\[Fit= \begin{cases}\frac{1}{1+f_{i}()}&\text{if }f_{i}()\geq 0\\ 1+|f_{i}()|&\text{if }f_{i}()<0\end{cases}  \tag{26}\]4. The random solutions are generated from the above equation, this solution set chooses candidate and partner solutions from the remainder set.