Skip to main content
Scientific Reports logoLink to Scientific Reports
. 2025 Nov 14;15:39914. doi: 10.1038/s41598-025-23711-7

Evaluating machine learning approaches for multiple attack classification with improved computational efficiency in IoT networks

Maher Alharby 1,2,✉
PMCID: PMC12618690  PMID: 41238674

Abstract

The rapid expansion of Internet of Things (IoT) devices has introduced significant security challenges, making IoT networks increasingly vulnerable to cyber-attacks. This research study develops and evaluates a comprehensive approach for detecting and classifying Denial of Service, Distributed Denial of Service, and Mirai attacks in IoT environments using five supervised machine learning algorithms: Random Forest, Gradient Boosting, Naive Bayes, Decision Tree, and K-Nearest Neighbors, applied to the CICIoT2023 dataset. Our methodology incorporates data preprocessing techniques, including undersampling for class imbalance, and implements three feature selection methods: Chi-square, Principal Component Analysis, and Random Forest Regressor. We thoroughly evaluate model performance by measuring accuracy, precision, sensitivity, and F1-score metrics. In addition, we assess computational efficiency by considering training and prediction times. Our results demonstrate state-of-the-art performance, achieving the highest reported accuracy of 99.99% for the CICIoT2023 dataset, surpassing results reported in existing literature. Furthermore, our best-performing Decision Tree model exhibits significantly improved computational efficiency, with a 98.71% reduction in training time and a 99.53% reduction in prediction time compared to previous studies, while maintaining superior accuracy. This research contributes valuable insights into the effectiveness and efficiency of various machine learning approaches for IoT security, offering practical implications for developing robust and computationally efficient intrusion detection systems in resource-constrained IoT environments.

Keywords: IoT security, DoS attacks, Machine learning, Cyber attacks, CICIoT2023 dataset

Subject terms: Computer science, Information technology

Introduction

The Internet of Things (IoT) has emerged in our increasingly connected world, integrating various devices and systems to enhance efficiency and convenience across various sectors. IoT technology has enhanced how we interact with our environment and manage resources, from smart homes to industrial applications. This rapid expansion of IoT devices has led to unprecedented growth in data traffic, with global networks experiencing exponential increases in data streams from smart devices1. However, this rapid growth and increasing interconnectivity have introduced significant cybersecurity challenges2,3.

The expanding IoT ecosystem faces cyber threats that exploit the interconnected nature of these devices. These attacks pose risks to individual privacy and data security and have significant consequences for businesses, critical infrastructure, and national security. The complexity of IoT ecosystems, along with the limited processing power and storage capacity of IoT devices, creates unique challenges for implementing effective security measures4.

Recent research in IoT security has made significant progress in developing intrusion detection systems. Studies have explored various machine learning approaches5,6, from traditional algorithms to deep learning techniques. Researchers have explored several datasets, such as Bot-IoT, CICDDoS2019, and the recent CICIoT2023. Their investigations have focused on different types of attacks, specifically targeting Denial of Service (DDoS) detection and the broader classification of multiple attack types.

Despite these advances, several critical limitations persist in existing IoT security research. Many previous studies focus solely on DDoS attacks, neglecting other critical threats such as Denial of Service (DoS) and Mirai attacks. This limited focus restricts a thorough understanding of the diverse threat landscape in IoT security. The issue of class imbalance is often neglected, which can lead to biases in models and compromise the reliability of the results. Additionally, many studies tend to rely on just one feature selection technique or overlook feature selection altogether, which restricts the understanding of how effective different methods can be. There is also a significant gap in considering computational efficiency, as many studies focus mainly on accuracy metrics without assessing training and prediction times. These factors are essential for practical applications in resource-constrained IoT environments.

In this study, we address the critical security challenges faced by IoT ecosystems by developing and evaluating advanced intrusion detection systems. Unlike previous research that often focuses solely on DDoS attacks, our approach encompasses a range of threats, including DoS and Mirai attacks alongside DDoS. Our methodology employs traditional machine learning algorithms, including Random Forest, Gradient Boosting, Naive Bayes, Decision Tree, and K-Nearest Neighbors, to classify network traffic into normal, DoS, DDoS, and Mirai categories using the CICIoT2023 dataset. To enhance the robustness of our approach, we implement three distinct feature selection techniques: Chi-square, Principal Component Analysis (PCA), and Random Forest Regressor (RFR), comparing their impact on model performance and efficiency. Furthermore, our study addresses the often-overlooked issue of class imbalance in IoT security datasets by employing undersampling techniques, thereby improving the reliability and generalizability of our models.

This research makes four primary contributions to the field of IoT security. First, we provide a comprehensive evaluation of traditional machine learning algorithms across multiple attack types using the recent CICIoT2023 dataset. This addresses the limitation of existing studies that focus on a single attack type. Second, we systematically compare three distinct feature selection methods to identify the most effective approach for IoT intrusion detection, offering insights into their relative performance and theoretical advantages. Third, we address the critical research gap in computational efficiency by measuring and analyzing both training and prediction times alongside classification accuracy, providing practical insights for resource-constrained IoT environments. Finally, we implement undersampling techniques to tackle class imbalance issues, ensuring the development of more reliable and generalizable models.

Our comprehensive analysis revealed significant findings that advance the state-of-the-art in IoT intrusion detection. The RFR feature selection method consistently outperformed previous results in the literature. Among the machine learning algorithms evaluated, Random Forest, Decision Tree, and Gradient Boosting stood out for their exceptional performance, all achieving 99.99% accuracy with RFR feature selection across various attack types. Furthermore, our approach demonstrated remarkable improvements in computational efficiency. The Decision Tree model achieved a 98.71% reduction in training time and a 99.53% reduction in prediction time compared to the best reported results in existing studies, while maintaining superior accuracy. The study also revealed important insights into attack classification challenges, particularly the inherent difficulty in distinguishing between DoS and DDoS attacks due to their shared network traffic characteristics, while Mirai attacks were generally well-classified due to their distinct operational patterns. These findings, combined with our superior accuracy and computational efficiency, provide valuable contributions to the field of IoT security.

The structure of this paper is organized as follows: Section 2 provides essential background information on IoT security challenges, focusing on DoS, DDoS, and Mirai attacks, as well as an overview of the machine learning algorithms employed in this study. Section 3 presents a comprehensive literature review, comparing our approach with existing studies in IoT intrusion detection. Section 4 discusses the methodology used in this article. Section 5 presents our experimental results, thoroughly analyzing each algorithm’s performance across different feature selection methods. Section 6 discusses the results obtained in this study compared to existing studies. Finally, Section 7 wraps up the paper by providing a summary of our main findings, examining their impact on IoT security, and offering recommendations for future research in this area.

Background

This section provides an overview of three prominent IoT attack types: DoS, DDoS, and Mirai botnet attacks. It explores their characteristics, mechanisms, and potential impacts on IoT ecosystems. The section then delves into the realm of supervised machine learning, discussing its application in IoT security and intrusion detection. Particular attention is given to five key supervised learning algorithms: Random Forest, Gradient Boosting, Naive Bayes, Decision Tree, and K-Nearest Neighbors. Each algorithm’s fundamental principles, strengths, and potential applications in IoT security are examined. Additionally, this section investigates the intersection of these machine learning techniques with IoT attack detection, highlighting how these algorithms can be leveraged to identify and classify various attack patterns in network traffic data.

IoT attacks

The IoT security includes various potential threats and attack vectors. While it is not possible to cover all types of attacks in a single study, our research focuses on three widely recognized and impactful categories in IoT environments: DoS, DDoS, and Mirai botnet attacks. We selected these categories because of their significant effects on IoT networks, their diverse methods of operation, and their representation of both traditional and emerging threats. By concentrating on these specific attacks, we aim to provide a clear and thorough analysis of the critical security challenges facing IoT systems today. In this section, we will explore the characteristics, mechanisms, and potential impacts of these attacks, providing essential background information for our subsequent analysis and findings.

DDoS attacks are a significant threat to internet-based applications, aiming to disrupt services by overwhelming target systems with excessive traffic7,8. These attacks utilize compromised devices to send large volumes of packets, causing systems to become unresponsive to legitimate user requests. The CICIoT2023 dataset provides detailed subcategories of DDoS attacks, including various flood and fragmentation types. Common flood attacks include SYN flood, which exhausts IoT device resources with half-open TCP connections7; UDP flood, involving large unauthorized UDP packets7; and ICMP flood, which aims to take networks offline9. HTTP flood attacks generate traffic resembling normal network activity, making detection challenging10. Slowloris attacks gradually increase open connection requests, leading to system congestion10. Synonymous IP flood attacks target DNS servers with high-volume requests for non-existent domains11. Fragmentation attacks involve sending packets that exceed the allowed maximum size. These include ACK fragmentation, ICMP fragmentation, and UDP fragmentation attacks. These attacks aim to consume victim resources by forcing systems to process fragmented packets containing random or irrelevant information12.

