Abstract
This work investigates the deployment of Deep Learning (DL) models for network intrusion detection on resource-constrained IoT devices, using the public CICIoT2023 dataset. In particular, we consider the following DL models: Long Short-Term Memory (LSTM), Gated Recurrent Unit (GRU), Recurrent Neural Network (RNN), Convolutional Neural Network (CNN), Temporal Convolutional Network (TCN), Multi-Layer Perceptron (MLP). Bayesian optimization is employed to fine-tune the models’ hyperparameters and ensure reliable performance evaluation across both binary (2-class) and multi-class (8-class, 34-class) intrusion detection. Then, the computational complexity of each DL model is analyzed—in terms of the number of Multiply–ACCumulate operations (MACCs), RAM usage, and inference time—through the STMicroelectronics Cube.AI Analyzer tool, with models being deployed on an STM32H7S78-DK board. To assess the practical deployability of the considered DL models, a trade-off score (balancing classification accuracy and computational efficiency) is introduced: according to this score, our experimental results indicate that MLP and TCN outperform the other models. Furthermore, Post-Training Quantization (PTQ) to 8-bit integer precision is applied, allowing the model size to be reduced by more than with negligible performance degradation. This demonstrates the effectiveness of quantization in optimizing DL models for real-world deployment on resource-constrained IoT devices.
1. Introduction
The Internet of Things (IoT) represents a revolutionary technological paradigm where physical objects—denoted as smart objects and embedded with sensors, software, and connectivity—seamlessly interact with each other and with end-users across heterogeneous communication networks. Therefore, the IoT enables continuous data collection, sharing, and analysis, sustaining innovative concepts such as smart cities, smart agriculture, smart healthcare, and smart homes [1]. In fact, the rapid expansion of IoT is largely driven by advancements in short- (e.g., BLE [2] and Wi-Fi [3]) and long-range wireless networks (e.g., NB-IoT and LoRaWAN [4]), edge computing, Software-Defined Networking (SDN), and sensor innovation [5]. As an example, Cisco foresees that, by 2030, the number of IoT-connected devices will be more than 500 B, owing to the increasing global adoption of IoT technologies across a variety of industries and sectors [6,7].
Nevertheless, this rapid growth also brings significant challenges, in particular with regard to scalability, security, privacy, and data management. As the number of connected devices increases, the detection of unauthorized access and malicious activity within IoT networks becomes an urgent concern [8,9], because the widespread deployment of IoT devices across diverse sectors makes them attractive targets for malicious actors, exposing these devices to a wide range of security threats and vulnerabilities [10].
To this end, security threats on IoT networks vary by network type—literature studies show that approximately of IoT devices exhibit security vulnerabilities, with an average of 25 faults detected per device [11]—while common vulnerabilities may include the following [12]:
- Insecure communication: data transmission by IoT devices may occur without adequate encryption, enabling attackers to intercept or manipulate communication [13].
- Lack of device identity management: the absence of robust Identity Management mechanisms complicates the verification of a device’s authenticity, creating potential security gaps in IoT networks.
- Insufficient authentication and authorization: many IoT devices lack strong authentication and authorization protocols, allowing unauthorized individuals to access sensitive data or control devices.
To mitigate these risks, Intrusion Detection Systems (IDSs) are recognized as essential components of IoT security infrastructures, monitoring network traffic, detecting potential security threats, and preventing attacks, thereby enhancing the overall security of IoT systems [14]. Therefore, given the growing complexity and scale of IoT networks, the integration of IDSs is crucial to protect against increasingly sophisticated threats targeting connected IoT devices. Simultaneously, applying AI-based models—in particular, Machine Learning (ML) and Deep Learning (DL)—can significantly enhance the performance of IDSs, since these models improve the accuracy of detecting and classifying IoT attacks due to their ability to extract patterns of input data.
In this paper, the performance of different ML and DL models—namely, Simple Recurrent Neural Network (SimpleRNN); Long Short-Term Memory (LSTM); Gated Recurrent Unit (GRU); Multi-Layer Perceptron (MLP); one-dimensional Convolutional Neural Network (1D-CNN)—on a publicly available dataset, denoted as CICIoT2023 [15] and including network traffic traces comprising different attack classes—namely, Denial of Service (DoS); Distributed DoS (DDoS); Spoofing; Web; Brute Force; Recon; Mirai botnet—is detailed and discussed in terms of accuracy and computational complexity. Moreover, Post-Training Quantization (PTQ) is considered for compressing pre-trained models for efficient deployment on constrained IoT devices (e.g., STM32H7S78-DK board [16]).
The main contributions of the paper can be summarized as follows:
- Resource-constrained IDS design for IoT nodes: We propose an AI-based IDS specifically tailored for deployment on resource-constrained IoT devices, further validated on a STM32H7S78-DK board to address realistic embedded constraints.
- Comprehensive evaluation on a large-scale, highly imbalanced IoT dataset: The considered IDS is evaluated using the CICIoT2023 dataset, comprising over 46 M network traffic records collected from 105 IoT devices and featuring 34 distinct attack types (including DoS, DDoS, spoofing, brute-force, Mirai botnet attacks, etc.).
- Systematic handling of class imbalance: A hybrid data balancing strategy, combining random undersampling and random oversampling, is introduced to mitigate the severe imbalance between benign and malicious traffic traces, improving model generalization while avoiding excessive training time and overfitting.
- Multi-granularity attack classification analysis: Three dataset configurations—namely, binary (2-class), grouped (8-class), and fine-grained (34-class)—are considered, enabling a thorough analysis of the trade-offs between detection accuracy, computational cost, and deployability on a constrained hardware (HW).
- Feature selection driven by statistical relevance: A one-way ANOVA-based feature ranking is employed to identify and retain the most important features, reducing input dimensionality and computational complexity while preserving essential attack-related correlations.
- Bayesian optimization for HW-aware hyperparameter tuning: The performance of DL models is enhanced through BO, allowing an efficient exploration of the hyperparameter space while balancing accuracy and computational cost.
- End-to-end HW-aware evaluation and deployment: Models are evaluated in terms of Multiply–Accumulate operations (MACCs), RAM usage, and inference latency using the STM Cube.AI Analyzer, ensuring practical deployability on a constrained IoT board.
- Quantization-enabled efficiency enhancement: In order to reduce computational complexity and memory footprint, 8-bit integer quantization of weights and activations is applied, improving inference efficiency while maintaining competitive detection accuracy on the STM32H7S78-DK board.
The remainder of the paper is organized as follows: In Section 2, an overview of related works is given. Section 3 discusses a general representation of an IoT system, together with an overview of common vulnerabilities. Section 4 introduces the chosen dataset, the proposed data analysis techniques, and the considered ML and DL models. Section 5 presents the experimental performance results and the PTQ technique. Finally, in Section 6 we draw our conclusions.
2. Related Works
In order to provide some background on detection and classification of network intrusions and cyber-attacks targeting IoT architectures, in the following we analyze relevant state-of-the-art studies employing ML and DL models and associated evaluation metrics, providing insights into each model’s effectiveness in accurately classifying attacks within the IoT domain. For the sake of clarity and completeness, a comparison between these literature studies presented in the remainder of this section and the model proposed in this paper, along with its main research axes, is shown in Table 1.
Table 1.
Comparison of related studies and the proposed model across key evaluation criteria.
2.1. ML/DL Models for IoT NIDS on CICIoT2023
In [17], the performance of several DL models—namely, Deep Neural Networks (DNNs) [25], CNNs, and RNNs—is discussed considering their application to a publicly available dataset (namely, CICIoT2023 [15]). The experimental results show that RNNs return the best performance among all the considered models—with an accuracy of , a precision of , a recall of , and an F1-score of . This reflects the effectiveness of RNNs in detecting both normal and malicious packets, outperforming the other evaluated DL models.
In [15], the authors evaluate five different ML methods—namely, Logistic Regression, Perceptron, AdaBoost, Random Forest (RF), and DNN—across three classification tasks—namely, binary, 8-class, and 34-class classification. Among them, RF demonstrates the highest performance with recall, precision, and F1-score for the 34-class classification, and recall, precision, and F1-score for the 8-class classification. Finally, RF excels in binary classification with recall, precision, and F1-score, demonstrating its robust performance across varying classification complexities.
In [18], a Federated Learning (FL)-based IDS, aiming at enhancing cybersecurity in IoT networks, is proposed, with FL achieving a accuracy in detecting binary attacks and showcasing the potential of FL in distributed environments where data privacy is essential. Then, class imbalance in the training dataset—a common issue in intrusion detection tasks—is addressed applying the Synthetic Minority Oversampling Technique (SMOTE) [26].
A hybrid model, combining LSTM networks with XGBoost to improve the detection of Mirai botnet attacks, is proposed in [19], benchmarking this approach against alternative models—including DNNs, CNNs, standalone LSTM, and a hybrid RF-LSTM model. Obtained experimental results show that LSTM-XGBoost outperforms the others, in detail achieving a accuracy and precision, recall, and F1-score, thus highlighting its ability to detect complex botnet patterns with high precision and reliability. Additionally, Mirai detection is explored in [20], where a DNN-Light Gradient Boosting Machine (LGBM) hybrid model achieves strong results with accuracy, precision, recall, and F1-score up to . This performance significantly exceeds that of other models, such as Support Vector Machine (SVM), LGBM, and Stochastic Gradient Descent (SGD), which reach , , and accuracy scores, respectively.
In [21], a CNN-based model is proposed for attack detection, featuring a MB model size and a 6 s inference time. This CNN model outperforms alternative models (DNN and LSTM) for binary classification, showing precision, recall, and F1-score equal to , , and , respectively.
A DL-based DDoS detection mechanism is introduced in [22] using a modified GRU (mGRU) model optimized for low computational complexity. In detail, mGRU guarantees a very good performance, achieving precision, recall, and F1-score. Nevertheless, its efficiency is limited by a high execution time (equal to s), indicating its inapplicability in real-time applications.
Finally, binary and multi-class detection of network attacks using classifiers such as SVM, AdaBoost, Decision Tree (DT), and RF are discussed in [23]. In detail, AdaBoost delivers strong results in binary classification, returning a recall, a precision, and a F1-score. However, the larger the number of classes, the more significant the performance degradation: The 8-class classification returns recall, precision, and F1-score drops to , , and , respectively, while the 34-class classification reflects recall, precision, and F1-score.
2.2. TinyML for Intrusion Detection
In [27], the authors investigate the efficiency of TinyML for IoT security by quantizing a two-layer LSTM model (with 64 and 32 units) into a TinyLSTM using TensorFlow Lite on the CICEVSE2024 dataset [28]. As a result, the quantized model achieves an F1-score of up to , while reducing the baseline model size of LSTM by , the inference time by , and the inference memory by .
Authors in [29] demonstrate the critical trade-offs in deploying TinyML for IoT cybersecurity, showing that while dynamic and static 16-bit floating point quantization techniques effectively balance performance (preserving over accuracy on the USTC-TFC2016 dataset [30] while halving model sizes and accelerating inference), more aggressive 8-bit integer quantization achieves maximum compression (up to size reduction) at the cost, however, of severe accuracy degradation. On the other hand, PQT maintains a high detection rate but sacrifices latency and efficiency gains, which are essential for real-time edge deployment.
In [24], a HW-aware intrusion detection framework jointly optimizing accuracy and deployability by enforcing strict flash, RAM, and computing constraints is presented. In detail, the authors combine HW-constrained grid search for tree-based models (LightGBM [31], XGBoost, and RF) with HW-aware neural architecture search for compact 1D-CNNs. The proposed approach is validated on the Edge-IIoTset dataset [32] with an on-device evaluation on an edge gateway–class platform. Notably, all models are evaluated using native inference formats, without applying quantization.
Finally, in [33], a TinyML model for IoT attack detection, combining a lightweight DT and a small NN with a Logistic Regression meta-learner, is deployed on an Arduino Nano 33 BLE Sense. The model achieves exceptional performance on the ToN-IoT dataset [34], returning accuracy, a F1-score, and a near-perfect false positive rate equal to , while operating with ultra-low latency ( ms) and power consumption ( mW).
3. Vulnerabilities in IoT Architectures
3.1. IoT Layers
Before analyzing in detail the suitability of the considered AI models in supporting IDS in identifying and classifying IoT network attacks, it is useful to discuss the general architecture of an IoT system, as shown in Figure 1. In detail, an IoT node can be seen as composed of four layers, each featuring the following specific responsibilities in contributing to its seamless integration with other devices.
Figure 1.
General mapping of an IoT architecture.
- Perception Layer: This layer, also known as sensing layer, corresponds to the lowest layer in an IoT architecture and consists of physical devices—such as sensors, actuators, and smart appliances—directly interacting with the environment to collect and process real-time data.
- Network Layer Inside an IoT domain, this layer manages the connectivity and the data transmission between IoT devices, gateways, and the higher layers, thus exploiting an ensemble of communication protocols (e.g., Zigbee, BLE, IEEE 802.11 Wi-Fi, LTE/5G cellular, LoRaWAN) to support seamless information transfer across the IoT ecosystem.
- Middleware Layer: This layer acts as an intermediate layer between network and application layers and provides essential services such as data filtering, aggregation, and protocol translation, thus ensuring interoperability and easing efficient management and deployment of IoT applications.
- Application Layer: This layer enables specific use cases by delivering services and insights to end-users and additional applications, in detail directly interfacing with the users and providing an ecosystem for the deployment of IoT applications (e.g., smart homes, healthcare, and industrial automation).
3.2. IoT Security Vulnerabilities
In the following, a brief discussion on well-known vulnerabilities of IoT systems is provided from different perspectives.
3.2.1. Active and Passive Attacks
Knowing that cyber-attacks affecting IoT networks can differ with respect to the specific targeted network, the following first classification can focus on the type of actor conducting the attack, namely active or passive:
- Active attack: it refers to a type of security attack wherein the attacker engages in direct communication with the intended target system or network. This attack involves the deliberate alteration or disruption of a network’s operations through the injection of malicious traffic or the execution of unauthorized commands.
- Passive attack: it is classified as a security attack wherein the attacker establishes an indirect connection with the target network and observes the communication occurring therein. In this case, an assailant would observe, intercept, or surreptitiously listen to data transfers without making any modifications or exerting any influence over the information, thus primarily aiming to illegally obtain access to sensitive or secret data or information without raising suspicion or detection.
For completeness, in Section 3.2.2, Section 3.2.3, Section 3.2.4 and Section 3.2.5, we delve into attacks specific for each IoT layer detailed in Section 3.1, namely: perception layer, network layer, middleware layer, application layer, respectively. A comprehensive summary of these attacks is given in Table 2.
Table 2.
Network attacks categorized along their main targeted architecture layer.
3.2.2. Attacks to the Perception Layer
The main cyber-challenges the IoT perception layer might suffer for can be summarized as follows:
- Tampering: This attack aims at creating a direct physical connection with the IoT device and controlling its operational tasks, then involving HW manipulation (e.g., establishing connections with ports or interfaces on the device) or modifications to its settings [35].
- DoS: This attack foresees an attacker flooding the IoT sensors with an extraordinary volume of traffic or requests, leading to sensor overload, data loss, and service disruption [36].
- Jamming: This corresponds to a deliberate attack strategy disrupting or obstructing wireless communication signals, thus preventing information transmission [37].
- Fake node injection: This is one of the most severe attacks for an IoT device, since it features a malicious node to be injected into an IoT network to gain access to such network, then spreading misleading information across the network itself. Consequently, unauthorized nodes will enable an attacker to access the entire network.
- Sleep deprivation attack: This attack aims at affecting the energy source of (often battery-powered) sensor nodes. In fact, this attack keeps IoT nodes active by altering their sleep cycle—usually employed to minimize their energy consumption—and, consequently, their functionalities, quickly depleting and disrupting the overall IoT network [38].
3.2.3. Attacks to the Network Layer
The main cyber-challenges affecting the network layer can be summarized as follows:
- Routing attacks: This attack focuses on altering the routes established in the IoT network, thus aiming at transmitting data and messages to malicious intermediary nodes, or interfering with the network’s data transmission process.
- IP Spoofing: This attack features a malicious node posing as another device or changing the origin IP address inside the packets flowing inside the network itself to tamper with the IoT network and gain unauthorized access.
- Sybil attack: This attack foresees that the attacker will try to access the network by using a phony identity, in turn also activating fake nodes as normal devices within the network and impairing the network’s operation by creating incorrect and/or large amounts of information [39].
- Traffic analysis attack: This attack targets to analyze and intercept data packets exchanged intra IoT nodes, as well as between IoT devices and remote entities, in order to extract valuable information.
3.2.4. Attacks to the Middleware Layer
The main cyber-challenges the middleware layer might suffer from can be summarized as follows:
- Man-in-the-Middle (MITM) attack: This attack foresees the ability of an unauthorized entity to intercept (and potentially manipulate) the communication occurring between IoT devices.
- Malwares: Threats like viruses, Trojan horses, and malware represent a (sub-)set of tools used by attackers to access (in an unauthorized way) undisclosed and private information, with data theft happening by exploiting executable codes (often developed in machine language).
- DoS attack: This class of intrusion foresees an attacker overwhelming the IoT network with a heavy amount of requests, thus resulting in the network’s congestion due to excessive traffic. As a result, IoT devices deplete energy and resources, thus preventing the user from accessing his/her data.
3.2.5. Attacks to the Application Layer
Finally, the main cyber-challenges affecting the application layer can be summarized as follows:
- Cross-Site Scripting (XSS): In this type of attack, the attacker adds harmful scripts to be run (at run-time) into the IoT node’s command-line or Web interfaces, thus compromising its responsiveness as well as the user’s protected information.
- SQL injection: This attack occurs when the attacker succeeds in manipulating the input parameters used in an SQL query and in executing such malicious SQL queries into the target database.
- Sniffing attack: This attack involves the ability of the attacker to successfully collect and monitor the data traffic between IoT devices and the services at the application layer, thus handling and controlling them without any authorized permission.
4. Proposed Model
In the following, the proposed IDS, designed to accurately identify and classify IoT attacks by means of AI models suitable for deployment on constrained IoT nodes, is discussed. The proposed models (detailed in Section 4.3) demonstrate their ability to discover intricate interconnections among features in the considered dataset. For completeness, as further outlined in Section 4.1.3, we selectively omit the features that do not significantly contribute to the classification process, thus obtaining an efficient training process execution by diminishing the complexity without sacrificing essential correlations.
4.1. Dataset
In this study, the CICIoT2023 dataset [15] comprising records collected from 105 IoT devices, has been identified as the reference dataset. More in detail, the traffic traces include benign records and malicious records and encompass 33 types of cyber-attacks, including DoS, DDoS, spoofing, brute force, and Mirai Botnet attacks. For completeness, the extracted features and their corresponding descriptions are listed in Table 3.
Table 3.
Features contained in the CICIoT2023 dataset.
As detailed in Table 4, three variations in the dataset have been considered in order to conduct a comprehensive evaluation: (i) a 34-class () dataset retaining all the attack types; (ii) an 8-class () dataset, obtained by grouping together similar classes of attack; and (iii) a binary (2-class, ) dataset, obtained by splitting the network attacks into benign and malicious predominant classes. As a first remark, this allows for a thorough analysis of the performance returned by the proposed IDS exploiting different DL models. Then, as a second remark, reducing the number of classes enhances the approach applicability, decreases the training time, and lowers memory and computational requirements.
Table 4.
Classification of network attacks and their occurrences, divided by their major class.
Looking at the distributions of the considered attack classes detailed in Table 4, it should be highlighted that the majority of the occurrences are related to DoS and DDos attacks, thus leading to an a priori imbalanced dataset. This aspect has to be carefully taken into account when discussing the performance of the AI models embedded in an IDS. Hence, for completeness, the class distributions for 2-, 8-, and 34-class configurations are listed in Table 5, Table 6, and Table 7, respectively.
Table 5.
Class distribution for the binary () classification configuration.
Table 6.
Class distribution for the 8-class () classification configuration.
Table 7.
Class distribution for the 34-class () classification configuration.
Finally, even for clarity and completeness, the overall approach adopted to refine the dataset—addressing its imbalance and complexity—and to train the chosen AI models is shown in Figure 2. Then, each AI algorithm is subsequently evaluated, exploiting the set of metrics detailed in Section 4.4.
Figure 2.
Data workflow and model definition and evaluation.
4.1.1. Data Balancing
In order to address the imbalance of the dataset (as mentioned at the beginning of Section 4.1) and mitigate the overfitting effect, the target’s sample size has been defined as based on the data labeled as benign and representing normal network flows. Furthermore, a Random UnderSampler [40] has been applied in order to reduce the majority classes to match the target sample number—equal to —and to ensure a more balanced class distribution without introducing any bias toward dominant categories. Then, a Random OverSampler [26] has been applied to the minority classes to increase their sample size, thus aligning them with the target. This combined approach enhances the ability of the model to generalize across both benign and malicious instances, thus improving the performance of the IDS while reducing the risk of false positives. Moreover, balancing the dataset before training prevents the model from learning the dominant class distribution, thus ensuring a more comprehensive understanding of all categories. The combined application of these sampling techniques addresses the challenge of oversampling a heavily imbalanced dataset, which may lead to extremely long training times and the risk of generating non-representative samples, possibly causing a degradation in the model’s ability to generalize.
4.1.2. Data Normalization
Since a normalization stage is essential for ensuring all features uniformly contribute to the model (preventing any single variable from dominating the learning process), they are measured on the chosen CICIoT2023 dataset on different scales. Unfortunately, this may negatively affect the models’ performance. Hence, using a scaler is crucial to mitigate the impact of these varying scales, leading to a fair consideration of each feature during model training.
To this end, a PowerTransformer [41], which not only normalizes the features but also stabilizes the variance and makes the data distribution more Gaussian-like, has been employed. This transformation is particularly beneficial, as the model’s convergence speed increases and its overall performance improves, thus allowing more effective learning and generalization. For each anomaly detection configuration (namely, 2, 8, and 34 classes), the dataset was partitioned into three subsets: for training, for validation, and for testing.
4.1.3. Feature Selection
Finally, particular attention has been dedicated to the quality of the dataset. Knowing that quality plays a critical role in the performance of ML/DL models, since datasets often contain features with low variance that contribute little to the model’s ability to capture underlying patterns, various feature selection techniques can be considered to retain only the most informative features.
Once the features are standardized to a uniform scale, different methods can be applied to rank their relevance. In this study, the one-way ANOVA approach [42] is employed to assess and rank each feature based on its significance, since ANOVA quantifies the extent to which a feature differentiates between the means of distinct classes, assigning higher scores to features exhibiting higher discriminatory capabilities.
Moreover, to further refine the selection, a threshold to identify a significant drop in feature importance between consecutive features has been applied. In particular, a drop in the ANOVA score between two adjacent features has been set as the cut-off to distinguish highly relevant features from those with a limited impact. Nevertheless, the selection of a minimum number of features is generated.
Overall, this approach was applied to all three versions of the dataset (2-class, 8-class, and 34-class), each characterized by distinct distributions of benign instances. Consequently, feature selection was performed separately for each version, with many features consistently identified as top contributors across all three datasets. As shown in Figure 3, increasing the number of classes requires retaining additional features to effectively correlate them with specific classes. This impacts both the size and complexity of the trained models, as a larger feature set can potentially result in a simpler model for classifying the attack.
Figure 3.
One-way ANOVA feature selection: number of selected features per type of dataset.
In particular, the following features (from the list in Table 3) have been selected for each dataset:
- 2-class dataset: rst count, urg count, Variance, Flow duration, Std, Radius, Covariance, Header Length, Max, ack flag number, AVG, Magnitude, HTTPS, Tot size.
- 8-class dataset: Variance, RST count, URG count, Std, Radius, Magnitude, AVG, Tot size, Max, Min, Covariance, Protocol type, Flow duration, Header Length, Tot sum, ack flag number.
- 34-class dataset: ICMP, fin flag number, Protocol Type, Variance, Header Length, syn flag number, rst count, Magnitude, AVG, Radius, Std, urg count, Min, Tot size, Max, Covariance, rst flag number, syn count, flow duration, TCP, psh flag number, Tot sum, UDP, fin count, ack flag number, ack count.
4.2. Hyperparammeter Optimization
With specific regard to DL models, it is well-known that hyperparameters, although remaining fixed during the training process, still play a crucial role in determining the model’s architecture and the overall performance efficiency. Consequently, an automatic tuning of categorical, discrete, and continuous hyperparameters is accomplished through a Hyperparammeter Optimization (HPO) task. More in detail, the primary goal of HPO is to identify the optimal hyperparameters’ set by minimizing the chosen performance metric, i.e., as
where represents the optimal hyperparameters’ set, corresponds to the model’s performance metric evaluated on a validation set , and denotes the hyperparameter search space, i.e., the set of all possible combinations of hyperparameter values.
Moreover, we consider a BO for hyperparameter tuning: this effectively enhances the performance of the evaluated DL models by systematically exploring the hyperparameters’ space and balancing both exploration and exploitation. On the operational side, the KerasTuner library [43] has been employed to effectively implement BO. For the sake of completeness, Table 8 presents the optimized parameters along with their defined ranges in the search space.
Table 8.
Hyperparameters considered for the model tuning, along with their defined ranges.
4.3. Model Training
In the following, we present the DL models that have been evaluated in this study, highlighting their strengths and limitations. For clarity and completeness, their shared general architecture is outlined in Figure 4.
Figure 4.
General architecture of the considered DL models.
4.3.1. SimpleRNN
SimpleRNN’s cells represent the most lightweight RNN layer, with a SimpleRNN’s layer featuring m hidden units, n features, and o outputs, taking an input at time t and processing it to produce an input activation equal to
where is the input weight matrix; and is the bias vector.
Then, SimpleRNN updates the hidden state by using the previous state and the activation function as follows:
where is the hidden weight matrix; and is the hidden state bias vector.
Finally, the output is calculated as
where is the hidden-to-output weight matrix; and is the output bias vector. Note that, in our particular case, and correspond to the REctified Linear Unit (ReLU) activation function [44], while corresponds to the softmax function [45].
Moreover, unlike traditional FeedForward Networks (FFNs) [46], RNNs have connections forming cycles, allowing them to maintain hidden state information and capture temporal dependencies. RNNs are employed in tasks like Natural Language Processing (NLP), speech recognition, and time-series prediction. However, they face challenges like the vanishing gradient problem, which limits their ability to capture long-term dependencies [47].
4.3.2. Long Short-Term Memory (LSTM)
LSTM networks address the vanishing gradient problem afflicting the RNN models. In detail, LSTMs use memory cells with gates to regulate information flow, allowing them to capture and remember long-term dependencies in sequential data. An LSTM architecture typically consists of memory cells along with input, forget, and output gates. These components commonly use the sigmoid function () as the recurrent activation and the hyperbolic tangent function (tanh) as the standard activation—in our implementation, the ReLU function is instead used as activation function. The architecture is based on the following layers:
where is the input gate state; is the forget gate state; is the output gate state; is the cell state using the cell update ; and is the hidden state update. Input matrices , , and , associated with the input, have dimensions ; hidden matrices , , and , associated with the previous hidden state, have dimensions .
Finally, it is noteworthy to highlight that LSTMs excel in tasks involving time-series data, NLP, and speech recognition, making them suitable for applications requiring the modeling of intricate temporal relationships and handling of sequential patterns. Therefore, an adequate data processing is essential to prevent overfitting and to minimize computational complexity when using these models. Despite their effectiveness, they are susceptible to exploding gradients, particularly in regression problems [48].
4.3.3. Gated Recurrent Unit (GRU) and Bidirectional GRU
Similarly to LSTMs, GRUs offer an efficient solution for sequence modeling, exhibiting similar limitations to LSTM but benefiting from a simplified architecture, which makes them—in terms of both efficiency and complexity— more suitable to edge computing [49]. The difference between GRU and LSTM lies on the cells type, which involve the following operations:
where is the update gate; is the reset gate; , represent the candidate hidden state and hidden state update, respectively. Input matrices , and , associated with the input layer, have dimensions ; hidden matrices , and , associated with the previous hidden state, have dimensions .
4.3.4. Multi-Layer Perceptron (MLP)
MLP is the simplest FFN, composed of multiple neurons layers. Then, being trained using backpropagation, MLPs are versatile and employed in various applications, such as classification and regression tasks [50]. The architecture is based on the following layers:
where is the input weight matrix; is the input bias vector; is the hidden weight matrix; is the hidden bias vector, with ; is the output weight matrix; is the output bias vector.
4.3.5. 1-Dimensional CNN (1D-CNN)
CNNs are DL architectures designed for visual data processing, being highly effective for image data thanks to their ability in capturing spatial hierarchies. However, they can be used also for sequence classification by transforming data sequences using convolutional operations. Unfortunately, CNNs demand a high computational power and may impose some limitations on the time-series data in order to work properly [51]. For clarity, a 1D CNN can be analytically described as
where denotes the pre-activation feature map obtained by convolving the input from the previous layer , with the weight matrix (or filter tensor) via the convolution operator ⊛, and adding the bias vector ; is the temporal length of the input; is the number of input channels; is the number of convolutional filters; is the filter size, for layer . The activated feature map is given by , which is obtained by applying a non-linear activation function (e.g., ReLU, sigmoid, tanh) to . The pooled feature map is where the max-pooling operator selects, for each channel, the maximum value within each pooling window , according to , thereby reducing the temporal resolution from to . The flattened representation is obtained by applying the vectorization operator, denoted as , that re-arranges all the elements of into a one-dimensional vector. Finally, is the activated output of the fully connected layer, where corresponds to the number of neurons in the layer.
4.3.6. Temporal Convolutional Network (TCN)
TCN is a particular 1D-CNN-based DL model proposed for processing sequential data and featuring three key features: (i) Causal Convolutions, preventing information leakage from future to past data and ensuring that predictions are made only on the basis of current and past data and are not influenced by future information; (ii) Dilated Convolutions, allowing the model to capture long-range temporal dependencies in the data and improving its ability to extract features from sequences; (iii) Flexible Sequence Length Handling, enabling TCN to process sequential data with any length and mapping them to output sequences with the same length [52].
4.4. Evaluation Metrics
In order to assess the performance of the chosen DL models on the selected dataset for the IDS of interest, the following evaluation metrics have been employed.
4.4.1. Accuracy
Accuracy (denoted as ) measures the ratio between the number of correctly predicted instances and the total number of instances. It can be expressed as
where TP, TN, FP, and FN represent the numbers of true positives, true negatives, false positives, and false negatives, respectively. The accuracy ranges from 0 (with none of the instances being correctly classified) to 1 (with all instances being correctly classified). Although is an indicator of the overall model performance, it may be misleading in the case of imbalanced datasets.
4.4.2. Precision
Precision (denoted as ) indicates the ratio between the number of correctly predicted positive cases and the total number of positives. It can be expressed as
The precision ranges from 0 (worst case) to 1 (best case). Consequently, a high precision is associated with a low false positive rate, making it critical in applications where false positives are critical.
4.4.3. Recall
Recall (denoted as and also as sensitivity) measures how effectively the model allows to detect truly positive instances. It can be defined as the ratio between the number of true positives and the sum between the number of true positives and false negatives (i.e., the number of all positives):
The recall ranges from 0 (worst case) to 1 (best case). Therefore, a high recall is essential when missing positive cases is detrimental, such as in medical diagnoses or intrusions detection.
4.4.4. F1-Score
The F1-Score (denoted as ) balances precision and recall as follows:
The F1-Score ranges from 0 (if the precision or the recall is 0) to 1 (indicating perfect precision and recall). It is useful especially for imbalanced datasets, as it simultaneously takes into account both false positives and false negatives.
4.4.5. Matthews Correlation Coefficient (MCC)
The MCC is defined as follows:
Unlike the F1-Score, the MCC offers a more balanced perspective on the performance by incorporating all confusion matrix elements, with values ranging from (no prediction at all) to (perfect prediction).
Unlike accuracy, the MCC is more robust in the case of imbalanced datasets.
4.4.6. Cohen’s Kappa Coefficient
The Cohen’s Kappa Coefficient [53] (denoted as ) is a statistical measure quantifying the agreement between predicted and actual labels, while adjusting for agreement occurring by chance. It is defined as follows:
Unlike accuracy, provides a more reliable evaluation in the presence of class imbalance. In fact, values range from (complete disagreement) to (perfect agreement), where 0 indicates a random agreement. In other words, the best case is with close to 1.
4.4.7. Receiver Operating Characteristic (ROC) Curve and Area Under Curve (AUC)
The ROC curve is a function of a threshold x: more precisely, it returns the accuracy of a binary classifier deciding on the basis of the threshold x. It corresponds to the ratio between true positives and false positives, namely . The AUC can be expressed as follows:
where is the ROC curve. The AUC represents the model’s capability to distinguish between classes. In fact, a perfect classifier has an AUC equal to 1, while an AUC equal to denotes a limited discrimination ability.
4.5. Model Complexity
In the following, the computational complexity of the considered models is evaluated in terms of three metrics, namely: (i) Multiply–ACCumulate operations (MACCs), (ii) RAM usage, and (iii) inference time. The evaluation has been conducted through the STMicroelectronics Cube.AI Analyzer tool [16], a cloud-based platform designed to assess the performance of ML/DL models on resource-constrained devices, with 32-bit floating point (FP32) models being deployed on a STM32H7S78-DK board [16] featuring a 600 MHz ARM Cortex-M7 microcontroller, 620 KB internal memory, and 16 MB external RAM.
The obtained experimental results, shown in Figure 5 and detailed in Table 9 for clarity and completeness, indicate LSTM as the model which has the highest computational demand and requires substantially more MACCs and RAM than the other algorithms. In contrast, TCN and MLP exhibit the lowest average computational complexities, with TCN achieving a reduction in the inference time (if compared to LSTM) and using approximately less RAM than GRU. Similarly, MLP reduces the number of MACCs by in comparison to LSTM. This makes both TCN and MLP suitable for deployment on resource-constrained devices, where computational efficiency is fundamental.
Figure 5.
Comparison, in terms of number of MACCs, RAM usage, and inference time, between the considered FP32 ML and DL models.
Table 9.
Experimental results related to the computational complexity returned by the considered FP32 DL models.
Finally, it should be highlighted that the considered DL models have been evaluated not only on the basis of their accuracy in detecting several types of attacks, but also considering their deployability according to multiple computational metrics. To this end, given the challenges of deploying complex AI models on resource-constrained devices, an 8-bit integer (INT8) quantization of activations and weights has been applied to further reduce the computational complexity and enhance the efficiency. A detailed discussion of these quantization techniques and their impact on the performance is given in Section 5.2.
5. Results
In order to present the findings of the proposed experimental analysis, detailing the performance of each considered DL model discussed in Section 4.3, we first analyze each model’s ability to accurately classify network traffic, distinguishing between benign and malicious network activities. Then, we examine the models’ performance across different classes and levels of complexity, looking for the optimal configuration suitable for real-time IoT security applications. We recall the following:
- The selected performance metrics are: accuracy , precision , recall , F1-Score , MCC , and Cohen’s Kappa Coefficient .
- The selected complexity evaluation metrics are: number of MACCs, RAM usage, and inference time.
5.1. Network Traffic Classification Performance
As shown in Table 10, LSTM achieves the highest performance in the context of 2-class () anomaly detection, providing the highest accuracy () and showing high values of the other evaluation metrics. Instead, as shown in Table 11, LSTM still demonstrates slightly better results in the context of 8-class () anomaly detection, outperforming the other models in terms of accuracy, precision, recall, F1-score, Cohen’s Kappa Coefficient, and MCC. Finally, as detailed in Table 12, considering the more complex 34-class () anomaly detection task, MLP emerges as the top-performing model, achieving the highest accuracy, F1-score, Cohen’s Kappa Coefficient, MCC, and recall. Nevertheless, the differences (in terms of performance) returned by the models are minimal, showing that no single model consistently dominates across all the tasks. Therefore, the trade-off between computational efficiency and complexity should guide the model’s selection, in particular with regard to applications requiring a deployment on resource-constrained devices or real-time processing environments.
Table 10.
Performance of the considered FP32 DL models in the 2-class () anomaly detection.
Table 11.
Performance of the considered FP32 DL models in the 8-class () anomaly detection.
Table 12.
Performance of the considered FP32 DL models in the 34-class () anomaly detection.
Then, in order to check the validity of the results not only on the basis of overall metrics, but also at class level, confusion matrices returned by 2-, 8-, and 34-class configurations, together with the mapping between attack classes and their corresponding numerical labels, are detailed in Appendix A.
5.2. Post-Training Quantization (PTQ)
Since (as mentioned in Section 4) it is of interest to verify the deployability of the considered DL models on resource-constrained IoT devices, the application of a PTQ technique emerges as a highly effective mechanism to reduce the computational complexity and enhance the efficiency. In detail, PTQ specifically focuses on compressing pre-trained models for efficient deployment on tiny IoT devices by converting models’ weights from FP32 values to INT8 values, thus significantly reducing both model size and memory footprint and enhancing inference efficiency without requiring a re-training. On the operational side, we employ both Keras and TensorFlow Lite (TFlite) libraries, with PTQ compressing and quantizing the Keras model by converting it to the TFLite format, which, in turn, corresponds to a lightweight data representation useful for deploying ML and DL models on resource-constrained embedded devices [54].
After applying PTQ on the considered AI models, the obtained results are shown in Figure 6, where an average model size’s reduction of , with an average accuracy drop of only across all considered anomaly detection classes, is shown. This highlights the significance of quantization to optimize resource utilization and energy efficiency in constrained devices. In fact, quantizing CNNs to an 8-bit representation usually results in a slight performance degradation with the benefit of a significant memory utilization reduction [55].
Figure 6.
Comparison of the considered DL models, in terms of model size and accuracy, using both Keras and TensorFlow Lite, averaged across all dataset classes.
5.3. Accuracy-Computational Complexity Trade-Off
In order to simultaneously evaluate both accuracy and computational complexity of the considered DL models, we define a new trade-off score, denoted as , to provide a balanced assessment by considering normalized accuracy alongside computational complexity (including the number of MACCs, RAM usage, and execution time) [56]. In the following, we summarize the steps required to calculate . We remind you that is an effective evaluation metric in relative terms, i.e., it allows you to fairly compare a set of DL models among themselves. In other words, does not represent an “absolute” performance metric of a single DL model.
5.3.1. Metrics Normalization
All the considered complexity metrics are normalized to the range using the following min–max scaling strategy:
where corresponds to the considered complexity metric (namely: number of MACCs, RAM usage, inference time, respectively); represents the original value of the k-th complexity metric; and correspond to the minimum and maximum values of across all considered DL models; is the normalized value of the k-th complexity metric.
5.3.2. Efficiency Score Computation
In order to represent the computational complexity of each considered model, we introduce an efficiency score, denoted as , defined as the following weighted average of the normalized complexity metrics (defined in Section 5.3.1):
where , , and represent the weights assigned to each complexity metric, respectively. In order to avoid a biased performance analysis, we assign the same weight to all considered complexity metrics, i.e., we set .
5.3.3. Trade-Off Score
Finally, the trade-off score , balancing the ratio between normalized accuracy and efficiency score , is defined as follows:
According to the definition in (12), a high value of is representative of a better performance jointly considering accuracy and computational resource utilization.
For completeness, the trade-off score obtained by the considered DL models across the different datasets is shown in Figure 7. As can be observed, TCN emerges as the algorithm offering the most efficient balance between accuracy and computational complexity in the 2- and 8-class cases, i.e., in simple intrusion detection scenarios. In the more complex 34-class scenario, MLP is instead the algorithm returning the best trade-off.
Figure 7.
Trade-off score obtained by the considered DL models across 2-, 8-, and 34-class datasets.
5.4. Deployment on Resource-Constrained Devices
To evaluate the practical feasibility of deploying DL models on resource-constrained devices, quantized TCN and MLP models—being the best-performing models, according to the results shown in Section 5.3.3—were implemented and tested on the STM32H7S78-DK board, trying to assess how the number of output classes affects the algorithms’ computational and memory requirements when executed directly on the target HW.
In more detail, the complexity was analyzed in terms of the number of MACCs, RAM usage, and inference time, with these metrics obtained through on-board profiling tools and real-time measurements during the inference phase on the STM32H7S78-DK board. The obtained metrics are shown in Table 13, where 8-bit quantized (INT8) TCN and MLP models have been considered for the different output class configurations of interest—namely, for . For completeness, in Table 13 we also recall the accuracies of the algorithms.
Table 13.
Experimental results related to the computational complexity (in terms of accuracy, MACCs, RAM usage, and inference time) returned by quantized INT8 TCN and MLP models.
For the sake of completeness, the relative percentage difference (denoted as ) between the performance (for a given metric) returned by unquantized (FP32) and quantized (INT8) TCN and MLP models, considering the different output class configurations (namely, ), is shown in Table 14. In particular, this percentage difference is calculated as follows:
where corresponds to the considered evaluation (either performance or complexity) metric (namely, accuracy, number of MACCs, RAM usage, inference time, flash usage, model size, respectively); and represent the original value of the k-th metric returned by unquantized (FP32) and quantized (INT8) DL models, respectively. For better readability, instead of including the values of flash memory occupation and model size in Table 9 (for FP32 DL models) and Table 13 (for INT8 DL models), they have been included in Table 15 (columns 5–8).
Table 14.
Relative difference () between 32-bit (FP32) and quantized 8-bit (INT8) TCN and MLP models, in terms of accuracy, MACCs, RAM, inference time, flash, and model size.
Table 15.
Detail on the type and number of MACCs, flash and model size returned by FP32 and quantized INT8 TCN and MLP models.
As highlighted in Table 14, INT8 quantization produces a significant model size reduction for both TCN and MLP, exceeding in most cases. In particular, with regard to MLP, the number of MACCs remains essentially consistent (with variations smaller than ), the RAM usage increases moderately (between and ), the inference time decreases (between and ), and the flash usage is significantly reduced (between and ), thus reflecting lower weight storage needs. This highlights how dense layers (e.g., MLP) benefit from reduced computational cost and memory requirements (when quantized), thus leading to faster inference despite slightly higher RAM demands.
In contrast, TCN provides a different result. While model size is also reduced by more than and flash usage remains nearly constant, RAM usage and inference time of quantized versions increase substantially—between and , and between and , respectively. This behavior primarily occurs because TCN architectures, in particular one-dimensional convolutional layers, cannot be fully quantized to INT8, while, instead, MLP supports complete INT8 quantization. This is particularly evident given the type of MACCs shown in Table 15 as follows:
- smul_f32_f32 performs a scalar multiplication between two FP32 values;
- op_f32_f32 represents a generic operation—such as addition, activation, or normalization—applied to FP32 data;
- smul_s8_s8 and op_s8_s8 perform, adopting signed INT8 data types, the same operations operated by MACCs 1 and 2;
- smul_s8_f32 and smul_f32_s8 perform conversions from signed INT8 to FP32 and vice versa.
Thus, it is clear how TCN limitations in INT8 quantization arise because of an increased internal complexity—in terms of additional layers and MACCs, mainly dilated convolutions and dynamic padding—being not supported in integer form by both TensorFlow Lite and Cube-AI [57] from STMicroelectronics [58]. This leads to an unexpected increase in both RAM and flash memory usage, since several conversion and intermediate operations (to bridge between FP32 and INT8 arithmetic) are required during the quantization task. Specifically, the following apply:
- As indicated by the operations’ breakdown, the bulk of the computation still relies on FP32 multiplications (namely, ), with several conversion layers having to be added before and after convolutional and element-wise operations (e.g., and ).
- Each additional layer requires temporary buffers to store intermediate activations in both FP32 and INT8 formats: this drastically increases the RAM consumption at runtime, and in the worst case, the device has insufficient internal RAM, temporary buffers have to be stored into external RAM, and the performance degrades much more.
- Each quantized layer needs to store its scale and zero-point parameters for proper rescaling between quantized tensors: this results in the need to add metadata that partially hinders the expected flash memory reduction. Moreover, as discussed for RAM, in the case of insufficient internal flash memory, an external memory should be used, further degrading the performance.
The final result is that, even though quantization decreases the overall weight storage by about , the proliferation of intermediate buffers and conversion operations results in higher runtime memory demands and slightly larger flash usage—especially in architectures which make extensive use of convolutional and residual connections, e.g., TCN.
Overall, the obtained results highlight that INT8 quantization effectively reduces model and memory requirements for embedded deployment, while its impact on RAM and inference time depends on the specific model architecture. Comparing the accuracy of FP32 and INT8 implementations of MLP and TCN models for all classes, it can be seen (from Table 14) that the accuracy loss due to quantization is negligible in binary anomaly detection (), but increases when multiple classes (namely, ) are considered.
5.5. Quantized Models Accuracy-Computational Complexity Trade-Off
Finally, we evaluate the performance of quantized TCN and MLP models on the anomaly detection task using the trade-off score . For the 2-class task, both TCN and MLP models achieve high accuracy (above ), with TCN slightly outperforming MLP, albeit with higher resource usage due to mixed-precision quantization (as discussed in Section 5.4). Then, as the task complexity increases (with 8-class and 34-class configurations), TCN maintains significantly higher accuracy and trade-off score, whereas the fully quantized MLP sacrifices accuracy in exchange for reduced model size and complexity.
5.6. Limitations of the Proposed Work
Finally, for the sake of clarity and completeness, it might be useful to highlight that, despite the promising performance of the proposed IDS and the consequent HW-aware evaluation, the following limitations emerge from our experimental analysis:
- Quantization support for complex architectures: While MLP models can be fully quantized to INT8 with minimal impact on performance, TCN architectures suffer from incomplete quantization due to the presence of dilated convolutions and dynamic padding. This leads to increased RAM usage (up to ) and inference time (up to ) despite significant reductions in model size.
- Trade-off between accuracy and computational efficiency: Although quantization reduces model size and flash usage, the accuracy of fully quantized MLP models decreases slightly (average drop ), highlighting the trade-off between resource efficiency and detection performance, in particular for multi-class () scenarios.
- Scope of the evaluation: The study focuses on a single constrained platform (STM32H7S78-DK) and FP32-to-INT8 quantization schemes. Results may differ on alternative HW platforms, bit-widths, or DL frameworks, limiting the generality of the deployment conclusions.
6. Conclusions
The proposed study focuses on the integration of IDSs in IoT networks to protect against increasingly sophisticated threats targeting connected IoT devices. In particular, different DL models—namely, LSTM, GRU, RNN, CNN, TCN, and MLP—have been evaluated over a publicly available dataset (namely, CICIoT2023) including network traffic traces comprising different attack classes, for anomaly detection on resource-constrained IoT devices. Then, BO has been applied to optimize the hyperparameters of the considered DL models, which have then been evaluated for both binary (2-class) and multi-class (8-class, 34-class) intrusion detection tasks. The models’ performance has been assessed on an STM32H7S78-DK board (virtually available through the cloud-based STM Cube.AI Analyzer tool) considering the number of MACCs, RAM usage, and inference time as computational complexity metrics. Then, their deployability on resource-constrained IoT devices has been evaluated by introducing a trade-off score , balancing both classification accuracy and computational complexity, obtaining that TCN and MLP guarantee the most efficient balance with respect to the other DL models, on the basis of the specific intrusion detection task. Furthermore, PTQ has been considered in order to evaluate the impact, on both model size and classification accuracy, of parameter quantization (from FP32 to INT8). The obtained experimental results demonstrate a significant model size reduction (greater than ) for both TCN and MLP with all considered classes. However, there are differences between TCN and MLP: Models based on dense layers (such as MLP) benefit from lower computational costs and memory requirements after quantization; convolution-based models (such as TCN), instead, exhibit increased runtime and RAM usage—particularly when the number of output classes grows—while showing only a marginal increase in the number of MACCs. These findings highlight that post-training INT8 quantization should be applied by taking into account the considered model and the final goal (e.g., latency or computational complexity).
Author Contributions
Conceptualization, A.M., D.A., L.D. and G.F.; methodology, A.M., D.A., L.D. and G.F.; software, A.M. and D.A.; validation, A.M., D.A., L.D. and G.F.; formal analysis, A.M., D.A., L.D. and G.F.; investigation, A.M., D.A., L.D. and G.F.; resources, A.M. and D.A.; data curation, A.M., D.A., L.D. and G.F.; writing—original draft preparation, A.M., D.A., L.D. and G.F.; writing—review and editing, A.M., D.A., L.D. and G.F.; visualization, A.M., D.A., L.D. and G.F.; supervision, L.D. and G.F.; project administration, L.D. and G.F.; funding acquisition, L.D. and G.F. All authors have read and agreed to the published version of the manuscript.
Funding
This work was partially supported by the European Union’s Horizon Europe research and innovation program Key Digital Technology (KDT) Joint Undertaking (JU) under grant agreement No. 101097267, OPEVA project—“OPtimization of Electric Vehicle Autonomy,” and grant agreement No. 101139769, DistriMuSe project—“Distributed Multi-Sensor Systems for Human Safety and Health.” This work was also partially supported by the European Union—Next Generation EU under the Italian National Recovery and Resilience Plan (NRRP), Mission 4, Component 2, Investment 1.3, CUP J33C22002880001, partnership on “Telecommunications of the Future” (PE00000001—program “RESTART”), and by the Italian Complementary National Plan (PNC)–I.1 “Research initiatives for innovative technologies and pathways in the health and welfare sector,” D.D. 931 of 06/06/2022, the “DigitAl lifelong pRevEntion” (DARE) initiative, code PNC0000002, CUP B53C22006240001. The KDT JU received support from the European Union’s Horizon Europe research and innovation programme and the nations involved in the mentioned projects. The work reflects only the authors’ views; the European Commission is not responsible for any use that may be made of the information it contains.
Institutional Review Board Statement
Not applicable.
Informed Consent Statement
Not applicable.
Data Availability Statement
The data presented in this study have been derived from the public dataset “CICIoT2023: A Real-Time Dataset and Benchmark for Large-Scale Attacks in IoT Environment” at https://doi.org/10.3390/s23135941.
Conflicts of Interest
The authors declare no conflicts of interest. The funders had no role in the design of the study; in the collection, analyses, or interpretation of data; in the writing of the manuscript; or in the decision to publish the results.
Abbreviations
The following abbreviations are used in this manuscript:
| 1D-CNN | One-dimensional Convolutional Neural Network |
| AUC | Area Under Curve |
| DDoS | Distributed DoS |
| DL | Deep Learning |
| DNN | Deep Neural Network |
| DoS | Denial of Service |
| DT | Decision Tree |
| FFN | FeedForward Network |
| FL | Federated Learning |
| GRU | Gated Recurrent Unit |
| HPO | Hyper-Parameter Optimization |
| IDS | Intrusion Detection System |
| IoT | Internet of Things |
| LGBM | Light Gradient Boosting Machine |
| LSTM | Long Short-Term Memory |
| MACC | Multiply–ACCumulate operation |
| MCC | Matthews Correlation Coefficient |
| MITM | Man-in-the-Middle |
| ML | Machine Learning |
| MLP | Multi-Layer Perceptron |
| NLP | Natural Language Processing |
| PTQ | Post-Training Quantization |
| ReLU | REctified Linear Unit |
| RF | Random Forest |
| ROC | Receiver Operating Characteristic |
| SDN | Software-Defined Networking |
| SGD | Stochastic Gradient Descent |
| SimpleRNN | Simple Recurrent Neural Network |
| SMOTE | Synthetic Minority Oversampling Technique |
| SVM | Support Vector Machine |
| TCN | Temporal Convolutional Network |
| TFlite | TensorFlow Lite |
| XSS | Cross-Site Scripting |
Appendix A. Confusion Matrices of the Considered DL Models
As detailed in Section 5.1, in the following the confusion matrices returned by 2-, 8-, and 34-class configurations, are shown in Figure A1, Figure A2, and Figure A3, respectively, along with the corresponding mapping between attack classes and their corresponding numerical labels, listed in Table A1, Table A2, and Table A3, respectively.
Figure A1.
Confusion matrices returned by the considered FP32 DL models in the 2-class () anomaly detection: (a) LSTM, (b) GRU, (c) RNN, (d) CNN, (e) TCN, (f) MLP.
Table A1.
Label encoding for the binary () classification.
Figure A2.
Confusion matrices returned by the considered FP32 DL models in the 8-class () anomaly detection: (a) LSTM, (b) GRU, (c) RNN, (d) CNN, (e) TCN, (f) MLP.
Table A2.
Label encoding for the 8-class () classification.
Figure A3.
Confusion matrices returned by the considered FP32 DL models in the 34-class () anomaly detection: (a) LSTM, (b) GRU, (c) RNN, (d) CNN, (e) TCN, (f) MLP.
Table A3.
Label encoding for the 34-class () classification.
References
- Rejeb, A.; Suhaiza, Z.; Rejeb, K.; Seuring, S.; Treiblmaier, H. The Internet of Things and the Circular Economy: A Systematic Literature Review and Research Agenda. J. Clean. Prod. 2022, 350, 131439. [Google Scholar] [CrossRef] [Scilit]
- Hirsch, C.; Davoli, L.; Grosu, R.; Ferrari, G. DynGATT: A Dynamic GATT-based Data Synchronization Protocol for BLE Networks. Comput. Netw. 2023, 222, 109560. [Google Scholar] [CrossRef] [Scilit]
- Davoli, L.; Belli, L.; Cilfone, A.; Ferrari, G. Integration of Wi-Fi Mobile Nodes in a Web of Things Testbed. ICT Express 2016, 2, 95–99. [Google Scholar] [CrossRef] [Scilit]
- Pagliari, E.; Davoli, L.; Ferrari, G. Harnessing Communication Heterogeneity: Architectural Design, Analytical Modeling, and Performance Evaluation of an IoT Multi-Interface Gateway. IEEE Internet Things J. 2024, 11, 8030–8051. [Google Scholar] [CrossRef] [Scilit]
- Premalatha, B.; Prakasam, P. A Review on FoG Computing in 5G Wireless Technologies: Research Challenges, Issues and Solutions. Wirel. Pers. Commun. 2024, 134, 2455–2484. [Google Scholar] [CrossRef] [Scilit]
- Salsano, S.; Veltri, L.; Davoli, L.; Ventre, P.L.; Siracusano, G. PMSR–Poor Man’s Segment Routing, a Minimalistic Approach to Segment Routing and a Traffic Engineering Use Case. In Proceedings of the 2016 IEEE/IFIP Network Operations and Management Symposium (NOMS), Istanbul, Turkey, 25–29 April 2016; pp. 598–604. [Google Scholar] [CrossRef] [Scilit]
- Zikria, Y.B.; Ali, R.; Afzal, M.K.; Kim, S.W. Next-Generation Internet of Things (IoT): Opportunities, Challenges, and Solutions. Sensors 2021, 21, 1174. [Google Scholar] [CrossRef] [Scilit]
- Belli, L.; Cirani, S.; Davoli, L.; Ferrari, G.; Melegari, L.; Picone, M. Applying Security to a Big Stream Cloud Architecture for the Internet of Things. Int. J. Distrib. Syst. Technol. (IJDST) 2016, 7, 37–58. [Google Scholar] [CrossRef] [Scilit]
- Heidari, A.; Jabraeil Jamali, M.A. Internet of Things Intrusion Detection Systems: A Comprehensive Review and Future Directions. Clust. Comput. 2022, 26, 3753–3780. [Google Scholar] [CrossRef] [Scilit]
- Jiang, X.; Lora, M.; Chattopadhyay, S. An Experimental Analysis of Security Vulnerabilities in Industrial IoT Devices. ACM Trans. Internet Technol. 2020, 20, 16. [Google Scholar] [CrossRef] [Scilit]
- Bertino, E.; Islam, N. Botnets and Internet of Things Security. Computer 2017, 50, 76–79. [Google Scholar] [CrossRef] [Scilit]
- Khan, M.A.; Salah, K. IoT Security: Review, Blockchain Solutions, and Open Challenges. Future Gener. Comput. Syst. 2018, 82, 395–411. [Google Scholar] [CrossRef] [Scilit]
- Davoli, L.; Protskaya, Y.; Veltri, L. An Anonymization Protocol for the Internet of Things. In Proceedings of the 2017 International Symposium on Wireless Communication Systems (ISWCS), Bologna, Italy, 28–31 August 2017; pp. 459–464. [Google Scholar] [CrossRef] [Scilit]
- Asharf, J.; Moustafa, N.; Khurshid, H.; Debie, E.; Haider, W.; Wahab, A. A Review of Intrusion Detection Systems Using Machine and Deep Learning in Internet of Things: Challenges, Solutions and Future Directions. Electronics 2020, 9, 1177. [Google Scholar] [CrossRef] [Scilit]
- Neto, E.C.P.; Dadkhah, S.; Ferreira, R.; Zohourian, A.; Lu, R.; Ghorbani, A.A. CICIoT2023: A Real-Time Dataset and Benchmark for Large-Scale Attacks in IoT Environment. Sensors 2023, 23, 5941. [Google Scholar] [CrossRef] [Scilit] [PubMed]
- STMicroelectronics. Discovery Kit with STM32H7S7L8 MCU. Available online: https://www.st.com/en/evaluation-tools/stm32h7s78-dk.html (accessed on 1 January 2026).
- Abbas, S.; Bouazzi, I.; Ojo, S.; Al Hejaili, A.; Sampedro, G.A.; Almadhor, A.; Gregus, M. Evaluating Deep Learning Variants for Cyber-Attacks Detection and Multi-Class Classification in IoT Networks. Peerj Comput. Sci. 2024, 10, e1793. [Google Scholar] [CrossRef] [Scilit] [PubMed]
- Abbas, S.; Al Hejaili, A.; Sampedro, G.A.; Abisado, M.; Almadhor, A.S.; Shahzad, T.; Ouahada, K. A Novel Federated Edge Learning Approach for Detecting Cyberattacks in IoT Infrastructures. IEEE Access 2023, 11, 112189–112198. [Google Scholar] [CrossRef] [Scilit]
- Vajrobol, V.; Gupta, B.B.; Gaurav, A.; Chuang, H.M. Adversarial Learning for Mirai Botnet Detection based on Long Short-Term Memory and XGBoost. Int. J. Cogn. Comput. Eng. 2024, 5, 153–160. [Google Scholar] [CrossRef] [Scilit]
- Gharaibeh, H.; Aljaidi, M.; Nasayreh, A.; Al-Na’amneh, Q.; Jaradat, A.S.; Samara, G.; Al Mamlook, R.E. Deep Feature Extraction Framework Based on DNN for Enhancing Mirai Attachment Classification in Machine Learning. In Proceedings of the 2023 2nd International Engineering Conference on Electrical, Energy, and Artificial Intelligence (EICEEAI), Zarqa, Jordan, 27–28 December 2023; pp. 1–5. [Google Scholar] [CrossRef] [Scilit]
- Becerra-Suarez, F.L.; Tuesta-Monteza, V.A.; Mejia-Cabrera, H.I.; Arcila-Diaz, J. Performance Evaluation of Deep Learning Models for Classifying Cybersecurity Attacks in IoT Networks. Informatics 2024, 11, 32. [Google Scholar] [CrossRef] [Scilit]
- Aguru, A.D.; Erukala, S.B. A Lightweight Multi-Vector DDoS Detection Framework for IoT-enabled Mobile Health Informatics Systems using Deep Learning. Inf. Sci. 2024, 662, 120209. [Google Scholar] [CrossRef] [Scilit]
- Kumar, A.G.; Rastogi, A.; Ranga, V. Evaluation of Different Machine Learning Classifiers on New IoT Dataset CICIoT2023. In Proceedings of the 2024 International Conference on Intelligent Systems for Cybersecurity (ISCS), Gurugram, India, 3–4 May 2024; pp. 1–6. [Google Scholar] [CrossRef] [Scilit]
- Diab, A.; Chehade, A.; Ragusa, E.; Gastaldo, P.; Zunino, R.; Baghdadi, A.; Rizk, M. Intrusion Detection on Resource-Constrained IoT Devices with Hardware-Aware ML and DL. arXiv 2025, arXiv:2512.02272. [Google Scholar]
- Saxe, J.; Berlin, K. Deep Neural Network based Malware Detection using Two Dimensional Binary Program Features. In Proceedings of the 2015 10th International Conference on Malicious and Unwanted Software (MALWARE), Fajardo, PR, USA, 20–22 October 2015; pp. 11–20. [Google Scholar] [CrossRef] [Scilit]
- The Imbalanced-Learn Developers. RandomOverSampler. Available online: https://imbalanced-learn.org/stable/references/generated/imblearn.over_sampling.RandomOverSampler.html (accessed on 1 January 2026).
- Thapa, S.; Poudel, S.; Abouyoussef, M. TinyML-Enabled Intrusion Detection for Securing Electric Vehicle Supply Equipment (EVSE). In Proceedings of the 2025 1st International Conference on Secure IoT, Assured and Trusted Computing (SATC), Dayton, OH, USA, 25–27 February 2025; pp. 1–5. [Google Scholar] [CrossRef] [Scilit]
- Buedi, E.D.; Ghorbani, A.A.; Dadkhah, S.; Ferreira, R.L. Enhancing EV Charging Station Security Using a Multi-dimensional Dataset: CICEVSE2024. In Proceedings of the Data and Applications Security and Privacy XXXVIII, San Jose, CA, USA, 15–17 July 2024; pp. 171–190. [Google Scholar] [CrossRef] [Scilit]
- Arcot, S.; Masum, M.; Kader, M.S.; Saha, A.; Chowdhury, M. TinyML for Cybersecurity: Deploying Optimized Deep Learning Models for On-Device Threat Detection on Resource-Constrained Devices. In Proceedings of the 2024 IEEE International Conference on Big Data (BigData), Washington, DC, USA, 15–18 December 2024; pp. 5542–5550. [Google Scholar] [CrossRef] [Scilit]
- Wang, W.; Zhu, M.; Zeng, X.; Ye, X.; Sheng, Y. Malware Traffic Classification using Convolutional Neural Network for Representation Learning. In Proceedings of the 2017 International Conference on Information Networking (ICOIN), Da Nang, Vietnam, 11–13 January 2017; pp. 712–717. [Google Scholar] [CrossRef] [Scilit]
- Ke, G.; Meng, Q.; Finley, T.; Wang, T.; Chen, W.; Ma, W.; Ye, Q.; Liu, T.Y. LightGBM: A Highly Efficient Gradient Boosting Decision Tree. In Proceedings of the 31st International Conference on Neural Information Processing Systems, Long Beach, CA, USA, 4–9 December 2017; pp. 3149–3157. [Google Scholar] [CrossRef]
- Ferrag, M.A.; Friha, O.; Hamouda, D.; Maglaras, L.; Janicke, H. Edge-IIoTset: A New Comprehensive Realistic Cyber Security Dataset of IoT and IIoT Applications for Centralized and Federated Learning. IEEE Access 2022, 10, 40281–40306. [Google Scholar] [CrossRef] [Scilit]
- Sharma, A.; Rani, S.; Shabaz, M. An Optimized Stacking-Based TinyML Model for Attack Detection in IoT Networks. PLoS ONE 2025, 20, e0329227. [Google Scholar] [CrossRef] [Scilit] [PubMed]
- Booij, T.M.; Chiscop, I.; Meeuwissen, E.; Moustafa, N.; Den Hartog, F.T. ToN_IoT: The Role of Heterogeneity and the Need for Standardization of Features and Attack Types in IoT Network Intrusion Data Sets. IEEE Internet Things J. 2022, 9, 485–496. [Google Scholar] [CrossRef] [Scilit]
- Sengupta, J.; Ruj, S.; Das Bit, S. A Comprehensive Survey on Attacks, Security Issues and Blockchain Solutions for IoT and IIoT. J. Netw. Comput. Appl. 2020, 149, 102481. [Google Scholar] [CrossRef] [Scilit]
- Syed, N.F.; Baig, Z.; Ibrahim, A.; Valli, C. Denial of Service Attack Detection through Machine Learning for the IoT. J. Inf. Telecommun. 2020, 4, 482–503. [Google Scholar] [CrossRef] [Scilit]
- Pirayesh, H.; Kheirkhah Sangdeh, P.; Zeng, H. Securing ZigBee Communications Against Constant Jamming Attack Using Neural Network. IEEE Internet Things J. 2021, 8, 4957–4968. [Google Scholar] [CrossRef] [Scilit]
- Balueva, A.; Desnitsky, V.; Ushakov, I. Approach to Detection of Denial-of-Sleep Attacks in Wireless Sensor Networks on the Base of Machine Learning. In Studies in Computational Intelligence; Springer International Publishing: Berlin/Heidelberg, Germany, 2019; pp. 350–355. [Google Scholar] [CrossRef] [Scilit]
- Yan, J.; Jiang, T.; Lin, L.; Wu, Z.; Ye, X.; Tian, M.; Wang, Y. A Novel Sybil Attack Detection Scheme in Mobile IoT based on Collaborate Edge Computing. EURASIP J. Wirel. Commun. Netw. 2023, 2023, 25. [Google Scholar] [CrossRef] [Scilit]
- The Imbalanced-Learn Developers. RandomUnderSampler. Available online: https://imbalanced-learn.org/stable/references/generated/imblearn.under_sampling.RandomUnderSampler.html (accessed on 1 January 2026).
- Scikit-Learn. PowerTransformer. Available online: https://scikit-learn.org/stable/modules/generated/sklearn.preprocessing.PowerTransformer.html (accessed on 1 January 2026).
- SciPy Core Developer. One-Way ANOVA Tests. Available online: https://docs.scipy.org/doc/scipy/reference/generated/scipy.stats.f_oneway.html (accessed on 1 January 2026).
- Keras Google Group. KerasTuner. Available online: https://keras.io/keras_tuner/ (accessed on 1 January 2026).
- Keras Google Group. ReLU layer. Available online: https://keras.io/api/layers/activation_layers/relu/ (accessed on 1 January 2026).
- Keras Google Group. Layer Activation Functions—Softmax. Available online: https://keras.io/api/layers/activations/#softmax-function (accessed on 1 January 2026).
- Alsadi, N.; Gadsden, S.A.; Yawney, J. Intelligent Estimation: A Review of Theory, Applications, and Recent Advances. Digit. Signal Processing 2023, 135, 103966. [Google Scholar] [CrossRef] [Scilit]
- Zhang, J.; Man, K. Time Series Prediction using RNN in Multi-Dimension Embedding Phase Space. In Proceedings of the 1998 IEEE International Conference on Systems, Man, and Cybernetics (SMC), San Diego, CA, USA, 11–14 October 1998; Volume 2, pp. 1868–1873. [Google Scholar] [CrossRef] [Scilit]
- Al-Selwi, S.M.; Hassan, M.F.; Abdulkadir, S.J.; Muneer, A. LSTM Inefficiency in Long-Term Dependencies Regression Problems. J. Adv. Res. Appl. Sci. Eng. Technol. 2023, 30, 16–31. [Google Scholar] [CrossRef] [Scilit]
- Khandelwal, S.; Lecouteux, B.; Besacier, L. Comparing GRU and LSTM for Automatic Speech Recognition; Research Report; LIG: Saint-Martin-d’Hères, France, 2016; Available online: https://hal.science/hal-01633254 (accessed on 1 January 2026).
- Kurt, I.; Ture, M.; Kurum, A.T. Comparing Performances of Logistic Regression, Classification and Regression Tree, and Neural Networks for Predicting Coronary Artery Disease. Expert Syst. Appl. 2008, 34, 366–374. [Google Scholar] [CrossRef] [Scilit]
- Zhao, B.; Lu, H.; Chen, S.; Liu, J.; Wu, D. Convolutional Neural Networks for Time Series Classification. J. Syst. Eng. Electron. 2017, 28, 162–169. [Google Scholar] [CrossRef] [Scilit]
- Mazinani, A.; Davoli, L.; Ferrari, G. Deep Learning Algorithms for Cryptocurrency Price Prediction: A Comparative Analysis. Distrib. Ledger Technol. Res. Pract. 2025, 4, 1–38. [Google Scholar] [CrossRef] [Scilit]
- McHugh, M.L. Interrater Reliability: The Kappa Statistic. Biochem. Medica 2012, 22, 276–282. [Google Scholar] [CrossRef] [Scilit]
- Abadi, M.; Agarwal, A.; Barham, P.; Brevdo, E.; Chen, Z.; Citro, C.; Corrado, G.S.; Davis, A.; Dean, J.; Devin, M.; et al. TensorFlow: Large-Scale Machine Learning on Heterogeneous Distributed Systems. arXiv 2016, arXiv:1603.04467. [Google Scholar] [CrossRef] [Scilit]
- Wu, J.; Leng, C.; Wang, Y.; Hu, Q.; Cheng, J. Quantized Convolutional Neural Networks for Mobile Devices. In Proceedings of the 2016 IEEE Conference on Computer Vision and Pattern Recognition (CVPR), Los Alamitos, CA, USA, 27–30 June 2016; pp. 4820–4828. [Google Scholar] [CrossRef] [Scilit]
- Mazinani, A.; Davoli, L.; Pau, D.P.; Ferrari, G. Air Quality Estimation with Embedded AI-Based Prediction Algorithms. In Proceedings of the 2023 International Conference on Information Technology Research and Innovation (ICITRI), Jakarta, Indonesia, 16 August 2023; pp. 87–92. [Google Scholar] [CrossRef] [Scilit]
- STMicroelectronics. STM32Cube.AI (X-CUBE-AI v10.0)—Free AI Model Optimizer for STM32. Available online: https://stm32ai.st.com/stm32-cube-ai (accessed on 1 January 2026).
- Burrello, A.; Dequino, A.; Pagliari, D.J.; Conti, F.; Zanghieri, M.; Macii, E.; Benini, L.; Poncino, M. TCN Mapping Optimization for Ultra-Low Power Time-Series Edge Inference. In Proceedings of the 2021 IEEE/ACM International Symposium on Low Power Electronics and Design (ISLPED), Newport Beach, CA, USA, 5–7 August 2021; pp. 1–6. [Google Scholar] [CrossRef] [Scilit]
Disclaimer/Publisher’s Note: The statements, opinions and data contained in all publications are solely those of the individual author(s) and contributor(s) and not of MDPI and/or the editor(s). MDPI and/or the editor(s) disclaim responsibility for any injury to people or property resulting from any ideas, methods, instructions or products referred to in the content. |
© 2026 by the authors. Licensee MDPI, Basel, Switzerland. This article is an open access article distributed under the terms and conditions of the Creative Commons Attribution (CC BY) license.














