Skip to Content
DigitalDigital
  • Article
  • Open Access

19 May 2026

17 Pages

Autonomous Reinforcement Learning-Based Intrusion Detection for IoT Cyber Defense

Computer Science Department, King Hussein School of Computing Sciences, Princess Sumaya University for Technology, Al-Jubeiha, P.O. Box 1438, Amman 11941, Jordan

Abstract

The rapid proliferation of Internet of Things (IoT) devices has dramatically expanded the attack surface for cyber threats, exposing critical infrastructure to sophisticated intrusion attempts that traditional static intrusion detection systems (IDS) fail to counter effectively. This paper proposes an autonomous reinforcement learning (RL)-based IDS framework for dynamic IoT networks, capable of adaptive, real-time threat detection without human intervention. The proposed system integrates a Deep Q-Network (DQN) agent with a hybrid convolutional neural network–long short-term memory (CNN-LSTM) feature extractor to identify and classify malicious network traffic across 33 attack categories. We evaluate the framework on two recent, publicly available benchmark datasets: CICIoT2023, comprising 8.94 GB of traffic from 105 real IoT devices, and CIC IoT-DIAD 2024, a flow-based dataset with diverse attack and benign scenarios. Experimental results demonstrate superior detection performance compared to baseline classifiers, including SVM, Random Forest, and standalone deep learning models, with improved F1-score, reduced false alarm rate (FAR), and lower detection latency. The reward-shaping strategy explicitly penalizes false positives, addressing a key limitation of prior RL-based IDS approaches. This work contributes a scalable, dataset-agnostic autonomous defense architecture suitable for real-world IoT deployment.

1. Introduction

The Internet of Things (IoT) ecosystem has undergone unprecedented growth, with an estimated 18.8 billion connected devices globally as of 2024, a figure projected to exceed 30 billion by 2030 [1]. These devices span critical domains including smart healthcare, industrial control systems, smart cities, and autonomous vehicles, generating vast volumes of sensitive network traffic. However, the resource-constrained nature of IoT endpoints, combined with their heterogeneous protocols and limited computational capacity, renders them inherently vulnerable to a wide range of cyberattacks, including distributed denial-of-service (DDoS), man-in-the-middle (MITM), botnet infiltration, and reconnaissance campaigns [2,3].
Traditional intrusion detection systems rely on static rule-based or signature-based mechanisms that are fundamentally incapable of adapting to the evolving threat landscape [4]. While machine learning (ML) and deep learning (DL) approaches have demonstrated improved detection accuracy over legacy systems, they are predominantly trained offline and lack the capacity for autonomous online adaptation in dynamic network environments [5,6]. A particularly critical gap exists in the ability of current IDS frameworks to autonomously update decision policies in response to novel, unseen attack patterns without retraining.
Reinforcement learning (RL) presents a compelling paradigm for autonomous cyber defense [7]. By framing intrusion detection as a sequential decision-making problem, an RL agent learns optimal detection policies through interaction with the network environment, guided by reward signals that minimize both false negatives and false positives [8,9]. Prior RL-based IDS work suffers from two limitations: (1) reliance on outdated benchmark datasets that do not reflect contemporary IoT attack vectors, and (2) reward functions that inadequately penalize false alarms, limiting operational viability [10].
Table 1 presents a structured comparison of Intrusion Detection Systems (IDS) categorized by their adaptation capabilities, progressing from static detection systems to offline learning systems, and finally to adaptive or online learning systems. Static systems rely on predefined rules and known threat signatures, offering no ability to adapt to new or evolving attacks. Offline learning systems improve detection performance by leveraging machine learning and deep learning models trained on historical datasets; however, their adaptation is limited since updates require retraining. In contrast, adaptive or online learning systems continuously learn from real-time data and environmental feedback, enabling dynamic policy updates and improved detection of previously unseen threats. Overall, the table highlights a clear evolution in IDS design, where increasing adaptation capability enhances flexibility, responsiveness, and effectiveness in addressing modern cybersecurity challenges.
Table 1. Classification of Intrusion Detection Systems (IDS) Based on Adaptation Capability.
Unlike existing RL-based IDS approaches that primarily focus on improving classification accuracy on legacy datasets, the proposed RL-IoTIDS framework emphasizes operationally adaptive intrusion detection for modern IoT environments by integrating hybrid spatial–temporal state encoding, asymmetric false-positive-aware reward engineering, and cross-dataset online adaptation. The framework is specifically designed to address the practical limitations of static IDS models in dynamic IoT deployments.
This paper addresses these gaps through the following contributions:
  • We propose an autonomous RL-based IDS framework integrating a DQN agent with a CNN-LSTM feature extractor, tailored for IoT network environments.
  • We evaluate on two recent publicly available IoT datasets: CICIoT2023 [11] and CIC IoT-DIAD 2024 [12], ensuring contemporary relevance and reproducibility.
  • We introduce a false-positive-aware reward-shaping mechanism that substantially reduces operational false alarm rates compared to baseline RL approaches.
  • We conduct a comprehensive comparative evaluation against SVM, Random Forest, CNN, and LSTM baselines, demonstrating statistically significant improvements in F1-score and FAR.
  • Unlike prior studies that primarily evaluate isolated RL or deep learning models on legacy datasets, this work focuses on the operational integration of adaptive reinforcement learning with modern IoT traffic representations and cost-sensitive reward engineering for practical autonomous cyber defense.
