A Machine Learning-Based Network Intrusion Detection System Using the NSL-KDD Dataset

Authors

  • Anupama N
  • R Ashok Kumar
  • Samana M B

Keywords:

Decision tree, Intrusion detection system, Machine learning, NSL-KDD dataset, Random Forest, Support vector machine

Abstract

NIDS are known to be an important security measure that is introduced to address an increase in the number and complexity of attacks on cyberspace. This study describes the approach developed, implemented, and evaluated for the machine learning-based NIDS using the NSL-KDD dataset. In total, 41 features are captured for the connections in the network that can be grouped into connection features, content features, and traffic (time-window and host-based) data. The features are reduced after going through label encoding, normalization, and univariate feature selection, so that 41 features are reduced to a set of 20 features. In total, three types of classifiers were trained and tested on the KDDTest+ data set – Decision Tree, SVM, and Random Forest. The classifiers were used to determine which class each connection belongs to among the Normal, DoS, Probe, R2L, and U2R classes. These models were compared using different measures (accuracy, precision, recall, and F1 score) and demonstrated their success rates, with SVM being the most successful at 72.78%. The Flask web framework is used to connect the trained models to an application that is capable of producing the predictions instantly, along with the associated confidence scores for all the models. The evaluation shows that the overall accuracy metric could be deceiving when evaluating intrusion detection and that class-wise metrics need to be used for selecting models.

References

J. P. Anderson, “Computer Security Threat Monitoring and Surveillance,” Technical Report, James P. Anderson Company, Fort Washington, PA, USA, Apr. 1980.

D. E. Denning, “An intrusion-detection model,” IEEE Transactions on Software Engineering, vol. SE-13, no. 2, pp. 222–232, Feb. 1987.

V. Chandola, A. Banerjee, and V. Kumar, “Anomaly detection: A survey,” ACM Computing Surveys, vol. 41, no. 3, pp. 1–58, Jul. 2009.

R. Sommer and V. Paxson, “Outside the closed world: On using machine learning for network intrusion detection,” 2010 IEEE Symposium on Security and Privacy, Oakland, CA, USA, 2010, pp. 305–316.

C. Yin, Y. Zhu, J. Fei, and X. He, “A deep learning approach for intrusion detection using recurrent neural networks,” IEEE Access, vol. 5, pp. 21954–21961, 2017.

F. Pedregosa et al., “Scikit-Learn: Machine Learning in Python,” Journal of Machine Learning Research, vol. 12, no. 85, pp. 2825–2830, 2011.

J. McHugh, “Testing intrusion detection systems: A critique of the 1998 and 1999 DARPA intrusion detection system evaluations as performed by Lincoln Laboratory,” ACM Transactions on Information and System Security, vol. 3, no. 4, pp. 262–294, Nov. 2000.

M. Tavallaee, E. Bagheri, W. Lu, and A. A. Ghorbani, “A detailed analysis of the KDD CUP 99 data set,” 2009 IEEE Symposium on Computational Intelligence for Security and Defense Applications (CISDA), Ottawa, ON, Canada, Jul. 2009, pp. 1–6.

Canadian Institute for Cybersecurity, University of New Brunswick, “ISCX NSL-KDD dataset 2009,” UNB, 2009.

L. Dhanabal and S. P. Shantharajah, “A study on NSL-KDD dataset for intrusion detection system based on classification algorithms,” International Journal of Advanced Research in Computer and Communication Engineering, vol. 4, no. 6, pp. 446–452, Jun. 2015.

S. Revathi and A. Malathi, “A detailed analysis on NSL-KDD dataset using various machine learning techniques for intrusion detection,” International Journal of Engineering Research & Technology, vol. 2, no. 12, pp. 1848–1853, Dec. 2013.

J. R. Quinlan, “Induction of decision trees,” Machine Learning, vol. 1, no. 1, pp. 81–106, Mar. 1986.

C. Cortes and V. Vapnik, “Support-vector networks,” Machine Learning, vol. 20, no. 3, pp. 273–297, Sep. 1995.

L. Breiman, “Random forests,” Machine Learning, vol. 45, no. 1, pp. 5–32, Oct. 2001.

A. L. Buczak and E. Guven, “A survey of data mining and machine learning methods for cyber security intrusion detection,” IEEE Communications Surveys & Tutorials, vol. 18, no. 2, pp. 1153–1176, 2nd Quart., 2016.

N. V. Chawla, K. W. Bowyer, L. O. Hall, and W. P. Kegelmeyer, “SMOTE: Synthetic minority over-sampling technique,” Journal of Artificial Intelligence Research, vol. 16, pp. 321–357, 2002.

M. Ring, S. Wunderlich, D. Scheuring, D. Landes, and A. Hotho, “A survey of network-based intrusion detection data sets,” Computers & Security, vol. 86, pp. 147–167, Sep. 2019.

I. Sharafaldin, A. Habibi Lashkari, and A. A. Ghorbani, “Toward Generating a New Intrusion Detection Dataset and Intrusion Traffic Characterization,” Proceedings of the 4th International Conference on Information Systems Security and Privacy, 2018, pp. 108–116.

Published

2026-11-26

How to Cite

Anupama N, R Ashok Kumar, & Samana M B. (2026). A Machine Learning-Based Network Intrusion Detection System Using the NSL-KDD Dataset. Journal of Network Security Computer Networks, 12(3), 46–54. Retrieved from https://matjournals.net/engineering/index.php/JONSCN/article/view/4518

Issue

Section

Articles