# Blockchain Based Secure Routing and Trust Management in Wireless Sensor Networks +
## 5 Simulation Results
### Performance Metrics
#### 5.2.6 Detection Accuracy  
This is defined as the ratio of trusted SNs identified as malicious nodes to the total number of malicious nodes in the entire network. It is computed by the following equation [10]:  
\[DA=\frac{M_{identified}}{M_{total}}. \tag{9}\]  
Figure 1(a) shows the PDR with respect to the number of rounds. The number of data packets decreases with an increasing number of rounds. A large number of SNs participate in packet transmission, which reduces the computational overhead of a single SN. The proposed model increases the probability of the data packets being received successfully. Therefore, there is a high value of PDR in an initial round. As long as all SNs remain alive, they send more packets to the BSs. Moreover, the figure depicts the PDR with respect to round number. The SNs are not enriched with energy because they have limited batteries. Therefore, they are more likely to die as the number of rounds increases, due to which PDR decreases. Furthermore, Figure 1(b) shows the network throughput with respect to authenticated and nonauthenticated nodes. In a network where no authentication is performed, any malicious node can become a part of the network and perform malicious activities, whereas, in a network with authentication, only registered and authentic nodes become part of the network. The figure shows that the throughput of the network gradually increases as the number of rounds increases. Figure 2(a) shows the impact of different malicious nodes on FPR and FNR. As the number of malicious nodes increases, FPR and FNR also increase. The reason is that a large number of malicious nodes broadcast a large amount of wrong information in the network. Figure 2(b) illustrates the impact of different malicious nodes on the DA. As the number of malicious nodes is increased, the DA of the network is decreased. Moreover, when the number of malicious nodes is greater than 20, DA is decreased due to greater FPR and FNR. Figure 3(a) shows the comparison of the network lifetime of the proposed model with BTM. It also depicts the network stability period and shows that SNs do not communicate directly with the BSs due to the long distance between them. In the network BTM, no authentication mechanism is performed, thus malicious nodes can join the network, impersonate the identity of the legitimate nodes and transmit wrong information, which affects the network performance. In the proposed model, authentication of nodes is performed. Therefore, external malicious nodes are not allowed to become part of the network. After the authentication, the nodes behaving selfishly are detected on the basis of their trust values and then removed from the network. Thus, the network lifetime of the proposed model outperforms that of BTM. Figure 3(b) shows the lifetime of a network that depends on the residual energy of the SNs. These figures only depict the operability of our proposed model and the blockchain mechanism has no impact on the stability period and residual energy. The blockchain provides transparency in the network about the interactions taking place between nodes, which further helps in avoiding the interception of the external nodes. Moreover, only those nodes take part in the network communication, which are being authenticated in the first place. In the BTM with no authentication, the malicious nodes participate in the network and send excessive amount of wrong information to the forwarder nodes that consume a lot of energy while transferring the packets, while little energy is consumed in the proposed model. Figure 3: _Cont._  
Figure 2: (**a**) Packet delivery ratio, (**b**) throughput. Figure 5a shows the amount of time consumed in trust evaluation of different numbers of nodes. It is clear from the figure that the time taken in calculating the computational cost in the trust evaluation of 10 nodes is 0.39 ms while, for 100 nodes, the computational cost is 17.37 ms.