# PECSA: Practical Edge Computing Service Architecture Applicable to Adaptive IoT-Based Applications
## 4 Materials and Methods
### Trust Evaluation Mechanism  
#### 4.1.1 Trust Evaluation Mechanism in the IoT  
The major functions of the nodes in the IoT include data acquisition, data forwarding, and request generation. Trust evaluation models should be established based on their functions. Thus, evidence used to compute the direct trust \(Tu(i,j)\) may include the device's endurance capacity, packet loss rate, bandwidth, transmission delay, device activity, data correctness rate, and overall success rate of historical events. To record historical events, each node maintains a trust table that stores some information about the adjacent nodes and the trust states, as shown in Table 1. A white list and a black list are used to record the number of positive and negative historical events in the table. \(e_{(i,j)}^{w}\) and \(e_{(i,j)}^{b}\) denote the number of positive activities and negative activities of node \(v_{i}\) towards node \(v_{j}\), respectively. A single interactive activity of \(v_{i}\) toward \(v_{j}\) can be seen as an outcome of lossing a coin. When there is a positive activity, \(e_{(i,j)}^{w}\) adds 1; otherwise, \(e_{(i,j)}^{b}\) adds 1. Thus, \(e_{(i,j)}^{w}/e_{(i,j)}^{b}\) can be seen as an outcome of a Bernoulli trial with the probability-of-success parameter \(\theta_{i,j}\) following a Beta distribution \(Beta(\alpha_{i,j},\beta_{i,j})\). Considering an exponential decay [29], the hyper parameters \(\alpha_{i,j},\beta_{i,j}\) are given as follows:  
\[\begin{split}\alpha(i,j)&=e^{-\vartheta\Delta t} \cdot\alpha(i,j)^{{}^{\prime}}+e_{(i,j)}^{w}\\ \beta(i,j)&=e^{-\vartheta\Delta t}\cdot\beta(i,j)^{{} ^{\prime}}+e_{(i,j)}^{b}\end{split} \tag{1}\]  
where \(\Delta t\) is the trust update interval and \(\alpha(i,j)^{{}^{\prime}}\) and \(\beta(i,j)^{{}^{\prime}}\) are the hyper parameters in the last update interval. According to [29], the decay factor \(\varphi\) is a small positive number. We adopt the Bayesian framwork [29] as the underlying model to evaluate the direct trust \(Tu(i,j)\); here, \(Tu(i,j)\) denotes the trust value of node \(v_{j}\) from the perspective of node \(v_{i}\).  
\[Tu(i,j)=\frac{\alpha(i,j)}{\alpha(i,j)+\beta(i,j)} \tag{2}\]  
For the sustainable development of IoT-based business, the initial value of \(\alpha(i,j)^{{}^{\prime}}\) and \(\beta(i,j)^{{}^{\prime}}\) are suggested to be set as 1 and 0, respectively. The update interval is a time slice, which can be set as several seconds or tens of seconds. When a new update interval arrives, each node will update its trust values. It is easy to obtain that \(Tu(i,j)\) is a value in the interval \([0,1]\). We set a threshold \(Td_{it}\) to separate the outliers from honest nodes. If a node is honest, its trust value is located in the interval \([Td_{it},1]\). Otherwise, it is located in \([0,Td_{it})\). The value of the observation window and \(Td_{it}\) are set according to the monitoring sensitivity.  
\begin{table}
\begin{tabular}{c c c c c c} \hline \hline
**Adjacent Nodes** & **Trust Value** & **Location List** & **White List** & **Black List** & **Time** \\ \hline node \(v_{1}\) & 0.7 & GPS position 1 & \(e_{(i,1)}^{w}\) & \(e_{(i,1)}^{b}\) & 1 \\ node \(v_{2}\) & 0.8 & GPS position 2 & \(e_{(i,2)}^{w}\) & \(e_{(i,2)}^{b}\) & 2 \\ node \(v_{3}\) & 0.9 & GPS position 3 & \(e_{(i,3)}^{w}\) & \(e_{(i,3)}^{b}\) & 3 \\ \hline \hline \end{tabular}
\end{table}
Table 1: Trust table of node \(v_{i}\).  
The level of trust value is helpful for the node in the IoT to reveal the outliers and establish a set of credible adjacent nodes and reliable routes for data transmission. If \(Tu(i,j)\) is located in \([Td_{it},1]\), node \(j\) is selected in the route list of node \(i\), otherwise it is moved out of the route list of node \(i\). For the sustainable development of IoT-based business, the initial trust value of new entrants is suggested to be set in the interval \([Td_{it},1]\).