Computer Networks · M2 · mocks
Q3 · Longest-prefix matching
M2 mock C
Q1(a)+Q1(b) compulsory; choose any two of Q2/Q3/Q4 · 10 marks attempted
Question. A router has routes 0.0.0.0/0 via A, 172.16.0.0/16 via B and 172.16.8.0/21 via C. Which route is used for destination 172.16.10.45? Show the range checks. [3 practice marks]
Answer
Given
| Prefix | Next hop |
|---|---|
| 0.0.0.0/0 | A |
| 172.16.0.0/16 | B |
| 172.16.8.0/21 | C |
Destination=172.16.10.45.
To find
Most specific matching next hop.
Formula and why
Choose the largest matching prefix length; an entry that does not contain the destination is ineligible.
Step-by-step solution
- /0 matches all destinations.
- /16 covers 172.16.0.0–172.16.255.255, so it matches.
- /21 mask is 255.255.248.0; third-octet step=8. The block is 172.16.8.0–172.16.15.255, containing third octet 10.
- Of /0, /16 and /21, /21 is longest.
Final answer: next hop C via 172.16.8.0/21.