HiViT-IDS: An Efficient Network Intrusion Detection Method Based on Vision Transformer
Abstract
:1. Introduction
- During Data Pre-processing, unnecessary features are eliminated, and one-dimensional data are converted into images, which are then input into a ViT-based model for the efficient detection of malicious traffic.
- The proposed model is compared with mainstream DTL-based IDS approaches. It demonstrates competitive accuracy while substantially reducing training time, providing a significant advantage in complex network environments.
- On the ToN-IoT and Edge-IIoTset IoT security datasets, the HiViT-IDS achieves detection accuracies exceeding 99%.
2. Related Work
3. HiViT-IDS
3.1. Dataset Description and Data Pre-Processing Module
3.2. Data Transformation Module
3.3. ViT Classifier Module
4. Result and Analysis
4.1. Experimental Environment and Model Hyperparameters
4.2. Evaluation Metrics
- False Positive (FP): Denotes the situation in which the system mistakenly identifies normal behavior or traffic as malicious activity or an attack.
- False Negative (FN): Indicates a situation where the system fails to identify genuine attacks or malicious activities, misclassifying them as normal behavior.
- True Positive (TP): Represents the instance where the system accurately detects real attacks or malicious activities and appropriately classifies them as threats.
- True Negative (TN): Describes the case in which the system accurately recognizes normal behavior or traffic as non-malicious.
4.3. Results and Analysis on ToN IoT Dataset
4.4. Results and Analysis of Edge-IIoTset Dataset
5. Conclusions
Author Contributions
Funding
Institutional Review Board Statement
Informed Consent Statement
Data Availability Statement
Conflicts of Interest
References
- Khanam, S.; Ahmedy, I.; Idris, M.Y.I.; Jaward, M.H. Towards an effective intrusion detection model using focal loss variational autoencoder for internet of things (IoT). Sensors 2022, 22, 5822. [Google Scholar] [CrossRef] [PubMed]
- Eliando, E.; Purnomo, Y. LockBit 2.0 Ransomware: Analysis of infection, persistence, prevention mechanism. CogITo Smart J. 2022, 8, 232–243. [Google Scholar] [CrossRef]
- Harry. The Puddle Attack Behind the Florida Water Plant Hack Comes to Light. 2021. Available online: https://www.ciocso.com/article/13148.html (accessed on 17 July 2021).
- Idrissi, I.; Azizi, M.; Moussaoui, O. A stratified IoT deep learning based intrusion detection system. In Proceedings of the 2022 2nd International Conference on Innovative Research in Applied Science, Engineering and Technology (IRASET), Meknes, Morocco, 3–4 March 2022; IEEE: Piscataway, NJ, USA, 2022; pp. 1–8. [Google Scholar] [CrossRef]
- Yan, Y.; Yang, Y.; Fang, S.; Gao, M.; Chen, Y. MUS Model: A Deep Learning-Based Architecture for IoT Intrusion Detection. Comput. Mater. Contin. 2024, 80, 875. [Google Scholar] [CrossRef]
- Depren, O.; Topallar, M.; Anarim, E.; Ciliz, M.K. An intelligent intrusion detection system (IDS) for anomaly and misuse detection in computer networks. Expert Syst. Appl. 2005, 29, 713–722. [Google Scholar] [CrossRef]
- Alzahrani, R.J.; Alzahrani, A. A novel multi algorithm approach to identify network anomalies in the IoT using Fog computing and a model to distinguish between IoT and Non-IoT devices. J. Sens. Actuator Netw. 2023, 12, 19. [Google Scholar] [CrossRef]
- Li, D.; Hu, Y.; Xiao, G.; Duan, M.; Li, K. An active defense model based on situational awareness and firewalls. Concurr. Comput. Pract. Exp. 2023, 35, 1. [Google Scholar] [CrossRef]
- Ferrag, M.A.; Shu, L.; Friha, O.; Yang, X. Cyber security intrusion detection for agriculture 4.0: Machine learning-based solutions, datasets, and future directions. IEEE/CAA J. Autom. Sin. 2021, 9, 407–436. [Google Scholar] [CrossRef]
- Zhu, N.; Zhu, C.; Zhou, L.; Zhu, Y.; Zhang, X. Optimization of the random forest hyperparameters for power industrial control systems intrusion detection using an improved grid search algorithm. Appl. Sci. 2022, 12, 10456. [Google Scholar] [CrossRef]
- Kethineni, K.; Pradeepini, G. Intrusion detection in internet of things-based smart farming using hybrid deep learning framework. Clust. Comput. 2024, 27, 1719–1732. [Google Scholar] [CrossRef]
- Oseni, A.; Moustafa, N.; Creech, G.; Sohrabi, N.; Strelzoff, A.; Tari, Z.; Linkov, I. An explainable deep learning framework for resilient intrusion detection in IoT-enabled transportation networks. IEEE Trans. Intell. Transp. Syst. 2022, 24, 1000–1014. [Google Scholar] [CrossRef]
- Alshehri, M.S.; Ahmad, J.; Almakdi, S.; Al Qathrady, M.; Ghadi, Y.Y.; Buchanan, W.J. SkipGateNet: A Lightweight CNN-LSTM Hybrid Model with Learnable Skip Connections for Efficient Botnet Attack Detection in IoT. IEEE Access 2024, 12, 35521–35538. [Google Scholar] [CrossRef]
- Toldinas, J.; Venčkauskas, A.; Damaševičius, R.; Grigaliūnas, Š.; Morkevičius, N.; Baranauskas, E. A novel approach for network intrusion detection using multistage deep learning image recognition. Electronics 2021, 10, 1854. [Google Scholar] [CrossRef]
- Moustafa, N.; Slay, J. UNSW-NB15: A comprehensive data set for network intrusion detection systems (UNSW-NB15 network data set). In Proceedings of the 2015 Military Communications and Information Systems Conference (MilCIS), Canberra, Australia, 10–12 November 2015; IEEE: Piscataway, NJ, USA, 2015; pp. 1–6. [Google Scholar]
- Erhan, D.; Anarım, E. Boğaziçi University distributed denial of service dataset. Data Brief 2020, 32, 106187. [Google Scholar] [CrossRef] [PubMed]
- Okey, O.D.; Melgarejo, D.C.; Saadi, M.; Rosa, R.L.; Kleinschmidt, J.H.; Rodríguez, D.Z. Transfer learning approach to IDS on cloud IoT devices using optimized CNN. IEEE Access 2023, 11, 1023–1038. [Google Scholar] [CrossRef]
- Sharafaldin, I.; Lashkari, A.H.; Ghorbani, A.A. Toward generating a new intrusion detection dataset and intrusion traffic characterization. In Proceedings of the 4th International Conference on Information Systems Security and Privacy, Funchal, Portugal, 22–24 January 2018; Volume 1, pp. 108–116. [Google Scholar] [CrossRef]
- Kanimozhi, V.; Jacob, T.P. Artificial intelligence based network intrusion detection with hyper-parameter optimization tuning on the realistic cyber dataset CSE-CIC-IDS2018 using cloud computing. In Proceedings of the 2019 International Conference on Communication and Signal Processing (ICCSP), Melmaruvathur, India, 4–6 April 2019; IEEE: Piscataway, NJ, USA, 2019; pp. 33–36. [Google Scholar]
- Yan, F.; Zhang, G.; Zhang, D.; Sun, X.; Hou, B.; Yu, N. TL-CNN-IDS: Transfer learning-based intrusion detection system using convolutional neural network. J. Supercomput. 2023, 79, 17562–17584. [Google Scholar] [CrossRef]
- Dhanabal, L.; Shantharajah, S. A study on NSL-KDD dataset for intrusion detection system based on classification algorithms. Int. J. Adv. Res. Comput. Commun. Eng. 2015, 4, 446–452. [Google Scholar]
- Zhao, J.; Liu, Y.; Zhang, Q.; Zheng, X. CNN-AttBiLSTM Mechanism: A DDoS Attack Detection Method Based on Attention Mechanism and CNN-BiLSTM. IEEE Access 2023, 11, 136308–136317. [Google Scholar] [CrossRef]
- Sharafaldin, I.; Lashkari, A.H.; Hakak, S.; Ghorbani, A.A. Developing realistic distributed denial of service (DDoS) attack dataset and taxonomy. In Proceedings of the 2019 International Carnahan Conference on Security Technology (ICCST), Chennai, India, 1–3 October 2019; IEEE: Piscataway, NJ, USA, 2019; pp. 1–8. [Google Scholar]
- Aburasain, R.Y. Enhanced Black Widow Optimization with Hybrid Deep Learning Enabled Intrusion Detection in Internet of Things-based Smart Farming. IEEE Access 2024, 12, 16621–16631. [Google Scholar] [CrossRef]
- Moustafa, N. A new distributed architecture for evaluating AI-based security systems at the edge: Network TON_IoT datasets. Sustain. Cities Soc. 2021, 72, 102994. [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]
- Wajahat, A.; He, J.; Zhu, N.; Mahmood, T.; Nazir, A.; Ullah, F.; Qureshi, S.; Dev, S. Securing Android IoT devices with GuardDroid transparent and lightweight malware detection. Ain Shams Eng. J. 2024, 15, 102642. [Google Scholar] [CrossRef]
- Chaganti, R.; Mourade, A.; Ravi, V.; Vemprala, N.; Dua, A.; Bhushan, B. A particle swarm optimization and deep learning approach for intrusion detection system in internet of medical things. Sustainability 2022, 14, 12828. [Google Scholar] [CrossRef]
- 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. Internet Things 2024, 28, 101351. [Google Scholar] [CrossRef]
- Yang, L.; Shami, A. A transfer learning and optimized CNN based intrusion detection system for Internet of Vehicles. In Proceedings of the ICC 2022-IEEE International Conference on Communications, Seoul, Republic of Korea, 16–20 May 2022; IEEE: Piscataway, NJ, USA, 2022; pp. 2774–2779. [Google Scholar]
- Seo, E.; Song, H.M.; Kim, H.K. GIDS: GAN based intrusion detection system for in-vehicle network. In Proceedings of the 2018 16th Annual Conference on Privacy, Security and Trust (PST), Northern Ireland, UK, 28–30 August 2018; IEEE: Piscataway, NJ, USA, 2018; pp. 1–6. [Google Scholar] [CrossRef]
- Latif, S.; Boulila, W.; Koubaa, A.; Zou, Z.; Ahmad, J. Dtl-ids: An optimized intrusion detection framework using deep transfer learning and genetic algorithm. J. Netw. Comput. Appl. 2024, 221, 103784. [Google Scholar] [CrossRef]
- El-Ghamry, A.; Darwish, A.; Hassanien, A.E. An optimized CNN-based intrusion detection system for reducing risks in smart farming. Internet Things 2023, 22, 100709. [Google Scholar] [CrossRef]
- Lokman, S.F.; Othman, A.T.; Bakar, M.H.A.; Musa, S. The impact of different feature scaling methods on intrusion detection for in-vehicle controller area network (CAN). In Proceedings of the Advances in Cyber Security: First International Conference, ACeS 2019, Penang, Malaysia, 30 July–1 August 2019; Revised Selected Papers 1. Springer: Berlin/Heidelberg, Germany, 2020; pp. 195–205. [Google Scholar]
- Khanday, S.A.; Fatima, H.; Rakesh, N. Implementation of intrusion detection model for DDoS attacks in Lightweight IoT Networks. Expert Syst. Appl. 2023, 215, 119330. [Google Scholar] [CrossRef]
- Vaswani, A. Attention is all you need. arXiv 2017, arXiv:1706.03762. [Google Scholar]
- Liu, Y.; Wu, L. Intrusion detection model based on improved transformer. Appl. Sci. 2023, 13, 6251. [Google Scholar] [CrossRef]
- HASAN, M.A.; Bhargav, T.; SANDEEP, V.; REDDY, V.S.; AJAY, R. Image classification using convolutional neural networks. Int. J. Mech. Eng. Res. Technol. 2024, 16, 173–181. [Google Scholar]
- Elrawy, M.F.; Awad, A.I.; Hamed, H.F. Intrusion detection systems for IoT-based smart environments: A survey. J. Cloud Comput. 2018, 7, 1–20. [Google Scholar] [CrossRef]
- Tan, M.; Le, Q. Efficientnetv2: Smaller models and faster training. In Proceedings of the International Conference on Machine Learning, PMLR, Virtual, 18–24 July 2021; pp. 10096–10106. [Google Scholar] [CrossRef]
- Friha, O.; Ferrag, M.A.; Shu, L.; Maglaras, L.; Choo, K.K.R.; Nafaa, M. FELIDS: Federated learning-based intrusion detection system for agricultural Internet of Things. J. Parallel Distrib. Comput. 2022, 165, 17–31. [Google Scholar] [CrossRef]
- Nguyen, T.M.; Vo, H.H.P.; Yoo, M. Enhancing Intrusion Detection in Wireless Sensor Networks Using a GSWO-CatBoost Approach. Sensors 2024, 24, 3339. [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]
- Long, Z.; Yan, H.; Shen, G.; Zhang, X.; He, H.; Cheng, L. A Transformer-based network intrusion detection approach for cloud security. J. Cloud Comput. 2024, 13, 5. [Google Scholar] [CrossRef]
- Kheddar, H. Transformers and Large Language Models for Efficient Intrusion Detection Systems: A Comprehensive Survey. arXiv 2024, arXiv:2408.07583. [Google Scholar]
- Chen, X.; Qin, Y.; Xu, W.; Bur, A.M.; Zhong, C.; Wang, G. Explicitly Increasing Input Information Density for Vision Transformers on Small Datasets. arXiv 2022, arXiv:2210.14319. [Google Scholar]
Hyperparameter | Value | Hyperparameter | Value |
---|---|---|---|
input_shape | [224, 224, 3] | patch_size | 8 |
learning_rate | 0.001 | num_patches | 256 |
num_epochs | 55 | projection_dim | 64 |
batch_size | 32 | num_heads | 2 |
image_size | 128 | transformer_layers | 1 |
weight_decay | 0.0001 | mlp_head_units | [2048, 1024] |
Model | Accuracy (%) | Precision (%) | Recall (%) | F1 (%) | Train Time (s) | Test Time (s) |
---|---|---|---|---|---|---|
CNN | 99.40 | 99.41 | 99.10 | 99.35 | 192.79 | 1.70 |
VGG19 | 98.49 | 98.24 | 98.49 | 98.35 | 148.58 | 0.99 |
VGG16 | 98.49 | 98.06 | 98.49 | 98.21 | 143.17 | 0.87 |
InceptionV3 | 98.80 | 98.99 | 98.80 | 98.83 | 219.00 | 1.82 |
EfficientNetB7 | 98.80 | 98.85 | 98.80 | 98.80 | 891.26 | 7.28 |
Xception | 99.10 | 98.54 | 99.10 | 98.81 | 143.39 | 1.50 |
HiViT-IDS | 99.70 | 99.71 | 99.70 | 99.70 | 53.49 | 0.89 |
Model | Accuracy (%) | Precision (%) | Recall (%) | F1 (%) | Train Time (s) | Test Time (s) |
---|---|---|---|---|---|---|
DTL-IDS [32] | 100.00 | 100.00 | 100.00 | 100.00 | 22,442.83 | 5.19 |
TL-CNN-IDS [20] | 99.69 | 99.69 | 99.69 | 99.69 | 2475.19 | 2.01 |
Li [30] | 99.79 | 99.79 | 99.79 | 99.79 | 4528.93 | 1.89 |
ELETL-IDS [17] | 99.89 | 99.89 | 99.89 | 99.89 | 8103.83 | 2.64 |
CNN-LSTM [43] | 97.69 | 95.72 | 96.01 | 95.82 | 629.40 | 3.61 |
Transformer [44] | 95.35 | 93.46 | 94.82 | 94.14 | 2502.59 | 14.05 |
HiViT-IDS | 99.70 | 99.71 | 99.70 | 99.70 | 53.49 | 0.89 |
Model | Accuracy (%) | Precision (%) | Recall (%) | F1 (%) | Train Time (s) | Test Time (s) |
---|---|---|---|---|---|---|
CNN | 93.85 | 93.87 | 93.85 | 93.84 | 518.94 | 1.3 |
InceptionV3 | 99.40 | 99.17 | 99.40 | 99.24 | 569.89 | 2.1 |
VGG16 | 77.81 | 60.85 | 77.81 | 68.20 | 484.73 | 2.7 |
VGG19 | 98.95 | 98.93 | 98.95 | 98.93 | 455.74 | 2.1 |
InceptionResNetV2 | 95.43 | 96.21 | 95.43 | 94.95 | 1405.88 | 3.4 |
EfficientNetB7 | 98.78 | 98.78 | 98.78 | 98.78 | 3194.08 | 4.3 |
Xception | 72.04 | 51.90 | 72.04 | 60.33 | 506.06 | 3.2 |
HiViT-IDS | 100 | 100 | 100 | 100 | 160.91 | 1.4 |
Model | Accuracy (%) | Precision (%) | Recall (%) | F1 (%) | Train Time (s) | Test Time (s) |
---|---|---|---|---|---|---|
DTL-IDS [32] | 100 | 100 | 100 | 100 | 32512.08 | 6.15 |
TL-CNN-IDS [20] | 99.80 | 99.81 | 99.80 | 99.81 | 3911.99 | 2.32 |
Li [30] | 99.85 | 99.86 | 99.85 | 99.85 | 7821.13 | 4.15 |
ELETL-IDS [17] | 99.96 | 99.97 | 99.96 | 99.97 | 10993.93 | 4.75 |
CNN-LSTM [43] | 94.92 | 88.35 | 77.31 | 78.27 | 5833.60 | 83.59 |
Transformer [44] | 95.92 | 88.84 | 88.10 | 88.47 | 9727 | 214.6 |
HiViT-IDS | 100 | 100 | 100 | 100 | 160.91 | 1.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. |
© 2025 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 (https://creativecommons.org/licenses/by/4.0/).
Share and Cite
Zhou, H.; Zou, H.; Li, W.; Li, D.; Kuang, Y. HiViT-IDS: An Efficient Network Intrusion Detection Method Based on Vision Transformer. Sensors 2025, 25, 1752. https://doi.org/10.3390/s25061752
Zhou H, Zou H, Li W, Li D, Kuang Y. HiViT-IDS: An Efficient Network Intrusion Detection Method Based on Vision Transformer. Sensors. 2025; 25(6):1752. https://doi.org/10.3390/s25061752
Chicago/Turabian StyleZhou, Hai, Haojie Zou, Wei Li, Di Li, and Yinchun Kuang. 2025. "HiViT-IDS: An Efficient Network Intrusion Detection Method Based on Vision Transformer" Sensors 25, no. 6: 1752. https://doi.org/10.3390/s25061752
APA StyleZhou, H., Zou, H., Li, W., Li, D., & Kuang, Y. (2025). HiViT-IDS: An Efficient Network Intrusion Detection Method Based on Vision Transformer. Sensors, 25(6), 1752. https://doi.org/10.3390/s25061752