4.2.1. Longest Prefix Match
The router always prefers the most specific route (longest prefix). For each packet it strips the incoming frame to read the destination IP, collects every route whose prefix contains that address, picks the longest, and then builds a new Layer 2 frame (new source and destination MAC) for the chosen next hop.
Example: Destination 192.168.1.50
- Route A: 192.168.0.0/16 (covers .50 ✓)
- Route B: 192.168.1.0/24 (covers .50 ✓) ← Selected (more specific)
- Route C: 10.0.0.0/8 (doesn't cover .50 ✗)