4.3.13 · D5Computer Networks

Question bank — Routing — forwarding table, routing table

2,185 words10 min readBack to topic

Before we start, one shared vocabulary reminder, in plain words:

The single figure on this page is your visual anchor for every bitwise question — keep it in view:

Figure — Routing — forwarding table, routing table

True or false — justify

True or false: the routing table and the forwarding table always contain the same number of entries.
False. The routing table can hold several candidate routes for one prefix (learned by different protocols); the forwarding table keeps only the single winning route per prefix, so it is usually smaller.
True or false: a packet is looked up in the routing table for every single packet that arrives.
False. Per-packet lookups happen in the forwarding table (data plane); the routing table is consulted by protocols and only when it changes, not per packet.
True or false: 0.0.0.0/0 matches only addresses that no other route covers.
False. It matches every address (zero required bits agree). It merely loses to any more specific route because longest-prefix-match prefers the largest prefix length.
True or false: a /25 network is larger than a /24 network.
False. /25 has more network bits and fewer host bits, so it holds fewer hosts (128 vs 256). Longer prefix = smaller network.
True or false: if two prefixes both match a destination, the router uses whichever appears first in the table.
False. IP forwarding ignores table order; it picks the longest (most specific) matching prefix, regardless of position — the right panel of the figure shows the length-25 bar winning.
True or false: the forwarding table stores next-hop IP addresses but never a physical interface.
False. The FIB stores the resolved outgoing interface (and typically next-hop and MAC), because the data plane needs a physical door to send the packet out, not just an IP.
True or false: administrative distance is compared inside the forwarding table when choosing where to send a packet.
False. Administrative distance and metric are used in the routing table to elect one winner; the forwarding table already contains only that winner, so no such comparison happens at forwarding time.
True or false: changing a routing protocol's metric can change which door a packet leaves by, even though the packet itself never touches the routing protocol.
True. The metric alters which route wins in the RIB, and that winner is re-installed into the FIB — so the per-packet decision changes indirectly.
True or false: a directly-connected network needs no next-hop IP in the forwarding entry.
True. For a directly-connected prefix the destination is one hop away on that interface, so the "next hop" is effectively the destination itself; only the outgoing interface (and ARP-resolved MAC) is needed.

Spot the error

"To forward a packet, AND the destination with the mask; if the result is non-zero the prefix matches." — what's wrong?
The test is equality, not non-zero: the prefix matches iff (D AND M) == (P AND M) (with , , as defined above). A non-zero AND result says nothing about matching a specific network.
"Longest prefix match means we pick the prefix with the most 1-bits in the mask." — where's the subtle trap?
For a well-formed mask (contiguous 1s then 0s), "most 1-bits" happens to equal "largest prefix length", so it looks right. But the rule is defined by prefix length , not bit-counting. The figure's inset shows a malformed mask like 255.0.255.0 (1s at bits 0–7 and 16–23): it has 16 one-bits yet is not a valid /16, so counting ones misleads — always trust the prefix length .
"The FIB is just the RIB copied verbatim into faster memory." — correct the claim.
The FIB is a distilled structure: only best paths, stripped of protocol/metric fields and with next-hops recursively resolved to interfaces. It is derived from, not a verbatim copy of, the RIB.
"Since the default route matches everything, a router with only 0.0.0.0/0 can never make a wrong forwarding choice." — find the flaw.
It always matches, but it may send packets down a path that cannot actually reach the destination. Matching is not the same as reachability; a default route is a guess of last resort.
"We should search the routing table first, and only if it fails, search the forwarding table." — fix the ordering.
The order is reversed and the roles are wrong: forwarding reads the FIB per packet; the RIB was already used earlier (control plane) to build that FIB. Forwarding never falls back to searching the RIB per packet.
"A route with a longer prefix always wins, so administrative distance is pointless." — reconcile the two ideas.
They operate at different stages and on different comparisons. Longest-prefix-match compares prefixes of different lengths for one packet; administrative distance breaks ties between routes to the same prefix from different protocols. Both are needed.

Why questions

