# Rank and Wormhole Attack Detection Model for RPL-Based Internet of Things Using Machine Learning
## 4 Results and Discussion
### Results and Findings  
For the proposed model to detect the RA and WHA in an RPL-based IoT network, we have performed substantial analysis using Python language. The model is trained on 70% of the training dataset and tested on the remaining 30% of unseen dataset. Furthermore, we have performed feature engineering and fine tuning to improve the accuracy of the model and compared it against our benchmark research as well as other ML classifiers to validate the obtained results. The results obtained from the experiment exhibited promising results in both classic ML-based evaluation metrics and multiclass-related metrics. The model achieved a training accuracy of 0.998 and a testing accuracy of 0.997 for the detection of both types of attacks, as shown in Figure 5.  
The model achieved an average training precision of 0.997 and average testing precision of 0.99 as shown in Figure 6.  
The model achieved an average training recall of 0.997 and an average testing recall of 0.998 as shown in Figure 7.  
Furthermore, the multiclass classification-related performance evaluation is summarized in Table 4. Table 5 presents the overall results and their comparison with other ML classifiers including ML-LGBM [13], gated recurrent unit-based DL (GRU-DL) [14], gradient boosting, XGBoost, and multiclass SVM, demonstrating that our proposed model MC-MLGBM outperforms the mentioned classifiers. Furthermore, the light gradient boosting model at the base of our multiclass classifier has a lower fitting time as compared to other classifiers, for instance, XGBoost, while it also distinguishes RA from WHA and separates the benign traffic traces from attack traffic traces in the LIoTN-RPL dataset. Mobility is also addressed in our study by extracting the mobility-induced dataset using the random waypoint mobility model [34; 35] in the Cooja simulator. Figure 5: Training and testing accuracy of the proposed model. Figure 6: Training and testing precision of the proposed model. The main findings from the results are summarized as follows: \begin{table}
\begin{tabular}{c c c} \hline \hline
**Evaluation Metric** & **Train/Test** & **Result** \\ \hline \hline
**Accuracy** & Training & 0.998 \\ \cline{2-3}  & Testing & 0.997 \\ \hline
**Precision** & Training & 0.997 \\ \cline{2-3}  & Testing & 0.99 \\ \hline
**Recall** & Training & 0.998 \\ \cline{2-3}  & Testing & 0.997 \\ \hline  & **Cross entropy** & 0.116 \\ \hline  & **Cohn’s Kappa** & 0.93 \\ \hline  & **MCC** & 0.927 \\ \hline \hline \end{tabular}
\end{table} 
Table 4: Performance Analysis of the Proposed Model. \begin{table}
\begin{tabular}{c c c c c c c c c} \hline \hline
**Model** & \multicolumn{2}{c}{**Attack**} & \multirow{2}{*}{**Accuracy**} & \multirow{2}{*}{**Precision**} & \multirow{2}{*}{**Recall**} & \multirow{2}{*}{**Cross**} & \multirow{2}{*}{**Cohn’s Kappa**} & \multirow{2}{*}{**MCC**} \\ \cline{2-3}  & & & & & & & & \\ \hline Proposed & \multirow{2}{*}{MC-MLGBM} & \multirow{2}{*}{✓} & \multirow{2}{*}{✓} & \multirow{2}{*}{0.998} & \multirow{2}{*}{0.997} & \multirow{2}{*}{0.998} & \multirow{2}{*}{0.116} & \multirow{2}{*}{0.93} & \multirow{2}{*}{0.927} \\ MC-MLGBM & & & & & & & & \\ \hline ML-LGBM & & & & & & & & \\ \hline \multirow{3}{*}{GRU-DL} & \multirow{3}{*}{✓} & \multirow{3}{*}{✓} & 0.99 for selective features & \multirow{3}{*}{-} & \multirow{3}{*}{-} & \multirow{3}{*}{-} & \multirow{3}{*}{-} & \multirow{3}{*}{-} \\ MC-SVM & & & & & & & & \\ \hline GB & & & & & & & \\ \hline XGBost & & & & & & & \\ \hline \hline \end{tabular}
\end{table} 
Table 5: Comparison of the Proposed Model with Benchmark and Other Classifiers. Figure 7: Training and testing recall of the proposed model. * The results obtained from the experiments illustrate that the proposed model performs well in terms of addressing both the RPL-specific RA and SN-inherited WHA with respect to overall accuracy (99.7%), precision (99%), and detection rate (99.7%).