# Artificial Neural Network-Based Mechanism to Detect Security Threats in Wireless Sensor Networks
## 5 Results and Discussion  
This section outlines and discusses the main finding of the proposed work. The number of packets sent and received (the packet delivery ratio), energy consumption and the trustworthiness of the node in the other network were the main criteria used for detection of malicious nodes in WSN in our proposed work. Network simulation (NS-2) was used to simulate and analyze the performance of the proposed detection system. Table 3 contains a list of the simulation parameters that were used in the experiments. The AODV routing protocol was employed in the experiment, and a 60-s simulation time is chosen. During the simulation, different scenarios were considered. Initially, no malicious node was used, and the number of packets received at the base station, the packet drop rate and the energy consumed by the network were recorded for 60 s. In the rest of the scenarios, the same parameters were noted during a black-hole attack, a gray-hole attack and a wormhole attack. The combined simulation results of packets received during each scenario are shown in Figure 7.  
In the last scenario, the proposed system was implemented, and all types of malicious nodes used in the previous scenarios, along with normal nodes, were used. Almost the same number of packets were received at the base station during all attacks as were received during the normal scenario (without attacks), as shown in Figure 8.  
Figures 9 and 10 show that among all the scenarios, during the black-hole attack, the packet drop rate and the energy consumption of the network were especially high. \begin{table}
\begin{tabular}{l l l} \hline \hline
**S.No** & **Parameters** & **Range/Value** \\ \hline
1 & Area & 1000 \(\times\) 1000 m \\
2 & Nodes & 500 \\
3 & BS location & 1300-1400 m \\
4 & Initial energy & 1.5 J \\
5 & Trust & 1 or 0 \\
6 & Routing Protocol & AODV \\
7 & Simulation Time & 120 s \\
8 & Bandwidth & 25 Kbps \\
9 & Transmission range & 50 m \\
10 & Packet size & 512 Bytes \\ \hline \hline \end{tabular}
\end{table} 
Table 3: Simulation Parameters. Figure 7: Packets received at the base station. network was almost like that of the network in the absence of the attacks, as shown in Figure 11.  
Moreover, when the proposed system was deployed and all the routing attacks were launched during the simulation, the rate of packet drop was very low due to early detection of malicious nodes, as shown in the Figure 12.  
The proposed model's performance indicators are contrasted with those of other machine learning algorithms like random forest (RF), decision trees (DT), and support vector machines (SVM). The analysis takes into account the following parameters: recall, accuracy, precision, F1-Score, and specificity. There are total 2000 input vectors in the dataset, which is composed of normal and abnormal data, with the abnormal data including three routing attacks. The complete dataset was split in a ratio of 75:15:10 in order to verify the proposed model's detection rate and accuracy rate. Whereas for training we used 75% input vectors, in testing, we used 15% data, with 10% input vectors from the dataset used for validation. Table 4 lists the distribution of datasets for all attacks and normal scenarios. Figure 11: Energy consumption during routing attacks in the presence of the proposed system. Figure 12: Packet drops rate comparison. The performance of the proposed system during the testing phase was evaluated using a confusion matrix, shown in Table 5. Results are classified as true positive (_TP_), true negative (_TN_), false positive (_FP_), and false negative (_FN_) in our confusion matrix. The examples are labeled \"Normal\" for a normal scenario, \"B.H.\" for a black-hole attack, \"G.H.\" for a gray-hole attack, and \"W.H.\" for a wormhole attack in order to make the analysis simpler. Performance measures such as detection rate (_DR_), false-positive rate (_FPR_), accuracy, and precision given in Table 6 are derived from the confusion-matrix values and examined for various attack scenarios.