DoS attacks are a persistent threat to network security, designed to cause services unavailable to legitimate users. Unlike DDoS attacks, which use multiple sources, DoS attacks typically originate from a single source13. The CICIoT2023 dataset includes several types of DoS attacks, each exploiting vulnerabilities in network protocols and services. TCP flood attacks, a common type of DoS, inundate the target system with a large number of TCP packets, often with forged source IP addresses. This flood of packets consumes server resources, making it unable to process legitimate requests14. HTTP flood attacks target web servers by sending multiple HTTP requests, exhausting the server’s ability to respond to honest user traffic. These attacks are particularly challenging to detect as they mimic normal user behavior15. SYN flood attacks target vulnerabilities in the TCP three-way handshake mechanism to disrupt network communication. An attacker initiates numerous SYN requests without completing the TCP handshake, resulting in multiple half-open connections that drain its resources16. On the other hand, UDP flood attacks leverage the UDP protocol’s connectionless nature. By sending many UDP packets to random ports on the target system, the attacker forces the system to repeatedly check for applications listening on those ports, potentially leading to system unresponsiveness17. These DoS attack types highlight the diverse techniques employed by attackers to disrupt network services.

The Mirai botnet attack represents a significant threat to IoT security, explicitly targeting vulnerable Internet-connected devices. Unlike traditional DoS or DDoS attacks, Mirai-based attacks exploit many poorly secured IoT devices to create a powerful botnet capable of launching massive attacks18. The CICIoT2023 dataset includes several Mirai attack variants, each employing different techniques to overwhelm target systems. A variant of the Mirai attack, known as GREIP flood, combines the use of GRE (Generic Routing Encapsulation) protocol packets with IP flooding techniques. This attack type encapsulates malicious traffic within GRE packets, potentially bypassing standard traffic filters and overwhelming the target’s network infrastructure19. Greeth flood attacks, another Mirai variant, specifically target Ethernet frames. By flooding the network with a high volume of Ethernet traffic, this attack can flood network bandwidth and overload network equipment19. The UDPPlain attack, a more straightforward but effective Mirai attack type, floods the target with a high volume of UDP packets. These packets often have spoofed source IP addresses, making it challenging to filter out malicious traffic. Due to the connectionless nature of UDP, the attack can quickly overwhelm the target’s ability to process incoming data19. These Mirai attack variants demonstrate the evolving complexity of IoT-based attacks, highlighting the need for comprehensive security measures that can detect and mitigate a wide range of attack strategies in IoT environments.

Supervised machine learning

Supervised machine learning algorithms play a crucial role in intrusion detection systems, particularly in IoT environments where the ability to accurately classify network traffic is essential. These algorithms learn from labeled training data, where each instance is paired with a known outcome, to create models capable of predicting the class of new instances. In the context of IoT security, supervised learning algorithms are trained on datasets containing both normal network traffic and various types of attacks, enabling them to distinguish between benign and malicious activities. The effectiveness of these algorithms lies in their ability to generalize patterns learned from historical data to new, potentially evolving threats. Our study focuses on five widely used supervised machine learning algorithms, each with its unique approach to classification:

Random Forest (RF)20 is an ensemble method that constructs multiple decision trees and aggregates their predictions. It operates by building many decision trees at training time and outputting the class of the individual trees. RF is particularly good at handling high-dimensional data and provides a measure of feature importance, making it valuable for understanding which network characteristics are most expressive of attacks.

Gradient Boosting (GB)21 builds a series of weak learners, typically decision trees, in a stage-wise fashion. It works by iteratively training new models to correct the errors of the existing ensemble, effectively learning from its mistakes. GB is known for its high predictive accuracy and excellent performance, making it a strong candidate for complex classification tasks such as intrusion detection.

Naive Bayes (NB)22 is a probabilistic classifier that outperforms in scenarios with limited training data. Despite its simplicity and the “naive” assumption that all features are independent, NB often performs exceptionally well in text classification and spam filtering. In the context of network security, its ability to handle high-dimensional data efficiently can be beneficial.

Decision Tree (DT)23 creates models based on simple decision rules inferred from data features. It builds classification or regression models as a tree structure, breaking down a dataset into smaller subsets while incrementally developing an associated decision tree. The process used by DTs to make decisions can be easily visualized and understood. This quality is essential in security applications where transparency is crucial.

K-Nearest Neighbors (KNN)24 is an instance-based learning algorithm that classifies objects according to the majority class among their nearest neighbors. The algorithm assumes that data points with similar features are assigned similar labels. KNN is conceptually simple yet effective, especially when the decision boundary is irregular. In network security, it can be beneficial for detecting abnormalities based on the similarity of traffic patterns to known attacks or benign samples.

By comparing these diverse algorithms, we aim to thoroughly evaluate their performance in detecting and categorizing DoS, DDoS, and Mirai attacks in IoT networks, offering insights into their respective strengths and limitations in this critical application domain. This comparison will shed light on which algorithms are most effective for different aspects of IoT security, potentially guiding future developments in intrusion detection systems.

Related work

As the IoT network systems expand, their complexity increases, making devices that transmit data wirelessly vulnerable to attacks. The emergence of new IoT protocols often results in numerous daily attacks, which can compromise computing processes. Unlike local network attacks, assaults on IoT devices can spread over large areas with severe consequences. The diversity and distribution of IoT applications further complicate IoT security, making it more challenging and complicated than traditional cybersecurity approaches25. This study is dedicated to IoT security and aims to adapt well-established techniques such as anomaly detection and network behavior analysis to enhance IoT network security. The unique characteristics and limitations of IoT devices, including limited processing power and diverse communication protocols, justify the focus on IoT-specific literature. These distinctive features require customized security solutions to address the unique challenges within the IoT ecosystem. Table 1 summarizes recent studies on IoT intrusion detection, comparing them with our work in terms of datasets, attack types, classifiers, data balancing, feature selection, and run-time performance.

Table 1.

Comprehensive comparison of our study with existing literature on IoT intrusion detection.

Ref Year Datasets Attacks Classifiers Data Balancing Feature Selection Train Time Predict Time
26 2022 Bot-IoT DDoS, DoS

SVM, DT, RF,

RNN, LSTM,

GRU, MLP

Random consecutive

flow selection

Custom feature

sets

✗ ✓
27 2021 CICDDoS2019 DDoS

KNN, SVM, NB,

DT, RF, LR

✗ RFR ✗ ✗
28 2022 Bot-IoT DDoS, DoS

RF, DT, NB,

KNN, ANN

✗ ✗ ✗ ✗
8 2022 CICDDoS2019 DDoS

RF, DT,

MLR, NB

Up-sampling RFR ✗ ✗
29 2020 CICDDoS2019 DDoS LSTM, CNN ✗ IG ✗ ✓
30 2021 CICDDoS2019 DDoS

NB, SVM, ADA,

XGB, KNN, RF

✗

Removal of zero variance &

low correlation columns

✓ ✗
31 2024 CICDDoS2019 DDoS

RF, DT, ADA,

XGB, MLP, DNN

✗ PCC ✓ ✗
32 2023 CICIoT2023 Various

LR, PER, Ada,

RF, DNN

✗ ✗ ✗ ✗
33 2024 CICIoT2023 Various DNN, CNN, RNN ✗ ✗ ✗ ✗
34 2024 CICIoT2023 Various LSTM ✗ ✗ ✗ ✗
35 2023

CIC IDS2017,

N-BaIoT,

CICIoT2023

Various

DNN, BiLSTM,

DL-BiLSTM

✗ IPCA ✓ ✓
36 2024

CICIoT2023,

TON_IoT

DDoS

RF, DT, GB, ADA,

NB, LR, KNN, CNN,

MLP, LSTM, CNN-LSTM

✗ PCC ✗ ✗
37 2024

EdgeIIoT,

CICIoT2023,

UNSW-NB15

Various DNN SMOTE DTC ✗ ✗
38 2024 CICIoT2023 Various

RF, ADA, LR,

PER, DNN

SMOTE PCC ✗ ✗
39 2024 N_BaIoT Various CNN-GRU (AttackNet) ✗ ✗ ✓ ✓
40 2024 BoT-IoT Various LSTM Focal loss MGA ✓ ✗
41 2025 UNSW-NB15, X-IIoTID Various BiLSTM ✗ PCC, Agglomerative Clustering ✗ ✗
42 2025 Edge-IIoTset, X-IIoTID Various DNN ✗ ✗ ✓ ✓
Our Work 2024 CICIoT2023

DDoS, DoS,

Mirai

RF, GB, NB,

DT, KNN

Undersampling

PCA, RFR,

Chi-square

✓ ✓

