IAE Academy

GATE 2022 CS Q.55: solution and answer

GATE 2022 · CSQ.55 · 2 marks · MSQ

Consider routing table of an organization's router shown below:

Which of the following prefixes in CIDR notation can be collectively used to correctly aggregate all of the subnets in the routing table?

  1. (A)

    12.20.164.0/20

  2. (B)

    12.20.164.0/22

  3. (C)

    12.20.164.0/21

  4. (D)

    12.20.168.0/22

See the question in the paper

Answer and solution

ANSWER

The correct options are B and D: 12.20.164.0/22 and 12.20.168.0/22 together cover exactly the third-octet values 164 to 171.

Official answer: B, DSource: Official answer key, GATE 2022 CS (IIT Kharagpur)

  1. Convert each mask to a prefix length. Mask 255.255.252.0 has third octet , so it is /22. Mask 255.255.254.0 has third octet , so it is /23.

  2. Find the third-octet range of each subnet. 12.20.164.0/22 covers 164 to 167. 12.20.170.0/23 covers 170 to 171. 12.20.168.0/23 covers 168 to 169. 12.20.166.0/23 covers 166 to 167.

  3. 12.20.166.0/23 lies inside 12.20.164.0/22, so it adds nothing new. The union of all the subnets is 12.20.164.0 to 12.20.171.255, that is third-octet values 164 to 171, eight values in all.

  4. A /22 block holds 4 third-octet values and starts at a multiple of 4. So 12.20.164.0/22 covers 164 to 167, and 12.20.168.0/22 covers 168 to 171 (168 is a multiple of 4, so the block is aligned).

  5. These two /22 prefixes together cover exactly 164 to 171, with nothing extra. So B and D, used together, aggregate all the subnets correctly.

  6. Check the others. 12.20.164.0/21 is the aligned block 12.20.160.0/21, which covers 160 to 167. It misses 168 to 171, and it also covers 160 to 163, which are not in the table. It is not correct.

  7. 12.20.164.0/20 is the aligned block 12.20.160.0/20, which covers 160 to 175. It includes every subnet, but it also covers 160 to 163 and 172 to 175, which are not in the table. Those addresses would be wrongly sent along this route instead of the default route R3. So it is not a correct aggregation.

KEY IDEA

Convert each mask to a prefix length, write each subnet as a range of third-octet values, and take the union (164 to 171). Choose the prefixes whose aligned blocks cover that union exactly, with no extra addresses.

WATCH OUT FOR

Picking the single prefix /20 because it contains all four subnets. It also covers 160 to 163 and 172 to 175, which are not in the table, so traffic for those addresses would be sent along this route instead of to the default route R3. Another slip is reading 12.20.164.0/21 as starting at 164, when the aligned /21 block starts at 160.

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

More IPv4 questions