This project implements a comprehensive solution for detecting and mitigating Distributed Denial of Service (DDoS) attacks in Software-Defined Networks (SDN) using various machine learning techniques.
The system integrates machine learning models with a POX SDN controller to detect and mitigate DDoS attacks in real-time. The project includes:
- Implementation of multiple ML algorithms (Random Forest, SVM, KNN, Decision Tree, Naive Bayes)
- Integration with POX controller for real-time traffic analysis
- Feature extraction from network flows
- Real-time attack detection and mitigation
- Performance evaluation and comparison of ML models
- Interactive dashboard for monitoring and analysis
- Multiple ML Models: Implementation and comparison of 5 different machine learning algorithms
- Real-time Detection: Integration with POX controller for real-time traffic analysis
- Feature Engineering: Extraction of 23 traffic features for accurate attack detection
- Visualization: Interactive dashboard with charts and statistics
- Model Evaluation: Comprehensive performance metrics and comparisons
- Attack Mitigation: Automatic blocking of detected attack traffic
The project implements and compares the following machine learning models:
- Random Forest - Achieves 99.88% accuracy (best performer)
- Support Vector Machine (SVM) - 97.5% accuracy
- K-Nearest Neighbors (KNN) - 96.2% accuracy
- Decision Tree - 98.1% accuracy
- Naive Bayes - 94.3% accuracy
The dataset contains network traffic data with 23 features:
- dt (decision time)
- switch (switch identifier)
- src (source address)
- dst (destination address)
- pkt_count (packet count)
- byte_count (byte count)
- duration
- duration_nsec (duration in nanoseconds)
- total_duration
- flows (number of flows)
- pkt_rate (packet rate)
- pair_flow
- protocol
- port_no (port number)
- tx_bytes (transmitted bytes)
- rx_bytes (received bytes)
- tx_kbps (transmitted kilobits per second)
- rx_kbps (received kilobits per second)
- tot_kbps (total kilobits per second)
- label (classification label - normal/attack)
- packetins
- byte_per_flow (bytes per flow)
- packet_per_flow (packets per flow)
The system consists of the following components:
- POX Controller: Manages the SDN network and collects traffic statistics
- Feature Extractor: Processes raw traffic data into feature vectors
- ML Classifier: Uses trained models to classify traffic as normal or attack
- Flow Manager: Installs flow rules to block malicious traffic
- Dashboard: Provides visualization and monitoring capabilities
- Node.js (v14 or higher)
- Python 3.6 or higher
- POX controller
- Required Python packages: numpy, pandas, scikit-learn, joblib, matplotlib, seaborn
-
Clone the repository:
git clone https://github.com/yourusername/ddos-detection-sdn-ml.git cd ddos-detection-sdn-ml -
Install dependencies:
npm install -
Train the ML models:
npm run train -
Start the POX controller:
npm run start-controller -
Start the dashboard:
npm run dev
To train the machine learning models on the dataset:
npm run train
This will:
- Load the dataset (or create a synthetic one if not available)
- Preprocess the data
- Train all five ML models
- Evaluate their performance
- Save the trained models for use with the controller
To start the POX controller with ML-based DDoS detection:
npm run start-controller
The controller will:
- Load the trained Random Forest model
- Monitor network traffic
- Extract features from flows
- Classify traffic as normal or attack
- Block malicious flows
To evaluate and compare the performance of all models:
python src/ml/evaluate_models.py
This will generate detailed performance metrics and visualizations.
The dashboard provides a comprehensive view of the system's operation, including:
- Real-time traffic statistics
- Attack detection alerts
- Model performance comparison
- Dataset information
- Controller status
├── data/ # Dataset storage
├── models/ # Trained ML models
├── results/ # Evaluation results and visualizations
├── src/
│ ├── components/ # React components for dashboard
│ ├── ml/ # Machine learning code
│ │ ├── train_models.py # Model training script
│ │ └── evaluate_models.py # Model evaluation script
│ ├── pox/ # POX controller integration
│ │ └── pox_controller.py # Controller with ML integration
│ └── App.tsx # Main application component
├── public/ # Static assets
└── README.md # Project documentation
The Random Forest model achieves the best performance with:
- 99.88% accuracy
- 99.9% precision
- 99.85% recall
- 99.87% F1 score
- Integration with real network environments
- Implementation of additional ML algorithms
- Development of adaptive detection thresholds
- Support for additional attack types
- Distributed controller architecture
This project is licensed under the MIT License - see the LICENSE file for details.
- The POX controller team
- scikit-learn library
- React and Chart.js for visualization