Network Intrusion Detection System using Random Forest Algorithm
Abstract
The rapid growth of internet services, cloud platforms, and connected devices has made network infrastructures more appealing targets for cybercriminals. The increase in denial-of-service attacks, unauthorized access attempts, malware spread, and data theft has put significant strain on traditional security measures. Signature-based intrusion detection tools are effective against previously identified attacks. However, they struggle whenever an attacker makes even a small change to a known exploit or uses a completely new method. The limitation has driven the security community to seek out data-driven, learning-based solutions.The paper introduces a Real-Time Network Intrusion Detection System (RT-NIDS) that uses the Random Forest ensemble classifier. The classifier was selected for its ability to resist overfitting, handle noisy and complex traffic data, and balance computational cost with classification accuracy. The system captures live packet flows, processes and encodes the resulting data, identifies a concise set of key traffic features, and inputs them into a group of decision trees. The combined outcome of these trees decides whether a flow is safe or harmful. The classifier was trained and tested on three popular benchmark datasets: NSL-KDD, UNSW-NB15, and CICIDS2017. Its performance was compared to Decision Tree, Support Vector Machine, and k-Nearest Neighbor models, all under the same preprocessing conditions. The proposed model achieved 98.1% accuracy, precision, recall, and an F1-score. It consistently outperformed the other algorithms while maintaining a false-positive rate below 1.3%.