Almaraz-Rivera et al.26 developed an intrusion detection system for IoT networks using the Bot-IoT dataset. They addressed the class imbalance problem by randomly selecting consecutive flows for each attack type. They created three feature subsets to evaluate the impact of temporal data. These subsets were evaluated using seven algorithms: RF, DT, Long Short-Term Memory (LSTM), Multilayer Perceptron (MLP), Gated Recurrent Unit (GRU), Recurrent Neural Network (RNN), and Support Vector Machine (SVM) for both binary and multiclass classification of DDoS and DoS attacks. The study achieved an average accuracy of over 99% across the experiments, with binary classification reaching 99.89-99.972% and multiclass 99.862-99.945%. Decision Tree and MLP emerged as the best-performing models, with Decision Tree capable of processing over 30,000 flows per second, demonstrating real-time feasibility.

Alzahrani et al.27 explore the application of various machine learning algorithms to detect DDoS attacks within network traffic. The study uses the CICDDoS2019 dataset to evaluate six machine learning models: KNN, SVM, NB, DT, RF, and Logistic Regression (LR). The RFR method was employed as a feature selection technique, which improved the accuracy of machine learning methods in identifying attack traffic. The DT and RF algorithms showed the highest accuracy, both achieving 99%. However, DT outperformed RF concerning computation time, making it a more efficient option for real-time detection.

Kumar et al.28 proposed an artificial neural network algorithm incorporating DT, RF, KNN, and NB algorithms, utilizing the Bot-IOT dataset. They subsequently evaluated this algorithm using traffic data from a custom testbed comprising 20 IoT devices. The resulting dataset contained 3 million DoS, 5 million DDoS, and 2 million normal traffic samples. The results revealed that KNN and the hybrid approach achieved the highest accuracies at 99.466% and 99.611%, respectively. The artificial neural network was also independently tested with various activation functions, yielding the best accuracy at 99.529%. These comparative analyses concluded that machine learning techniques perform better in resource-constrained systems, while deep learning algorithms excel in environments with extensive data and computational resources.

Patil et al.8 present a real-time system for detecting DDoS attacks using Spark Streaming and Kafka. The system employs distributed machine learning algorithms from Spark MLlib, including RF, DT, Multinomial Logistic Regression (MLR), and NB. It was evaluated using the CICDDoS2019 dataset, including benign traffic and six DDoS attacks. The RF algorithm achieved the best results with an average classification accuracy of 89.05% for seven classes.

Jia et al.29 developed FlowGuard, an intelligent edge defense mechanism against IoT DDoS attacks. The system has two main components: a flow filter and a flow handler. The flow filter filters malicious flows based on rules created by the flow handler and detects attacks based on traffic variations. The flow handler identifies and classifies malicious flows using two machine learning models: LSTM for attack identification and Convolutional Neural Network (CNN) for attack classification. The Information Gain (IG) feature selection method was employed to enhance the efficiency and effectiveness of the proposed models. FlowGuard was evaluated using both simulated data and the CICDDoS2019 dataset. When evaluated on the CICDDoS2019 dataset, the system reached 99.9% accuracy in detecting attacks and 98.9% accuracy in classifying attack types.

Seifousadati et al.30 investigate using machine learning algorithms to detect DDoS attacks on IoT devices using the CICDDoS2019 dataset. The study emphasizes feature selection and preprocessing to enhance the detection capabilities of the models. Specifically, they employed a feature selection method that removed columns with zero variance and low correlation to improve model performance. Several algorithms were evaluated, with Adaptive Boosting (ADA) and Extreme Gradient Boosting (XGB) emerging as the most effective, achieving 100% accuracy in identifying DDoS attacks.

Becerra-Suarez et al.31 provide an in-depth evaluation of machine learning methods for DDoS detection using the CICDDoS2019 dataset. They evaluated six algorithms: RF, DT, ADA, XGB, MLP, and Dense Neural Network (DNN). The initial 80 features were reduced to 22 through the Pearson correlation coefficient (PCC) method. For hyperparameter optimization, the authors applied the Tree of Parzen Estimators (TPE), finding it more efficient than conventional grid search approaches. The RF classifier emerged as the top performer, achieving 99.97% accuracy in detecting DDoS attacks. XGB closely followed with 99.95% accuracy, while DT achieved 99.88%. The other algorithms (ADA, MLP, DNN) showed accuracies ranging from 99.59% to 99.70%.

The CICIoT2023 dataset, introduced by Neto et al.32, simulates large-scale cyber-attacks on a network of 105 IoT devices. It covers seven attack categories: DDoS, DoS, reconnaissance, web-based, brute force, spoofing, and Mirai. To demonstrate its utility, the dataset was divided into training (80%) and testing (20%) sets, then normalized for machine learning applications. Five machine learning methods were evaluated: LR, Perceptron (PER), ADA, RF, and DNN. While overall performance decreased when classifying multiple attack groups, RF and DNN maintained relatively high accuracy and F1 scores. The models performed well in classifying attacks with numerous occurrences, such as DDoS, DoS, and Mirai. However, they struggled with less common attacks like web-based and brute force, often misclassifying them as benign or other attack types. The multiclass classification showed decreased performance for benign traffic, recon, and spoofing, possibly due to similar traffic patterns. This phenomenon deserves further investigation in future research.

Abbas et al.33 focuses on applying deep learning models to detect and classify cyber-attacks within IoT networks. The study explores various deep learning models, including DNN, CNN, and RNN, to identify cyber-attacks in IoT environments. Using the CICDIoT2023 dataset, the study implements data preprocessing techniques such as robust scaling and label encoding for categorical variables to enhance model performance. The experimental results show that among the different models tested, the RNN model achieved the highest accuracy at 96.56%, indicating its effectiveness in detecting cyber-attacks compared to other methods.

Jony et al.34 explore the application of LSTM networks for intrusion detection in IoT environments. Utilizing the extensive CIC-IoT2023 dataset, the study demonstrates that the LSTM-based model can detect known and evolving cyber-attack patterns. The model achieved an accuracy rate of 98.75% and an F1 score of 98.59%.

Wang et al.35 introduced the Deep Learning-Bidirectional Long Short-Term Memory (DL-BiLSTM) algorithm, a lightweight model for detecting IoT attacks. This approach combines DNN and BiLSTM techniques. The research utilized CICIDS2017, N-BaIoT, and CICIoT2023 datasets. They employed Incremental Principal Component Analysis (IPCA) as a feature selection technique to reduce the number of dataset features. The modelś computational complexity was further decreased through dynamic quantization. When evaluated against other deep learning algorithms using the CICIoT2023 dataset, the DL-BiLSTM algorithm achieved the highest accuracy rate of 93.13% in detecting attack types.

Yaras et al.36 present a new hybrid deep learning algorithm for detecting DDoS attacks in IoT environments. The algorithm combines one-dimensional CNN and LSTM networks. It was evaluated using two recent datasets: CICIoT2023 and TON_IOT. The main contributions include developing a high-accuracy intrusion detection system for big data, excelling in both binary and multiclass classification. Using the CICIoT2023 dataset, the model achieved 99.995% accuracy for binary classification and 99.96% for multiclass classification. On the TON_IOT dataset, the model achieved an accuracy of 98.75% for binary classification.

Nkoro et al.37 utilize DNN for detecting cyber threats in Metaverse learning platforms. The study uses recent IoT cybersecurity datasets to model and evaluate the DNN’s performance. The study uses the Synthetic Minority Over-sampling (SMOTE) technique for data balancing and a Decision Tree Classifier (DTC) for feature selection. The DNN model achieves high binary classification accuracy across different datasets: 99.9% for EdgeIIoT, 99.10% for CICIoT2023, and 99.9% for UNSW-NB15. For multiclass classification, the model achieves 71.22% accuracy on EdgeIIoT (15 classes), 70.53% on CICIoT2023 (34 classes), and 84.74% on UNSW-NB15 (9 classes).

Khan et al.38 present a study on anomaly detection in IoT-based healthcare using the CICIoT2023 dataset. The research evaluates five machine learning algorithms: RF, ADA, LR, PER, and DNN. The dataset was preprocessed and balanced using the SMOTE technique. Features were selected using the PCC selection method. RF emerged as the best-performing algorithm, achieving an accuracy of 95.55% for the 8-Class experiment. The prediction times were decreased from 13.08s to 6.64s after applying the feature selection method.

Recent advancements highlight the trend towards more sophisticated and specialized models. Nandanwar and Katarya39 developed a deep learning intrusion detection system for Industrial IoT. Their method addresses real-time processing and high accuracy needs for critical infrastructure. The system detects various attacks efficiently and is suitable for resource-constrained IoT devices.