Table 2 highlights the key differences between five RL-based intrusion detection approaches and the proposed RL-IoTIDS framework. Unlike prior studies, the proposed approach integrates hybrid CNN-LSTM spatial–temporal encoding, asymmetric false-positive-aware reward engineering, modern large-scale IoT datasets, and online adaptive learning within a unified autonomous intrusion detection architecture. This comparison further clarifies the novelty and operational contributions of the proposed framework.
Table 2. Comparative analysis of recent RL-based IoT intrusion detection frameworks and the proposed RL-IoTIDS architecture.
The remainder of this paper is structured as follows. Section 2 reviews related work. Section 3 presents the proposed architecture. Section 4 describes datasets and preprocessing. Section 5 details the experimental setup. Section 6 presents results and discussion. Section 7 concludes the paper.

3. Proposed Model Architecture

The proposed framework, designated RL-IoTIDS, comprises four principal components: an environment module, a CNN-LSTM state encoder, a DQN agent, and a false-positive-aware reward shaper.
Figure 1 illustrates the overall workflow of the proposed reinforcement learning-based intrusion detection system (RL-IoTIDS) for IoT environments. The framework begins by collecting continuous network traffic streams from IoT devices and transforming them into timestamped flow records represented as multidimensional feature vectors. These records are processed using a hybrid CNN–LSTM feature extractor, where the 1D CNN captures spatial correlations among flow features, while the bidirectional LSTM models temporal dependencies across consecutive network flows. The resulting encoded state vector is then provided to a Double Deep Q-Network (Double DQN) agent responsible for adaptive decision-making. The agent estimates Q-values, selects optimal actions using an ε-greedy policy, and continuously updates its learning policy using experience replay and target network synchronization within the Markov Decision Process (MDP) feedback loop. This architecture enables dynamic and autonomous intrusion detection while reducing false alarms and improving adaptability to evolving IoT attack patterns.
Figure 1. Overall architecture of the proposed RL-IoTIDS framework.

3.1. Environment Design

The RL environment models a monitored IoT network segment, where network traffic is continuously observed and represented as a sequence of flow records. At each discrete timestep t, the environment presents the agent with a high-dimensional feature vector derived from a single network flow instance, capturing both statistical and protocol-level characteristics of the traffic. The agent then selects an action from a predefined discrete action space A = {Allow, Alert, Block}, corresponding to different security responses to the observed traffic. Specifically, Allow permits the traffic to pass without intervention, Alert flags the flow for further inspection, and Block actively prevents the traffic from proceeding.
Following the agent’s decision, the environment evaluates the selected action against the ground-truth label associated with the network flow and returns a scalar reward reflecting the correctness and operational impact of the decision. Positive rewards are assigned to correct classifications, while penalties are imposed for incorrect actions, particularly false negatives (failing to block an attack) and false positives (incorrectly blocking legitimate traffic). The environment then transitions to the next state, representing the subsequent network flow record, thereby enabling continuous interaction.
This formulation models the intrusion detection process as a Markov Decision Process (MDP), defined by the tuple (S, A, P, R, γ) where S denotes the state space of network traffic features, A is the action space, P represents the state transition dynamics, R is the reward function, and γ\gamma is the discount factor controlling the importance of future rewards. The objective of the RL agent is to learn an optimal policy that maximizes the expected cumulative discounted reward over time. This approach enables the system to move beyond static classification by continuously refining its decision-making policy through interaction with the environment, thereby improving adaptability to evolving and previously unseen attack patterns in IoT networks.

3.2. State Representation: CNN-LSTM Feature Extractor

