## 4 Trust Model
### Direct Trust  
In evaluating direct trust we used sliding window mechanism to take the latest interactions first. The latest event \(\mathbf{E}\) can be divided into \(t\) time periods, i.e., \(\mathbf{E}=[E_{1},E_{2},E_{3},\cdots,E_{t}]\). It is supposed that in each event \(E_{i}\), node \(x\) can monitor \(n_{i}\) times the forwarding behavior of node \(z\). The packet forwarding ratios of node \(z\) in time event \(E_{i}\) is denoted by a vector \(\mathbf{V}_{n_{i}}=[V_{n_{1}},V_{n_{2}},V_{n_{3}},\cdots,V_{n_{i}}]\). Here, we set threshold level (\(L\)), if the number of time for which packet forwarding ratio is higher then threshold (\(L\)). If the number of times of which packet forwarding ratio \(m_{i}\) is below threshold then \(L\) is \(n_{i}-m_{i}\). We adopted the Bayes theorem framework to reduce errors in computing the reputation of a targeted node. Reputation in Bayes theorem is calculated using the previous reputation level and likelihood function.  
The Dirichlet distribution [37] has three parameters \([\alpha,\beta,\gamma]\), showing positive, negative, and neutral evidence, while the total sum of an event is not greater than 1. Dirichlet distributions are commonly used as prior distributions in Bayesian statistics. Here, the current reputation vector represents the posterior and the last reputation vector shows prior probability. The general form of Dirichlet distribution function for these two functions is \(Dir(a,b)=x^{a-1}(1-x)^{b-1}/D(a,b)\), where \(D(a,b)\) in this equation is a normalization constant and ensure that the total probability is 1. We set \(Dir(a,b)=\int_{a}^{b}x^{a-1}(1-x)^{b-1}dx\), where \(x\) implies \([0,1]\). We assume that \(R_{i}\) represents the value of the \(i\)th reputation evaluation vector according to the Dirichlet distribution, and then calculation of posterior probability is \(R_{i}=(fi(x)\int_{a}^{b}fi(x)R_{i-1}dx)R_{i-1}\), where \(a\) and \(b\) are integration interval. In this paper, two mutually independent events that are satisfy by Dirichlet distribution are taken as whether the forwarding rate is higher than the threshold value L, then it can be obtained \(fi(x)=\mathrm{C}_{n_{i}}^{m_{i}}x^{m_{i}}(1-x)^{n_{i}-m_{i}}\). The reputation evaluation vector sequence of node x to z is \(R_{n}=[R_{1},R_{2},R_{3},\cdots,R_{t}]\). As mentioned above, if \(R_{i-1}\sim Dir(a_{i-1},b_{i-1})\), then \(R_{i}\sim Dir(a_{i-1}+m_{i},b_{i-1}+n_{i}-m_{i})\) then the values \(a_{1}=m_{1},b_{1}=n_{1}-m_{1},\cdots,a_{i}=a_{i-1}+m_{i},b_{i}=b_{i-1}+n_{i}-m _{i}\). Therefore, at beginning, i.e., \(t_{0}\), we can set \(a_{0}=b_{0}=1,R_{0}\sim beta(1,1)\) where \(beta(\alpha,\beta)\) denotes a beta distribution. One of the trust metrics \(t_{d_{i}}\) in \(E_{i}\) time period can be computed and updated by using the expectation of beta distribution. The formula given as follow:  
\[t_{d_{i}}=\frac{a_{i}}{a_{i}+b_{i}}, \tag{1}\]  
for \(i=1,2,3,\cdots\). The direct trust of node \(z\) concerning node \(x\) observation is also affected by the amount of packet forwarded and interaction time. Therefore we use total packets forwarded and time attenuation factors for the above scenario. Then we use the following equation to compute direct trust.  
\[dt_{xz}=\frac{\sum_{i=1}^{t}\rho^{t-i}\mathrm{M}_{xz}^{i}}{M}t_{d_{i}}, \tag{2}\]where \(\sum_{i=1}^{t}\rho^{t-i}\quad(0<\rho<1)\) denotes the time attenuation function with a weighting (or forgetting) factor \(\rho\), and M\({}_{xz}^{i}\) denotes the amount of packets forwarded by node \(z\) for node \(x\) during the time event \(E_{i}\). As more packets are forwarded, the confidence of the obtained trust value increases.