Saheed et al.40 proposed the IoT-Defender framework, which combines a Modified Genetic Algorithm (MGA) for feature selection with a fine-tuned LSTM network for intrusion detection in edge-enabled IoT networks. This approach achieved 99.41% accuracy on the BoT-IoT dataset, demonstrating the effectiveness of hybrid models in resource-constrained environments. In another work, Saheed et al.41 introduced a privacy-preserving framework for CPS-IIoT networks that uses a Bidirectional LSTM (BiLSTM) with a scaled dot-product attention mechanism. This model, which incorporates Pearson Correlation Coefficient (PCC) and agglomerative clustering for privacy, achieved outstanding performance on the UNSW-NB15 and X-IIoTID datasets. Further pushing the boundaries of explainability and privacy, Saheed et al.42 developed a privacy-preserving DNN framework that employs Shapley Additive exPlanations (SHAP) to interpret model decisions. This model achieved near-perfect accuracy on the Edge-IIoTset and X-IIoTID datasets while maintaining fast training times, offering a robust solution for real-time threat detection in CPS-IoT networks.

However, existing studies in attack detection for IoT environments have notable limitations. Many of these studies focus solely on DDoS attacks, overlooking other critical threats such as DoS and Mirai attacks. Furthermore, many researchers have not addressed the crucial issue of class imbalance in their datasets, which can lead to biased models. Another common drawback is the insufficient exploration of feature selection methods, as many studies rely on a single approach or skip this step altogether. Furthermore, while some studies employ advanced deep learning models, they often fail to consider important practical factors, such as training and prediction times.

Our work addresses these limitations and makes several unique contributions to the field. Unlike many previous studies, we extended our scope to include DoS and Mirai attacks alongside DDoS, providing a more comprehensive approach to IoT security. We utilize the CICIoT2023 dataset, which is among the latest and most comprehensive datasets for IoT security studies. We employ an undersampling technique for data balancing to address the common class imbalance issue. Our feature selection approach is more robust, combining PCA, RFR, and Chi-square methods, offering a more diverse and potentially more effective strategy than the single-method approaches used in most existing studies. In addition, we focus on training and prediction times, which are crucial factors for real-world implementation. We comprehensively evaluate different approaches using a combination of traditional machine learning algorithms (RF, GB, NB, DT, and KNN). This approach significantly enhances the current understanding of IoT security and provides practical insights for implementing effective attack detection systems in real-world situations.

Research methodology

This section outlines the comprehensive approach adopted in this study for classifying IoT network attacks using machine learning techniques. Our methodology encompasses several essential stages, including dataset acquisition, data preprocessing, feature selection, and evaluating various machine learning classifiers. This systematic approach ensures a thorough exploration of the CICIoT2023 dataset’s potential for identifying and categorizing IoT-based cyber threats. Figure 1 presents the study’s methodological framework, depicting a flowchart that outlines the workflow from data preprocessing to model evaluation, highlighting the interconnected steps and logical progression.

Fig. 1.

Fig. 1

Proposed methodological framework.

CICIoT2023 dataset

The CICIoT2023 dataset, produced by Neto et al.32, is constructed from an IoT topology consisting of 105 devices (67 IoT devices and 38 Zigbee and Z-Wave devices). This arrangement is intended to replicate a realistic smart home environment. The testbed includes smart home devices, cameras, and sensors, all configured to execute and record multiple types of attacks. Researchers generated 33 distinct attack types, which are organized into seven categories: DDoS, DoS, reconnaissance, web-based, brute-force, spoofing, and Mirai. The dataset includes both benign and malicious network traffic, with 47 features extracted from each network flow. Regarding sample distribution, DDoS attacks are the most prevalent, accounting for 73% of the dataset, followed by DoS attacks at 17%. In comparison, Web-based and Brute-force attacks represent less than 1% of the total data. This study concentrates on three primary types of attacks: DoS, DDoS, and Mirai. It also considers benign traffic, as these categories provide the most substantial number of data samples. Other attack classes, such as spoofing, web-based attacks, and brute force attacks, have limited data samples, which could compromise the performance and reliability of machine learning models if included in the analysis.

Data preprocessing

The preprocessing operation handles the dataset before using it in the suggested models. It involved handling null and infinite records, dropping all duplicate records, balancing the different classes in the dataset using the undersampling technique, and transforming all non-numeric values using Label Encoder. Finally, the data was scaled to convert the feature vector to a more suitable format for machine learning models.

Data cleaning: Our data preparation began with examining the dataset to ensure its integrity and suitability for machine learning algorithms. We systematically reviewed all rows, identifying and removing any rows that contained null or infinite values, which could potentially skew our analysis. We also conducted a duplicate check, removing any redundant entries to avoid bias in our models.

Data balancing: Given that the number of attack samples significantly outweighs the benign samples in our dataset, it is crucial to balance the data to achieve optimal results. For this purpose, we employed an undersampling technique to equalize the number of samples across all classes.

Undersampling involves reducing the number of samples in the majority classes (attack samples) to match the number in the minority class (benign samples). This approach helps prevent bias towards the majority classes and ensures that our machine learning models can learn equally from all classes43. In our study, we employed random undersampling, which randomly removes samples from the majority classes until their sizes match that of the minority class.

While undersampling effectively addresses class imbalance and reduces computational overhead, it has potential drawbacks that should be considered. The main limitation is the loss of potentially valuable information from the majority classes, which can diminish the model’s ability to capture the full diversity of attack patterns. In addition, undersampling may lead to overfitting if the remaining samples are not representative of the entire population. However, we chose undersampling over alternative techniques like SMOTE for several reasons: (1) it preserves the authenticity of real network traffic data without introducing synthetic samples that might not accurately reflect actual IoT attack characteristics; (2) it significantly reduces computational complexity and training time, which is crucial for resource-constrained IoT environments; and (3) given the large size of the CICIoT2023 dataset, there are still sufficient samples remaining after undersampling to maintain model generalizability.

After applying the undersampling technique to our imbalanced dataset, we achieved equal samples for each class. Specifically, each class (DoS, DDoS, Mirai, and benign) was reduced or maintained to contain exactly 302,896 records. This resulted in a total of 1,211,584 records in our balanced dataset. This balanced distribution ensures that our machine learning models are not biased towards any particular class during training. Figure 2 illustrates the balanced class distribution achieved by applying the undersampling technique, demonstrating the equalized representation of 25% of total records for each class in our final dataset.

Fig. 2.

Fig. 2

The balanced class distribution achieved by applying the undersampling technique.

Label encoding: We utilized label encoding to convert all non-numeric values into their corresponding numerical representations, ensuring compatibility with numerous machine learning algorithms that only accept numerical inputs. For instance, the ’Label’ column, which denotes the class of each network traffic instance, was encoded using a numerical scheme: 0 for benign traffic, 1 for DDoS attacks, 2 for DoS attacks, and 3 for Mirai attacks. This encoding ensures compatibility with our machine learning models and preserves a clear relationship among the various classes of network traffic.

Feature scaling: A crucial preprocessing step in our methodology to normalize the data and enhance computational efficiency. Given that the CICIoT2023 dataset used in this study contains variables with diverse scales, we employed feature scaling to convert the feature vectors into a format more suitable for machine learning models. Among the various scaling techniques available, we opted for StandardScaler() from the Scikit-Learn library, widely recognized for its effectiveness in machine learning applications44.

The StandardScaler() technique45 transforms our dataset to achieve a distribution with a mean of zero and a standard deviation of one. This is done by subtracting the mean from each value and dividing by the standard deviation. The process is mathematically expressed in Equation (1):

graphic file with name d33e1026.gif 1

Where z denotes the transformed feature value, x represents the original feature value, Inline graphic is the mean of the feature, and Inline graphic signifies the feature’s standard deviation.

By applying this standardization technique to the CICIoT2023 dataset, we ensure that all features contribute equally to the learning process of our machine learning models, regardless of their original scales. This approach not only normalizes our data but also potentially improves the convergence speed of our algorithms, which is particularly beneficial for the diverse range of IoT network traffic features present in our dataset.

Feature selection

This research utilizes three feature selection techniques to identify the most significant features for predicting IoT network attacks in the CICIoT2023 dataset. These methods reduce data dimensionality, improve model performance, and decrease computational costs. The techniques employed are Chi-Square selection, PCA, and RFR. Each method was configured to select the top 15 most informative features or components, as illustrated in Figs. 3, 4, and 5.

Fig. 3.

Fig. 3

Chi-square scores for the top 15 features identified using Chi-square.

Fig. 4.

Fig. 4

Explained variance ratio by principal component for the top 15 features identified using PCA.

Fig. 5.

Fig. 5

Feature importance scores for the top 15 features identified using RFR model.

