Skip to content
Tutorials Center
My learning

Topics

Lesson 57 of 79 ยท Modern Networks

Software-Defined Networking and Network Virtualization

Learn how SDN separates the control plane from the data plane, how OpenFlow match-action rules work, and how VXLAN overlays and NFV virtualize networks, with runnable models.

For most of the history of networking, every router and switch was a sealed box: dedicated hardware, a vendor's operating system, and a built-in brain that decided where packets go. To change the behavior of a network of a hundred boxes you logged in to each one. That worked when networks were small and changed slowly. It does not work for a cloud provider who creates thousands of virtual networks every hour, or for a company that wants to change a policy everywhere in a minute.

Software-defined networking (SDN) is the answer: take the decision-making out of the individual boxes and put it in software that you can program. A closely related idea, network virtualization, builds many independent virtual networks on top of one physical network. Together, they are the foundation of cloud data centers and modern carrier networks. This lesson explains both ideas and lets you run a model of each: a switch driven by a controller, and the encapsulation that makes overlay networks possible.

Three planes of a network device

Every network device does three jobs, and SDN is about separating them:

Plane Job Speed Example
Data plane (forwarding plane) Move each packet: look up a rule and send it out of a port Nanoseconds, in hardware The forwarding table of a switch
Control plane Decide what the rules should be: compute routes, learn MAC addresses, run OSPF or BGP Milliseconds to seconds, in software A routing protocol process
Management plane Configure, monitor and log Minutes SSH, SNMP, logging

In a traditional network, each device has all three. The control plane is distributed: every router runs its own copy of the routing protocol and builds its own table, and the network as a whole reaches a consistent state through message exchange (with the convergence delays you saw in distance-vector routing). In SDN, the control plane is logically centralized in a controller, a program (usually a cluster, for reliability) that sees the whole network and writes the forwarding rules into simple switches.

flowchart TB
    APP["Applications: routing, firewall, load balancing"] -->|"northbound API (REST)"| CTL["SDN controller: global view of the network"]
    CTL -->|"southbound API (OpenFlow, gNMI, P4Runtime)"| S1["Switch 1: data plane"]
    CTL --> S2["Switch 2: data plane"]
    CTL --> S3["Switch 3: data plane"]
    S1 --- S2
    S2 --- S3

The controller computes; the switches forward. Applications talk to the controller, and the controller talks to the switches.

Two interfaces matter. The southbound API is how the controller programs the switches. The best known is OpenFlow, the protocol that started the SDN movement around 2008. The northbound API is how applications and operators talk to the controller, typically a REST API. Operators can then write a network policy once, and the controller turns it into rules for each switch.

Match-action forwarding: OpenFlow

An OpenFlow switch has one or more flow tables. Each table row (a flow entry) has:

  • Match fields: any combination of the ingress port, source and destination MAC, VLAN, source and destination IP (with a prefix mask), protocol, and TCP or UDP ports,
  • a priority, so that a specific rule can override a general one,
  • actions: output to a port, drop, rewrite a header field, send to the controller, or jump to another table,
  • counters for how many packets and bytes matched.

When a packet arrives, the switch finds the highest-priority matching entry and applies its actions. If nothing matches (a table miss), a default entry typically sends the packet to the controller in a packet-in message. The controller then decides what to do, sends the packet on its way, and installs a new flow entry so that later packets of the same kind never leave the data plane. This style is called reactive. The alternative, proactive rules, installs the entries in advance so there are no misses.

The uniform match-action model means that one kind of box can behave as a switch, a router, a firewall or a load balancer, depending on the rules it is given.

A switch and a controller

The program below separates the two roles clearly. The Switch knows nothing except how to match packets against its table. The Controller runs a learning-switch application: it learns which port a host is on from the packets it sees, and installs flow entries for destinations it knows. The operator has also installed a high-priority policy rule that drops telnet (TCP port 23).

Python A match-action switch driven by a controller

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

The first packet from A to B is a table miss, and the controller does not yet know where B is, so it floods it. Then B answers, and now the controller knows A's port and installs a rule for A. The third packet is a miss again because B's rule is not there yet, and the controller installs it. From then on, every packet hits a rule and the controller is not involved: three of seven packets needed the controller, and the longer the conversation, the smaller that fraction. The telnet packet is dropped by the priority-200 policy before any forwarding rule is considered, even though it matches the forwarding rule for B as well.

