# Trust and Mobility-Based Protocol for Secure Routing in Internet of Things
## 4 SMTrust Design and Analysis
### Quantification of Trust Metrics  
Through the critical analysis of the trust metrics for security in IoT routing, six metrics have been selected for the development of the proposed trust-based solution. Direct trust is determined by the success rate (\(TM_{SR}\)) of the node. \(SR\) is the ratio of the number of packets forwarded (\(P_{F}\)) to the number of packets received (\(P_{R}\)). This is referred to as direct trust or reliability of the node and the node's suitability of effective communication in the network. Let \(N_{A}\) be the trustor node (the evaluator) and \(N_{B}\) be the trustee node (for which the trust is being evaluated), \(P_{R}\) be the number of packets received by \(N_{B}\), \(P_{D}\) be the number of packets dropped, then \(TM_{SR}\) determines the overall success rate of the node calculated by Equation (1).  
\[TM_{SR}=P_{F}/P_{R}\;,\;\textit{where}\;P_{F}=P_{R}-P_{D} \tag{1}\]  
Similarly, historical observations (\(H_{0}\)) are based on the recent trust value calculated for \(N_{B}\) by node \(N_{A}\), if this is the first-time trust index calculation for node \(N_{B}\) by node \(N_{A}\), then the value of \(H_{0}\) will be set to 1. This supports the assumption that all nodes join the network as trusted nodes. It also satisfies that the node is not suddenly assigned a bad or good trust reputation in the network, rather it develops gradually.  
\[TM(H_{0})=\textit{Recently observed trust value of }N_{B} \tag{2}\]  
The energy level (\(TM_{EL}\)) of a node is revealed by the ratio of the remaining energy (\(E_{R}\)) of the node to the maximum energy (\(E_{M}\)) or battery capacity of the node, calculated by Equation (3). The maximum value of \(TM_{EL}\) is 1 for a node with full battery.  
\[TM_{EL}=E_{R}/E_{M} \tag{3}\]  
Figure 4: Flow Diagram of SMTrust.  
The location of the node determines that its position is not ambiguous and is clearer. Moreover, the distance between the trustor node (\(N_{A}\)) and trustee node (\(N_{B}\)) shall play a part for the closeness of the two nodes. The closer the nodes, the better is the link stability for successful packets transmission. In the scenario of wireless networking, it is vital to consider the quality and stability of the link, preferably the wireless signal strength for the trustworthy parent selection. Received Signal Strength Indicator (RSSI) quantifies the wireless signal strength. Adding this factor shall enhance the calculation of the trust index. Moreover, the RSSI value indicates the signal strength; a higher RSSI means that the signal is stronger and the node position is closer. Hence the trust metric for location and link stability (\(TM_{LLS}\)) is determined by Equation (4).  
\[TM_{LLS}=RSSI\ value \tag{4}\]  
In trust computation, mobility is defined as the number of relocations the node has gone through from a previously noted position. The less the number of relocations, the more reliable is the node. Suppose that the previously noted location of trustee node \(N_{B}\) is \(L_{P}\) and the current location of \(N_{B}\) is \(L_{N}\), then mobility trust metric is calculated by Equation (5).  
\[TM_{Mobility}=Distance\ (L_{N},L_{P}) \tag{5}\]  
Recommended trust (\(TM_{RT}\)) depends on the neighbouring nodes' feedback or observation about trust of node \(N_{B}\) being evaluated by node \(N_{A}\). This is calculated as the average of all the trust recommendation values for \(N_{B}\) that node \(N_{A}\) received (in DIO messages) from its \(n\) neighbours.  
\[TM_{RT\ (NA,\ NB)}=\Sigma_{(1-n)}\ TrustIndex\ (N_{n},N_{B})/n \tag{6}\]  
Recommended trust can serve the purpose for trust calculation is two-fold; one is that it can be used in the weighted calculation of trust index value of trustee node, that is, the node being evaluated. Secondly, it can be used to keep an additional record for the one-hop neighbours' trust value.