Why can't a router just run its routing algorithm (like Dijkstra) once per arriving packet?
Routing algorithms are relatively slow and topology-wide; packets arrive millions per second. The heavy computation is done once in the control plane (where routes are decided) and cached as a lean FIB the data plane (where packets move) can search at line rate — see Control Plane vs Data Plane.
Why does ANDing the address with the mask isolate the network part?
The mask has 1s over the network bits and 0s over the host bits. ANDing with 1 keeps a bit; ANDing with 0 erases it — so host bits vanish and only the network bits remain to compare. The left panel of the figure shows the erased bits greyed out.
Why does the forwarding table hold exactly one entry per prefix while the routing table may hold several?
The routing table records all candidate routes so it can compare them; once administrative distance and metric elect a single best route, only that one is pushed to the FIB to keep per-packet lookup unambiguous and fast.
Why is longest-prefix-match the "most specific wins" rule, in plain terms?
A longer prefix pins down more leading bits, so it describes a smaller, more precisely located network. Choosing it means using the most detailed information you have about where the destination lives.
Why does a next-hop IP have to be resolved before it can live in the forwarding table?
The data plane can only push bits out of a physical port toward a link-layer (MAC) address. A next-hop IP must be recursively resolved to a directly-connected interface and then, on that link, to a MAC address — which for IPv4 is the job of ARP (a "who owns this IP?" broadcast). See ARP — Address Resolution Protocol.
Why do large routers keep the RIB in CPU RAM but the FIB in special memory like TCAM?
The RIB is large, rich, and rarely searched per packet, so ordinary RAM suffices. The FIB must be searched for every packet at line rate, so it lives in special hardware — TCAM (a memory that can match a whole table in one shot and return the longest prefix directly), covered in TCAM and Line-rate Forwarding.
Why can two routers running different protocols (say OSPF and RIP) disagree about the "best" path?
Each protocol measures cost differently (link-state cost vs hop count) and is trusted differently (administrative distance). The routing table reconciles them per prefix, but the underlying preference logic differs by protocol.

Edge cases

What does a router do with a packet whose destination matches no prefix and there is no default route?
It drops the packet (typically sending an ICMP "destination unreachable"), because no forwarding entry — not even 0.0.0.0/0 — tells it where to send it.
If a destination matches both 0.0.0.0/0 and a /32 host route, which wins and why?
The /32 wins: its prefix length (32) is the largest possible, so longest-prefix-match selects it over the length-0 default. A /32 pins down one exact address.
What is the prefix length of the default route, and what does a length of zero mean?
0.0.0.0/0 has length 0, meaning zero leading bits must agree — the match condition is vacuously satisfied for all addresses, which is exactly why it matches everything. See Default Gateway and 0.0.0.0/0.
If a packet's destination is the router's own interface IP, is it forwarded via the FIB?
No. It hits a local/receive route — an automatic entry the router installs for each of its own interface addresses that says "deliver this to me, don't forward it." The packet is handed up to the router's own stack (control plane) instead of going out a door.
What happens to the FIB the instant a link goes down and the routing protocol withdraws a route?
The control plane recomputes best paths and reinstalls the FIB; until that convergence completes, the FIB may still point at the dead path, so packets can be lost transiently — this is the convergence delay.
Two overlapping prefixes point to different interfaces, and a packet matches both. Is this a configuration error?
No — overlap is normal and intentional. Longest-prefix-match resolves it deterministically by choosing the more specific prefix; the shorter one acts as a broader fallback for addresses the longer one doesn't cover.
Can the same prefix legitimately appear in the routing table more than once?
Yes, as multiple candidate routes (different protocols or next-hops). The routing table keeps them all to compare; only the elected best route(s) reach the FIB. See IP Addressing and Subnetting for how prefixes are formed.
In IPv6, what plays the role that a /32 host route and ARP play in IPv4?
The most-specific host route in IPv6 is a /128 (one exact 128-bit address), and instead of ARP the link-layer address is found by Neighbor Discovery (ND, using ICMPv6 messages). Longest-prefix-match itself is identical — just over 128 bits instead of 32.
Does the default route look different in IPv6?
Yes in notation, not in behaviour: the IPv6 "match everything" route is ::/0 (prefix length 0), exactly analogous to IPv4's 0.0.0.0/0, and it likewise loses to any more specific prefix under longest-prefix-match.
Recall One-line self-test before you leave

Which table is searched per packet, and by which rule? ::: The forwarding table (FIB), by longest-prefix-match.