# xuanmai1812/sdn-server_load_balancing architecture

> Architecture diagram of the GitHub repository xuanmai1812/sdn-server_load_balancing, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-01). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/xuanmai1812/sdn-server_load_balancing
- Repository: https://github.com/xuanmai1812/sdn-server_load_balancing

## Overview

This repository is a Mininet/Ryu SDN demo for static, link-based load balancing behind a virtual IP. The client’s first ARP/IP packets reach the controller, which answers VIP ARP, chooses a healthy and preferably uncongested uplink and backend, installs bidirectional NAT flows on the core switch, and forwards the initial packet; later packets use the switch flows. The README documents failover and congestion monitoring as new-flow selection safeguards. The controller excerpt is partial, so links between its internal stages follow documented behavior where code is not shown.

Main entry points: [`static_linkbased_LB.py`](https://github.com/xuanmai1812/sdn-server_load_balancing/blob/main/static_linkbased_LB.py) (Ryu controller), [`tree-topo.py`](https://github.com/xuanmai1812/sdn-server_load_balancing/blob/main/tree-topo.py) (Mininet topology)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_network["Test network"]
  node_topology["Mininet topology<br/>[tree-topo.py]"]
end

subgraph group_control["Controller"]
  node_ryu["Ryu controller"]
  node_link_monitor["Link monitoring"]
  node_health_state["Link health state"]
  node_congestion_state["Congestion state"]
end

subgraph group_traffic["Traffic handling"]
  node_arp_proxy["VIP ARP proxy"]
  node_packet_handler["Packet-in handling"]
  node_lb_select["Uplink/server selection"]
  node_nat_flows["Bidirectional NAT flows"]
  node_packet_out["Initial packet forwarding"]
end

node_client(("External client"))
node_backends[("Backend servers")]
node_switches["OpenFlow switches"]

node_topology -->|"creates"| node_switches
node_topology -->|"creates"| node_backends
node_topology -->|"creates"| node_client
node_client -->|"sends traffic"| node_switches
node_switches -->|"Packet-In"| node_ryu
node_ryu -->|"starts"| node_link_monitor
node_link_monitor -->|"requests port stats"| node_switches
node_switches -->|"returns stats"| node_link_monitor
node_link_monitor -->|"updates"| node_congestion_state
node_switches -->|"reports port status"| node_ryu
node_ryu -->|"updates"| node_health_state
node_ryu -->|"dispatches"| node_packet_handler
node_packet_handler -->|"handles ARP"| node_arp_proxy
node_arp_proxy -->|"answers VIP ARP"| node_client
node_packet_handler -->|"handles VIP traffic"| node_lb_select
node_lb_select -->|"checks health"| node_health_state
node_lb_select -->|"checks congestion"| node_congestion_state
node_lb_select -->|"selects backend"| node_nat_flows
node_nat_flows -->|"installs flows"| node_switches
node_packet_handler -->|"forwards first packet"| node_packet_out
node_packet_out -->|"sends Packet-Out"| node_switches
node_switches -->|"forwards traffic"| node_backends

click node_topology "https://github.com/xuanmai1812/sdn-server_load_balancing/blob/main/tree-topo.py"
click node_ryu "https://github.com/xuanmai1812/sdn-server_load_balancing/blob/main/static_linkbased_LB.py"
click node_link_monitor "https://github.com/xuanmai1812/sdn-server_load_balancing/blob/main/static_linkbased_LB.py"
click node_health_state "https://github.com/xuanmai1812/sdn-server_load_balancing/blob/main/static_linkbased_LB.py"
click node_congestion_state "https://github.com/xuanmai1812/sdn-server_load_balancing/blob/main/static_linkbased_LB.py"
click node_arp_proxy "https://github.com/xuanmai1812/sdn-server_load_balancing/blob/main/static_linkbased_LB.py"
click node_packet_handler "https://github.com/xuanmai1812/sdn-server_load_balancing/blob/main/static_linkbased_LB.py"
click node_lb_select "https://github.com/xuanmai1812/sdn-server_load_balancing/blob/main/static_linkbased_LB.py"
click node_nat_flows "https://github.com/xuanmai1812/sdn-server_load_balancing/blob/main/static_linkbased_LB.py"
click node_packet_out "https://github.com/xuanmai1812/sdn-server_load_balancing/blob/main/static_linkbased_LB.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_topology,node_client toneBlue
class node_ryu,node_link_monitor,node_health_state,node_congestion_state,node_backends toneAmber
class node_arp_proxy,node_packet_handler,node_lb_select,node_nat_flows,node_packet_out toneMint
class node_switches toneIndigo
```

## Components

### Test network

- [Mininet topology](https://github.com/xuanmai1812/sdn-server_load_balancing/blob/main/tree-topo.py): `tree-topo.py`

### Controller

- [Ryu controller](https://github.com/xuanmai1812/sdn-server_load_balancing/blob/main/static_linkbased_LB.py): `static_linkbased_LB.py`
- [Link monitoring](https://github.com/xuanmai1812/sdn-server_load_balancing/blob/main/static_linkbased_LB.py): `static_linkbased_LB.py`
- [Link health state](https://github.com/xuanmai1812/sdn-server_load_balancing/blob/main/static_linkbased_LB.py): `static_linkbased_LB.py`
- [Congestion state](https://github.com/xuanmai1812/sdn-server_load_balancing/blob/main/static_linkbased_LB.py): `static_linkbased_LB.py`

### Traffic handling

- [VIP ARP proxy](https://github.com/xuanmai1812/sdn-server_load_balancing/blob/main/static_linkbased_LB.py): `static_linkbased_LB.py`
- [Packet-in handling](https://github.com/xuanmai1812/sdn-server_load_balancing/blob/main/static_linkbased_LB.py): `static_linkbased_LB.py`
- [Uplink/server selection](https://github.com/xuanmai1812/sdn-server_load_balancing/blob/main/static_linkbased_LB.py): `static_linkbased_LB.py`
- [Bidirectional NAT flows](https://github.com/xuanmai1812/sdn-server_load_balancing/blob/main/static_linkbased_LB.py): `static_linkbased_LB.py`
- [Initial packet forwarding](https://github.com/xuanmai1812/sdn-server_load_balancing/blob/main/static_linkbased_LB.py): `static_linkbased_LB.py`

### Other components

- **External client**
- **Backend servers**
- **OpenFlow switches**

## Connections

- Mininet topology → OpenFlow switches: creates (evidence: `tree-topo.py`)
- Mininet topology → Backend servers: creates (evidence: `tree-topo.py`)
- Mininet topology → External client: creates (evidence: `tree-topo.py`)
- External client → OpenFlow switches: sends traffic (evidence: `README.md`)
- OpenFlow switches → Ryu controller: Packet-In (evidence: `README.md`)
- Ryu controller → Link monitoring: starts (evidence: `static_linkbased_LB.py`)
- Link monitoring → OpenFlow switches: requests port stats (evidence: `README.md`)
- OpenFlow switches → Link monitoring: returns stats (evidence: `README.md`)
- Link monitoring → Congestion state: updates (evidence: `static_linkbased_LB.py`)
- OpenFlow switches → Ryu controller: reports port status (evidence: `README.md`)
- Ryu controller → Link health state: updates (evidence: `README.md`)
- Ryu controller → Packet-in handling: dispatches (evidence: `static_linkbased_LB.py`)
- Packet-in handling → VIP ARP proxy: handles ARP (evidence: `static_linkbased_LB.py`)
- VIP ARP proxy → External client: answers VIP ARP (evidence: `README.md`)
- Packet-in handling → Uplink/server selection: handles VIP traffic (evidence: `static_linkbased_LB.py`)
- Uplink/server selection → Link health state: checks health (evidence: `static_linkbased_LB.py`)
- Uplink/server selection → Congestion state: checks congestion (evidence: `static_linkbased_LB.py`)
- Uplink/server selection → Bidirectional NAT flows: selects backend (evidence: `README.md`)
- Bidirectional NAT flows → OpenFlow switches: installs flows (evidence: `README.md`)
- Packet-in handling → Initial packet forwarding: forwards first packet (evidence: `README.md`)
- Initial packet forwarding → OpenFlow switches: sends Packet-Out (evidence: `README.md`)
- OpenFlow switches → Backend servers: forwards traffic (evidence: `README.md`)