Raw network flow features are inherently high-dimensional and exhibit complex structural properties, including local correlations among statistical attributes and temporal dependencies across consecutive flows originating from the same source or session. Effectively modeling these characteristics is essential for accurate intrusion detection, particularly in dynamic IoT environments. To address this, a hybrid CNN–LSTM encoder architecture is employed to jointly capture spatial and temporal feature representations.
The convolutional neural network (CNN) component is designed to extract local feature patterns from the normalized flow feature vector. Specifically, three one-dimensional convolutional layers are utilized, with 64, 128, and 256 filters, respectively, each employing a kernel size of 3. These layers enable the model to learn hierarchical representations of local dependencies and interactions among neighboring features. The output feature maps are subsequently passed through non-linear activation functions and optional pooling layers to enhance feature abstraction and reduce dimensionality.
Following spatial feature extraction, the processed representations are fed into a two-layer bidirectional Long Short-Term Memory (BiLSTM) network, with 128 hidden units in each direction. The bidirectional structure allows the model to capture both forward and backward temporal dependencies, providing a more comprehensive understanding of sequential traffic behavior. This is particularly important for identifying attack patterns that evolve over time or depend on contextual flow sequences.
The final hidden states of the BiLSTM layers are concatenated and transformed into a compact, high-level representation, which serves as the state vector input to the Deep Q-Network (DQN) agent. This encoded state effectively integrates both spatial and temporal information, enabling the RL agent to make informed and context-aware decisions. By leveraging this hybrid architecture, the system enhances its ability to detect sophisticated, evolving cyber threats in IoT network environments.

3.3. DQN Agent

The reinforcement learning agent is implemented using a Double Deep Q-Network (Double DQN) architecture [28], enhanced with a dueling network structure [29] to improve learning stability and policy estimation accuracy. The Double DQN framework mitigates the overestimation bias commonly observed in standard Q-learning by decoupling action selection from evaluation during target computation, resulting in more reliable Q-value estimates and faster convergence in complex environments.
To further enhance performance, a dueling network head is incorporated, which decomposes the Q-value function into two components: the state-value function V (s), representing the overall quality of a given state, and the advantage function A (s, a), capturing the relative importance of each action. These components are combined to produce the final Q-value, enabling more efficient learning, particularly in states where the choice of action has a limited impact.
The Q-network consists of three fully connected layers with 512, 256, and 3 neurons, respectively. The first two layers use Rectified Linear Unit (ReLU) activation functions to capture non-linear relationships in the input features, while the final layer outputs Q-values for the three possible actions in the defined action space. This architecture balances representational capacity with computational efficiency.
Training is performed using an experience replay mechanism, where transitions of the form (s, a, r, s′) are stored in a replay buffer with a capacity of 100,000 samples. Mini-batches are randomly sampled from this buffer during training to reduce temporal correlations and improve learning stability. Additionally, a separate target network is maintained and updated every 1000 training steps, providing stable target Q-values and preventing oscillations during training.
The exploration–exploitation trade-off is managed using an epsilon-greedy policy, in which the agent selects a random action with probability ϵ\epsilonϵ and the best-known action otherwise. The value of ϵ\epsilonϵ is gradually annealed from 1.0 to 0.01 over 50,000 training steps, allowing the agent to explore the environment extensively in the early stages of training and progressively exploit the learned policy as convergence is approached.

3.4. False-Positive-Aware Reward Function

Standard reinforcement learning-based intrusion detection systems (RL-IDS) typically employ a symmetric reward structure, assigning a reward of +1 for correct classifications and −1 for incorrect ones. However, this formulation fails to capture the differing operational and security implications of various types of misclassification. In particular, false negatives—where malicious traffic is incorrectly classified as benign—pose a significant security risk, as they allow attacks to proceed undetected. Conversely, false positives—where legitimate traffic is incorrectly blocked—primarily impact system usability and operational efficiency. The reward coefficients were selected via empirical hyperparameter tuning on the validation set and guided by the operational cybersecurity cost asymmetry between false negatives and false positives.
To address this limitation, the proposed approach adopts an asymmetric reward function that explicitly differentiates between these outcomes. The reward at timestep tr, denoted as rt, is defined as follows:
r t =   + 1.0 ,   i f   y t = 1   ˄   y t ^ = 1   ( T r u e   P o s i t i v e )   + 0.5 ,   i f   y t = 0   ˄   y t ^ = 0   ( T r u e   N e g a t i v e ) − 2.0 ,   i f   y t = 1   ˄   y t ^ = 0   ( f a l s e   N e g a t i v e ) − 0.8 ,   i f   y t = 0   ˄   y t ^ = 1   ( f a l s e   P o s i t i v e )
This asymmetric reward structure assigns a higher penalty to false negatives compared to false positives (−2.0 vs. −0.8), reflecting the greater severity of undetected attacks in cybersecurity contexts. At the same time, false positives are still penalized to prevent excessive disruption to legitimate network activity. By incorporating domain-specific cost sensitivity into the reward design, the agent is encouraged to prioritize attack detection while maintaining acceptable operational performance.
The specific reward magnitudes were determined through systematic hyperparameter tuning on a validation subset, ensuring a balanced trade-off between detection accuracy and false alarm rates. This formulation enables the RL agent to learn a more realistic and practically viable decision policy for deployment in dynamic IoT environments.
The asymmetric reward values were selected based on the operational cost asymmetry commonly observed in cybersecurity environments, where false negatives are significantly more critical than false positives because undetected attacks may lead to system compromise or service disruption. Multiple reward configurations were experimentally evaluated during validation, and the selected configuration achieved the best trade-off between recall and false alarm rate (FAR). Preliminary experiments showed that excessively large penalties for false positives reduced detection sensitivity, whereas insufficient penalties increased alert fatigue. The final reward structure therefore reflects a balanced empirical design optimized for practical IoT intrusion detection scenarios.

