This project simulates a secure IoT environment using TLS and DTLS protocols. It includes an automated traffic simulator, a Supervised Multi-Class Deep Learning model to detect intrusions in real-time, a live dashboard, and an automated threat report generator.
The Intrusion Detection System (IDS) uses a Multi-Layer Perceptron (MLP) Neural Network built with sklearn.neural_network.MLPClassifier.
Instead of a simple "yes/no" anomaly detector, it is a Multi-Class Classifier designed to specifically identify different types of attacks.
Model Specifications:
- Inputs: 2 features (
payload_size,time_diff) - Hidden Layers: 3 dense layers
(128 nodes -> 64 nodes -> 32 nodes) - Activation Function: ReLU (Rectified Linear Unit)
- Optimizer: Adam
- Outputs (Classes):
1: Normal/Benign Traffic-2: DTLS Amplification Attack-3: TLS Heartbleed Attack-4: TLS POODLE Attack-5: DTLS Replay Attack
| File | Description |
|---|---|
iot_server.py |
TLS/DTLS server with real-time ML detection |
iot_client.py |
Normal IoT traffic simulator |
attacker_sim.py |
Attack traffic generator (4 attack types) |
ml_anomaly_detector.py |
Model training and evaluation |
dl_autoencoder.py |
MLP model class definition |
dashboard.py |
Real-time Flask dashboard |
threat_report.py |
Automated threat report generator |
certs/ |
TLS/DTLS SSL certificates |
traffic_log.csv |
Auto-generated traffic log (created at runtime) |
| Attack | Protocol | Payload Size | Description |
|---|---|---|---|
| Heartbleed | TLS | ~490 bytes | Malformed heartbeat request exploiting OpenSSL |
| POODLE | TLS | ~352 bytes | SSL 3.0 fallback exploit using CBC padding |
| Amplification | DTLS | ~4000 bytes | Massive UDP payload to overwhelm server |
| Replay | DTLS | ~680 bytes | Captured handshake replayed to hijack sessions |
- Live packet count, anomaly count, and attack rate
- Donut chart — normal vs anomaly traffic ratio
- Line chart — packets over time
- Bar chart — breakdown by attack type
- Live packet table with last 20 entries (auto-refreshes every 3 seconds)
pip install -r requirements.txtAlways start fresh before a new run:
del traffic_log.csv # Windows
rm traffic_log.csv # Linux/MacTerminal 1 — keep this running throughout:
python iot_server.pyTerminal 2 — open http://localhost:5050 in your browser:
python dashboard.pyTerminal 3 — let it run for a minute to build up baseline:
python iot_client.pyTerminal 4 — watch the dashboard go live with detections:
python attacker_sim.py --loop 30 --attack randomTerminal 3 — stop the client (Ctrl+C), then retrain:
python ml_anomaly_detector.pyTerminal 5:
python threat_report.pyGenerates threat_summary.txt and threat_report.csv in the project folder.