  Wireless sensor networks are considered to be among the most significant and
innovative technologies in the 21st century due to their wide range of
industrial applications. Sensor nodes in these networks are susceptible to a
variety of assaults due to their special qualities and method of deployment. In
WSNs, denial of service attacks are common attacks in sensor networks. It is
difficult to design a detection and prevention system that would effectively
reduce the impact of these attacks on WSNs. In order to identify assaults on
WSNs, this study suggests using two machine learning models: decision trees and
XGBoost. The WSNs dataset was the subject of extensive tests to identify denial
of service attacks. The experimental findings demonstrate that the XGBoost
model, when applied to the entire dataset, has a higher true positive rate
(98.3%) than the Decision tree approach (97.3%) and a lower false positive rate
(1.7%) than the Decision tree technique (2.7%). Like this, with selected
dataset assaults, the XGBoost approach has a higher true positive rate (99.01%)
than the Decision tree technique (97.50%) and a lower false positive rate
(0.99%) than the Decision tree technique (2.50%).
