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

PrefixNext hop
0.0.0.0/0A
172.16.0.0/16B
172.16.8.0/21C

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

  1. /0 matches all destinations.
  2. /16 covers 172.16.0.0–172.16.255.255, so it matches.
  3. /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.
  4. Of /0, /16 and /21, /21 is longest.

Final answer: next hop C via 172.16.8.0/21.