4. Datasets and Preprocessing

4.1. CICIoT2023

CICIoT2023 [11] is a large-scale IoT intrusion detection benchmark developed by the Canadian Institute for Cybersecurity (CIC) at the University of New Brunswick. The dataset captures network traffic from a testbed of 105 real heterogeneous IoT devices across 33 distinct attack categories, encompassing DDoS, DoS, Mirai botnet variants, man-in-the-middle attacks, and reconnaissance campaigns. The dataset comprises 8.94 GB of raw PCAP data, processed into CSV-format flow records with 46 features extracted using CICFlowMeter-V4.0. It has been adopted as a primary benchmark in multiple peer-reviewed publications since its release [27].

4.2. CIC IoT-DIAD 2024

CIC IoT-DIAD 2024 [12] is a flow-based IoT intrusion detection dataset released by CIC/UNB in 2024. The dataset provides comprehensive benign and attack traffic scenarios across a range of IoT device categories, with flow records generated under realistic network conditions. Its adoption in a 2025 Springer publication validates its suitability as a contemporary benchmark [25]. We employ this dataset as a secondary evaluation corpus to assess cross-dataset generalization of the proposed framework.

4.3. Preprocessing Pipeline

The preprocessing pipeline comprises four stages applied consistently across both datasets:
  • Feature cleaning: Removal of infinite and NaN values introduced by zero-duration flows; constant features eliminated via variance thresholding.
  • Normalization: Min-max scaling applied to all continuous features to the range [0, 1].
  • Class imbalance mitigation: Synthetic Minority Oversampling Technique (SMOTE) applied to minority attack categories with fewer than 1000 samples.
  • Dataset partitioning: Stratified split into training (70%), validation (15%), and test (15%) sets, preserving class distribution across all subsets.
To prevent data leakage, dataset partitioning was performed prior to oversampling and normalization. SMOTE was applied exclusively to the training subset, while normalization parameters were fitted on the training data and subsequently applied to the validation and test sets.
Figure 1 illustrates the four-stage preprocessing pipeline applied to the datasets, including feature cleaning, normalization, class imbalance mitigation using SMOTE, and stratified dataset partitioning into training, validation, and test sets.
Table 4 summarizes the key characteristics of the datasets used in this study, namely CICIoT2023 and CIC IoT-DIAD 2024. It highlights differences in dataset size, number of attack classes, feature dimensions, and release year. CICIoT2023 is larger, containing approximately 4.5 million flows across 33 attack categories, with 46 features, while CIC IoT-DIAD 2024 includes around 2.1 million flows across 12 attack classes, with 48 features. Both datasets are recent, reflecting modern IoT attack scenarios and providing a realistic basis for evaluating intrusion detection models.
Table 4. Summary of CICIoT2023 and CIC IoT-DIAD 2024 Datasets.

5. Experimental Setup

5.1. Baseline Methods

The proposed RL-IoTIDS framework is compared against four baseline classifiers: Support Vector Machine (SVM) with an RBF kernel, Random Forest (RF) with 200 estimators, a standalone CNN with the same convolutional backbone as the proposed model, and a standalone bidirectional LSTM. All baselines are trained using identical preprocessing pipelines and evaluated on the same test splits to ensure fair comparison.
Figure 2 presents the overall experimental framework for evaluating the proposed reinforcement learning-based IoT intrusion detection system (RL-IoTIDS) against multiple baseline classifiers. The pipeline begins with two modern IoT datasets, CICIoT2023 and CIC IoT-DIAD 2024, which differ in size, number of attack classes, and feature dimensions. A unified preprocessing pipeline is applied to both datasets, consisting of feature cleaning (removal of infinite and NaN values and elimination of constant features), min–max normalization to the range [0, 1], class imbalance mitigation using SMOTE for minority attack categories, and stratified dataset partitioning into training (70%), validation (15%), and test (15%) subsets.
Figure 2. Machine Learning Preprocessing Pipeline.
Following preprocessing, the proposed RL-IoTIDS model is compared with four baseline approaches: Support Vector Machine (SVM) with an RBF kernel, Random Forest with 200 estimators, a standalone CNN model, and a standalone bidirectional LSTM (BiLSTM). All models are trained using the same processed data and evaluated on identical test splits to ensure a fair and consistent comparison.
Figure 3 shows the overall experimental workflow and evaluation framework of the proposed RL-IoTIDS system for IoT intrusion detection. The figure begins with the utilized datasets, namely CICIoT2023 and CIC IoT-DIAD 2024, which contain multiple attack classes and network traffic features. The preprocessing pipeline includes feature cleaning to remove infinite and NaN values, normalization using min-max scaling to the range [0, 1], class imbalance mitigation using SMOTE for minority classes with fewer than 1000 samples, and stratified dataset partitioning into training, validation, and test sets. The figure also illustrates the evaluated models, including the proposed RL-IoTIDS framework, SVM with RBF kernel, Random Forest, standalone CNN, and standalone BiLSTM models. Finally, the evaluation stage summarizes the adopted performance metrics, including accuracy, precision, recall, macro-averaged F1-score, false alarm rate (FAR), and detection latency, while ensuring statistical reliability through averaging results over five independent experimental runs.
Figure 3. Framework of the Proposed RL-IoTIDS with Baseline Classifiers.
The baseline comparison in this study primarily focuses on widely adopted static ML/DL intrusion detection models to evaluate overall detection effectiveness under identical preprocessing and testing conditions. Although reinforcement learning approaches inherently provide adaptive capabilities beyond static classifiers, implementing and tuning multiple RL algorithms such as PPO and A2C requires substantially different environment interaction dynamics and optimization strategies, which is beyond the current study scope. Nevertheless, recent RL-based IDS studies are discussed in Section 2 to position the proposed framework relative to existing adaptive intrusion detection approaches.

