IP Addressing (CIDR)

GATE CS previous year questions · 4 questions

GATE CS 2025 Set 1 | Question 40

MCQ · 2 marks · −0.66

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?

Subnet AddressSubnet Mask (in CIDR notation)Interface
145.36.0.0/16E1
145.36.128.0/17E2
145.36.64.0/18E3
145.36.255.0/24E4
Default--E5
Options for GATE CS 2025 Set 1 | Question 40

Explanation

Answer: (A)

A router uses longest prefix match: among the entries that match the destination, the one with the longest mask wins. The first two octets (145.36) agree with every listed subnet, so only the third octet matters: \(109 = 01101101_2\).

  • /16 (145.36.0.0): matches.
  • /17 (145.36.128.0): needs the third octet to begin with bit 1 (128 to 255); 109 begins with 0, so no match.
  • /18 (145.36.64.0): needs the third octet to begin with 01 (64 to 127); 109 does, so it matches.
  • /24 (145.36.255.0): needs the third octet to be 255, so no match.

Of the matches (/16, /18 and the default route), /18 is the longest, so the packet is sent on E3.

Answer: A

GATE CS 2024 Set 1 | Question 31

MSQ · 1 mark

Which of the following fields is/are modified in the IP header of a packet going out of a network address translation (NAT) device from an internal network to an external network?

Options for GATE CS 2024 Set 1 | Question 31

Explanation

Answer: (A), (C)

A NAT device lets hosts with private addresses share a public address. For a packet leaving the internal network it replaces the private source address with its own public address (with port translation it also changes the source port, but that is in the TCP or UDP header) and records the mapping so that replies can be sent back.

  • Source IP: modified, as described.
  • Destination IP: unchanged, because the packet still goes to the same external host.
  • Header Checksum: modified. It covers the whole IP header, so it must be recomputed once the source address changes.
  • Total Length: unchanged, because the sizes of the header and the data stay the same.

Answer: A, C

GATE CS 2024 Set 1 | Question 58

NAT · 2 marks

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 _______

Explanation

Answer: 40

A router sends each packet by the longest prefix that matches its destination. In the last byte, 10.1.1.128/25 covers 128–255, 10.1.1.64/26 covers 64–127, 10.1.1.192/26 covers 192–255, and the /24 matches every 10.1.1.x address.

  • 10.1.1.16 matches only the /24: R1.
  • 10.1.1.72 matches the /24 and 10.1.1.64/26: R3.
  • 10.1.1.132 and 10.1.1.191 match the /24 and the /25 but not 10.1.1.192/26 (191 is just below 192): R2.
  • 10.1.1.205 matches the /24, the /25 and 10.1.1.192/26; the /26 is the longest: R4.

Two hosts are reached via R2, so \(2 \times 20 = 40\) packets go through it.

Answer: 40

GATE CS 2024 Set 2 | Question 38

MCQ · 2 marks · −0.66

Which one of the following CIDR prefixes exactly represents the range of IP addresses 10.12.2.0 to 10.12.3.255?

Options for GATE CS 2024 Set 2 | Question 38

Explanation

Answer: (A)

The range holds \(2 \times 256 = 512 = 2^{9}\) addresses, so the block needs 9 host bits: a /23 prefix. In the third octet, 2 is 00000010 and 3 is 00000011, so only its last bit varies, and 10.12.2.0 has all 9 host bits zero. So 10.12.2.0/23 covers exactly 10.12.2.0 to 10.12.3.255.

  • 10.12.2.0/24 covers only 10.12.2.0 to 10.12.2.255, half the range.
  • 10.12.0.0/22 covers 10.12.0.0 to 10.12.3.255, twice the range.
  • 10.12.2.0 does not start a /22 block; with a /22 mask it falls in the block 10.12.0.0 to 10.12.3.255, again too large.

Answer: A