The choice of these three feature selection methods is justified by their complementary approaches to feature evaluation in the context of IoT security. Chi-square testing provides a statistical framework for assessing categorical features, making it particularly effective for detecting attacks in IoT systems, where many features relate to discrete network states and protocols. Its primary strength lies in identifying features that show strong independence from attack classes46. On the other hand, PCA provides dimensionality reduction while preserving variance. This method is useful for analyzing high-dimensional IoT network traffic data that often includes correlated attributes, such as packet sizes and timing patterns47. However, a notable drawback of PCA is the potential loss of interpretability, making it challenging to trace how original features contribute to attack detection. RFR employs ensemble learning with multiple decision trees to evaluate feature importance, effectively capturing non-linear relationships and interactions in network traffic patterns20. It handles mixed data types and reveals complex dependencies, but can be computationally intensive and may favor features with more categories.

  • Chi-Square48,49 evaluates the independence between a feature and the class label, selecting the top 15 features with the highest chi-square scores. To enhance the performance of the proposed machine learning models, the Chi-square feature selection method was applied to determine the most relevant features in our dataset. The features with the strongest correlations were identified by computing the Chi-square statistic for each feature in relation to the target variable. Figure 3 presents the results of feature selection using the Chi-square technique.

  • PCA is a statistical approach that reduces dimensionality and finds data patterns, selecting the top 15 principal components that explain the most variance in the data. It converts the original variables into a new set of uncorrelated variables known as principal components, which are arranged according to the amount of variance they capture in the dataset50. Figure 4 illustrates the explained variance ratio for the top 15 features identified using PCA, highlighting the relative importance of each component in capturing data variability.

  • RFR is a versatile ensemble learning method primarily used for regression tasks, configured to identify the top 15 most important features based on impurity reduction. However, its feature importance mechanism can be utilized for feature selection in both regression and classification problems. In Random Forest, feature importance is determined by how much each feature reduces the impurity (or variance in the case of regression) of the split when used in the forest’s decision trees51. Figure 5 illustrates the feature importance scores derived from RFR model applied to the dataset.

Machine learning classifier

The study focuses on implementing and evaluating various supervised machine learning models for classification, including RF, DT, KNN, GB, and NB.

We utilized the Train-Test Split method to divide the dataset into training (80%) and testing (20%) subsets. We then conducted model tuning using a random search technique to optimize model performance. This approach allowed us to identify the best parameter values for each model, thereby maximizing their performance.

We evaluate the effectiveness of our proposed model using the CICIoT2023 dataset. The assessment employs six key performance metrics: Accuracy, Precision, Sensitivity, F1-score, Training Time, and Prediction Time. These metrics comprehensively evaluate the model’s performance and computational efficiency, offering a robust framework for evaluating and classifying IoT network attacks. To validate the performance improvements, we conducted statistical significance testing using t-tests. All reported results showed statistical significance at p Inline graphic, which confirms the reliability and validity of our comparative analysis.

Accuracy: This metric reflects the proportion of correct predictions made by the model:

graphic file with name d33e1146.gif 2

TP (True Positives) are positive cases that the model correctly identifies as positive. TN (True Negatives) are negative cases that the model correctly identifies as negative. FP (False Positives) are negative cases that the model incorrectly labels as positive. FN (False Negatives) are positive cases that the model incorrectly labels as negative.

Precision: It indicates the model’s ability to identify positive cases accurately. It is the ratio of true positive predictions to all positive predictions made by the model:

graphic file with name d33e1155.gif 3

Sensitivity: It assesses the model’s capacity to identify all positive cases. It is computed as the ratio of true positive predictions to all actual positive cases:

graphic file with name d33e1162.gif 4

F1-score: It provides a balanced measure of the model’s performance by combining precision and sensitivity. It is beneficial when dealing with imbalanced datasets. The F1-score is calculated as the harmonic mean of precision and sensitivity:

graphic file with name d33e1169.gif 5

Training time: It measures the duration required for the machine learning model to learn from 80% of the given dataset, constituting our training set. It reflects the computational resources needed during the model’s learning phase on this substantial portion of the data.

Prediction time: It represents the duration for the trained model to generate predictions on the remaining 20% of the dataset, which forms our test set. This metric is crucial for assessing the model’s efficiency in real-time applications, using a subset of data that the model has not seen during training.

Experimental design and results

In this study, we conducted a multiclass classification experiment to categorize IoT network traffic into four classes: DoS, DDoS, Mirai attacks, and benign traffic. We leveraged five machine learning classifiers for this task: RF, DT, KNN, GB, and NB. The study was conducted on a ThinkPad laptop running Windows 10 Pro, featuring an Intel Core i7 processor, 8GB of RAM, a 320GB SSD, and an x64-based architecture.

We utilized Python 3 and Kaggle Notebooks for code development and execution. Our toolkit included several essential libraries: Pandas for data manipulation, Scikit-Learn for implementing the machine learning models and algorithms, and Matplotlib with Seaborn for data visualization. We used the Imblearn library to apply undersampling techniques to mitigate class imbalance issues.

To calculate the time metrics, we employed Python’s time library52. The process involves setting a start timer before initiating the training phase on the training set or the testing phase on the test set, executing the respective task, and then setting an end timer upon completion. The total duration is calculated by determining the difference between the end and start times.

The performance results are summarized in Table 2, which shows accuracy, precision, sensitivity, F1-score, training time, and prediction time for each machine learning classifier. Before delving into the detailed results for each classifier, we present a concise summary of the main findings to provide an overview of our experimental outcomes and key insights derived from the comparative analysis of different machine learning algorithms and feature selection methods.

  • RF, DT, and GB classifiers consistently achieved the highest accuracy across all feature selection methods, achieving a 99.99% accuracy with RFR feature selection technique. In contrast, NB showed significantly lower performance compared to other algorithms, indicating its limitations for this specific classification task.

  • RFR feature selection method generally led to the best performance for most algorithms, significantly improving both accuracy and prediction times. PCA and chi-square methods performed similarly, with PCA slightly underperforming in most cases.

  • DT demonstrated the best balance between high accuracy and low computational cost, making it ideal for real-time applications.

  • There was notable confusion between DDoS DoS attacks across most classifiers due to their similar network traffic characteristics. In contrast, Mirai attacks were more accurately classified due to their unique characteristics, such as distinct payload signatures and unique propagation behaviors that differentiate them from traditional DoS and DDoS attacks.

Table 2.

Performance results of machine learning classifiers with different feature selection methods.

Classifiers Feature Accuracy Precision Sensitivity F1-score Train Time Predict Time
Selection (%) (%) (%) (%) (s) (s)
RF Chi-square 97.85 97.92 97.86 97.85 108.4 2.6
PCA 96.38 96.38 96.38 96.38 119.6 3.7
RFR 99.99 99.99 99.99 99.99 145.4 1.9
GB Chi-square 97.70 97.78 97.71 97.69 599.9 1.4
PCA 96.81 96.81 96.81 96.81 490.4 1.4
RFR 99.99 99.99 99.99 99.99 1198.4 1.4
NB Chi-square 67.43 62.65 67.55 62.02 2.6 0.08
PCA 73.99 68.07 74.14 65.83 2.6 0.08
RFR 57.72 58.78 57.97 53.43 2.6 0.08
DT Chi-square 97.66 97.71 97.67 97.66 7.9 0.04
PCA 96.17 96.17 96.17 96.17 5.9 0.05
RFR 99.99 99.99 99.99 99.99 9.1 0.03
KNN Chi-square 96.15 96.23 96.15 96.14 5.8 282.7
PCA 95.59 95.61 95.60 95.59 6.3 68.1
RFR 99.97 99.97 99.97 99.97 5.7 20.1

Random forest results

The Random Forest (RF) classifier was evaluated using three different feature selection methods: chi-square, PCA, and RFR. With chi-square feature selection, RF achieved high performance with 97.85% accuracy, 97.92% precision, 97.86% sensitivity, and 97.85% F1-score. The model was trained in 108.4 seconds and achieved a prediction time of 2.6 seconds. PCA feature selection resulted in slightly lower performance metrics, with all scores at 96.38%. The training time increased to 119.6 seconds, and the prediction time was 3.7 seconds, the longest among the three methods. RFR feature selection demonstrated superior performance, achieving near-perfect scores of 99.99% across all metrics. While it had the longest training time at 145.4 seconds, it also had the fastest prediction time of 1.9 seconds.

These results align closely with the confusion matrices shown in Fig. 6. The high accuracy of the RFR method is reflected in its confusion matrix, which shows almost perfect classification across all classes. The slightly lower performance of the chi-square and PCA methods can be observed in their confusion matrices, particularly in the confusion between DDoS and DoS classes.

Fig. 6.

Fig. 6

Confusion matrices for random forest with different feature selection methods.

In conclusion, while all methods produced good results, RFR outperformed other methods regarding classification metrics and prediction speed, albeit at the cost of longer training time.

Decision tree results

The Decision Tree (DT) classifier was evaluated using three different feature selection methods: chi-square, PCA, and RFR. With chi-square feature selection, DT achieved high performance with 97.66% accuracy, 97.71% precision, 97.67% sensitivity, and 97.66% F1-score. The model was trained in 7.9 seconds and achieved a prediction time of 0.04 seconds. PCA feature selection resulted in slightly lower performance metrics, with all scores at 96.17%. The training time decreased to 5.9 seconds, and the prediction time was 0.05 seconds, the longest among the three methods. RFR feature selection demonstrated superior performance, achieving near-perfect scores of 99.99% across all metrics. It had the longest training time at 9.1 seconds but the fastest prediction time of 0.03 seconds.

