Wireless sensor networks (WSNs) are increasingly prevalent in the Internet of Things ecosystem and have been used in several fields such as environmental monitoring, military, and healthcare. However, their limited resources and distributed architecture remain two main challenges: energy and security. Furthermore, denial of service (DoS) attacks are one of the principal cyber threats to WSNs. This research proposes a lightweight machine learning (ML) approach based on the extreme gradient boosting (XGBoost) model to detect these attacks in WSNs. Through an extensive investigation, we evaluate four prominent ML algorithms: random forest (RF), k-nearest neighbor (KNN), stochastic gradient descent (SGD), and XGBoost, using the WSN-DS dataset. In addition, we implement and investigate several feature selection techniques in order to have an improved version of the original dataset. Moreover, we evaluate the performance using various performance metrics, which include accuracy, precision, recall, F1-score, and processing time. The latter is a crucial consideration in WSN environments. For validation, we have employed 5-fold cross-validation to ensure robust and reliable results. The proposed model has achieved good performance in all metrics, with a maximum accuracy of up to 99.73%, and a 68% lower processing time compared to the other investigated classifiers.
Copyrights © 2025