5.2. Evaluation Metrics

The evaluation component includes five key performance metrics: accuracy, precision, recall, macro-averaged F1-score, and false alarm rate (FAR). In addition, detection latency is reported in milliseconds per flow to assess the practical efficiency of the models in real-time scenarios. To ensure statistical robustness, all experimental results are averaged over five independent runs with different random seeds. Overall, the figure illustrates a comprehensive, controlled evaluation framework for assessing the effectiveness and efficiency of the proposed RL-based intrusion detection system in IoT environments.

5.3. Implementation Details

All models are implemented in Python 3.10 using PyTorch 2.1 and Stable-Baselines3 for the RL components. Experiments are conducted on a system with an NVIDIA RTX 4090 GPU, 64 GB RAM, and an Intel Core i9-13900 K CPU. The DQN agent is trained for 200 episodes, with each episode comprising 10,000 environment steps. Hyperparameters are tuned via grid search on the validation set: learning rate in { 1 e − 4 ,   5 e − 4 , 1 e − 3 } discount factor in {0.95, 0.99}, and batch size in {64, 128, 256}. Best-performing configurations are reported in Table 5. The CNN encoder consists of three 1D convolutional layers with 64, 128, and 256 filters, respectively, each using a kernel size of 3 and ReLU activation. The temporal modeling component employs a two-layer bidirectional LSTM with 128 hidden units in each direction.
Table 5. Selected hyperparameters for RL-IoTIDS.

6. Results and Discussion

6.1. Overall Classification Performance

Table 6 presents the classification performance of all evaluated methods on the CICIoT2023 test set. RL-IoTIDS achieves the highest macro-averaged F1-score of 0.963 and the lowest FAR of 0.021, representing improvements of 2.1 and 1.4 percentage points, respectively, over the best-performing static baseline (Bi-LSTM). The superior FAR of the proposed model directly reflects the contribution of the false-positive-aware reward function described in Section 3.4.
Table 6. Comparative performance on CICIoT2023 test set.
Across all metrics, RL-IoTIDS consistently outperforms the four baselines. The SVM baseline performs worst, reflecting its difficulty in handling the high-dimensional, non-linearly separable feature space of IoT traffic. Random Forest achieves competitive accuracy but exhibits a higher FAR than the deep learning models, suggesting a tendency to over-classify benign traffic as malicious. Both CNN and Bi-LSTM achieve similar F1 Scores, confirming the value of deep feature extraction for IoT intrusion detection, while RL-IoTIDS surpasses both through adaptive policy optimization.
Although RL-IoTIDS achieved strong overall macro-averaged performance, certain low-frequency attack categories exhibited slightly lower recall compared with dominant classes. This behavior is primarily attributed to class imbalance and feature similarity between some attack patterns and benign traffic. In particular, reconnaissance and low-rate flooding attacks occasionally generated false positives due to overlapping statistical flow characteristics with legitimate burst traffic. Similarly, a limited number of false negatives were observed in rare attack categories with highly sparse training samples. Nevertheless, the proposed reward-shaping mechanism substantially reduced excessive false alarm generation compared with baseline models.

6.2. Cross-Dataset Generalization

