How briyithnarvaez04/sdn_ryu_dijkstra_ml_enfa3 works
1. Purpose and Runtime Topology
This repository implements an SDN monitoring, traffic-classification, and dynamic-routing demonstrator over an emulated 23-switch GÉANT topology. It runs as distributed processes: Mininet/OVS produces traffic and speaks OpenFlow to Ryu; Ryu hosts control, ML inference, routing, and Flask APIs; Node.js serves a browser dashboard and proxies API calls.
• códigos/modelo/icmpgeant.py
• códigos/sdnWeb/geant_controller.py
• códigos/sdnWeb/server.js
2. Network Emulation and Traffic Sources
Four Mininet topology entry points instantiate the same GÉANT-style Open vSwitch network and produce distinct traffic profiles: ICMP, HTTP, RTP/video, and low-latency gaming. They connect to the remote controller through OpenFlow 1.3, normally TCP 6633. Run one topology script after Ryu starts.
• códigos/modelo/icmpgeant.py
• códigos/modelo/httpgeant.py
• códigos/modelo/rtpgeant.py
• códigos/modelo/gaminggeant.py
3. Unified SDN Controller
GEANTUnifiedController is the architectural center. It receives OpenFlow packet, port-statistics, switch, and link-discovery events; maintains shared controller state; discovers hosts; installs forwarding/blocking rules; and converts topology events into an in-memory NetworkX graph. Ryu topology discovery (ryu.topology.switches with --observe-links) is a required boundary: without discovered edges, route calculation cannot operate.
• códigos/sdnWeb/geant_controller.py
• códigos/sdnWeb/html/classgeant__controller_1_1_g_e_a_n_t_unified_controller.html
• códigos/sdnWeb/html/classgeant__controller_1_1_shared_state.html
4. Metrics-to-ML-to-Routing Loop
At each port-statistics sampling interval, the controller derives throughput, utilization, packet size/rate, jitter, burstiness, RX/TX asymmetry, and error-related features. It aligns these features using the persisted feature-order contract, predicts one of VIDEO/HTTP/GAMING/ICMP, then updates link costs according to class-specific QoS policy factors. Dijkstra runs over the updated NetworkX graph; results drive forwarding decisions and cached route responses.
• códigos/modelo/TrafficModel.pkl
• códigos/modelo/LabelEncoder.pkl
• códigos/modelo/feature_columns.pkl
• códigos/sdnWeb/geant_controller.py
5. Offline Data and Model Pipeline
Captured class-specific metric CSVs are cleaned, stripped of OpenFlow/control and counter-overflow artifacts, balanced across classes, and consolidated. Training uses the balanced dataset to produce the RandomForest model, label encoder, and ordered feature list consumed at controller startup. This is an offline artifact-generation boundary; inference occurs only in the controller.
• códigos/modelo/build_dataset.py
• códigos/modelo/entrenamiento.py
• códigos/modelo/dataset_balanced.csv
• códigos/modelo/datasets/
6. API, Proxy, and Dashboard
The controller exposes Flask REST endpoints for status, topology, metrics, predictions, routes, hosts, policies, debugging, and snapshots on port 8888. The Express server proxies these under /api/*, serves static UI assets, and discovers LAN access addresses; this isolates the browser from controller host/CORS configuration. The frontend polls APIs, renders topology with D3, and renders metrics/ML/control views with Chart.js.
• códigos/sdnWeb/server.js
• códigos/sdnWeb/index.html
• códigos/sdnWeb/script.js
• códigos/sdnWeb/style.css
7. External Infrastructure and Startup Order
Material dependencies are Linux, Mininet, Open vSwitch, Python/Ryu, Flask, NetworkX, scikit-learn/joblib/pandas/numpy, and Node.js/Express. Chart.js and D3.js load from CDNs unless locally substituted. Start Ryu plus required topology modules, then one Mininet traffic topology, then the Node server. Primary ports are OpenFlow 6633, Ryu REST 8080, controller Flask 8888, and dashboard/proxy 3000.
• códigos/sdnWeb/package.json
• códigos/sdnWeb/geant_controller.py
• códigos/modelo/Doxyfile
Main entry points: geant_controller.py Shared controller state · dataset_balanced.csv Balanced dataset · entrenamiento.py Model training · TrafficModel.pkl Model artifacts
Components 16
Offline ML pipeline
Builds artifacts consumed by controller inference.
- Dataset builder · Cleans, filters, balances, and consolidates captured metrics.
códigos/modelo/build_dataset.py - Balanced dataset
códigos/modelo/dataset_balanced.csv - Model training · Trains the classifier and persists its feature contract.
códigos/modelo/entrenamiento.py - Model artifacts · RandomForest, label encoder, and ordered feature list.
códigos/modelo/TrafficModel.pkl
Emulated network
One traffic topology runs against the remote controller.
- Traffic topology scripts · ICMP, HTTP, RTP, or gaming traffic over the GÉANT OVS topology.
códigos/modelo/icmpgeant.py - 23-switch GÉANT topology · Emulated switches and hosts generate traffic and OpenFlow events.
Ryu controller
Control-plane, inference, routing, and Flask API runtime.
- Ryu link discovery · Observed links are required before routes can be calculated.
códigos/sdnWeb/geant_controller.py - OpenFlow event handling · Processes packets, port statistics, switches, links, and host discovery.
códigos/sdnWeb/geant_controller.py - Shared controller state · Tracks hosts, metrics, predictions, policies, and cached routes.
códigos/sdnWeb/geant_controller.py - Metrics features · Derives throughput, utilization, rates, jitter, burstiness, asymmetry, and errors.
códigos/sdnWeb/geant_controller.py - Traffic inference · Classifies VIDEO, HTTP, GAMING, or ICMP using the persisted feature order.
códigos/sdnWeb/geant_controller.py - QoS routing · Updates class-sensitive link costs and calculates forwarding paths.
códigos/sdnWeb/geant_controller.py - Forwarding and blocking rules
códigos/sdnWeb/geant_controller.py - Controller REST API · Serves status, topology, metrics, predictions, routes, hosts, policies, and snapshots.
códigos/sdnWeb/geant_controller.py
Dashboard
Browser UI is isolated from controller API access by Node proxy.
- Dashboard server and proxy · Serves UI and proxies /api/* to the controller.
códigos/sdnWeb/server.js - Topology and metrics dashboard · Polls API data and renders topology, ML, metrics, and controls.
códigos/sdnWeb/script.js
Connections 19
- Dataset builder → Balanced dataset: produces
- Balanced dataset → Model training: trains from
- Model training → Model artifacts: persists
- Traffic topology scripts → 23-switch GÉANT topology: instantiates
- 23-switch GÉANT topology → OpenFlow event handling: OpenFlow 1.3 :6633
- 23-switch GÉANT topology → Ryu link discovery: switch and link events
- Ryu link discovery → Shared controller state: topology graph
- OpenFlow event handling → Shared controller state: hosts and counters
- OpenFlow event handling → Metrics features: port samples
- Metrics features → Traffic inference: ordered features
- Model artifacts → Traffic inference: model and feature contract
- Traffic inference → QoS routing: traffic class
- Shared controller state → QoS routing: topology and policy state
- QoS routing → Forwarding and blocking rules: selected paths
- Forwarding and blocking rules → 23-switch GÉANT topology: flow mods
- Shared controller state → Controller REST API: status and snapshots
- QoS routing → Controller REST API: route responses
- Dashboard server and proxy → Controller REST API: proxies /api/*
- Topology and metrics dashboard → Dashboard server and proxy: polls API and static assets