Nabil ShehadehAll Projects
Data Science · Network Security

Real-Time Network Traffic Anomaly Detection

A production-ready system that ingests live network traffic via Kafka and Apache Spark, applies multiple ML algorithms to detect intrusions and DDoS attacks in real-time, and surfaces findings through an interactive Streamlit dashboard.

View on GitHub
Interactive Dashboard

Simulated real-time anomaly detection — alerts stream live and model performance metrics update automatically.

Live Alert Feed
Brute Force·172.16.8.23·Isolation Forest
10:06:27 PMConfidence: 89.7%
low
SQL Injection·203.0.113.5·Autoencoder
10:06:27 PMConfidence: 90.1%
high
Brute Force·45.33.32.156·Autoencoder
10:06:27 PMConfidence: 94.5%
low
DDoS·45.33.32.156·DBSCAN
10:06:27 PMConfidence: 80.5%
medium
SQL Injection·192.168.1.104·Isolation Forest
10:06:27 PMConfidence: 80.9%
medium
Brute Force·192.168.1.104·K-Means
10:06:27 PMConfidence: 74.2%
low
Brute Force·203.0.113.5·Isolation Forest
10:06:27 PMConfidence: 75.5%
low
Port Scan·198.51.100.12·K-Means
10:06:27 PMConfidence: 73.5%
medium
DDoS·198.51.100.12·Isolation Forest
10:06:27 PMConfidence: 75.1%
high
Botnet C2·198.51.100.12·Isolation Forest
10:06:27 PMConfidence: 94.0%
critical
Brute Force·10.0.0.47·Isolation Forest
10:06:27 PMConfidence: 88.7%
medium
DNS Amplification·198.51.100.12·Isolation Forest
10:06:27 PMConfidence: 98.2%
medium

2.4M

Packets Analyzed

last hour

347

Anomalies Detected

last hour

1.8%

False Positive Rate

ensemble avg.

42ms

Avg. Latency

detection time

Anomaly Detections Over Time

Detections per model, rolling 10-minute window

T-9mT-8mT-7mT-6mT-5mT-4mT-3mT-2mT-1mT-0m05101520
  • Isolation Forest
  • Autoencoder
  • K-Means
  • DBSCAN

Model Performance Metrics

Precision, Recall & F1 Score on CICIDS2017 benchmark

Iso. ForestAutoencoderK-MeansDBSCAN758289100
  • Precision %
  • Recall %
  • F1 Score
System Features

Real-Time Streaming Pipeline

Kafka + Apache Spark architecture ingests live network traffic and processes packets in real-time with sub-second latency.

Anomaly Detection Models

Ensemble of Isolation Forest, Autoencoder (deep learning), K-Means, and DBSCAN clustering for robust intrusion detection.

Multiple Data Sources

Supports the CICIDS2017 benchmark dataset and live Wireshark/Scapy packet captures for both retrospective and live analysis.

Live Streamlit Dashboard

Interactive dashboard with real-time alerts, anomaly statistics, and model performance metrics updated continuously.

Docker & CI/CD

Fully containerized with Docker Compose and automated GitHub Actions pipeline for testing and deployment.

ETL & Feature Engineering

Structured ETL pipeline for connection logs, packet parsing, and advanced feature extraction aligned with OSI model layers.

Detection Models

An ensemble of four algorithms provides complementary coverage across different anomaly types.

01

Isolation Forest

Unsupervised anomaly detection

Isolates anomalies by randomly partitioning the feature space. Highly effective for high-dimensional network traffic data.

02

Autoencoder (Neural Network)

Reconstruction-based detection

Learns a compressed representation of normal traffic. High reconstruction error signals an anomaly or intrusion.

03

K-Means Clustering

Cluster-based outlier detection

Groups traffic flows into clusters; data points far from cluster centroids are flagged as suspicious.

04

DBSCAN

Density-based detection

Identifies anomalies as low-density regions in the feature space, robust to noise and arbitrary cluster shapes.

Pipeline Architecture
01

Ingest

CICIDS2017 dataset or live Wireshark packet capture via Scapy/PyShark

02

Stream

Kafka producer publishes traffic flows; Spark/Flink consumer processes in real-time

03

Detect

Ensemble ML models score each flow; anomalies trigger live alerts

04

Visualize

Streamlit dashboard displays metrics, alerts, and model performance in real-time

Skills Demonstrated
In-stream data processing (Kafka + Spark)Predictive modeling & ensemble methodsNetwork protocol analysis (OSI model)ETL pipeline designStreaming analytics & live alertingDocker containerization & CI/CDFull-stack development (Python + Streamlit)
Technologies Used
Apache KafkaApache SparkScikit-learnIsolation ForestAutoencodersK-MeansDBSCANStreamlitPythonScapyPySharkDockerGitHub ActionsCICIDS2017
Nabil Shehadeh · nshehadeh@usc.edu2026