Unsupervised Deep Learning-Based Network Traffic Anomaly Detection for DDoS Mitigation in Smart Microgrid Communication Infrastructure
Abstract
1. Introduction
- An unsupervised detection approach requiring no labeled attack data, trained exclusively and specifically on normal microgrid gateway traffic;
- An explicit focus on the microgrid gateway communication layer, where Modbus TCP, MQTT, and DNP3 traffic converges;
- A synthetic OT-protocol-aware dataset with traffic parameters grounded in published protocol specifications;
- A comparative evaluation between the proposed deep learning model (CNN-LSTM) and unsupervised baselines (autoencoder and isolation forest) under identical conditions;
- Full system-level integration with a real-time monitoring platform supporting live anomaly detection and logging.
2. Materials and Methods
2.1. Related Work
2.1.1. DDoS Detection in Smart Grid and Microgrid Environments
2.1.2. Deep Learning for Network Anomaly Detection
2.1.3. Unsupervised Anomaly Detection for Industrial Control Systems
2.2. System Architecture and Data Generation
2.2.1. Platform Architecture
2.2.2. Microgrid Communication Model
2.2.3. Synthetic Traffic Generation
2.2.4. Attack Scenario Generation
2.3. Detection Methodology
2.3.1. Feature Engineering
2.3.2. CNN-LSTM Architecture (Proposed Model)
2.3.3. Anomaly Threshold Determination
2.3.4. Isolation Forest Baseline
2.3.5. Autoencoder Baseline
2.3.6. Ablation Baselines
2.4. Experimental Setup
2.4.1. Dataset Description
2.4.2. Evaluation Protocol
2.4.3. Evaluation Metrics
2.4.4. Implementation Details
3. Results and Discussion
3.1. Overall Detection Performance
Sensitivity to Evaluation Protocol
3.2. Per-Attack-Type Analysis
False-Negative Analysis
3.3. Anomaly Score Visualization
3.4. Ablation Study
3.5. Computational Cost Analysis
3.6. Operational Deployment Demonstration
4. Conclusions
Author Contributions
Funding
Data Availability Statement
Conflicts of Interest
Abbreviations
| API | Application Programming Interface |
| BMS | Battery Management System |
| CNN | Convolutional Neural Network |
| CQRS | Command Query Responsibility Segregation |
| DDoS | Distributed Denial of Service |
| DNP3 | Distributed Network Protocol 3 |
| FN | False Negative |
| FP | False Positive |
| GRU | Gated Recurrent Unit |
| ICS | Industrial Control System |
| IP | Internet Protocol |
| LR | Learning Rate |
| LSTM | Long Short-Term Memory |
| ML | Machine Learning |
| MQTT | Message Queuing Telemetry Transport |
| MSE | Mean Squared Error |
| OCSVM | One-Class Support Vector Machine |
| OT | Operational Technology |
| PLC | Programmable Logic Controller |
| QoS | Quality of Service |
| ReLU | Rectified Linear Unit |
| REST | Representational State Transfer |
| SCADA | Supervisory Control and Data Acquisition |
| SDN | Software-Defined Network |
| SHAP | Shapley Additive explanations |
| TCP | Transmission Control Protocol |
| TP | True Positive |
| WAMS | Wide-Area Monitoring System |
References
- Haxhismajli, B.; Hajrizi, E.; Qehaja, B.; Guliashki, V.; Marinova, G. Enhancing Microgrid Security: Web-Based Anomaly Detection Using Autoencoder. In Proceedings of the 32nd International Conference on Systems, Signals and Image Processing (IWSSIP), Skopje, North Macedonia, 24–26 June 2025. [Google Scholar]
- Diaba, S.Y.; Elmusrati, M. Proposed algorithm for smart grid DDoS detection based on deep learning. Neural Netw. 2023, 159, 175–184. [Google Scholar] [CrossRef] [PubMed]
- Naqvi, S.S.A.; Li, Y.; Uzair, M. DDoS attack detection in smart grid network using reconstructive machine learning models. PeerJ Comput. Sci. 2024, 10, e1784. [Google Scholar] [CrossRef] [PubMed]
- AlHaddad, U.; Basuhail, A.; Khemakhem, M.; Eassa, F.E.; Jambi, K. Ensemble model based on hybrid deep learning for intrusion detection in smart grid networks. Sensors 2023, 23, 7464. [Google Scholar] [CrossRef] [PubMed]
- Hosseini Rostami, S.M.; Pourgholi, M.; Asharioun, H. Enhancing resilience of distributed DC microgrids against cyber attacks using a transformer-based Kalman filter estimator. Sci. Rep. 2025, 15, 6815. [Google Scholar] [CrossRef] [PubMed]
- Halbouni, A.; Gunawan, T.S.; Habaebi, M.H.; Halbouni, M.; Kartiwi, M.; Ahmad, R. CNN-LSTM: Hybrid deep neural network for network intrusion detection system. IEEE Access 2022, 10, 99837–99849. [Google Scholar] [CrossRef]
- Altunay, H.C.; Albayrak, Z. A hybrid CNN+LSTM-based intrusion detection system for industrial IoT networks. Eng. Sci. Technol. Int. J. 2023, 38, 101322. [Google Scholar] [CrossRef]
- Abdallah, M.; Le Khac, N.A.; Jahromi, H.; Jurcut, A.D. A hybrid CNN-LSTM based approach for anomaly detection systems in SDNs. In Proceedings of the 16th International Conference on Availability, Reliability and Security (ARES), Vienna, Austria, 17–20 August 2021. [Google Scholar] [CrossRef]
- Sinha, P.; Sahu, D.; Prakash, S.; Yang, T.; Rathore, R.S.; Pandey, V.K. A high performance hybrid LSTM CNN secure architecture for IoT environments using deep learning. Sci. Rep. 2025, 15, 9684. [Google Scholar] [CrossRef] [PubMed]
- Alashjaee, A.M. Deep learning for network security: An Attention-CNN-LSTM model for accurate intrusion detection. Sci. Rep. 2025, 15, 21856. [Google Scholar] [CrossRef] [PubMed]
- Choi, W.-H.; Kim, J. Unsupervised learning approach for anomaly detection in industrial control systems. Appl. Syst. Innov. 2024, 7, 18. [Google Scholar] [CrossRef]
- Altaha, M.; Hong, S. Anomaly detection for SCADA system security based on unsupervised learning and function codes analysis in the DNP3 protocol. Electronics 2022, 11, 2184. [Google Scholar] [CrossRef]
- Zare, F.; Mahmoudi-Nasr, P.; Yousefpour, R. A real-time network based anomaly detection in industrial control systems. Int. J. Crit. Infrastruct. Prot. 2024, 45, 100676. [Google Scholar] [CrossRef]
- Ha, D.T.; Hoang, N.X.; Hoang, N.V.; Du, N.H.; Huong, T.T.; Tran, K.P. Explainable anomaly detection for industrial control system cybersecurity. IFAC-PapersOnLine 2022, 55, 1183–1188. [Google Scholar] [CrossRef]
- Ghosh, T.; Bagui, S.; Bagui, S.; Kadzis, M.; Bare, J. Anomaly detection for Modbus over TCP in control systems using entropy and classification-based analysis. J. Cybersecur. Priv. 2023, 3, 895–913. [Google Scholar] [CrossRef]
- Modbus Organization. Modbus Application Protocol Specification V1.1b3. 2012. Available online: https://www.modbus.org/file/secure/modbusprotocolspecification.pdf (accessed on 2 March 2026).
- OASIS. MQTT Version 5.0 Standard. 2019. Available online: https://docs.oasis-open.org/mqtt/mqtt/v5.0/mqtt-v5.0.html (accessed on 2 March 2026).
- IEEE Std 1815-2012; IEEE Standard for Electric Power Systems Communications-Distributed Network Protocol (DNP3). IEEE: Piscataway, NJ, USA, 2012.
- Bhatia, S.; Kush, N.; Djamaludin, C.; Akande, A.J.; Foo, E. Practical Modbus Flooding Attack and Detection. In Proceedings of the Twelfth Australasian Information Security Conference (AISC 2014), Auckland, New Zealand, 20–23 January 2014; pp. 57–65. [Google Scholar]
- Alatram, A.; Sikos, L.F.; Johnstone, M.; Szewczyk, P.; Kang, J.J. DoS/DDoS-MQTT-IoT: A dataset for evaluating intrusions in IoT networks using the MQTT protocol. Comput. Netw. 2023, 231, 109809. [Google Scholar] [CrossRef]
- Jin, D.; Nicol, D.M.; Yan, G. An event buffer flooding attack in DNP3 controlled SCADA systems. In Proceedings of the 2011 Winter Simulation Conference (WSC), Phoenix, AZ, USA, 11–14 December 2011; pp. 2614–2626. [Google Scholar] [CrossRef]
- Hochreiter, S.; Schmidhuber, J. Long short-term memory. Neural Comput. 1997, 9, 1735–1780. [Google Scholar] [CrossRef] [PubMed]
- Liu, F.; Ting, K.; Zhou, Z.-H. Isolation forest. In Proceedings of the 8th IEEE International Conference on Data Mining (ICDM), Pisa, Italy, 15–19 December 2008; pp. 413–422. [Google Scholar] [CrossRef]
- Paszke, A.; Gross, S.; Massa, F.; Lerer, A.; Bradbury, J.; Chanan, G.; Killeen, T.; Lin, Z.; Gimelshein, N.; Antiga, L.; et al. PyTorch: An imperative style, high-performance deep learning library. In Advances in Neural Information Processing Systems 32 (NeurIPS); Curran Associates: Red Hook, NY, USA, 2019. [Google Scholar]
- Pedregosa, F.; Varoquaux, G.; Gramfort, A.; Michel, V.; Thirion, B.; Grisel, O.; Blondel, M.; Prettenhofer, P.; Weiss, R.; Dubourg, V.; et al. Scikit-learn: Machine learning in Python. J. Mach. Learn. Res. 2011, 12, 2825–2830. [Google Scholar]





