## Security Analysis
### Full-Resilience Probability Analysis  
In this section, we provide the theoretical analysis of the full-resilience probability of the reputation system against selective routing attacks and unfair ratings.  
We assume that \(N\) nodes are uniformly distributed in a region of area \(A\). The probability density function (pdf) of the distance \(S\) between two nodes with a uniformly distributed node is given by [44]:  
\[f_{S}(s)=\frac{\widehat{s}}{9\pi}[18\pi-36\arcsin(\frac{\widehat{s}}{2})-9 \widehat{s}\sqrt{4-\widehat{s}^{2}}]\]  
where \(\widehat{S}=\frac{S}{a}\), and \(a=\sqrt{\frac{A}{\pi}}\).  
We assume that all of the nodes have the same transmission radio range \(r\). Two nodes establish a link if they are located within a distance of \(r\) from each other. The probability that the distance between two nodes is less than or equal to \(r\) is given by [45]:  
\[P_{1}=P(S\leq r)=\int_{0}^{r}f_{S}(s)ds\]The necessary condition for a monitoring node \(m\) to correctly rate node \(u\) is \(WN_{u}\
eq\emptyset\), i.e., at least one node must reside in the region \(R_{1}\) of area \(A_{1}(d)\), which results from the intersection of two circular communication regions with radius \(r\) and centered at \(u\) and its child node \(\omega\). The distance \(d\) between the two nodes \(u\) and \(\omega\), must be in the range between 0 and \(r\). The area \(A_{1}(d)\) is calculated, as follows:  
\[A_{1}(d)=2r^{2}cos^{-1}(\frac{d}{2r})-d\sqrt{r^{2}-\frac{d^{2}}{4}}\]  
The expected area \(E[A_{1}]\) is calculated as follows:  
\[E[A_{1}]=\int_{0}^{r}f_{S}(s)A_{1}(s)ds\]  
The expected number of witness nodes located in \(R_{1}\) is \(N_{A1}=\frac{E[A_{1}]N}{A}\)  
A monitoring node \(m\) is connected to the witness node \(w\) either directly or through a relay node. The relay node must reside in the region \(R_{2}\) of area \(A_{2}(d)\), which is resulted from the intersection of two circular communication regions with radius \(r\) and centered at \(m\) and \(w\). The area \(A_{2}(d)\) is calculated, as follows:  
\[A_{2}(d)=2r^{2}cos^{-1}(\frac{d}{2r})-d\sqrt{r^{2}-\frac{d^{2}}{4}}\]  
The expected area \(E[A_{2}]\) is calculated, as follows:  
\[E[A_{2}]=\int_{r}^{2r}f_{S}(s)A_{2}(s)ds\]  
The expected number of relay nodes located in \(R_{2}\) is \(N_{A2}=\frac{E[A_{2}]N}{A}\)  
The probability that at least one relay node resides in the region \(R_{2}\) is given by:  
\[I(d)=1-(1-\frac{A_{2}(d)}{A})^{N-2}\]  
The connection probability between the two nodes, which communicate in two hops and are separated by a distance \(d\) ranging between \(r\) and \(2r\), is calculated as follows [46]:  
\[P_{2}=\int_{r}^{2r}f_{S}(s)I(s)ds\]  
We consider that a monitoring node can directly communicate with \(N_{A1}^{1}\) witness nodes and with \(N_{A1}^{2}=(N_{A1}-N_{A1}^{1})\) witness nodes through relay nodes.  
In Figure 5, the witness node \(w\) can reach the monitoring node \(m\) via the relay nodes \(u\), \(w_{1}\), and \(w_{2}\). Nodes \(w_{1}\) and \(w_{2}\) also witness the traffic transmitted on \((u_{1},u)\) and \((u_{2},u)\), respectively.  
Figure 5: Communication between witness and monitoring nodes.  
The average probability that the monitoring node \(m\) is connected to all \(N_{A1}\) witness nodes is given by:  
\[P_{fullon}=P_{1}^{N_{A1}}P_{2}^{N_{A1}^{2}}\]  
Let \(P_{comp}\) be the probability that the node is compromised. The average probability that there is at least one path, which is free from compromised nodes, between one witness node and the monitoring node is:  
\[P_{sec}=\left\{\begin{array}{ll}P_{1}\times(1-P_{comp})&one-hop\\ P_{2}(1-P_{comp})(1-P_{comp}^{N_{A2}})&two-hop\end{array}\right.\]  
The average probability that there is at least one path, which is free from compromised nodes, between the majority of witness nodes and the monitoring node is:  
\[(\sum_{k=\lfloor\frac{N_{A1}}{2}\rfloor+1}^{N_{A1}}C_{k}^{N_{A1}}P_{sec}^{k}( 1-P_{sec})^{N_{A1}-k})\times P_{fullon}\]