Network Design and Operations
A router's routing table has four routes: 172.16.0.0/12 (next hop router B), 172.16.32.0/19 (router A), 172.16.48.0/20 (router C) and 0.0.0.0/0 (router D). To which router is a packet for 172.16.45.10 sent?
- ARouter A
- BRouter B
- CRouter C
Show answer and explanation
Answer: A. Router A
A router chooses, among the routes that match the destination, the one with the longest prefix (longest prefix match). The third octet, 45, is 00101101 in binary. A /19 compares the upper 3 bits of the third octet, and 45 AND 224 = 32, so the address matches 172.16.32.0/19 (172.16.32.0 to 172.16.63.255). A /20 compares the upper 4 bits, and 45 AND 240 = 32, which differs from 48, so it does not match 172.16.48.0/20 (172.16.48.0 to 172.16.63.255). The address also matches 172.16.0.0/12 and the default route, but the longest match, the /19, is chosen and the packet goes to router A.
- A. Correct. It is the longest of the matching routes, the /19.
- B. The /12 also matches, but the longer /19 matches too, so it is not chosen.
- C. 172.16.45.10 is not in the range of 172.16.48.0/20 (172.16.48.0 to 172.16.63.255), so it does not match.