Software-defined networking
Network controller
A central system that holds the network's intended state and configures the devices for you, behind an API.
A network controller (an SDN controller) is a central system that holds the network's intended state and configures the devices for you. Programs and people ask it through its northbound API, usually REST; it reaches the devices through its southbound side (NETCONF, OpenFlow, SSH). One request reaches every device it concerns. The controller is the source of truth: a change made by hand on a device is overwritten or reported.
How an SDN controller works, step by step
Software-defined networking splits a switch in two. The data plane forwards packets; the control
plane decides where they go. A classic switch runs both itself. SDN pulls the control plane out into one
controller that sees every switch and programs each one, as in
control plane and data plane. Follow the
SDN controllers lab, where two Open vSwitch switches, gate and backstage, carry a
festival's scanner, kiosk, ticket server and stage PC, and an os-ken controller reaches them on a management
network 10.0.9.0/24:
- The switches connect. Each switch runs in
fail_mode: secureand dials the controller on TCP 6653. The controller writes one flow into each: the table-miss flow, priority 0, which sends anything no other flow matches up to the controller. That is the southbound interface: OpenFlow 1.3 here, though a controller may also use NETCONF, gNMI or a vendor API. - The first frame asks. A host's first frame (an ARP request) meets only the table-miss flow, so the switch sends it to the controller in a packet-in message. The controller's learning-switch app notes where that MAC address lives and tells the switch to flood the frame (a packet-out).
- It writes flows. Once it knows where both ends live, the controller writes a flow per direction into each switch: match the in-port and the two MAC addresses, output to one port. Every later frame of that conversation is forwarded by the switch alone.
- The northbound side. People and programs drive the controller through its own API, usually a REST API: read any switch's flows, or POST a rule, such as a drop at a priority above the learned flows. One request reaches the switch it concerns, and the controller becomes the source of truth. The network APIs lab drives that kind of API on a router.
- The data plane carries on. Unplug the controller and the flows already written keep forwarding. Anything new, a pair of hosts that never talked, meets only the table-miss flow and goes nowhere.
What it looks like on a Linux machine
On a switch, ovs-vsctl show names the controller it dials and whether it is connected:
$ ovs-vsctl show
Bridge br0
Controller "tcp:10.0.9.2:6653"
is_connected: true
fail_mode: secure
Port scanner
Port kiosk
Port backstage
Before any traffic, its flow table holds only the table-miss flow:
$ ovs-ofctl -O OpenFlow13 --names dump-flows br0
cookie=0x0, duration=12.3s, table=0, n_packets=0, n_bytes=0, priority=0 actions=CONTROLLER:65535
After the scanner pings the ticket server, the controller has written one flow per direction:
priority=1,in_port=scanner,dl_src=02:f7:39:23:ff:d4,dl_dst=02:f4:33:22:fb:01 actions=output:backstage
priority=1,in_port=backstage,dl_src=02:f4:33:22:fb:01,dl_dst=02:f7:39:23:ff:d4 actions=output:scanner
The controller's REST API names switches by datapath ID and takes new flows as JSON:
$ curl -s http://10.0.9.2:8080/stats/switches
[1, 2]
$ curl -s -X POST -d '{"dpid": 1, "priority": 100, "match": {"eth_type": 2048,
"ipv4_src": "10.0.1.22", "ipv4_dst": "10.0.1.30"}, "actions": []}' \
http://10.0.9.2:8080/stats/flowentry/add
The switch then lists priority=100,ip,nw_src=10.0.1.22,nw_dst=10.0.1.30 actions=drop, an empty action list
being a drop.
What goes wrong, and how you see it
A rule doesn't take. A drop rule at priority 0 loses to the learned flows at priority 1 that match the same
packets: the highest priority that matches wins. dump-flows shows both, and the learned flow's n_packets
climbing. Send the rule again above every flow it must beat.
A switch lost its controller. ovs-vsctl show on it has no is_connected: true, and the controller's
/stats/switches leaves out its datapath ID. Conversations it already has flows for still work; new ones fail.
Check the controller address it dials and the management link.
The table-miss flow is gone. A delete that matched priority 0 and an empty match removed it, and a switch in
fail mode secure now drops every frame no flow matches. The controller writes it only when a switch connects, so put it
back through the API or reconnect the switch.
fail_mode is wrong. A switch left in fail_mode: standalone acts as an ordinary learning switch when the
controller is gone, forwarding traffic the controller's rules meant to block. ovs-vsctl show should read
fail_mode: secure.
Questions people ask
What is the difference between northbound and southbound APIs? Southbound is how the controller talks to the devices (OpenFlow, NETCONF, gNMI, a vendor API). Northbound is how people and programs talk to the controller, usually a REST API. One northbound call can touch every device.
Is SDN the same as OpenFlow? No. SDN is the idea of a separated, centralised control plane; OpenFlow is one southbound protocol for it. Many controllers now use NETCONF or gNMI instead, and the lab happens to use OpenFlow 1.3.
Does the network stop if the controller dies? Already-installed flows keep forwarding, so existing conversations survive. What stops is anything new: no new flows and no reaction to failures until the controller returns. That is why production controllers (ONOS, OpenDaylight) run as a cluster of three.
Read next
- REST API An HTTP interface where every thing is a URL and the methods are the verbs: GET reads, POST creates, PUT and PATCH change, DELETE removes.
- Configuration management Writing the wanted configuration down as files and letting a tool make every device match it.
- Configuration drift A device's running config moving away from its intended one, usually through changes made by hand.
- Control plane and data plane Deciding where traffic should go (control plane) against moving each packet by those decisions (data plane).
- OpenFlow The protocol an SDN controller uses to write match-and-action rules (flows) into a switch's flow table.
- NFV (network functions virtualization) Routers, firewalls, NAT and load balancers run as software on ordinary servers instead of as dedicated boxes.
- SD-WAN A WAN built as encrypted tunnels over several links at once, run from one controller that steers each application onto the best path.