Question

Consider the entries shown below in the forwarding table of an IP router. Each entry consists of an IP prefix and the corresponding next hop router for packets whose destination IP address matches the prefix. The notation "/N" in a prefix indicates a subnet mask with the most significant N bits set to 1.

PrefixNext hop router
10.1.1.0/24R1
10.1.1.128/25R2
10.1.1.64/26R3
10.1.1.192/26R4

This router forwards 20 packets each to 5 hosts. The IP addresses of the hosts are 10.1.1.16, 10.1.1.72, 10.1.1.132, 10.1.1.191, and 10.1.1.205 . The number of packets forwarded via the next hop router R2 is _______

Official answer and solution
Official answer
40
From
Official GATE 2024 answer key

Solution

Convert each prefix into its 4th-octet address range and apply Longest Prefix Matching (LPM) to each of the 5 destination IP addresses.

All prefixes begin with 10.1.1., so we can express each prefix by the range of its 4th octet:

  • 10.1.1.0/24: 0 to 2550 \text{ to } 255 (prefix length 24) →\rightarrow R1
  • 10.1.1.128/25: 128 to 255128 \text{ to } 255 (prefix length 25) →\rightarrow R2
  • 10.1.1.64/26: 64 to 12764 \text{ to } 127 (prefix length 26) →\rightarrow R3
  • 10.1.1.192/26: 192 to 255192 \text{ to } 255 (prefix length 26) →\rightarrow R4

Applying Longest Prefix Match (LPM) to the 5 hosts (20 packets each):

  1. 10.1.1.16: matches only /24 →\rightarrow R1
  2. 10.1.1.72: matches /24 and 10.1.1.64/26 →\rightarrow longest is /26 →\rightarrow R3
  3. 10.1.1.132: matches /24 and 10.1.1.128/25 →\rightarrow longest is /25 →\rightarrow R2 (20 packets)
  4. 10.1.1.191: matches /24 and 10.1.1.128/25 →\rightarrow longest is /25 →\rightarrow R2 (20 packets)
  5. 10.1.1.205: matches /24, 10.1.1.128/25, and 10.1.1.192/26 →\rightarrow longest is /26 →\rightarrow R4

Total packets forwarded via R2 =20+20=40= 20 + 20 = 40.

Final answer

40

Common trap

Routing 10.1.1.205 to R2 by overlooking the longer /26 prefix 10.1.1.192/26 (which would give 60).

The answer is the one in the official GATE answer key. The solution is this site's own explanation.

Source

Paper
GATE 2024 Computer Science and Information Technology - Set 1 (CS1)
Question
58 of 65
Section
Computer Science and Information Technology

Report an error in this question

GATE questions are the work of the organising institutes. This site is independent and is not affiliated with them.