GATE GUIDE

GATE CSE Subnetting Questions: CIDR, Masks and Forwarding

By MD ANISH AHAMADUpdated 28 Oct 202610 min read
GATE CSE Subnetting Questions: CIDR, Masks and Forwarding

Addressing questions in GATE CSE get solved like arithmetic, once you stop converting addresses to binary. A prefix length gives you a block size, a block size tells you where the boundaries fall, and everything else follows: the network address, the broadcast address, the host count, whether two machines can talk directly, and which forwarding-table entry wins. This guide gives the full method and the mistakes that cost marks.

In this guide
  1. Key takeaways
  2. What the 2027 syllabus covers
  3. Reading a prefix as a block size
  4. Network address, broadcast address, usable hosts
  5. The same-subnet test in one step
  6. Variable-length subnet masking
  7. Supernetting and aggregation
  8. Longest prefix match in a forwarding table
  9. The traps in one list
  10. How to practise

Key takeaways

What the 2027 syllabus covers

The clause that matters here is "IPv4 - Fragmentation, CIDR Notation". CIDR notation is the heading under which masks, network and broadcast addresses, host counts, subnetting into equal or unequal blocks, supernetting and forwarding-table lookup all sit. Routing appears separately as distance vector and link state. Classful addressing is not named in the 2027 text, although it is the backdrop for many older previous-year questions. The clause-by-clause comparison with 2026 is in the guide to what changed in the Computer Networks syllabus for 2027. Syllabus documents can be revised, so check the current official notification.

On weight: unofficial analyst compilations place Computer Networks at 6 to 11 marks per paper from 2009 to 2026, averaging about 8.2, with 8.3 across 2009 to 2017 and 8.0 across 2018 to 2026. The direction is flat. The recent high was 11 marks in 2022, and one analyst counted six Computer Networks questions in the 2026 second shift. Sources differ by 2 to 3 marks because borderline questions are classified differently. The subject ranking behind these numbers is in Computer Networks important topics.

Reading a prefix as a block size

Subtract the prefix from 32 and raise 2 to that power. A /26 has 32−26=632 - 26 = 6 host bits and a block of 26=642^6 = 64 addresses. A /22 has 32−22=1032 - 22 = 10 host bits and a block of 210=1,0242^{10} = 1{,}024. That single number drives everything else.

The mask is the same fact in another costume: nn ones followed by 32−n32 - n zeros. The only octet that ever matters is the one where the prefix boundary falls, and there the mask value is 256−block size256 - \text{block size}.

Prefix Mask Addresses in block Usable hosts Boundaries in the last octet
/24 255.255.255.0 256 254 0
/25 255.255.255.128 128 126 0, 128
/26 255.255.255.192 64 62 0, 64, 128, 192
/27 255.255.255.224 32 30 multiples of 32
/28 255.255.255.240 16 14 multiples of 16
/29 255.255.255.248 8 6 multiples of 8
/30 255.255.255.252 4 2 multiples of 4

When the prefix is shorter than 24 the same table shifts one octet left. A /22 is mask 255.255.252.0 with a block of 4 in the third octet, so the network addresses are 192.168.0.0, 192.168.4.0, 192.168.8.0 and so on. A /18 is mask 255.255.192.0, block 64 in the third octet. Move the block size into the correct octet and binary conversion becomes unnecessary for almost every question in this family.

Network address, broadcast address, usable hosts

Take 192.168.10.100/26. The block size is 64, so the boundaries in the last octet are 0, 64, 128 and 192. The value 100 falls in the 64 to 127 range. Therefore:

The general formula is:

usable hosts=232−n−2\text{usable hosts} = 2^{32-n} - 2

Two exceptions are worth carrying. A /31 holds two addresses and, on a point-to-point link, both are used as host addresses rather than as a network and broadcast pair, so it gives 2 usable. A /32 is a single host route and appears mainly inside forwarding tables. Unless a question sets up a point-to-point link explicitly, use the minus two form.

Running the other way is just as mechanical. If a department needs 300 hosts, you need at least 300+2=302300 + 2 = 302 addresses, the next power of two is 29=5122^9 = 512, so the prefix is 32−9=2332 - 9 = 23, a /23. Add 2 before rounding up, never after.

The same-subnet test in one step

Two hosts share a subnet if they have the same network address under the same mask, and you never need to compute both network addresses in full. Look at the octet where the prefix falls and compare the block index, which is the octet value divided by the block size, discarding the remainder:

block index=⌊octet valueblock size⌋\text{block index} = \left\lfloor \frac{\text{octet value}}{\text{block size}} \right\rfloor

Under a /26 mask, 192.168.10.100 and 192.168.10.130 give block indices ⌊100/64⌋=1\lfloor 100/64 \rfloor = 1 and ⌊130/64⌋=2\lfloor 130/64 \rfloor = 2, so they sit in different subnets and traffic between them must cross a router. Under a /24 mask the block size is 256 and both give index 0 (⌊100/256⌋=⌊130/256⌋=0\lfloor 100/256 \rfloor = \lfloor 130/256 \rfloor = 0), so they share a subnet. Same addresses, different answer, purely because of the mask. Questions in this family often hand you two addresses and ask which masks are valid.

Variable-length subnet masking

When departments need different host counts, cutting a block into equal parts wastes addresses. Variable-length subnet masking cuts a block into pieces of different sizes, and the working rule is to allocate the largest requirement first. If you place a small block at the start of the space, it sits on a boundary that a later, larger block also needs, and the allocation fails alignment.

