Network Traffic Prediction System
Machine learning models for predicting network traffic metrics from Wireshark packet data.
Models
This repository contains three Gradient Boosting regression models:
- Throughput/Bandwidth β predicts throughput in Mbps
- Packet Count β predicts packets per second
- Link Utilization β predicts link utilization percentage
Model Performance
| Model | RΒ² | MAE | RMSE |
|---|---|---|---|
| Throughput | 1.0000 | 91.9503 Mbps | 686.6935 |
| Packet Count | 0.9999 | 0.0776 pkt/s | 2.0357 |
| Link Utilization | 0.9927 | 0.0517% | 0.3974 |
β οΈ Note on Model Performance
The near-perfect RΒ² scores shown above (particularly for Throughput and Packet Count) result from the current feature set including the target variable itself as an input feature. This means these two models are not true forward-forecasting models in their current form β they reflect a strong correlation/reconstruction task rather than genuine prediction from independent inputs.
The Link Utilization model is less affected, though it is derived from throughput and may carry a similar effect.
This is disclosed for transparency. A corrected version would exclude the target column from its own feature set during training.
Input Features
The models use these features:
fwd_packets
bwd_packets
fwd_bytes
bwd_bytes
fwd_pkt_len_mean
bwd_pkt_len_mean
iat_mean
throughput_mbps
packet_count
Framework
- Python
- scikit-learn
- NumPy
- Pandas
- Joblib
Model Files
The trained models, scalers, feature definitions, metrics, and feature-importance plots are available in the kaggle_models/ directory.
Predicted Outputs
- Throughput/Bandwidth β "At 3:00 PM tomorrow, the incoming traffic will be X Gbps."
- Packet Count β "We expect X,XXX packets per second during the next 10-minute window."
- Link Utilization β "The backbone link will be at X% capacity between T1 and T2."
Quick Start
1. Install dependencies
pip install -r requirements.txt
2. Run with your Wireshark data
Hex-dump .txt file (from Wireshark Edit β Export β as Plain Text):
python run.py your_capture.txt
pcapng file:
python run.py your_capture.pcapng
Demo mode (no file needed):
python run.py
3. Options
--window N Aggregation window in seconds (default: 1)
--model-dir Directory to save trained models (default: models/)
--output-dir Directory for reports/charts (default: output/)
--no-plots Skip matplotlib chart generation
Output Files
output/
βββ prediction_output.txt β Human-readable report
βββ prediction_report.json β Machine-readable JSON
βββ plots/
βββ dashboard.png β Full prediction dashboard
βββ protocol_distribution.png
βββ traffic_timeseries.png
models/
βββ throughput_mbps_model.pkl
βββ throughput_mbps_scaler.pkl
βββ packet_count_model.pkl
βββ packet_count_scaler.pkl
βββ link_util_pct_model.pkl
βββ link_util_pct_scaler.pkl
Supported File Formats
| Format | Description |
|---|---|
.txt |
Wireshark hex-dump text export |
.pcapng |
Wireshark native capture format |
How to export hex dump from Wireshark
- Open your
.pcapngin Wireshark - Go to File β Export Packet Dissections β As Plain Text
- Check Packet bytes option
- Save as
.txt
Architecture
Raw Packets (.txt / .pcapng)
β
βΌ
Parser (Layer 2/3/4 decode)
β
βΌ
Feature Engineering (1s windows)
β’ packet_count, total_bytes, throughput
β’ protocol mix, unique IPs
β’ lag features (1,2,3,5 steps)
β’ rolling averages (3,5,10 windows)
β
βΌ
Gradient Boosting Regressor (Γ3)
β’ Model 1 β Throughput (Mbps)
β’ Model 2 β Packet Count (pkt/s)
β’ Model 3 β Link Utilization (%)
β
βΌ
Predictions + Report + Charts
No Paid APIs
Everything runs 100% locally using free open-source libraries:
- scikit-learn (ML)
- pandas / numpy (data)
- matplotlib (charts)
- joblib (model persistence)