Evaluation on CIC IoT-DIAD 2024 without fine-tuning (zero-shot transfer) yields a macro F1-score of 0.911, compared to 0.874 for the best-performing static baseline. This demonstrates that the CNN-LSTM state encoder learns transferable feature representations across heterogeneous IoT environments. After 20 episodes of online adaptation in the new environment, the F1-score further improves to 0.948, demonstrating the RL agent’s adaptive capability compared to static classifiers, which require full retraining when deployed to a new network.
During cross-dataset adaptation, the RL agent was initialized using the policy learned on CICIoT2023 and subsequently deployed on the CIC IoT-DIAD 2024 environment without parameter resetting. Online adaptation was performed for 20 episodes, with each episode consisting of 10,000 interaction steps. Ground-truth labels available within the benchmark environment were used exclusively for reward generation during training and were not directly exposed to the agent as input features. To ensure statistical reliability, all cross-dataset experiments were repeated across five independent runs with different random seeds, and the reported results correspond to the mean performance across these runs.
Figure 4 illustrates the online adaptation behavior of the proposed RL-IoTIDS framework during cross-dataset deployment on the CIC IoT-DIAD 2024 dataset. The RL agent was initially trained on CICIoT2023 and subsequently adapted without parameter reinitialization. The learning curve shows progressive improvement in detection performance across adaptation episodes, confirming the proposed framework’s ability to refine its policy in previously unseen IoT environments. The reported values represent the mean performance across five independent runs using different random seeds, highlighting both adaptation stability and generalization capability.
Figure 4. Cross-dataset online adaptation performance of RL-IoTIDS on the CIC IoT-DIAD 2024 dataset.

6.3. Reward-Shaping Ablation

Ablation experiments confirm the effectiveness of the false-positive-aware reward-shaping mechanism. As shown in Table 7, an agent trained with a symmetric reward (+1/−1) achieves a FAR of 0.047, whereas the proposed asymmetric reward reduces the FAR to 0.021 with only a marginal 0.4% decrease in recall. This trade-off is operationally significant in real-world IoT deployments, where high false alarm rates can lead to alert fatigue and reduce the practicality of IDS alerts. The asymmetric reward structure, therefore, offers a principled approach to balancing detection sensitivity with operational usability.
Table 7. Ablation study showing the impact of reward shaping on FAR and recall.
Figure 5 illustrates the average reward obtained by the RL-IoTIDS agent during training. The progressive increase and stabilization of the reward values indicate successful policy learning and convergence of the reinforcement learning process. The results demonstrate that the proposed reward-shaping strategy enables stable adaptation and effective decision optimization over training episodes.
Figure 5. Reward convergence curve during RL-IoTIDS training across 200 episodes.

6.4. Detection Latency

Figure 6 presents the mean detection latency per flow for different machine learning and deep learning models used in intrusion detection. SVM achieves the lowest latency at 0.4 ms, followed by Random Forest (1.2 ms), CNN (1.5 ms), and Bi-LSTM (1.6 ms). The proposed RL-IoTIDS framework incurs a latency of 1.8 ms due to the additional DQN inference step, resulting in a marginal overhead of approximately 0.2 ms compared to the CNN-LSTM baseline. Despite this increase, the latency remains well within acceptable limits for real-time IoT network monitoring, where timely detection is critical.
Figure 6. Detection latency comparison of baseline models and RL-IoTIDS.

7. Conclusions

This paper presents RL-IoTIDS, an autonomous reinforcement-learning-based intrusion detection framework for IoT cyber defense. Three key contributions were made: (1) a DQN agent with a CNN-LSTM state encoder that captures both local and temporal features of IoT network traffic; (2) a false-positive-aware asymmetric reward function that balances security sensitivity with operational false alarm tolerance; and (3) comprehensive evaluation on CICIoT2023 and CIC IoT-DIAD 2024, two contemporary publicly available datasets, demonstrating state-of-the-art F1-score of 0.963 and FAR of 0.021 on the primary benchmark.
Despite the promising performance achieved by the proposed RL-IoTIDS framework, several limitations remain. First, integrating CNN-LSTM feature extraction with reinforcement learning introduces additional computational overhead compared with lightweight static classifiers, potentially limiting deployment on highly resource-constrained IoT edge devices. Second, the reinforcement learning agent relies on reward feedback derived from labeled benchmark environments during training, which may not always be directly available in fully unsupervised real-world deployments. Third, although cross-dataset evaluation was conducted, the experiments remained limited to publicly available benchmark datasets rather than to live operational IoT infrastructures. Finally, the current study primarily focuses on flow-based traffic features and does not incorporate raw-packet payload analysis, which may limit detection capabilities against certain sophisticated or encrypted attack scenarios.
Several promising future directions emerge from this work. First, extending the state representation to include raw packet-level features would allow the model to exploit payload semantics alongside flow statistics, potentially improving the detection of encrypted attack traffic. Second, federated RL training across distributed IoT gateways represents a compelling direction for privacy-preserving deployment at scale, enabling collaborative policy learning without centralizing sensitive traffic data. Third, integrating with real-time threat intelligence feeds could enrich the reward signal with contextual attack-severity information, further improving the operational utility of autonomous IoT cyber defense systems.