| Feature | Description | Unit | Sampling Rate |
|---|---|---|---|
| Latency | Round-trip communication delay | ms | 2 s |
| Throughput | Data transfer rate at gateway interface | Mbps | 2 s |
| Packet Loss | Proportion of packets dropped | % | 2 s |
| Jitter | Inter-arrival time variation | ms | 2 s |
| Bandwidth Utilization | Proportion of available bandwidth in use | % | 2 s |
| Field | Description | Type | Example |
|---|---|---|---|
| SrcIp | Source IP address | String | 192.168.1.10 |
| DstIp | Destination IP address | String | 203.0.113.50 |
| Protocol | OT protocol identifier | String | Modbus/MQTT/DNP3 |
| BytesIn | Bytes received | Integer | - |
| BytesOut | Bytes sent | Integer | - |
| PacketsIn | Packets received | Integer | - |
| PacketsOut | Packets sent | Integer | - |
| TsStart | Flow start timestamp | Datetime | - |
| TsEnd | Flow end timestamp | Datetime | - |
| FlowDuration | TsEnd—TsStart | Seconds | - |
| Parameter | Modbus TCP | MQTT | DNP3 |
|---|---|---|---|
| Polling interval | 1–5 s | Event-driven | 2–10 s |
| Typical packet size | 60–260 bytes | 50–1500 bytes | 10–292 bytes |
| Function codes/message types | FC 03, 04 (read) | PUBLISH and SUBSCRIBE | Integrity poll; event class |
| Specification reference | [16] | [17] | [18] |
| Attack Scenario | Protocol | Traffic Signature | Metric Impact |
|---|---|---|---|
| Modbus SCADA Flooding | Modbus TCP | Few sources, large flows, bandwidth saturation, and disrupted polling regularity | BandwidthUtil 90–100%; high PacketLoss + Latency |
| MQTT Publish Storm | MQTT | Many sources, small flows, packet explosion, and quality of service (QoS) shift | Moderate BandwidthUtil; high PacketCount |
| DNP3 Response Flooding | DNP3 | Multi-source burst, small packets, high jitter, and timing deviation | Very high jitter; sharp latency spike |
| Scenario | Packet Rate (pkt/s) | Burst Duration (s) | Source IPs | Attack-to-Normal Ratio | Parameter Rationale |
|---|---|---|---|---|---|
| Modbus SCADA flooding | 800–1200 | 30–60 | 3–5 | ≈6:1 | Volumetric Modbus/TCP flood pattern characterized by Bhatia et al., with rate scaled to a 1 Mbps gateway link [19] |
| MQTT publish storm | 250–400 | 20–45 | 8–15 | ≈4:1 | Multi-source MQTT broker overload pattern (CONNECT- and PUBLISH-flood family); detection setting motivated by the DoS/DDoS-MQTT-IoT dataset of Alatram et al. [20] |
| DNP3 response flooding | 150–300 | 15–30 | 2–4 | ≈3:1 | Unsolicited-response flooding pattern modeled after the event-buffer flooding attack of Jin et al., exploiting the unsolicited-response mechanism defined in IEEE 1815-2012 [21] |
| Class | Label | Protocol | Windows | % of Test Set |
|---|---|---|---|---|
| Normal | 0 | All | ~8600 per fold | ~44% |
| Modbus Flood | 1 | Modbus TCP | ~3580 | ~19% |
| MQTT Storm | 2 | MQTT | ~3580 | ~19% |
| DNP3 Flood | 3 | DNP3 | ~3580 | ~18% |
| Feature | Mean | Std. Dev. | Min. | Max. | Skewness |
|---|---|---|---|---|---|
| Latency (ms) | 12.4 | 3.7 | 2.1 | 45.8 | 1.83 |
| Throughput (Mbps) | 4.6 | 1.9 | 0.3 | 12.1 | 0.72 |
| Packet Loss (%) | 0.8 | 0.6 | 0.0 | 4.2 | 2.14 |
| Jitter (ms) | 2.1 | 1.3 | 0.1 | 11.7 | 2.47 |
| Bandwidth Util. (%) | 38.2 | 14.7 | 3.5 | 78.6 | 0.41 |
| TotalBytesIn | 24,580 | 8430 | 1240 | 62,100 | 0.89 |
| TotalBytesOut | 18,920 | 7110 | 890 | 51,300 | 0.94 |
| TotalPacketsIn | 187 | 64 | 12 | 478 | 0.76 |
| TotalPacketsOut | 142 | 53 | 8 | 389 | 0.81 |
| UniqueSourceIPs | 4.2 | 1.1 | 1 | 9 | 0.63 |
| FlowCount | 6.8 | 2.3 | 1 | 18 | 0.71 |
| AvgFlowDuration (s) | 1.87 | 0.42 | 0.3 | 3.9 | 0.38 |
| Modbus % | 34.1 | 8.7 | 0.0 | 100.0 | 0.52 |
| MQTT % | 41.3 | 9.2 | 0.0 | 100.0 | −0.31 |
| DNP3% | 24.6 | 7.8 | 0.0 | 100.0 | 0.44 |
| (a) | |
|---|---|
| Parameter | Value |
| Learning rate | 0.001 |
| Batch size | 64 |
| LSTM hidden size | 128 |
| LSTM layers | 2 |
| LSTM dropout | 0.2 |
| CNN filters | [32, 64] |
| CNN kernel size | 3 |
| CNN pooling | AdaptiveAvgPool1d |
| CNN output dimension | 96 |
| Fusion input dimension | 224 (128 + 96) |
| Fusion hidden dimension | 128 |
| Fusion dropout | 0.3 |
| Fusion output dimension | 5 |
| Max. epochs | 100 |
| Early stopping patience | 10 |
| Learning-rate (LR) scheduler | None |
| Threshold percentile | 99.5th |
| Window size | 20 ticks |
| Window step | 1 tick |
| Optimizer | Adam |
| Normalization | Min–Max |
| (b) | |
| Parameter | Value |
| n_estimators | 100 |
| contamination | auto |
| max_samples | auto |
| max_features | 1.0 |
| random_state | 42 |
| Input dimension | 110 (flattened 20 × 5 + 10) |
| (c) | |
| Parameter | Value |
| Encoder architecture | 110 → 64 → 32 |
| Decoder architecture | 32 → 64 → 110 |
| Hidden-layer activation | ReLU |
| Output activation | Linear |
| Loss function | Mean squared error |
| Optimizer | Adam |
| Learning rate | 0.001 |
| Batch size | 64 |
| Max. epochs | 100 |
| Early stopping patience | 10 (on validation reconstruction error) |
| LR scheduler | None |
| Normalization | Min–Max |
| Threshold percentile | 99.5th |
| (d) | |
| Parameter | Value |
| Random seed | 42 |
| Python | 3.12 |
| PyTorch [24] | 2.10.0 |
| scikit-learn [25] | 1.8.0 |
| Hardware | AMD Ryzen 9 5900HX, 32 GB RAM, CPU-only |
| (a) | ||
|---|---|---|
| Model | Precision | Recall |
| CNN-LSTM (proposed) | 0.967 ± 0.012 | 0.953 ± 0.014 |
| Isolation forest | 0.921 ± 0.018 | 0.894 ± 0.021 |
| LSTM-only | 0.948 ± 0.015 | 0.931 ± 0.017 |
| CNN-only | 0.932 ± 0.019 | 0.907 ± 0.022 |
| Autoencoder | 0.926 ± 0.019 | 0.905 ± 0.024 |
| (b) | ||
| Model | Precision | Recall |
| CNN-LSTM (proposed) | 0.962 ± 0.024 | 0.946 ± 0.027 |
| Isolation forest | 0.913 ± 0.031 | 0.881 ± 0.035 |
| LSTM-only | 0.941 ± 0.027 | 0.922 ± 0.030 |
| CNN-only | 0.924 ± 0.030 | 0.898 ± 0.034 |
| Autoencoder | 0.917 ± 0.029 | 0.892 ± 0.033 |
| Model | Modbus Flood Recall | MQTT Storm Recall | DNP3 Flood Recall |
|---|---|---|---|
| CNN-LSTM | 0.981 ± 0.008 | 0.957 ± 0.013 | 0.923 ± 0.019 |
| Isolation forest | 0.942 ± 0.016 | 0.897 ± 0.024 | 0.843 ± 0.028 |
| LSTM-only | 0.968 ± 0.011 | 0.939 ± 0.016 | 0.887 ± 0.023 |
| CNN-only | 0.951 ± 0.014 | 0.912 ± 0.020 | 0.857 ± 0.026 |
| Autoencoder | 0.954 ± 0.014 | 0.908 ± 0.021 | 0.852 ± 0.027 |
| Attack Type | Low Intensity (FN/Total) | Medium Intensity (FN/Total) | High Intensity (FN/Total) | Total FN |
|---|---|---|---|---|
| Modbus SCADA flooding | 50/200 | 14/800 | 4/2580 | 68 |
| MQTT publish storm | 95/400 | 47/2500 | 12/680 | 154 |
| DNP3 response flooding | 175/1500 | 78/1280 | 23/800 | 276 |
| Window Size (ticks) | Precision | Recall |
|---|---|---|
| 10 | 0.934 ± 0.021 | 0.917 ± 0.024 |
| 20 (default) | 0.967 ± 0.012 | 0.953 ± 0.014 |
| 30 | 0.971 ± 0.011 | 0.949 ± 0.015 |
| 40 | 0.969 ± 0.013 | 0.944 ± 0.017 |
| Percentile | Precision | Recall |
|---|---|---|
| 90th | 0.891 ± 0.023 | 0.978 ± 0.009 |
| 95th | 0.928 ± 0.017 | 0.971 ± 0.011 |
| 97th | 0.947 ± 0.014 | 0.964 ± 0.013 |
| 99th | 0.961 ± 0.013 | 0.958 ± 0.014 |
| 99.5th (default) | 0.967 ± 0.012 | 0.953 ± 0.014 |
| Model | Parameters | Model Size (MB) | Training Time/Fold | Inference Time/Window |
|---|---|---|---|---|
| CNN-LSTM | ~243K | ~1.0 | ~8 min | ~2 ms |
| Isolation forest | N/A | ~15 | ~30 s | ~0.1 ms |
| LSTM-only | ~201K | ~0.8 | ~5 min | ~1.5 ms |
| CNN-only | ~13K | ~0.05 | ~2 min | ~0.5 ms |
| Autoencoder | ~18K | ~0.07 | ~3 min | ~0.3 ms |
| Stage | p50 (ms) | p95 (ms) | p99 (ms) |
|---|---|---|---|
| HTTP ingest → .NET handler entry | 1.6 | 3.8 | 5.4 |
| .NET handler → feature-engineering output | 9.2 | 17.4 | 24.8 |
| Feature-engineering output → FastAPI inference | 27.5 | 45.2 | 59.7 |
| FastAPI response → AnomalyEvent commit | 6.8 | 12.6 | 19.3 |
| End-to-end (HTTP send → DB commit) | 45.9 | 76.3 | 98.4 |
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.
Share and Cite
Haxhismajli, B.; Marinova, G.; Hajrizi, E.; Qehaja, B. Unsupervised Deep Learning-Based Network Traffic Anomaly Detection for DDoS Mitigation in Smart Microgrid Communication Infrastructure. Telecom 2026, 7, 58. https://doi.org/10.3390/telecom7030058
Haxhismajli B, Marinova G, Hajrizi E, Qehaja B. Unsupervised Deep Learning-Based Network Traffic Anomaly Detection for DDoS Mitigation in Smart Microgrid Communication Infrastructure. Telecom. 2026; 7(3):58. https://doi.org/10.3390/telecom7030058
Chicago/Turabian StyleHaxhismajli, Behar, Galia Marinova, Edmond Hajrizi, and Besnik Qehaja. 2026. "Unsupervised Deep Learning-Based Network Traffic Anomaly Detection for DDoS Mitigation in Smart Microgrid Communication Infrastructure" Telecom 7, no. 3: 58. https://doi.org/10.3390/telecom7030058
APA StyleHaxhismajli, B., Marinova, G., Hajrizi, E., & Qehaja, B. (2026). Unsupervised Deep Learning-Based Network Traffic Anomaly Detection for DDoS Mitigation in Smart Microgrid Communication Infrastructure. Telecom, 7(3), 58. https://doi.org/10.3390/telecom7030058

