SDN and OpenFlow
In a traditional network each router runs its own control plane and computes its own forwarding table. Software-defined networking (SDN) moves that logic out of the devices. Switches become simple, fast forwarders. A controller running on ordinary servers computes the rules and installs them. See Forwarding and routing for the data plane and control plane split this builds on.
You meet SDN daily without the name. Cloud virtual networks, Open vSwitch on hypervisors, Kubernetes CNI plugins such as Cilium, and data center fabrics all follow the same model: a central brain, programmable forwarders.
What defines SDN
Section titled “What defines SDN”| Characteristic | Meaning |
|---|---|
| Flow-based forwarding | Switches match on many header fields, not just the destination IP |
| Separate planes | Switches only forward. Control logic runs elsewhere |
| Control outside the switch | Control software runs on remote servers, as a controller plus applications |
| Programmable | Routing, access control, and load balancing are applications on top of the controller. Changing behavior means changing software, not hardware |
A side effect is unbundling. Switches, controllers, and control applications can come from different vendors or open-source projects, much as PC hardware, operating systems, and applications did.
Match plus action
Section titled “Match plus action”Traditional forwarding looks at one field, the destination IP, and picks an output port by longest-prefix match. Generalized forwarding replaces that table with a flow table. Each entry has:
| Part | Meaning |
|---|---|
| Match fields | Header values to compare against: ingress port, source and destination MAC, EtherType, VLAN ID, source and destination IP, IP protocol, ToS, and TCP or UDP ports. Wildcards and prefixes are allowed |
| Priority | If a packet matches several entries, the highest priority wins |
| Actions | What to do with a match, in order |
| Counters | Packets and bytes matched, and time since the last match |
| Timeouts | Remove the entry after a period of inactivity or a fixed lifetime |
OpenFlow 1.0 defined 12 match values. Later versions define dozens more. Not every header field is matchable, because every extra field makes the hardware lookup harder. The table is usually held in TCAM, which can compare against over a million entries in one cycle.
Actions include:
- Forward out one port, flood to all ports except the ingress, or send to a group.
- Drop. An entry with no actions discards the packet.
- Rewrite fields in the Ethernet, IP, or TCP/UDP headers before forwarding. This is how a switch can do NAT or change a VLAN tag.
- Send to the controller for a decision.
One mechanism, then, covers forwarding, load balancing, firewalling, and NAT. They are all rules in the same table.
Examples with Open vSwitch
Section titled “Examples with Open vSwitch”Open vSwitch (OVS) is a software switch with an OpenFlow table. It runs on most hypervisors, so you can try these rules on a Linux host. Port numbers are examples.
# Forwarding by source and destination: traffic from 10.10.0.0/16 to 10.20.0.0/16 uses port 2sudo ovs-ofctl add-flow br0 "priority=100,ip,nw_src=10.10.0.0/16,nw_dst=10.20.0.0/16,actions=output:2"
# Load balancing by ingress port: two clients headed to the same prefix take different uplinkssudo ovs-ofctl add-flow br0 "priority=100,in_port=3,ip,nw_dst=10.30.0.0/16,actions=output:1"sudo ovs-ofctl add-flow br0 "priority=100,in_port=4,ip,nw_dst=10.30.0.0/16,actions=output:2"
# Firewalling: drop SSH to one server, and drop everything not otherwise allowedsudo ovs-ofctl add-flow br0 "priority=200,tcp,nw_dst=10.20.0.10,tp_dst=22,actions=drop"sudo ovs-ofctl add-flow br0 "priority=0,actions=drop"
# Rewrite: send traffic for a virtual IP to a real backendsudo ovs-ofctl add-flow br0 "priority=150,ip,nw_dst=10.20.0.100,actions=mod_nw_dst:10.20.0.10,output:2"
# Inspect the table, including packet counters for each rulesudo ovs-ofctl dump-flows br0The load balancing rules show what destination-based forwarding cannot do. Both flows have the same destination prefix, so a router would send them out the same port. Adding the ingress port to the match lets the switch split them. The firewall works the same way: only traffic that matches a forward rule gets through, and a final priority-0 rule drops the rest.
The controller
Section titled “The controller”A controller has three layers.
flowchart TD
APPS["Control applications<br/>routing, access control, load balancing"]
subgraph CTL["SDN controller"]
NB["Northbound interface<br/>REST API, intents, event callbacks"]
ST["State management<br/>topology, host and link status, flow tables, statistics"]
SB["Communication layer<br/>southbound interface"]
NB --> ST --> SB
end
SW["Switches and routers<br/>flow tables"]
APPS <--> NB
SB <-->|"OpenFlow, NETCONF, OVSDB"| SW
| Layer | Job |
|---|---|
| Southbound | Talks to the switches. OpenFlow is the best known protocol. NETCONF and OVSDB are others |
| State management | Keeps a current, network-wide view: topology, link and port status, installed flow rules, counters |
| Northbound | Lets applications read that state, write rules, and subscribe to events. Usually a REST API. Some controllers also accept intents, high-level goals such as “host A may reach host B” that the controller turns into rules |
The controller is logically centralized but physically distributed. Applications see one service, while in production it runs as a cluster of servers replicating the state. That gives fault tolerance and capacity without losing the single point of view. ONOS is an open-source controller built this way, with a distributed core, an intent framework, and several southbound protocols.
Large operators use the same pattern with intent-based management: operators declare the desired network state, and controllers continuously compare it with what devices report and fix the difference. Kubernetes controllers follow the same idea of reconciling desired and actual state.
OpenFlow messages
Section titled “OpenFlow messages”OpenFlow runs over TCP, by default on port 6653.
| Direction | Message | Purpose |
|---|---|---|
| Controller to switch | Configuration | Query or set switch parameters |
Modify-state (flow-mod) | Add, change, or delete flow entries and port settings | |
| Read-state | Fetch counters and statistics | |
Send-packet (packet-out) | Make the switch emit a specific packet on a port | |
| Switch to controller | packet-in | A packet matched no entry, or an entry says “ask the controller” |
flow-removed | An entry timed out or was deleted | |
port-status | A port or link went up or down |
Going deeper: SDN controller internals covers flow rule fields, multi-table pipelines, controller clustering, and intent reconciliation.
Reactive and proactive rules
Section titled “Reactive and proactive rules”A controller can install rules two ways:
| Style | How it works | Trade-off |
|---|---|---|
| Reactive | The first packet of a flow has no match and goes to the controller as packet-in. The controller decides, installs a rule, and later packets are forwarded by the switch | Table stays small. First packet is slow, and a burst of new flows can overload the controller |
| Proactive | The controller installs rules ahead of time, from topology and policy | No first-packet delay. Needs more table space and planning |
Production networks mostly use proactive rules for the fabric and reactive handling for exceptions.
What happens when a link fails
Section titled “What happens when a link fails”- A leaf switch loses a link to a spine and sends
port-statusto the controller. - The controller’s state layer marks the link down and notifies the routing application, which subscribed to link events.
- The application recomputes shortest paths on the new topology.
- The controller sends
flow-modmessages to every switch whose rules used the failed link, and traffic moves to the surviving paths.
In a traditional network the same event triggers OSPF flooding and a recalculation on every router. In SDN one computation runs in one place.
Traditional control compared with SDN
Section titled “Traditional control compared with SDN”| Per-router control | SDN | |
|---|---|---|
| Control logic | Inside each router | On the controller servers |
| Link between planes | The forwarding table | The flow table |
| Communication | Router to router (OSPF, BGP) | Switch to controller (OpenFlow) |
| Trigger | Protocol timers and neighbor updates | Events such as port-status and packet-in |
| Recomputation | Each router runs its own algorithm | The controller computes and distributes the result |
SDN does not replace routing protocols everywhere. Many data centers combine both: BGP or OSPF between devices for the underlay, and a controller for overlays, policy, and virtual networks. See Routing protocols.
Troubleshooting
Section titled “Troubleshooting”| Symptom | Likely cause | Fix |
|---|---|---|
| First packets of a flow are slow, later ones fast | Reactive rules: each new flow waits for the controller | Install rules proactively, or add controller capacity |
| Traffic stops when the controller restarts | The switch fails closed and has no rules without the controller | Choose the fail mode deliberately. In OVS: ovs-vsctl set-fail-mode br0 standalone (acts as a normal switch) or secure (keeps only installed rules) |
| A rule shows zero hits | A higher-priority rule matches first, or a missing protocol prerequisite | Check ovs-ofctl dump-flows for overlapping priorities |
| New rules are rejected | Hardware flow table is full | Aggregate rules with wildcards, or move policy into software switches |
Middleboxes and network function virtualization
Section titled “Middleboxes and network function virtualization”A middlebox sits on the path between hosts and does more than forward packets. Three categories cover nearly all of them:
| Category | Examples |
|---|---|
| Address translation | NAT, carrier-grade NAT |
| Security | Firewalls, IDS and IPS, email security gateways |
| Performance | Caches, load balancers, TCP splitters, compression |
See Networking services for NAT and Firewalls for the security side.
Dedicated hardware appliances were costly and hard to scale, each with its own software and management tools. Network function virtualization (NFV) runs the same functions as software on commodity servers. The software stack is common, capacity scales by adding instances, and the functions can be chained and managed centrally.
| Hardware appliance | NFV | Cloud-managed service | |
|---|---|---|---|
| Runs on | Proprietary hardware | Commodity servers, VMs, or containers | Provider infrastructure |
| Scaling | Buy bigger boxes | Add instances | On demand |
| Management | Per device | Central, software-driven | The provider’s console and API |
| Examples | Hardware firewall or load balancer | Virtual firewall, software load balancer | Cloud NAT gateway, managed load balancer, security groups |
Middleboxes break the original design principle that the network core should be simple and that intelligence belongs on the end hosts. NAT rewrites transport ports, and firewalls and IDS read application data, all inside the network. Purists say this undermines end-to-end communication. Pragmatists answer that address shortage, security, and performance needs would not be met otherwise. See Design principles: narrow waist and end-to-end.
In Kubernetes, the same ideas appear as network policies (distributed firewalling), Services (load balancing and rewriting), and the networking model that CNI plugins implement.