🚀 IMPORTANT
This repository supports two different workflows:
Use this if you have:
.pcapngfiles- Wireshark packet captures
- Wireshark text exports
Use this if you downloaded datasets such as:
- CIC-IDS2017
- UNSW-NB15
- KDD Cup 1999
- Network Traffic Flows
➡️ If you are using a Kaggle dataset, skip directly to Method 2.
The trained model from this project is published on Hugging Face — you can browse or download it directly instead of retraining from scratch.
- Analyze real network captures
- Parse
.pcapngand Wireshark exports - Generate traffic statistics
- Predict future traffic metrics
- Generate reports and visualizations
- Train ML models from network datasets
- Automatic dataset column mapping
- Forecast future traffic
- Save reusable models
- Generate feature importance charts
Network-Traffic-Prediction-using-Machine-Learning/
│
├── run.py
├── traffic_predictor.py
├── visualize.py
├── generate_sample_data.py
│
├── kaggle_train.py
├── kaggle_predict.py
│
├── requirements.txt
└── README.md
Use this workflow if you have real packet capture files.
| Format | Description |
|---|---|
| .pcapng | Wireshark capture |
| .txt | Wireshark plain text export |
pip install -r requirements.txtpython run.py capture.pcapngpython run.py capture.txtpython run.py--window NAggregation window in seconds.
--model-dirDirectory for trained models.
--output-dirDirectory for reports and charts.
--no-plotsDisable graph generation.
output/
├── prediction_output.txt
├── prediction_report.json
└── plots/
├── dashboard.png
├── protocol_distribution.png
└── traffic_timeseries.png
- Open capture in Wireshark
- File → Export Packet Dissections
- Select "As Plain Text"
- Enable "Packet Bytes"
- Save as
.txt
Example:
At 3:00 PM tomorrow,
the incoming traffic will be 1.2 Gbps.
Example:
We expect 15,000 packets per second
during the next prediction window.
Example:
The backbone link will be at 78%
capacity between T1 and T2.
https://www.kaggle.com/datasets/cicdataset/cicids2017
https://www.kaggle.com/datasets/mrwellsdavid/unsw-nb15
https://www.kaggle.com/datasets/jsrojas/ip-network-traffic-flows-labeled-with-87-apps
https://www.kaggle.com/datasets/galaxyh/kdd-cup-1999-data
- Open dataset page
- Click Download
- Extract ZIP
- Place CSV file beside
kaggle_train.py
Install Kaggle:
pip install kaggleCreate API token:
https://www.kaggle.com/settings
Download dataset:
kaggle datasets download -d cicdataset/cicids2017 --unzipBasic training:
python kaggle_train.py --file dataset.csvExample:
python kaggle_train.py --file Friday-WorkingHours.csvCustom model directory:
python kaggle_train.py --file dataset.csv --model-dir kaggle_modelsLimit rows:
python kaggle_train.py --file dataset.csv --rows 500000Three independent Gradient Boosting models are created:
| Model | Prediction |
|---|---|
| Model 1 | Throughput/Bandwidth (Mbps) |
| Model 2 | Packet Count (pkt/s) |
| Model 3 | Link Utilization (%) |
kaggle_models/
├── kaggle_throughput_mbps_model.pkl
├── kaggle_throughput_mbps_scaler.pkl
├── kaggle_packet_count_model.pkl
├── kaggle_packet_count_scaler.pkl
├── kaggle_link_util_pct_model.pkl
├── kaggle_link_util_pct_scaler.pkl
├── kaggle_training_metrics.json
└── feature_importance_plots
Interactive mode:
python kaggle_predict.py --model-dir kaggle_modelsPredict using new CSV:
python kaggle_predict.py \
--model-dir kaggle_models \
--file new_data.csvCustom forecast:
python kaggle_predict.py \
--model-dir kaggle_models \
--steps 20 \
--window 60Disable graph:
python kaggle_predict.py \
--model-dir kaggle_models \
--no-plotAt 3:00 PM tomorrow,
the incoming traffic will be X Mbps/Gbps.
We expect X,XXX packets per second
during the next prediction window.
The backbone link will operate at X% capacity.
Raw Network Data
│
▼
Feature Engineering
│
▼
Traffic Metrics
│
▼
Gradient Boosting Regressor
│
├── Throughput Model
├── Packet Count Model
└── Link Utilization Model
│
▼
Future Traffic Forecast
│
▼
Reports + Visualizations
- Python
- Pandas
- NumPy
- Scikit-Learn
- Matplotlib
- Joblib
pip install -r requirements.txt
python run.py capture.pcapngpip install -r requirements.txt
python kaggle_train.py --file dataset.csv
python kaggle_predict.py --model-dir kaggle_models