E02Concept13:30In production

How a router really forwards a packet: RIB, FIB, and CEF

In production now

Subscribe and you'll get it the day it goes live. A new episode every week.

Subscribe on YouTube

About this episode

A 100G port gives a router about seven nanoseconds per packet, so how does it decide where each one goes? In this episode we open the router up: the control plane and the data plane, how routes compete for the RIB, how the RIB becomes the FIB, what the adjacency table rewrites at every hop, and why CEF and hardware forwarding replaced process and fast switching. Part of Ping Academy's free course "IP/MPLS: Zero to Service Provider".

What you'll learn

  • Explain the difference between the control plane and the data (forwarding) plane, and which work happens in each.
  • Describe how routing sources (connected, static, IS-IS, BGP) offer routes to the RIB, and how administrative distance and metric decide what gets in.
  • Explain how the RIB is turned into the FIB (recursion resolved, ECMP ready) and what the adjacency table adds.
  • List what a router rewrites at every hop (MACs, TTL, IP header checksum, FCS) and what it leaves alone (source and destination IP).
  • Compare process switching, fast switching, and CEF, and explain why hardware forwarding (ASIC/TCAM) needs a precomputed FIB.
  • Find each table on FRR (show ip route), Linux (ip route, ip route get, ip neigh), and Cisco (show ip cef, show adjacency detail).

Cheat sheet

  • Control plane (CPU: IS-IS, BGP, static, connected) decides paths. Data plane (forwarding chips or kernel) moves packets using tables built in advance.
  • Each protocol keeps its own database (IS-IS LSDB, BGP table) and offers its best route per prefix to the RIB.
  • Administrative distance (lower wins) picks the source when several offer the same prefix and length: connected 0 · static 1 · eBGP 20 · OSPF 110 · IS-IS 115 · iBGP 200 (FRR and Cisco defaults). Within one protocol, lowest metric wins.
  • The FIB is compiled from the RIB: only prefix, next hop, interface. Recursive next hops are pre-resolved and ECMP paths are listed. It is a full copy, not a traffic-driven cache.
  • The adjacency table (from ARP) holds the pre-built Ethernet header for each next hop.
  • Per-hop rewrite: new dst/src MAC, TTL −1 (TTL expired → drop + ICMP Time Exceeded from the CPU), IPv4 header checksum updated, new FCS. Source and destination IP unchanged.
  • Process switching: CPU per packet. Fast switching: first packet via CPU, then route cache (traffic-driven, churns). CEF: FIB + adjacency built in advance (topology-driven).
  • Hardware: the route processor programs the FIB into line-card ASICs/NPUs; TCAM matches all entries in parallel (0/1/don't-care bits). Misses and exceptions are punted to the CPU.
  • FRR lab: show ip route = zebra's RIB (> selected, * in FIB). FIB = Linux kernel: ip route, ip route get <dst>, ip neigh. Cisco: show ip route, show ip cef, show adjacency detail (IOS XR: show route, show cef).
  • MPLS keeps the split: LDP → LIB (control) → LFIB (data), just like RIB → FIB.