## 5 Methodology
### Simulation Experiments  
NS3 is an essential for network research and development, especially when it comes to simulating intricate networks like Mobile Ad Hoc Networks (MANETs). NS3 is well known for its extensive emulation features, which let researchers precisely simulate and examine the behavior of different kinds of networks in many scenarios. Its significance is further shown by the fact that NS3 is widely used in academia to test network protocols, create  
Figure 3: The proposed S-2 EC-ERF framework.  
network topologies, and carry out performance assessments. NS3 can model network traffic and topology realistically and implements networking protocols in great detail. Its adaptable architecture also makes it possible to incorporate actual devices and applications into the simulation environment, thus offering a strong foundation for in-depth network research. Thus, NS3 can make solutions by creating a more dependable and efficient network in addition to facilitating a greater understanding of network dynamics.  
NetAnim is an essential part of the NS3 simulator, which acts as a GUI tool. NetAnim improves the analysis and comprehension of network simulations. Its main task is to graphically depict the movements and network protocol dynamics in a variety of simulated environments.  
The NS3.27 simulator was used to perform the simulation. The network is configured to replicate the dynamics of a WSN comprising 100 nodes for 50 s, with each initially equipped with 200 joules of energy. The energy consumption is set at 0.00174 joules per transmitted packet, thereby reflecting the realistic constraints and considerations inherent in WSNs, where the energy resources available to nodes are restricted. To optimize energy efficiency within the network, the ECP-LEACH routing protocol was employed. The ECP-LEACH routing protocol utilizes a threshold mechanism to identify opportune moments for transitioning nodes into a sleep state during periods of inactivity. This strategic approach significantly contributes to extending the overall lifetime of the network.  
The network configuration also incorporated a base station. The nodes send packets to the base station. Each node is assigned a mobility characteristic known as a Random Rectangle Position, with a speed of 20 m/s, within an area of 1000 m \(\times\) 1000 m. The simulation encompasses five scenarios, detailed in Table 2, which aim to comprehensively examine the network's behavior under varying cyber threat landscapes. These scenarios progressively adjust the ratio of normal nodes to attack nodes, thus creating a spectrum of network configurations for analysis.  
The network parameters are shown in Table 3. Figure 4 shows the designed simulation network. The simulation was generated graphically using the NetAnim tool, where the blue color represents the normal nodes, and the red color represents the attack nodes. Four experiments were performed at the node level to choose the best framework for security and energy efficiency. These experiments are the following:  
* First experiment: The ERF-LET algorithm was used in the proposed framework for attack detection; this experiment is referred to as the S-2 EC-ERF framework.
* Second experiment: The LR algorithm was applied in the proposed framework; this experiment is referred to as the S-2 EC-LR framework.
* Third experience: The DT algorithm wasdeployed in the proposed framework; this experiment is referred to as the S-2 EC-DT framework.
* Fourth experience: The AdaBoost algorithm performed in the proposed framework; this experiment is referred to as the S-2 EC-Ada framework.  
\begin{table}
\begin{tabular}{c c c} \hline \hline
**Scenario Number** & **Number of Normal Nodes** & **Number of Attack Nodes** \\ \hline
1 & 95 & 5 \\
2 & 90 & 10 \\
3 & 85 & 15 \\
4 & 80 & 20 \\
5 & 75 & 25 \\ \hline \hline \end{tabular}
\end{table}
Table 2: Simulation scenarios.