These results align closely with the confusion matrices shown in Fig. 7. The high accuracy of the RFR method is reflected in its confusion matrix, which shows almost perfect classification across all classes. The slightly lower performance of the chi-square and PCA methods can be observed in their confusion matrices, particularly in the confusion between DDoS and DoS classes.

Fig. 7.

Fig. 7

Confusion matrices for decision tree with different feature selection methods.

In conclusion, while all methods produced good results, RFR outperformed other methods regarding classification metrics and prediction speed, albeit at the cost of slightly longer training time. Interestingly, the DT classifier shows significantly faster training and prediction times compared to RF, while maintaining comparable accuracy levels, especially with the RFR feature selection method.

Gradient boosting results

The Gradient Boosting (GB) classifier was evaluated using three different feature selection methods: chi-square, PCA, and RFR. With chi-square feature selection, GB achieved high performance with 97.70% accuracy, 97.78% precision, 97.71% sensitivity, and 97.69% F1-score. The model was trained in 599.9 seconds and achieved a prediction time of 1.4 seconds. PCA feature selection resulted in slightly lower performance metrics, with all scores at 96.81%. The training time decreased to 490.4 seconds, while the prediction time remained at 1.4 seconds. RFR feature selection demonstrated superior performance, achieving near-perfect scores of 99.99% across all metrics. It had the longest training time at 1198.4 seconds, with the prediction time consistent at 1.4 seconds across all methods.

These results align closely with the confusion matrices shown in Fig. 8. The high accuracy of the RFR method is reflected in its confusion matrix, which shows almost perfect classification across all classes. The slightly lower performance of the chi-square and PCA methods can be observed in their confusion matrices, particularly in the confusion between DDoS and DoS classes.

Fig. 8.

Fig. 8

Confusion matrices for gradient boosting with different feature selection methods.

In conclusion, while all methods produced good results, RFR outperformed other methods regarding classification metrics, albeit at the cost of significantly longer training time. Notably, the GB classifier shows longer training times compared to other algorithms, especially with RFR feature selection. However, it maintains consistent prediction times across all feature selection methods and achieves high accuracy, particularly with RFR feature selection.

K-nearest neighbor results

The K-Nearest Neighbor (KNN) classifier was evaluated using three different feature selection methods: chi-square, PCA, and RFR. With chi-square feature selection, KNN achieved good performance with 96.15% accuracy, 96.23% precision, 96.15% sensitivity, and 96.14% F1-score. The model was trained in 5.8 seconds but had a notably long prediction time of 282.7 seconds. PCA feature selection resulted in slightly lower performance metrics, with scores around 95.60%. The training time increased slightly to 6.3 seconds, while the prediction time significantly decreased to 68.1 seconds. RFR feature selection demonstrated superior performance, achieving near-perfect scores of 99.97% across all metrics. It had the shortest training time at 5.7 seconds and greatly reduced the prediction time to 20.1 seconds.

These results align closely with the confusion matrices shown in Fig. 9. The high accuracy of the RFR method is reflected in its confusion matrix, which shows almost perfect classification across all classes. The lower performance of the chi-square and PCA methods can be observed in their respective confusion matrices, particularly in the confusion between Benign, DDoS, and DoS classes.

Fig. 9.

Fig. 9

Confusion matrices for K-nearest neighbors with different feature selection methods.

In conclusion, while all methods produced good results, RFR significantly outperformed other methods regarding classification metrics and drastically improved prediction speed. Notably, the KNN classifier shows consistent and fast training times across all feature selection methods. However, prediction times vary greatly, with RFR feature selection providing the best balance between high accuracy and reasonable prediction time.

Naive Bayes results

The Naive Bayes (NB) classifier was evaluated using three different feature selection methods: chi-square, PCA, and RFR. With chi-square feature selection, NB achieved moderate performance with 67.43% accuracy, 62.65% precision, 67.55% sensitivity, and 62.02% F1-score. PCA feature selection resulted in improved performance metrics, with 73.99% accuracy, 68.07% precision, 74.14% sensitivity, and 65.83% F1-score. Surprisingly, RFR feature selection demonstrated lower performance, with 57.72% accuracy, 58.78% precision, 57.97% sensitivity, and 53.43% F1-score. Notably, the training time (2.6 seconds) and prediction time (0.08 seconds) remained constant across all feature selection methods.

These results align closely with the confusion matrices shown in Fig. 10. The moderate performance of the chi-square method is reflected in its confusion matrix, showing significant misclassifications, particularly between DDoS and DoS classes. The PCA confusion matrix illustrates improved classification for the Benign class but still shows confusion between DDoS and DoS classes. Unexpectedly, the RFR confusion matrix reveals poor performance, with a large number of misclassifications, especially for the Mirai class.

Fig. 10.

Fig. 10

Confusion matrices for Naive Bayes with different feature selection methods.

In conclusion, for the NB classifier, PCA feature selection outperformed other methods in terms of classification metrics. Notably, the NB classifier shows consistent and fast training and prediction times across all feature selection methods. However, its overall performance is significantly lower compared to other classifiers, particularly with RFR feature selection. This unusual behavior of the NB classifier with RFR arises from the conflict between RFR’s feature selection and the NB algorithm’s assumption of independence. RFR focuses on interdependent features, whereas NB assumes conditional independence, leading to biased probability estimates and reduced classification performance.

Discussion

This section analyzes our contributions to IoT intrusion detection using the CICIoT2023 dataset. We compare our method with existing research, assess its practical impact, and discuss the challenges associated with its deployment in edge-cloud systems. Although our focus is on centralized machine learning, integrating edge computing could further improve real-time response and reduce latency.

Comparative analysis and performance evaluation

Table 3 provides a detailed overview of the methodologies, performance metrics, and computational efficiency of our study compared to other works in the literature. Based on this comparative analysis, our study demonstrates several significant contributions and advantages over existing research that uses the CICIoT2023 dataset for the detection of IoT intrusions.

Table 3.

Comparison of our study with existing studies using the CICIoT2023 dataset for IoT intrusion detection.

Aspect Our Study 32 35 33 34 36 37 38
Algorithms RF, GB, NB, DT, KNN RF, DNN, MLP, LR, AdaBoost DL-BiLSTM DNN, CNN, RNN LSTM RF, DT, GB, Ada, NB, LR, KNN, CNN, MLP, LSTM, CNN-LSTM DNN RF, Ada, LR, PER, DNN
Feature Selection Chi-square, PCA, RFR Not specified IPCA Not specified Not specified PCC DTC PCC
Data Balancing Under-sampling Not specified Not specified Not specified Not specified Not specified SMOTE SMOTE
Best Accuracy 99.99% (DT with RFR) 99.43% (RF) 93.13% (DL-BiLSTM) 98.56% (CNN) 99.23% (LSTM) 99.96% (CNN-LSTM) 70.53% (DNN) 95.55% (DNN)
Training Time DT: 9.1s Not reported 708.4s Not reported Not reported Not reported Not reported Not reported
Prediction Time DT: 0.03s Not reported 6.4s Not reported Not reported Not reported Not reported Not reported

In terms of classification performance, our approach achieves the highest accuracy for multi-class detection and categorization of IoT attacks. As shown in the table, our DT model with RFR feature selection attains a 99.99% accuracy for attack classification, surpassing the best performance reported in the literature. This result is marginally better than the 99.96% accuracy reported by36, which used a CNN-LSTM hybrid model. Our superior accuracy confirms the effectiveness of our methodology in accurately distinguishing between various types of IoT attacks, demonstrating that traditional machine learning algorithms, when properly optimized, can outperform complex deep learning models in this domain.

From a methodological perspective, our study stands out for its comprehensive evaluation of multiple machine learning algorithms and feature selection methods. Although many previous studies typically focus on a single algorithm or a limited set of techniques, we compare five different classifiers (RF, GB, NB, DT, KNN) and three feature selection techniques (Chi-square, PCA, RFR). This broad approach provides valuable information on the relative strengths of different algorithms and feature selection methods in the context of IoT security. Regarding data preprocessing, our study addresses the critical issue of class imbalance through undersampling, a consideration often overlooked in previous research. As indicated in Table 3, only two other studies (37 and38) explicitly mention data balancing techniques, both using SMOTE. Our use of undersampling offers an alternative approach to handling imbalanced datasets in IoT intrusion detection.

From a practical deployment perspective, our study is one of the few to report training and prediction times, with our best-performing model (DT) demonstrating superior computational efficiency. Our model achieves a training time of 9.1s and a prediction time of 0.03s, significantly outperforming the results reported by Wang et al.35. Specifically, our approach offers a 98.71% reduction in training time and a 99.53% reduction in prediction time while maintaining higher accuracy. This emphasis on computational efficiency is crucial for real-world IoT intrusion detection systems, where resource constraints and real-time processing requirements are essential considerations.

