Computer Networks · TEE · papers

Q5(c) · Longest-prefix matching

2024-12-06 · AI-only Sem V variant

Exact historical variant. Current-syllabus questions solved; excluded topics and source limitations stated.

Q5(c). An 8-bit forwarding table maps prefixes 01→interface1, 10→2, 011→3, 100→4, 001→5, otherwise→6. Determine interfaces for destinations (1)00111101, (2)01010101, (3)11001001 using longest-prefix matching. [5 marks]

Answer

Given

Prefixes01→1,10→2,011→3,100→4,001→5,default→6.

To find

Output interface for each destination.

Formula and why

Among matching prefixes choose the one with the most bits; use default only when none match.

The leading bits must match from the first bit; a substring appearing later does not count.

Solution

Step 1. Compare each destination from the left

DestinationMatching prefixesLongestInterface
001111010010015
0101010101 (but not011)011
11001001NoneDefault6

Step 2. Write final order

5, 1, 6.