IAE Academy

GATE 2025 CS1 Q.40: solution and answer

GATE 2025 · CS1Q.40 · 2 marks · MCQ

A packet with the destination IP address 145.36.109.70 arrives at a router whose routing table is shown. Which interface will the packet be forwarded to?

GATE 2025 CS1 question 40: A routing table with columns Subnet Address, Subnet Mask (in CIDR notation), Interface.Tap to open full size
Figure from the GATE 2025 CS1 paper. It is part of the question.
Figure description

A routing table with columns Subnet Address, Subnet Mask (in CIDR notation), Interface. Rows: 145.36.0.0 /16 E1; 145.36.128.0 /17 E2; 145.36.64.0 /18 E3; 145.36.255.0 /24 E4; Default -- E5.

  1. (A)

    E3

  2. (B)

    E1

  3. (C)

    E2

  4. (D)

    E5

Answer and solution

ANSWER

The packet is forwarded to interface E3, option (A).

Official answer: ASource: Official answer key, GATE 2025 CS1 (IIT Roorkee)

  1. A router forwards by longest-prefix match: find every entry whose prefix matches the destination, then take the match with the longest mask. If nothing else matches, the default route applies.

  2. All four non-default entries begin with 145.36, which is also the first two octets of the destination 145.36.109.70. Only the third octet separates them. The destination's third octet is .

  3. Why the /18 range is 64 to 127: the first 18 bits are the 16 bits of 145.36 plus the top 2 bits of the third octet. The entry's third octet is , so its top two bits are . The remaining 6 bits are free, giving to , which is 64 to 127. Since also starts with , it matches.

  4. Likewise /17 needs the top bit of the third octet to be 1 (128 to 255), but starts with 0, so it does not match. /24 needs the third octet to equal 255, so it does not match either.

  5. The matching entries are /16 (E1), /18 (E3) and the default (/0, E5). The longest prefix is /18, so the packet is forwarded to E3, which is option (A).

KEY IDEA

Use longest-prefix match: list every entry whose prefix covers the destination, then choose the one with the longest mask. Here only the third octet decides, and /18 covers third octets 64 to 127.

WATCH OUT FOR

Picking the first matching row (/16, E1) instead of the most specific one, or forgetting that a /18 starting at 64 stops at 127 and so does cover 109.

From the GATE 2025 CS1 paper. Every question of this paper · Download the full paper · All 20 IPv4 questions, with notes

More IPv4 questions