Why centralize?

Advantage Explanation
Global view The controller sees all topology and traffic, so it can optimize paths, balance load and detect problems in a way that single routers cannot
Fast change A policy is written once and applied everywhere in seconds. The software can be tested and versioned like code
Simple hardware Switches only need a fast match-action pipeline. Features arrive as software updates
Automation Cloud platforms create networks through APIs, with no human typing commands into devices
Innovation New behavior no longer waits for a vendor's next release

There are also real concerns. The controller is a single point of failure and a target, so it is run as a replicated cluster, and switches keep forwarding with their existing rules if it fails. A badly written controller can break the entire network at once. The delay of a packet-in makes purely reactive designs unsuitable for high-volume flows, which is why most deployments install rules proactively. In practice many real networks use SDN inside a data center or a WAN, while the routing between organizations remains BGP. Programmable chips and the language P4 go one step further and let you define how the data plane itself parses and processes packets.

Network virtualization and overlays

Virtualization of servers created a new problem: virtual machines move between physical hosts and belong to different customers. A cloud provider needs to give each customer a private network, with its own address space, that follows the machines wherever they are, on top of a shared physical network. VLANs cannot do it well: there are only 4094 of them, and they extend a Layer 2 domain across the whole physical network.

The solution is an overlay network. Packets between virtual machines are encapsulated in ordinary IP packets between physical hosts, and the physical network (the underlay) only sees and routes those outer packets. The best-known overlay protocol is VXLAN (Virtual eXtensible LAN):

  • The sender's VTEP (VXLAN tunnel endpoint, usually the virtual switch on the host) takes the VM's whole Ethernet frame, adds an 8-byte VXLAN header with a 24-bit VXLAN network identifier (VNI), wraps it in a UDP datagram (destination port 4789), and sends it to the remote VTEP's IP address.
  • The receiving VTEP strips the outer headers, uses the VNI to decide which virtual network the frame belongs to, and delivers it to the VM.
  • With 24 bits, there are about 16 million VNIs, against 4094 VLANs, and two tenants can use the same private addresses without any conflict, because the VNI keeps their traffic apart.

Other overlay protocols (GENEVE, NVGRE, GRE) differ in the details. They all trade a few bytes of overhead for isolation and mobility.

Python VXLAN encapsulation, overhead and tenant separation

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

The header for VNI 5001 begins with the flag byte 08 (meaning "VNI valid") and carries 00 13 89 (5001) in the VNI field. Encapsulation costs 50 bytes: 14 for the outer Ethernet header, 20 for IPv4, 8 for UDP and 8 for VXLAN. A full-size inner frame of 1514 bytes becomes an outer IP packet of 1550 bytes, which does not fit in a standard 1500-byte link. This is the most common VXLAN deployment problem. The fix is to raise the MTU of the underlay (jumbo frames of 9000 bytes are standard in data centers) or to lower the MTU of the virtual machines to 1450. The lookup table at the end shows two tenants with the same address 10.0.0.5 reaching different physical hosts because of their VNIs.

Virtual switches and network functions

Inside each host, a virtual switch such as Open vSwitch or the Linux bridge connects the VMs and containers to each other and to the physical network. Open vSwitch speaks OpenFlow, so an SDN controller can program it. The virtual switch is where VXLAN encapsulation happens, where per-VM firewall rules are enforced, and where traffic is measured.

Network function virtualization (NFV) applies the same thinking to appliances: instead of buying a hardware firewall, load balancer, NAT box or intrusion detection system, you run the function as software in a VM or container on standard servers, and scale it with demand. The controller can then steer traffic through a chain of these functions, service chaining, for example firewall, then intrusion detection, then load balancer, without recabling anything. Mobile carriers run their 5G core this way.

Network functions virtualization (NFV)

SDN separates the control plane from the data plane. NFV attacks a different problem: network functions such as firewalls, load balancers, NAT, intrusion detection and WAN optimizers used to be sold as dedicated hardware boxes. NFV runs them as software, called virtualized network functions (VNFs), on ordinary servers in virtual machines or containers. The parts of the standard architecture are:

  • NFVI (NFV infrastructure): the servers, storage, network and the virtualization layer that VNFs run on.
  • VNFs: the software functions themselves (a virtual firewall, a virtual router).
  • MANO (management and orchestration): the software that starts, stops, scales and chains VNFs according to templates.