Analyzing the classification patterns in our results, we identified important insights into IoT attack detection challenges. The observed confusion patterns in our study, particularly between DDoS and DoS attacks, reveal the inherent difficulty in distinguishing these attack types. The frequent misclassification between these two attack categories can be attributed to their similar characteristics in network traffic. Both DDoS and DoS attacks aim to overwhelm target systems, resulting in comparable patterns in packet transmission rates, connection establishment frequencies, and bandwidth usage. This observation reflects a broader challenge in cybersecurity, where similar attack mechanisms often generate overlapping traffic signatures, making precise classification challenging even for advanced machine learning models. In contrast, Mirai attacks demonstrated superior classification accuracy across all models due to their unique operational characteristics. These attacks specifically target IoT devices through distinct propagation patterns, unique payload signatures associated with the exploitation of IoT devices, and particular communication protocols used for coordinating the botnet.

In conclusion, our study achieves the highest accuracy in multi-class IoT attack detection and provides a more comprehensive evaluation of machine learning techniques. It addresses data imbalance and considers computational efficiency. These contributions offer valuable insights for developing robust and efficient intrusion detection systems for IoT environments.

Practical deployment challenges

The transition from laboratory-validated intrusion detection models to real-world IoT environments introduces challenges beyond computational efficiency. Although our decision tree approach achieves 99.99% accuracy in controlled settings, real deployment must address scalability, security, and privacy.

Deploying decision trees in IoT requires adaptability to diverse devices and evolving threats5. Their interpretability and low retraining cost are beneficial, but frequent updates are needed to counter new attack vectors. Scalability remains a central challenge for large IoT networks. Our lightweight model supports edge deployment, but effective model distribution and synchronization demand robust hierarchical strategies. Adversarial attacks on machine learning models are a major concern53. Although decision trees are more interpretable than black-box models, strong resilience requires adversarial training, input validation, and secure updates. Privacy-preserving techniques in IoT security offer both challenges and opportunities. Our approach analyzes raw network traffic, which may expose sensitive information. Incorporating federated learning or differential privacy could enhance detection while protecting user data. However, maintaining 99.99% accuracy with these methods is challenging due to the added noise or computational overhead54,55.

Conclusion

The rapid expansion of IoT devices has introduced significant security challenges, making these interconnected systems increasingly vulnerable to cyber-attacks. The complexity of IoT ecosystems, combined with limited computational resources and diverse communication protocols, necessitates innovative approaches to intrusion detection that balance effectiveness with efficiency. Our research has explored machine learning techniques to detect and classify DoS, DDoS, and Mirai attacks in IoT environments. The main contributions of this study include: (1) a comprehensive evaluation of traditional machine learning algorithms across multiple attack types using the recent CICIoT2023 dataset, (2) systematic comparison of three distinct feature selection methods (Chi-square, PCA, and RFR) with theoretical justification for their selection, (3) addressing critical research gaps in computational efficiency by measuring both training and prediction times, and (4) implementation of undersampling techniques to handle class imbalance issues while maintaining model generalizability.

Our analysis revealed several key findings that advance the state of the art in IoT intrusion detection. With RFR feature selection, the RF, DT, and GB algorithms consistently outperformed existing studies, achieving a near-perfect accuracy of 99.99% across multiple attack types. Notably, our DT model achieved the highest accuracy and exhibited remarkable computational efficiency, offering a 98.71% reduction in training time and a 99.53% reduction in prediction time compared to the best-reported results in existing studies. Furthermore, we identified specific challenges in attack classification, particularly the complexity involved in differentiating between DDoS and DoS attacks due to their similar network traffic characteristics. These results confirm the importance of algorithmic choice and feature selection in developing efficient and accurate intrusion detection systems for IoT environments.

For our future work, we plan to expand our research in several key areas. We intend to implement deep learning models, such as CNN and LSTM networks, to identify more complex attack patterns. Additionally, we see potential in integrating our high-efficiency traditional machine learning methods with emerging edge computing architectures. This integration could lead to the development of distributed IoT security systems that maintain real-time responsiveness while ensuring detection accuracy. We also aim to enhance real-time detection capabilities by developing streaming data processing techniques that can analyze actual network traffic. In addition, we plan to create privacy-preserving extensions of our methodology by incorporating approaches such as federated learning, differential privacy, and homomorphic encryption. Furthermore, we will expand our study to encompass a wider range of IoT attack types and assess the performance of our models on diverse IoT datasets to ensure their generalizability. Exploring the scalability and adaptability of our approach across various IoT ecosystems is another critical research direction. We intend to examine how our methodology can be tailored to specialized IoT domains, including industrial control systems, smart city infrastructures, and healthcare monitoring networks, where attack patterns and resource constraints may differ significantly from those in general IoT environments. Finally, based on our findings, we expect to develop and deploy a lightweight user-friendly intrusion detection system suitable for resource-constrained IoT devices.

Acknowledgements

This scientific paper is derived from a research grant funded by Taibah University, Madinah, Kingdom of Saudi Arabia - with grant number (447-13-994).

Author contributions

M.A conceptualized and designed the study, performed the data analysis, and wrote the manuscript.

Funding

This scientific paper is derived from a research grant funded by Taibah University, Madinah, Kingdom of Saudi Arabia - with grant number (447-13-994).

Data availability

The datasets are available at https://www.kaggle.com/datasets/mharby/dataset

Declarations

Competing interests

The authors declare no competing interests.

Footnotes

Publisher’s note

Springer Nature remains neutral with regard to jurisdictional claims in published maps and institutional affiliations.

Change history

12/26/2025

The original online version of this Article was revised to correct an incomplete affiliation. In the original version, the university name was omitted, and the affiliation was incorrectly listed as “Department of Cybersecurity, College of Computer Science and Engineering, Madinah, Saudi Arabia.” This has now been corrected in the Article.

