Sub topic 11
Control Plane Versus Data Plane
This chapter assumes you know longest prefix match, the difference between connected, static, and dynamic routes, and how a router rewrites the Layer 2 frame. It separates the work of deciding where traffic should go from the work of moving each packet.
Two jobs inside one box
A router does two kinds of work.
- Building the map. It learns which prefixes exist, which neighbors lead to them, and which path is best. This work is occasional and can be complex.
- Moving packets. For every packet that arrives, it looks up the destination, decrements the TTL, rewrites the frame, and sends it out. This work is constant, simple, and very fast.
These jobs are the control plane and the data plane. The data plane is also called the forwarding plane. Keeping them apart lets a router make slow, careful decisions while it forwards millions of packets per second.
| Property | Control plane | Data plane |
|---|---|---|
| Question it answers | "Where should traffic for this prefix go?" | "Where does this packet go right now?" |
| Unit of work | A route or a protocol message | A packet |
| Typical activity | Run OSPF or BGP, apply static routes, compare candidate routes | Longest prefix match, TTL decrement, checksum update, frame rewrite |
| Main data structure | RIB (Routing Information Base) | FIB (Forwarding Information Base) |
| Speed | Milliseconds to seconds | Nanoseconds to microseconds per packet |
| Typical implementation | General-purpose CPU, software | Specialized hardware or an optimized kernel path |
A third area, the management plane, covers SSH, SNMP, and configuration tools. Operators use it to configure the other two planes. It does not forward user traffic.
From RIB to FIB
The control plane holds many candidate routes. Several sources can offer a route to the same prefix: connected interfaces, static configuration, OSPF, BGP. The router compares them by administrative distance and then by metric. The lowest value wins. The winners go into the RIB.
The control plane then compiles the RIB into the FIB. The FIB is a lookup structure that holds only what the data plane needs: a prefix, an outgoing interface, and a next hop. It has no protocol state or alternative routes. Because it is small and uniform, it can be stored in a trie or in special memory such as TCAM and searched at line rate.
Information moves in one direction on the fast path. The data plane reads the FIB and never consults the RIB or runs a protocol.
A small model in Python
This program models the split. The control plane keeps candidate routes and picks the best one for each prefix. It then builds a FIB sorted so the longest prefix comes first. The data plane only searches that FIB.
import ipaddress
class ControlPlane:
def __init__(self):
# prefix -> list of (admin_distance, metric, next_hop, source)
self.candidates = {}
def learn(self, prefix, next_hop, source, distance, metric=0):
net = ipaddress.ip_network(prefix)
self.candidates.setdefault(net, []).append(
(distance, metric, next_hop, source)
)
def withdraw(self, prefix, source):
net = ipaddress.ip_network(prefix)
remaining = [c for c in self.candidates.get(net, []) if c[3] != source]
if remaining:
self.candidates[net] = remaining
else:
self.candidates.pop(net, None)
def build_fib(self):
fib = []
for net, options in self.candidates.items():
best = min(options, key=lambda c: (c[0], c[1]))
fib.append((net, best[2]))
# Longest prefixes first, so the first match is the longest match.
fib.sort(key=lambda entry: entry[0].prefixlen, reverse=True)
return fib
def forward(fib, destination):
addr = ipaddress.ip_address(destination)
for net, next_hop in fib:
if addr in net:
return next_hop
return None
cp = ControlPlane()
cp.learn("0.0.0.0/0", "192.0.2.1", "static", distance=1)
cp.learn("10.0.0.0/8", "192.0.2.2", "rip", distance=120, metric=3)
cp.learn("10.1.0.0/16", "192.0.2.3", "static", distance=1)
cp.learn("10.1.0.0/16", "192.0.2.4", "ospf", distance=110, metric=20)
fib = cp.build_fib()
print(forward(fib, "10.1.2.3")) # 192.0.2.3 (static beats OSPF)
print(forward(fib, "10.9.9.9")) # 192.0.2.2
print(forward(fib, "8.8.8.8")) # 192.0.2.1
# The static route is withdrawn. Traffic keeps using the old FIB
# until the control plane installs a new one.
cp.withdraw("10.1.0.0/16", "static")
print(forward(fib, "10.1.2.3")) # 192.0.2.3 (stale FIB)
fib = cp.build_fib()
print(forward(fib, "10.1.2.3")) # 192.0.2.4 (OSPF takes over)The last four lines show the key behavior. The data plane acts on the FIB it holds. A change in the control plane has no effect on forwarding until the new FIB is installed.
Seeing the split on Linux
On Linux, the kernel holds the FIB and daemons such as FRR or BIRD act as the control plane. They install routes into the kernel and tag each route with the protocol that installed it.
# The routing table the kernel forwards with
ip -4 route show table main
# Routes grouped by who installed them
ip route show proto kernel # connected networks, added automatically
ip route show proto static # added by an administrator
ip route show proto dhcp # learned from a DHCP server
# Ask the data plane what it would do with one destination
ip route get 10.1.2.3
# Check whether this machine is allowed to forward at all
sysctl net.ipv4.ip_forwardThe proto column shows which control-plane source owns each route. ip route get queries the data-plane result, not the candidates.
Traffic that never takes the fast path
Most packets are only transit traffic and stay on the fast path. Some packets need the router's CPU instead. Hardware routers call this punting a packet to the slow path. Examples:
- Routing protocol messages addressed to the router, such as OSPF hellos or BGP sessions.
- ARP and neighbor discovery requests for the router's own addresses.
- Packets whose TTL has expired, which need an ICMP Time Exceeded reply.
- Packets that need fragmenting or carry unusual IP options.
- ICMP echo requests sent directly to the router.
Because the CPU is much slower than the forwarding hardware, routers apply rate limits to punted traffic. This is control plane policing. One consequence matters in practice. A router can show high latency or loss in ping or traceroute while it forwards transit traffic perfectly. The probe packets are being handled by the slow path.
What each plane's failure looks like
Separating the planes explains several behaviors that otherwise look odd.
- Control plane healthy, data plane broken. The routing table is correct, but packets are dropped. Likely causes are a missing ARP entry, an MTU problem, an access list, or a FIB that was not updated.
- Control plane down, data plane still working. If a routing process crashes, the router can keep forwarding with the last FIB. Features such as graceful restart and non-stop forwarding rely on this. The risk is stale routes, because the router cannot react to failures while it recovers.
- Convergence delay. After a link fails, the control plane must detect it, exchange updates, recompute, and install the new FIB. Until then, packets may follow dead paths or be dropped. The data plane forwards faithfully, but on old instructions.
- RIB and FIB disagree. A route can appear in the RIB but not in the FIB, for example when hardware table space is full. Then
show ip routelooks right while traffic fails. Compare the RIB with the FIB, not just the RIB.
Common mistakes
- Treating the router CPU's performance as the forwarding limit. On hardware routers the data plane has its own capacity, and the CPU only affects convergence and punted traffic.
- Testing a router's forwarding health by pinging the router. That tests the control plane's slow path.
- Forgetting that a Linux host does not forward by default. Without
net.ipv4.ip_forward=1, it behaves as an end host even with a full routing table. - Changing a route and assuming it takes effect instantly. Installation into the FIB takes time, and dynamic protocols may take longer.
Exercise
A router's routing table (RIB) lists a route to 10.5.0.0/16 via 192.0.2.9, but packets for that network are dropped. A ping to the router's own address works. Name two control-plane or data-plane causes you would check and the reason a working ping does not rule them out.
Show answer
Check whether the route is actually in the FIB (it may be in the RIB but not installed, for example because hardware table space is full or installation lagged), and check whether the next hop 192.0.2.9 resolves in ARP or neighbor discovery, because a missing Layer 2 entry causes drops on the data plane. A ping to the router's own address is handled by the router's CPU on the slow path, so it shows the router is reachable but says nothing about whether transit traffic is forwarded.
Exercise
In the Python model, a static route for 10.1.0.0/16 has administrative distance 1, and an OSPF route for the same prefix has distance 110. Which one reaches the FIB, and what happens to forwarding if the static route is withdrawn but the FIB is not rebuilt?
Show answer
The static route reaches the FIB because the lowest administrative distance wins. If it is withdrawn but the FIB is not rebuilt, the data plane keeps using the old FIB and still sends traffic to the static next hop until the control plane installs a new FIB. After the rebuild, the OSPF route takes over.