Funding

This research received no external funding.

Institutional Review Board Statement

Not applicable.

Data Availability Statement

The CICIoT2023 and CIC IoT-DIAD 2024 datasets are publicly available from the Canadian Institute for Cybersecurity at https://www.unb.ca/cic/datasets/index.html (accessed on 1 April 2026).

Acknowledgments

The author would like to acknowledge the support provided by Princess Sumaya University for Technology (PSUT), Amman, Jordan, for facilitating this research. Grammarly was used for language refinement, and Canva was used to enhance figure clarity and presentation. These tools were used only for editing and visualization support.

Conflicts of Interest

The author declares no conflicts of interest.

Abbreviations

The following abbreviations are used in this manuscript:
IoTInternet of Things
IDSIntrusion Detection System
RLReinforcement Learning
DQNDeep Q-Network
CNNConvolutional Neural Network
LSTMLong Short-Term Memory
FARFalse Alarm Rate

References

  1. Miller, T.; Mikiciuk, G.; Durlik, I.; Mikiciuk, M.; Łobodzińska, A.; Śnieg, M. The IoT and AI in agriculture: The time is now—A systematic review of smart sensing technologies. Sensors 2025, 25, 3583. [Google Scholar] [CrossRef] [Scilit]
  2. Bollineni, C.; Sharma, M.; Hazra, A.; Kumari, P.; Manipriya, S.; Tomar, A. IoT for next-generation smart healthcare: A comprehensive survey. IEEE Internet Things J. 2025, 12, 32616–32639. [Google Scholar] [CrossRef] [Scilit]
  3. Sajo, A.; Sarjiyus, O. A Recurrent Neural Network Approach for Detecting and Mitigating Denial of Service (DoS) and Man in the Middle (MitM) Attacks in Cyberspace. J. Sci. Innov. Technol. Res. 2025, 9, 033. [Google Scholar] [CrossRef] [Scilit]
  4. Al-Zewairi, M.; Almajali, S.; Ayyash, M.; Rahouti, M.; Martinez, F.; Quadar, N. Multi-stage enhanced zero trust intrusion detection system for unknown attack detection in internet of things and traditional networks. ACM Trans. Priv. Secur. 2025, 28, 1–28. [Google Scholar] [CrossRef] [Scilit]
  5. Hozouri, A.; Mirzaei, A.; Effatparvar, M. A comprehensive survey on intrusion detection systems with advances in machine learning, deep learning and emerging cybersecurity challenges. Discov. Artif. Intell. 2025, 5, 314. [Google Scholar] [CrossRef] [Scilit]
  6. Rakine, I.; Oukaira, A.; El Guemmat, K.; Atouf, I.; Ouahabi, S.; Talea, M.; Bouragba, T. Comprehensive Review of Intrusion Detection Techniques: ML and DL in Different Networks. IEEE Access 2025, 13, 104345–104367. [Google Scholar] [CrossRef] [Scilit]
  7. Babar, A.; Halabi, T.; Zulkernine, M. Autonomous and adaptive cyber incident detection and response in industrial cyber-physical systems using hierarchical reinforcement learning. ACM Trans. Cyber-Phys. Syst. 2026, 10, 1–27. [Google Scholar] [CrossRef] [Scilit]
  8. Kim, Y.; Hong, S.-Y.; Park, S.; Kim, H.K. Reinforcement learning-based generative security framework for host intrusion detection. IEEE Access 2025, 13, 15346–15362. [Google Scholar] [CrossRef] [Scilit]
  9. Yang, X.; Howley, E.; Schukat, M. Agent-based dynamic thresholding for adaptive anomaly detection using reinforcement learning. Neural Comput. Appl. 2025, 37, 18775–18791. [Google Scholar] [CrossRef] [Scilit]
  10. Fan, J.; Shar, L.K.; Zhang, R.; Liu, Z.; Yang, W.; Niyato, D.; Lam, K.-Y. Deep learning approaches for anti-money laundering on mobile transactions: Review, framework, and directions. IEEE Internet Things J. 2026, 13, 10407–10431. [Google Scholar] [CrossRef] [Scilit]
  11. Canadian Institute for Cybersecurity. CIC IoT Attack Dataset 2023. Available online: https://www.unb.ca/cic/datasets/iotdataset-2023.html (accessed on 1 April 2026).
  12. Canadian Institute for Cybersecurity. CIC IoT-DIAD. 2024. Available online: https://www.unb.ca/cic/datasets/index.html (accessed on 1 April 2026).
  13. Tiwari, S.; Bastian, N.D.; Kul, G. DQN-IDS: A Deep Reinforcement Learning Approach for Open Set-Enabled Intrusion Detection. In Proceedings of the Workshop on Security and Privacy in Standardized IoT (SDIoTSec) 2026, San Diego, CA, USA, 23 February 2026. [Google Scholar]
  14. Hu, Y.; Feng, Y.; Zhao, Y.; Mao, X. IoT-ONDDQN: A detection model based on deep reinforcement learning for IoT data security. Comput. Commun. 2025, 241, 108263. [Google Scholar] [CrossRef] [Scilit]
  15. Khayat, M.; Barka, E.; Serhani, M.A.; Sallabi, F.; Shuaib, K.; Khater, H.M. Reinforcement learning with deep features: A dynamic approach for intrusion detection in IoT networks. IEEE Access 2025, 13, 92319–92337. [Google Scholar] [CrossRef] [Scilit]
  16. Almahaqeri, S.A.; Almourish, M.H.; Nasser, A.A.; Alghawli, A.S.A.; Elsayed, A.A.; Alhejoj, A.N. An optimized gradient boosting framework for IoT intrusion detection: A comprehensive evaluation on the CICIoT2023 dataset. Sci. Rep. 2026, 47399. [Google Scholar] [CrossRef] [Scilit] [PubMed]
  17. Tseng, S.-M.; Wang, Y.-Q.; Wang, Y.-C. Multi-class intrusion detection based on transformer for IoT networks using CIC-IoT-2023 dataset. Future Internet 2024, 16, 284. [Google Scholar] [CrossRef] [Scilit]
  18. Hossain, M.A. Deep learning-based intrusion detection for IoT networks: A scalable and efficient approach. EURASIP J. Inf. Secur. 2025, 2025, 28. [Google Scholar] [CrossRef] [Scilit]
  19. Shtayat, M.B.M.; Hasan, M.K.; Sulaiman, R.; Islam, S.; Khan, A.U.R. An explainable ensemble deep learning approach for intrusion detection in industrial internet of things. IEEE Access 2023, 11, 115047–115061. [Google Scholar] [CrossRef] [Scilit]
  20. Sharafaldin, I.; Lashkari, A.H.; Ghorbani, A.A. Toward generating a new intrusion detection dataset and intrusion traffic characterization. ICISSp 2018, 1, 108–116. [Google Scholar]
  21. He, M.; Wang, X.; Wei, P.; Yang, L.; Teng, Y.; Lyu, R. Reinforcement learning meets network intrusion detection: A transferable and adaptable framework for anomaly behavior identification. IEEE Trans. Netw. Serv. Manag. 2024, 21, 2477–2492. [Google Scholar] [CrossRef] [Scilit]
  22. Nguyen, T.T.; Reddi, V.J. Deep reinforcement learning for cyber security. IEEE Trans. Neural Netw. Learn. Syst. 2021, 34, 3779–3795. [Google Scholar] [CrossRef] [Scilit]
  23. Shafi, M.; Lashkari, A.H. Toward generating a large-scale IoT-Zwave intrusion detection dataset: Smart device profiling, intruders behaviour, and traffic characterization. Internet Things 2025, 34, 101747. [Google Scholar] [CrossRef] [Scilit]
  24. Dadkhah, S.; Neto, E.C.P.; Ferreira, R.; Molokwu, R.C.; Sadeghi, S.; Ghorbani, A. Ciciomt2024: Attack vectors in healthcare devices-a multi-protocol dataset for assessing iomt device security. Preprints 2024, 28, 101351. [Google Scholar] [CrossRef] [Scilit]
  25. Hossain, M.A.; Islam, M.S. An ensemble-based machine learning approach for botnet-based DDoS attack detection. In 2023 IEEE International Conference on Telecommunications and Photonics (ICTP); IEEE: New York, NY, USA, 2023. [Google Scholar]
  26. Kheddar, H.; Dawoud, D.W.; Awad, A.I.; Himeur, Y.; Khan, M.K. Reinforcement-learning-based intrusion detection in communication networks: A review. IEEE Commun. Surv. Tutor. 2024, 27, 2420–2469. [Google Scholar] [CrossRef] [Scilit]
  27. Jakotiya, K.; Shirsath, V.; Mishra, R.G. Feature Engineering Using Machine Learning Techniques on CIC-IOT-2023 Dataset. In International Conference on Machine Vision and Augmented Intelligence; Springer: Berlin/Heidelberg, Germany, 2023. [Google Scholar]
  28. Van Hasselt, H.; Guez, A.; Silver, D. Deep reinforcement learning with double q-learning. In Proceedings of the AAAI Conference on Artificial Intelligence; AAAI Press: Palo Alto, CA, USA, 2016. [Google Scholar]
  29. Wang, Z.; Schaul, T.; Hessel, M.; Hasselt, H.; Lanctot, M.; Freitas, N. Dueling network architectures for deep reinforcement learning. In International Conference on Machine Learning; PMLR: Cambridge, MA, USA, 2016. [Google Scholar]
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.

Article Metrics

Citations

Article Access Statistics

Multiple requests from the same IP address are counted as one view.