References

  • 1.Bittencourt, L. et al. The internet of things, fog and cloud continuum: Integration and challenges. Internet Things3, 134–155 (2018). [Google Scholar]
  • 2.Kagita, M. K., Thilakarathne, N., Gadekallu, T. R., Maddikunta, P. K. R. & Singh, S. A review on cyber crimes on the internet of things. Deep Learning for Security and Privacy Preservation in IoT 83–98 (2022).
  • 3.Lakhan, A. et al. Iot workload offloading efficient intelligent transport system in federated acnn integrated cooperated edge-cloud networks. J. Cloud Comput.13, 79 (2024). [Google Scholar]
  • 4.Almutairi, M. & Sheldon, F. T. Iot-cloud integration security: A survey of challenges, solutions, and directions. Electronics14, 1394 (2025). [Google Scholar]
  • 5.Rahman, M. M., Al Shakil, S. & Mustakim, M. R. A survey on intrusion detection system in iot networks. Cyber Secur. Appl.3, 100082 (2025). [Google Scholar]
  • 6.Fiaz, K. et al. A two-phase blockchain-enabled framework for securing internet of medical things systems. Internet Things28, 101335 (2024). [Google Scholar]
  • 7.Cil, A. E., Yildiz, K. & Buldu, A. Detection of ddos attacks with feed forward based deep neural network model. Expert Syst. Appl.169, 114520 (2021). [Google Scholar]
  • 8.Patil, N. V., Krishna, C. R. & Kumar, K. Ssk-ddos: distributed stream processing framework based classification system for ddos attacks. Clust. Comput.25, 1355–1372 (2022). [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 9.Cebeloglu, F. S. & Karakose, M. A cyber security analysis used for unmanned aerial vehicles in the smart city. In 2019 1st International Informatics and Software Engineering Conference (UBMYK), 1–6 (IEEE, 2019).
  • 10.Sreeram, I. & Vuppala, V. P. K. Http flood attack detection in application layer using machine learning metrics and bio inspired bat algorithm. Appl. Comput. Inform.15, 59–66 (2019). [Google Scholar]
  • 11.Raptis, G. E., Katsini, C. & Alexakos, C. Towards automated matching of cyber threat intelligence reports based on cluster analysis in an internet-of-vehicles environment. In 2021 IEEE International Conference on Cyber Security and Resilience (CSR), 366–371 (IEEE, 2021).
  • 12.Kumari, P. & Jain, A. K. A comprehensive study of ddos attacks over iot network and their countermeasures. Comput. Secur.127, 103096 (2023). [Google Scholar]
  • 13.Singh, S., Singh, A. & Goyal, V. An analytical view of dos or ddos attacks for network architecture. In Distributed Intelligent Circuits and Systems 1–27 (World Scientific, 2024). [Google Scholar]
  • 14.Nedyalkov, I. Studying the impact of different tcp dos attacks on the parameters of voip streams. Telecom5, 556–587 (2024). [Google Scholar]
  • 15.Kshirsagar, D. & Kumar, S. An ontology approach for proactive detection of http flood dos attack. Int. J. Syst. Assur. Eng. Manag.14, 840–847 (2023). [Google Scholar]
  • 16.Sudar, K. M. & Nagaraj, P. Tcpflood defender: Tcp syn flood attacks detection in sdn environment using statistical and ensemble machine learning methods. In Software-Defined Network Frameworks 291–308 (CRC Press, 2024). [Google Scholar]
  • 17.Lee, J., Kim, M., Song, W., Kim, Y. & Kim, D. Rescuing quic flows from countermeasures against udp flooding attacks. In Proceedings of the 39th ACM/SIGAPP Symposium on Applied Computing, 1072–1080 (2024).
  • 18.Gelgi, M., Guan, Y., Arunachala, S., Samba Siva Rao, M. & Dragoni, N. Systematic literature review of iot botnet ddos attacks and evaluation of detection techniques. Sensors24, 3571 (2024). [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 19.Dahiya, P. & Bhattacharya, S. Miraibotguard: Federated learning for intelligent defense against mirai threats. In 2024 2nd International Conference on Device Intelligence, Computing and Communication Technologies (DICCT), 1–6 (IEEE, 2024).
  • 20.Breiman, L. Random forests. Mach. Learn.45, 5–32 (2001). [Google Scholar]
  • 21.Friedman, J. H. Stochastic gradient boosting. Comput. Stat. Data Anal.38, 367–378 (2002). [Google Scholar]
  • 22.Frank, E., Trigg, L., Holmes, G. & Witten, I. H. Naive bayes for regression. Mach. Learn.41, 5–25 (2000). [Google Scholar]
  • 23.Gehrke, J. & Ye, N. Decision tree. In The Handbook of Data Mining 3–23 (CRC Press, 2003). [Google Scholar]
  • 24.Peterson, L. E. K-nearest neighbor. Scholarpedia4, 1883 (2009). [Google Scholar]
  • 25.Babu, M. R. & Veena, K. A survey on attack detection methods for iot using machine learning and deep learning. In 2021 3rd International conference on signal processing and communication (ICPSC), 625–630 (IEEE, 2021).
  • 26.Almaraz-Rivera, J. G., Perez-Diaz, J. A. & Cantoral-Ceballos, J. A. Transport and application layer ddos attacks detection to iot devices by using machine learning and deep learning models. Sensors22, 3367 (2022). [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 27.Alzahrani, R. J. & Alzahrani, A. Security analysis of ddos attacks using machine learning algorithms in networks traffic. Electronics10, 2919 (2021). [Google Scholar]
  • 28.Kumar, P., Bagga, H., Netam, B. S. & Uduthalapally, V. Sad-iot: Security analysis of ddos attacks in iot networks. Wirel. Pers. Commun.122, 87–108 (2022). [Google Scholar]
  • 29.Jia, Y., Zhong, F., Alrawais, A., Gong, B. & Cheng, X. Flowguard: An intelligent edge defense mechanism against iot ddos attacks. IEEE Internet Things J.7, 9552–9562 (2020). [Google Scholar]
  • 30.Seifousadati, A., Ghasemshirazi, S. & Fathian, M. A machine learning approach for ddos detection on iot devices. arXiv preprint arXiv:2110.14911 (2021).
  • 31.Becerra-Suarez, F. L., Fernández-Roman, I. & Forero, M. G. Improvement of distributed denial of service attack detection through machine learning and data processing. Mathematics12, 1294 (2024). [Google Scholar]
  • 32.Neto, E. C. P. et al. Ciciot 2023: A real-time dataset and benchmark for large-scale attacks in iot environment. Sensors23, 5941 (2023). [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 33.Abbas, S. et al. Evaluating deep learning variants for cyber-attacks detection and multi-class classification in iot networks. PeerJ Comput. Sci.10, e1793 (2024). [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 34.Jony, A. I. & Arnob, A. K. B. A long short-term memory based approach for detecting cyber attacks in iot using cic-iot2023 dataset. J. Edge Comput.3, 28–42 (2024). [Google Scholar]
  • 35.Wang, Z. et al. A lightweight intrusion detection method for iot based on deep learning and dynamic quantization. PeerJ Comput. Sci.9, e1569 (2023). [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 36.Yaras, S. & Dener, M. Iot-based intrusion detection system using new hybrid deep learning algorithm. Electronics13, 1053 (2024). [Google Scholar]
  • 37.Nkoro, E. C., Nwakanma, C. I., Lee, J.-M. & Kim, D.-S. Detecting cyberthreats in metaverse learning platforms using an explainable dnn. Internet Things25, 101046 (2024). [Google Scholar]
  • 38.Khan, M. M. & Alkhathami, M. Anomaly detection in iot-based healthcare: machine learning for enhanced security. Sci. Rep.14, 5872 (2024). [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 39.Nandanwar, H. & Katarya, R. Deep learning enabled intrusion detection system for industrial iot environment. Expert Syst. Appl.249, 123808 (2024). [Google Scholar]
  • 40.Saheed, Y. K., Misra, S., Chockalingam, S., Abdulganiyu, O. H. & Al-Turjman, F. Modified genetic algorithm and fine-tuned long short-term memory network for intrusion detection in the internet of things networks with edge capabilities. Appl. Soft Comput.115, 111434 (2024). [Google Scholar]
  • 41.Saheed, Y. K., Abdulganiyu, O. H., Misra, S., Al-Turjman, F. & Chukwuere, J. E. Cps-iiot-p2attention: Explainable privacy-preserving with scaled dot-product attention in cyber physical system-industrial iot network. IEEE Access13, 81118–81142 (2025). [Google Scholar]
  • 42.Saheed, Y. K. & Misra, S. Cps-iot-ppdnn: A new explainable privacy preserving dnn for resilient anomaly detection in cyber-physical systems-enabled iot networks. Chaos, Solitons Fractals191, 115939. 10.1016/j.chaos.2024.115939 (2025). [Google Scholar]
  • 43.Yen, S. & Lee, Y. Under-sampling approaches for improving prediction of the minority class in an imbalanced dataset. Lecture notes in control and information sciences344, 731 (2006).
  • 44.Thara, D., PremaSudha, B. & Xiong, F. Auto-detection of epileptic seizure events using deep neural network with different feature scaling techniques. Pattern Recognit. Lett.128, 544–550 (2019). [Google Scholar]
  • 45.Scikit-learn Organization. Standardscaler. (accessed 9 May 2024). https://scikit-learn.org/stable/modules/generated/sklearn.preprocessing.StandardScaler.html (2024).
  • 46.Liu, H. & Motoda, H. Feature Selection for Knowledge Discovery and Data Mining Vol. 454 (Springer, 2012). [Google Scholar]
  • 47.Abdi, H. & Williams, L. J. Principal component analysis. Wiley Interdiscip. Rev. Comput. Stat.2, 433–459 (2010). [Google Scholar]
  • 48.Liu, H. & Setiono, R. Chi2: Feature selection and discretization of numeric attributes. In Proceedings of 7th IEEE international conference on tools with artificial intelligence, 388–391 (IEEE, 1995).
  • 49.Li, J. et al. Feature selection: A data perspective. ACM Comput. Surv. (CSUR)50, 1–45 (2017). [Google Scholar]
  • 50.Jolliffe, I. T. & Cadima, J. Principal component analysis: a review and recent developments. Philos. Trans. R. Soc. A: Math. Phys. Eng. Sci.374, 20150202 (2016). [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 51.Akhiat, Y., Manzali, Y., Chahhou, M. & Zinedine, A. A new noisy random forest based method for feature selection. Cybern. Inf. Technol.21, 10–28 (2021). [Google Scholar]
  • 52.Python Organization. time — time access and conversions. (accessed 9 May 2024). https://docs.python.org/3/library/time.html.
  • 53.Alsharif, E. & Alharby, M. An ensemble machine learning approach for detecting and classifying malware attacks on mobile devices. Arab. J. Sci. Eng.50(5), 1–17 (2025). [Google Scholar]
  • 54.Almotairi, S. et al. Personal data protection model in iomt-blockchain on secured bit-count transmutation data encryption approach. Fusion Pract. Appl.16, 152–170 (2024). [Google Scholar]
  • 55.Almotairi, A., Atawneh, S., Khashan, O. A. & Khafajah, N. M. Enhancing intrusion detection in iot networks using machine learning-based feature selection and ensemble models. Syst. Sci. Control Eng.12, 2321381 (2024). [Google Scholar]

Associated Data

This section collects any data citations, data availability statements, or supplementary materials included in this article.

Data Availability Statement

The datasets are available at https://www.kaggle.com/datasets/mharby/dataset


Articles from Scientific Reports are provided here courtesy of Nature Publishing Group

RESOURCES