## 1 Introduction
Examples of feature selection technologies are Water Cycle (WC) [20], Particle Swarm Optimization (PSO) [21], Simulated Annealing (SA) [22], Harmony Search (HS) [19], and Genetic Algorithm (GA) [23]. Since the main objective of this paper is to find the best solution to protect the perception layer from DoS attacks while taking into account the capabilities of these devices, we will analyze the effects of various machine learning algorithms along with different feature selection techniques in order to balance their performance accuracy for DoS detection with their consumption energy. As some studies, such as [24; 25], have shown that machine learning techniques (logistic regression, SVM, and DT) are more appropriate for real-world deployment of wireless devices than a deep learning mechanism, machine learning techniques are favored. That is due to the need for a significant amount of training data for deep learning algorithms in order to provide high-accuracy classification performance. On the other hand, the IDS technique in WSNs must be compatible with their protocols. In WSNs there are different routing protocols that are used to transmit data packets to the Access Point (AP), such as Low Power and Lossy Networks (RPL) in 6 LoWPAN [26], Adhoc On Demand Distance Vector (AODV) routing in ZigBee [27], and Low Energy Aware Cluster Hierarchy (LEACH) [28]. LEACH is one of the most widely used hierarchical routing protocols due to its limited power consumption, and is used in this study due to the fact that the WSN-Data Set [29] on which we rely for analysis was collected according to this protocol. It aims to boost energy efficiency by using a rotation-based Cluster Head(CH) selection process with a random number. However, the reliance on randomness in rotation-based CH selection is considered a weakness in the LEACH protocol, and various studies [30; 31; 32; 33; 34] have improved its performance. It remains possible to improve the protocol further in terms of increasing its efficiency in selecting the appropriate CH in each loop, and increasing the network lifetime. By summarizing previous studies and applications, we see that there has been an increase in the use of WSNs recently, that these devices play multiple roles, and the biggest challenges for WSNs remain security and energy. To overcome these challenges, several solutions that discuss data security performance problems have been proposed [10; 11; 12; 13; 35; 36] that do not consider the impact on wireless power consumption. Moreover, other studies have discussed the concept of energy conservation from a data security-independent perspective [30; 31; 32; 33; 34]. Therefore, in this study, we will create a complete picture that combines both elements (security and energy), by determining how best to raise the level of security in WSNs and protect them from DoS attacks with minimal energy consumption. We modified the cluster protocol to increase network performance efficiency while saving energy and increasing DoS detection. Moreover, in certain situations, WSN nodes must be used in sensitive areas and we cannot power them up regularly; thus, we sought to save as much energy as possible while preserving security. In this work, we will contribute to improving DoS detection and reduce power consumption in WSNs. The following are the main contributions of this work:  
1. We modified the LEACH protocol to reduce randomness in determining the CH nodes by adding other factors such as node residual power, distance between nodes, and distance to AP in order to increase efficiency and extend the lifetime of the WSN. 2. We analyzed the effect of feature selection techniques along with machine learning algorithms on the accuracy of DoS detection. 3. We studied the effect of this modified LEACH protocol on the best-performing technique in terms of network lifetime. This is in contrast to related studies that have improved the accuracy of DoS detection over WSN without analyzing its actual effect on sensors. The rest of our paper is set out as follows.