# Context-Aware Trust and Reputation Routing Protocol for Opportunistic IoT Networks
## 3 Proposed CATR Routing Protocol for OppIoT Networks
### Direct Trust Computation  
A node's Direct Trust (DT) is established by its actions within the network. As pointed out earlier in Section 3, its value is obtained as a weighted-average function with five parameters, namely the Beta Trust Degree of a node (BT) obtained from the Computation of Beta Trust Degree sub-module, the Encounter Frequency Degree (EF) obtained from the Computation of Encounter Frequency Degree sub-module, the Packet Forwarding Degree (PF) of a node obtained from the Computation of Packet Forwarding Degree sub-module, the Recent Contact Degree (\(RD\)) of a node obtained from the Computation of Recent Contact Degree sub-module, and the Contact Durability Degree (\(CD\)) of a node obtained from the Computation of Contact Durability Degree sub-module. Therefore, the DT value \(DT_{nm}\) is computed dynamically each time that a node n (referred to as Trustee) has a packet to transmit encounters to another node m (referred to as Trustor) during its movement, and it is obtained as follows:  
\[DT_{nm} = f(BT,EF,PF,RC,CD) \tag{8}\] \[= \omega_{1}*BT+\omega_{2}*EF+\omega_{3}*PF+\omega_{4}*RC+\omega_{5}*CD\]  
where  
* \(\omega_{k}\); \(\forall k\) are constants such that \(\sum\limits_{k=1}^{5}\omega_{k}=1\). * \(BT\) is computed based on successful and unsuccessful encounters as \[BT_{mn}=\frac{se+1}{(se+ue+2)}\] (9) where node \(n\) is the Trustee and node \(m\) is the Trustor, \(se\) is the number of successful encounters, and \(ue\) is the number of unsuccessful encounters. The procedure to calculate \(BT_{mn}\) is given in Algorithm 1. * \(EF\) calculation: Whenever any node \(m\) carrying a data packet encounters a neighbor node \(n\), it determines \(EF_{nD}\)--the encounter frequency degree of \(n\) with the destination node \(D\)--which is computed as \[EF_{nD} = \frac{Encounter\;frequency\;of\;n\;with\;D}{Encounter\;frequency\;of\;n\; with\;all\;other\;nodes}\] (10) \[= \frac{f_{nD}}{\sum\limits_{k=1}^{K}f_{nk}}\] (11) where \(K\) is the total number of nodes encountered by node \(n\) until that instance of time, \(f_{nD}\) is the encounter frequency of \(n\) with \(D\), and \(f_{nk}\) is the encounter frequency \begin{table}
\begin{tabular}{l l} \hline
**Hashmaps** & **Significance** \\ \hline \multirow{4}{*}{_EncounterList_} & Hashmap consisting of fields \(<NId,f,\zeta,\lambda,t_{ber},t_{ce},t_{e}>\) that store records of encounter details of a node with other nodes in the network. These fields correspond to node identifier, encounter frequency, successful encounter, unsuccessful encounter, encounter begin time, encounter end time, and total encounter duration, respectively. \\ \hline \multirow{2}{*}{_ForwardingList_} & This hashmap stores records of packet forwarding using 3 fields \\  & \(<sid,ri,np>\) that correspond, respectively, to sender ID, receiver ID, and number of packets forwarded from _sid_ to _rid_. \\ \hline \multirow{2}{*}{_TrustDegree_} & Stores the trust value of nodes in two fields \(<Node,T_{Node}>\), where _Node_ represents a node for which its trust value is computed and \(T_{Node}\) is the trust value of that node. \\ \hline \end{tabular}
\end{table} 
Table 2: Hashmaps. of \(n\) with each of the \(K\) number of nodes. Typically, \(EF\) is understood as the ratio of the number of encounters between \(n\) and \(D\) to the frequency of contacts that \(n\) has had with other nodes. Node \(n\) is comparatively more suited to forward data packets toward node \(D\), as indicated by its greater \(ET\) value. The procedure to calculate \(EF_{nD}\) is given in Algorithm 2. * \(PF\) calculation: \(PF\) is computed by a node \(m\) whenever it encounters any neighbor \(n\), as follows: \[PF_{mn}=\frac{num_{mn}}{num_{n}}\] (12) where \(num_{mn}\) is the number of \(m\) packets forwarded by node \(n\) and \(num_{n}\) is the total number of packets forwarded by node \(n\) to all other nodes. The procedure to calculate \(PF_{mn}\) is given in Algorithm 3. * \(RC\) calculation: \(RC\) refers to the latest contact time between two nodes.