Forwarding internals and offload
Follow the forwarding pipeline
A router forwarding pipeline parses headers, chooses the routing context, applies applicable policy, looks up the destination, resolves the next hop, updates forwarding headers and queues the packet. For IPv4 forwarding this may include decrementing TTL and updating the header checksum. Software forwarding uses CPU instructions and memory; an ASIC implements supported operations in specialized hardware pipelines. A CPU slow path may handle exceptions, but not every miss or unsupported operation is punted: behavior depends on the device. A forwarding information base (FIB) is selected forwarding state, distinct from all candidates in the routing information base. A successful lookup does not prove a usable adjacency, permitted packet or available output queue.
Compare longest-prefix lookup algorithms
Use the toy FIB below. Destination 10.59.1.25 matches four entries including the default; the /32 wins. Destination 10.59.1.26 selects /24; 10.59.2.1 selects /16; 192.0.2.1 selects /0. A simple scan checks each entry; a binary prefix trie follows address bits and remembers the deepest terminal match. Its traversal has at most 32 bit steps for IPv4, excluding construction and memory costs. TCAM (ternary content-addressable memory) can represent match bits 0, 1 or wildcard and perform parallel matching with priority encoding. ASIC designs may use TCAM, SRAM or other lookup structures; capacity, update cost, resource sharing and pipeline stages vary. These algorithms represent the same unique-prefix decision in this toy example, not identical timing or real hardware behavior.
Prefix Next hop label0.0.0.0/0 default10.59.0.0/16 site10.59.1.0/24 rack10.59.1.25/32 hostUnderstand offload before interpreting a capture
On Linux, TCP segmentation offload (TSO) lets a capable NIC split a larger buffer into TCP segments; generic segmentation offload (GSO) provides a software segmentation mechanism. Generic receive offload (GRO) can combine received packets for processing. With a 1,500-byte IPv4 MTU, 20-byte IP and 20-byte TCP headers and no options, the maximum TCP data per full segment is 1,460 bytes. A hypothetical 4,000-byte TCP data buffer becomes payloads of 1,460, 1,460 and 1,080 bytes. The IP packet lengths are 1,500, 1,500 and 1,120. An Ethernet capture without VLAN or FCS adds 14 bytes per packet. FCS, preamble and interframe gap accounting are separate. A host capture before segmentation can show a larger buffer; a checksum may not yet be finalized before NIC checksum offload. Neither observation alone proves a wire MTU violation or corrupt transmission. The segmentation example is an arithmetic model, not an observed offload trace.
Queues and the cost of processing
Linux NAPI supports packet-event processing by polling after notification, with other polling modes also possible. Poll budgets and scheduling help share CPU time. Interrupt-driven processing can respond quickly to sparse arrivals; batching or polling can reduce per-packet overhead under load but changes latency and CPU usage. RSS can steer flows to NIC receive queues using header hashes and an indirection table; it does not guarantee equal load. In a discrete queue model with capacity 64 packets, initially 40, 50 arrivals then 32 serviced, only 24 arrivals fit, 26 drop and 32 remain after service. If service runs before arrivals the result differs. Record event ordering, counter scope and time window; a queue drop counter does not identify every downstream loss. Do not tune a host NIC or kernel based solely on a classroom model.
Practice with two independent models
For destination lookup, compare the simple scan and trie outputs for a destination on either side of a /24 boundary. For offload, repeat the arithmetic with 2,921 bytes of TCP data and the same headers: payloads 1,460, 1,460 and 1 byte. Explain why a capture before segmentation may report a different packet count and why hardware throughput cannot be inferred. For queues, test an initially empty 64-packet queue receiving 65 packets before any service. Record the one dropped packet and the assumed order. The following lesson builds a reproducible offline experiment with safe bounded inputs.
Check Your Understanding
Solidify your learning with the interactive assessment directly below this lesson.
Concept Quiz & Questions
Forwarding internals and offload Quiz
Reason about standards, forwarding internals and reproducible experiments.
Destination 10.59.1.25 matches /0, /16, /24 and /32. Which wins?
How many payload bytes fit with MTU 1500 and two 20-byte headers?
Which payload split is correct for 4000 bytes in the example?
Why may a host capture show a large TCP buffer?
A queue of 64 starts at 40, receives 50 before service. How many drop?