Take 192.168.20.0/24 and requirements of 60, 28, 12 and 5 hosts.

Requirement Addresses needed Block Prefix Allocation
60 hosts 62 64 /26 192.168.20.0 to 192.168.20.63
28 hosts 30 32 /27 192.168.20.64 to 192.168.20.95
12 hosts 14 16 /28 192.168.20.96 to 192.168.20.111
5 hosts 7 8 /29 192.168.20.112 to 192.168.20.119

Every allocation starts on a multiple of its own block size, which is what makes it a legal CIDR block. Addresses 192.168.20.120 to 192.168.20.255 stay free. A common form of this question offers four allocations and asks which is valid, and the invalid ones usually fail on alignment rather than on the host arithmetic.

Supernetting and aggregation

Supernetting is the reverse operation: several blocks collapse into one advertised prefix. Three conditions must hold together. The blocks must be contiguous, their count must be a power of two, and the first block's address must be a multiple of the combined block size.

192.168.8.0/24, 192.168.9.0/24, 192.168.10.0/24 and 192.168.11.0/24 aggregate to 192.168.8.0/22. Four blocks, contiguous, and 8 is a multiple of 4.

Shift the same four blocks by one and they do not aggregate. 192.168.9.0/24 through 192.168.12.0/24 are still four contiguous /24s, but 9 is not a multiple of 4, so no single /22 covers exactly those four and nothing else. The alignment condition is the part candidates skip, and it is exactly what the question is testing.

Longest prefix match in a forwarding table

A router does not read its table top to bottom and stop at the first hit. It collects every entry whose prefix matches the destination and forwards using the longest one, because that is the most specific route. Row order carries no meaning.

Prefix Next hop
0.0.0.0/0 R0
10.0.0.0/8 R1
10.12.0.0/16 R2
10.12.64.0/18 R3
10.12.72.0/21 R4

The two prefixes that need care are /18, whose block is 64 in the third octet, covering 10.12.64.0 to 10.12.127.255, and /21, whose block is 8 in the third octet, covering 10.12.72.0 to 10.12.79.255.

That last line is the role of the default route. A /0 prefix matches every destination with the lowest possible specificity, so it is chosen only when the table offers nothing else.

The traps in one list

The cross-subject version of this list is in common mistakes that cost marks in GATE CSE, and the mask, block-size and host-count relations are condensed in the GATE CSE formula sheet.

How to practise

Build one worksheet and reuse it. Take a single /24 from a private range, write every prefix from /25 to /30 with its mask, block size and host count, and check that you can produce any column from any other in under ten seconds. Then pick random addresses inside that block and write their network and broadcast addresses without touching binary.

After that, drill the forwarding table. Write five overlapping prefixes with a default route, place the most specific entry in the middle of the list, and answer six destinations. When that stops needing thought, the two-mark version in the paper takes under ninety seconds. The Computer Networks chapter of the GATE CSE 2027 book extends this method with a graded question bank on fragmentation, address translation and forwarding, each worked step by step.

Frequently asked questions

How do you calculate the number of usable hosts in a subnet?

Subtract the prefix length pp from 32 to get the host bits. The block then holds 232−p2^{32-p} addresses. Remove the network address and the directed broadcast address, so usable hosts equal 232−p−22^{32-p} - 2. A /26 holds 64 addresses and 62 usable hosts, and a /30 holds 4 addresses and 2 usable hosts.

What is the smallest CIDR block for a given number of hosts?

Add 2 to the host requirement, then round up to the next power of two. For 1,000 hosts you need at least 1,002 addresses, so the block size is 1,024 and the prefix is /22. Check the alignment too, because the starting address of the block must itself be a multiple of the block size.

How does longest prefix match work in a forwarding table?

The router compares the destination against every entry, keeps the entries whose prefix matches, and forwards using the one with the largest prefix length. Table order is irrelevant, so a more specific entry listed last still wins. The default route 0.0.0.0/0 matches everything with prefix length zero, which means it is chosen only when no other entry matches.

Is subnetting still in the GATE 2027 CS syllabus?

Yes. The Computer Networks section lists IPv4 with fragmentation, CIDR notation and network address translation. CIDR notation covers masks, network and broadcast addresses, host counts, subnetting and supernetting, and forwarding-table lookup. Routing appears separately as distance vector and link state. Confirm the wording against the current official syllabus PDF before you plan around it.

Why do /31 and /32 prefixes not follow the minus two rule?

A /31 holds only two addresses, so subtracting a network and a broadcast address would leave none. On point-to-point links both addresses are used as host addresses, giving two usable. A /32 is a single address used as a host route, common in forwarding-table questions. GATE questions on ordinary LAN subnets still expect the minus two form.

How much is Computer Networks worth in GATE CSE?

Unofficial analyst compilations put Computer Networks between 6 and 11 marks per paper from 2009 to 2026, with an average near 8.2 and a recent high of 11 in 2022. Sources disagree by 2 to 3 marks because borderline questions are classified differently. Addressing and forwarding items are a recurring part of that block.

Sources

Dates, fees and the syllabus are set by the GATE 2027 organising institute and can change. Always confirm at gate2027.iitm.ac.in.

Keep reading

GATE CSE 2027 book1,020 pages · ₹250 ₹300
Buy now — ₹250