A typical use is vCPE (virtual customer-premises equipment). Instead of installing a special router with many features at each customer, the provider sends a simple box and runs the extra functions (firewall, parental control, NAT) as VNFs in its own data center. Several VNFs are joined into a service chain, so traffic flows through firewall, then NAT, then load balancer.

The benefits are lower hardware cost, faster service launches (days instead of months), elastic scaling (run more instances when load grows) and flexibility. The drawbacks are that software on a general-purpose CPU may be slower than purpose-built chips unless tuned (with techniques such as DPDK or SmartNICs), the security of the virtualization layer matters, and orchestration is complex.

NFV versus SDN: they are complementary, not competitors. SDN is about how traffic is steered (a central controller programs the forwarding of switches), NFV is about where network functions run (in software instead of in boxes). SDN can steer traffic through a service chain of VNFs, and NFV can host the SDN controller itself.

SDN versus traditional networks

Aspect Traditional network SDN
Control Distributed: each device runs its own control plane Centralized logical controller
Configuration Device by device (CLI), often by hand Programmatic through APIs
Hardware Vendor-specific boxes Commodity switches with open protocols such as OpenFlow
Change speed Slow and error-prone Fast, scripted and testable
Strengths Mature, familiar, no central point of failure Flexibility, global view, easy automation, lower cost
Weaknesses Rigid architecture, limited scalability of management, expensive hardware Controller is a target and a possible bottleneck, security risk if the controller is compromised, immature skills and standards

SDN controllers are often described in layers: an application layer (programs that express intent), a control layer (the controller with its global view), and an infrastructure layer (the switches), joined by a northbound API (to applications) and a southbound API (to switches, for example OpenFlow). Models of SDN include controllers reached by APIs, overlay-based SDN and hybrid designs where SDN and traditional protocols coexist. A historical ancestor was Ethane (Stanford, 2007), which used a central controller to authorize each new flow according to a network-wide policy and then program the switches along the path. Its ideas (a logical central policy, flow-level control, simple switches) led to OpenFlow.

Python A service chain of virtual network functions

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

The orchestrator changes the service chain by editing a list, which is the whole point of NFV: adding the intrusion-detection step needed software, not a new box.

Check your understanding

Quick check ยท 5 questions

of 5 answered You scored / 5 ยท perfect!

  1. 1. What is the main idea of SDN?

    In SDN, switches only forward by simple rules, and a logically centralized controller decides what the rules should be.
  2. 2. An OpenFlow switch receives a packet that matches no flow entry. What typically happens?

    A table miss triggers a packet-in message to the controller. Reactive controllers then install an entry so that later packets hit the table.
  3. 3. Why can two tenants use the same private IP addresses in a VXLAN network?

    The VNI separates the virtual networks, so overlapping inner addresses never meet.
  4. 4. A VXLAN underlay uses a standard 1500-byte MTU. A VM sends a full 1500-byte IP packet. What happens?

    Inner Ethernet header, VXLAN, UDP and outer IP add up to 50 bytes. Raise the underlay MTU (for example to 9000) or lower the VM MTU to 1450.
  5. 5. What does NFV mean?

    Network function virtualization replaces dedicated appliances with software functions that can be scaled and chained.

Summary

  • Network devices have a data plane (forwarding), a control plane (deciding the rules) and a management plane. SDN moves the control plane into a logically centralized controller.
  • The controller programs switches through a southbound API such as OpenFlow, and offers a northbound API to applications.
  • OpenFlow switches forward by match-action flow entries with priorities and counters. A table miss goes to the controller, which can install rules reactively or in advance.
  • SDN brings a global view, fast change and automation. Controllers must be clustered, and the switches keep forwarding if the controller fails.
  • Overlay networks such as VXLAN encapsulate virtual-network frames in UDP between host tunnel endpoints. A 24-bit VNI separates tenants and allows overlapping addresses, at a cost of 50 bytes per packet, so MTUs need attention.
  • Virtual switches enforce policy inside hosts, and NFV runs network functions as software that can be chained.

Next, see these ideas applied to the networks of cloud providers in Cloud and Data Center Networking.