GATE / CS ARCHIVE

SIMILAR QUESTIONS / COMPUTER NETWORKS

Compare network addresses under masks

4 questions solved the same way, newest first. Back to Computer Networks

How these are solved

Apply each stated subnet mask bitwise to each address and compare network results. Preserve noncontiguous masks and unequal-mask variants rather than assuming a shared CIDR prefix.

2 marks · MCQ
Report issue

Subnet comparison using a /30 mask

IP Addressing, Fragmentation & Address Resolution

Question 28, GATE 2019: Machines M, N, P have IPv4 addresses 100.10.5.2, 100.10.5.5, 100.10.5.6 and all use mask 255.255.255.252. Are all in one subnet (A), only M/N together (B), only N/P together (C), or all in different subnets (D)?
Tap to enlarge
Your answer
Answer & solution

Official answer: C

Step through it (5 steps)

1. Two IPv4 interfaces are in the same subnet when bitwise AND of each address with the subnet mask yields the same network address. The first three octets are identical here, so only the last octet needs calculation.
2. The last mask octet 252 is binary 11111100. Thus the two low bits are host bits and each subnet spans four consecutive addresses, starting at multiples of four.
3. M has last octet 2=00000010; AND with 11111100 gives 0. Its network is 100.10.5.0/30, covering last octets 0 through 3.
4. N has 5=00000101 and P has 6=00000110. Masking either gives 4=00000100. Both belong to 100.10.5.4/30, covering 4 through 7.
5. Only N and P share a subnet, so C is correct. Comparing the first three octets alone would incorrectly assume a /24 mask; the supplied /30 mask is decisive.

Original paper, page 10 · Answer key

2 marks · MCQ
Report issue

Netmask separating two IPv4 hosts

IP Addressing, Fragmentation & Address Resolution

Question 47, GATE 2010: Hosts A and B have IP addresses 10.105.1.113 and 10.105.1.91, with a common netmask N. Which mask must not be used if they are to belong to the same network?
Options: (A) 255.255.255.0; (B) 255.255.255.128; (C) 255.255.255.192; (D) 255.255.255.224.
Tap to enlarge
Your answer
Answer & solution

Answer: D (no official key was published)

Step through it (6 steps)

The last octets are 113=01110001₂ and 91=01011011₂. A /24 mask gives the same network. A /25 mask (128) gives last-octet network 0 for both; a /26 mask (192) gives 64 for both. A /27 mask (224) gives 96 for 113 and 64 for 91, placing the hosts in different subnets. Therefore 255.255.255.224 must not be used, option D.

Network membership is determined by bitwise AND of address and mask. Since the first three octets agree, only the final octet matters. /26 partitions that octet into ranges 0–63,64–127,128–191,192–255, so both hosts are in 64–127. /27 splits it further into 64–95 and 96–127, separating 91 from 113.

Original paper, page 11

2 marks · MCQ
Report issue

Hosts with unequal subnet masks

IP Addressing, Fragmentation & Address Resolution

Question 45, GATE 2006: C1 has IP address 203.197.2.53 and mask 255.255.128.0. C2 has 203.197.75.201 and mask 255.255.192.0. What does each infer about the other’s network?
Options:
(A) Both consider the other local
(B) C2 considers C1 local, but C1 considers C2 remote
(C) C1 considers C2 local, but C2 considers C1 remote
(D) Both consider the other remote
Tap to enlarge
Your answer
Answer & solution

Answer: C (no official key was published)

Step through it (4 steps)

1. C1 uses /17, so both 203.197.2.53 and 203.197.75.201 map to 203.197.0.0. C2 uses /18, mapping itself to 203.197.64.0 and C1 to 203.197.0.0.

2. Therefore C1 treats C2 as local while C2 treats C1 as remote: C.

3. Teaching check: Each machine applies its own mask to both addresses. C1’s /17 groups third octets 0–127; C2’s /18 separates 0–63 from 64–127. Because the masks differ, being “on the same subnet” need not be a symmetric belief between these misconfigured hosts.

Original paper, page 6

2 marks · MCQ
Report issue

Subnet equality under a noncontiguous mask

IP Addressing, Fragmentation & Address Resolution

Question 82, GATE 2003: A network uses the printed subnet mask 255.255.31.0. Which pair of addresses could belong to that network?
A. 172.57.88.62 and 172.56.87.233
B. 10.35.28.2 and 10.35.29.4
C. 191.203.31.87 and 191.234.31.88 [GFG; GateForum prints 191.03.31.87 as the first address.]
D. 128.8.129.43 and 128.8.161.55
The printed mask is noncontiguous; apply its literal bitwise AND, not an assumed CIDR repair.
Question 82, GATE 2003: A network uses the printed subnet mask 255.255.31.0. Which pair of addresses could belong to that network?
A. 172.57.88.62 and 172.56.87.233
B. 10.35.28.2 and 10.35.29.4
C. 191.203.31.87 and 191.234.31.88 [GFG; GateForum prints 191.03.31.87 as the first address.]
D. 128.8.129.43 and 128.8.161.55
The printed mask is noncontiguous; apply its literal bitwise AND, not an assumed CIDR repair.
Tap to enlarge
Your answer
Answer & solution

Answer: D (no official key was published)

1. Membership under the printed mask requires address 1 AND mask = address 2 AND mask. Its first two 255 octets preserve both first octets, while the final zero octet discards the host's last octet.
2. A fails because 57≠56 in octet two; C fails because 203≠234. B's first two octets match, but 28 AND 31=28 and 29 AND 31=29, so it fails too.
3. For D, 129=10000001₂ and 161=10100001₂. AND with 31=00011111₂ gives 00000001₂ for both. Both network values are 128.8.1.0.
4. Thus the literal calculation selects D. Because 00011111 is not a contiguous prefix-mask octet, this is not a valid ordinary CIDR mask; that caveat must remain explicit.

Solution: Compare the bitwise AND of each address with the printed mask. Options A and C have unequal second octets, which are fully retained. Option B retains third octets 28 and 29 under AND 31, so they differ. For D, 129 AND 31=1 and 161 AND 31=1; both addresses therefore map to 128.8.1.0. The raw mask calculation gives D. The printed 31 octet is 00011111, so this is a noncontiguous mask and cannot be expressed as a standard CIDR prefix; it must not be silently changed to 224 or another contiguous-mask octet.

Original paper, page 12