Recall warm-up
- What is the prefix length (number of 1s) of the subnet mask 255.255.248.0?
Stuck? Peek at 3.1.3 Subnet masks, subnetting, network/broadcast & usable hosts
- Borrow s bits from host field, leaving h bits → 2ˢ subnets, each with 2ʰ − 2 usable hosts.
- Subnet address =
IP AND Mask; Broadcast = host bits all1s. - Stride Δ = 256 − Mask octet: blocks start at
0, Δ, 2Δ, …and end atΔ−1, 2Δ−1, …. - Valid mask octets: 128, 192, 224, 240, 248, 252, 254, 255.
- Why did Class B allocations exhaust the IPv4 address space so quickly?
Stuck? Peek at 3.1.2 Classful addressing (A–E) and special IPv4 addresses
- Classes by 1st octet: A = 0–127 (
0, 8 net bits), B = 128–191 (10, 16 net bits), C = 192–223 (110, 24 net bits), D = 224–239 (1110, multicast), E = 240–255 (1111, reserved). - Usable hosts = 2ʰ − 2 (exclude host all-0s = network address, host all-1s = directed broadcast).
- Specials:
0.0.0.0= this host (src only);255.255.255.255= limited broadcast (local LAN only);127.x.y.z= loopback.
- Classes by 1st octet: A = 0–127 (
- What is log₂(2048)?
Stuck? Peek at 0.2.4 Exponents, logarithms and basic probability
- 2ᵃ·2ᵇ = 2ᵃ⁺ᵇ; 2¹⁰ ≈ 10³ (estimates only).
- log₂ x = power of 2 giving x; bits for N values = ⌈log₂ N⌉.
- P(none) = (1−p)ⁿ · P(≥ 1) = 1 − (1−p)ⁿ · P(exactly 1) = n·p·(1−p)ⁿ⁻¹.
- (1 − 1/n)ⁿ → 1/e ≈ 0.368; 1/(2e) ≈ 0.184.
- 1 + 2 + … + 2ᵏ⁻¹ = 2ᵏ − 1; expected tries = 1/p.
The Hook
By 1993 the Internet faced two disasters at once: Class B blocks were nearly exhausted, and core routers were drowning in tens of thousands of individual Class C entries. The rescue was Classless Inter-Domain Routing (CIDR).
CIDR abolishes Classes A, B, and C completely. The network boundary can sit at any bit position from 0 to 32, written simply as a slash notation /n at the end of the address — and contiguous blocks can be glued together into a single router entry!
Predict First
Can you form a valid 1024-address CIDR block (/22, which spans four 256-address octets) starting at 192.168.2.0 (covering .2.0 through .5.255)?
No! In a /22 block, the last 10 bits are host bits, and in the network address all 10 host bits must be 0. That means the 3rd octet must end in 00₂ — so it must be a multiple of 4 (.0.0, .4.0, .8.0, .12.0, …). Starting at .2.0 violates the alignment rule!
Core Concept
Slash Notation (/n) & Block Size
In CIDR, an address block is written as a.b.c.d/n, where prefix length n is the number of leftmost network bits (1s in the mask), and h = 32 − n is the number of host bits.
- All addresses in the block are contiguous.
- Block size rule: The number of addresses in the block is a power of 2: N = 2³²⁻ⁿ = 2ʰ.
- Alignment (divisibility) rule: The first address (network address) as a 32-bit integer must be evenly divisible by N = 2ʰ (equivalently, its rightmost h bits are all
0).
Supernetting & Route Aggregation (Summarisation)
Just as subnetting splits one block into smaller blocks by increasing n, supernetting (route aggregation) combines 2ᵏ contiguous, aligned blocks of size /n into a single block of size /(n − k).
1. K must be a power of 2 (K = 2ᵏ).
2. The blocks must be contiguous (no missing block in the range).
3. The lowest block's starting address must be aligned to
/(n − k) (its last 32 − n + k bits are all 0).Finding the smallest enclosing supernet in binary
When asked for the single CIDR prefix that covers a list of addresses or blocks, write the varying octet in binary from the lowest address to the highest address and count how many leading bits stay identical:
| Block | 3rd Octet in Binary | Observation |
|---|---|---|
| 200.1.0.0/24 | 000000 00 | First 6 bits of 3rd octet are 000000 |
| 200.1.1.0/24 | 000000 01 | Last 2 bits of 3rd octet vary (00..11) |
| 200.1.2.0/24 | 000000 10 | Common prefix = 8 + 8 + 6 = 22 bits |
| 200.1.3.0/24 | 000000 11 | Aggregated CIDR = 200.1.0.0/22 |
Putting it together
- CIDR replaces fixed classes with arbitrary prefix lengths /n, giving block size 2³²⁻ⁿ.
- Every CIDR block must start at an address whose rightmost 32−n bits are zero (the alignment rule).
- Route aggregation merges 2ᵏ aligned contiguous /n blocks into a single /(n−k) prefix, shrinking router tables.
Visual
Worked Examples
For the CIDR block 200.10.16.0/21, find the total number of addresses, the first address, and the last (broadcast) address.
Show the full solution
Host bits h = 32 − 21 = 11 → Block size = 2¹¹ = 2048 addresses (which is 8 × 256, so 8 contiguous 3rd-octet values).
First address = 200.10.16.0.
Last address = 200.10.(16 + 8 − 1).255 = 200.10.23.255.
An organisation needs at least 1000 addresses. Which of the following is a valid CIDR block of minimal size for them? (A) 192.168.10.0/22 (B) 192.168.12.0/22 (C) 192.168.12.0/21
Show the full solution
Smallest power of 2 ≥ 1000 is 2¹⁰ = 1024 → h = 10 → prefix /22 (spans 4 values in the 3rd octet).
Alignment rule: the 3rd octet must be divisible by 4. 10 is NOT divisible by 4, while 12 IS divisible by 4! Answer: (B) 192.168.12.0/22.
An ISP owns four /24 blocks: 200.1.1.0/24, 200.1.2.0/24, 200.1.3.0/24, and 200.1.4.0/24. Can they be aggregated into a single /22 prefix without including any extra addresses?
Show the full solution
No! Even though there are 4 contiguous /24 blocks, a /22 block in the 3rd octet must start at a multiple of 4 (.0 or .4). Here .1, .2, .3 belong to 200.1.0.0/22 while .4 belongs to 200.1.4.0/22. The minimal exact advertisement is two blocks: 200.1.1.0/24, 200.1.2.0/23 (merging .2 and .3), and 200.1.4.0/24 (3 prefixes total)!
GATE Traps
- 4 contiguous blocks ≠ always 1 supernet! Always check that the starting octet is divisible by the number of /24s being merged (e.g.,
.1, .2, .3, .4cannot form a single/22). - "Exact aggregation" vs "Smallest single covering prefix": If a question asks for ONE prefix that covers
.1.0/24through.4.0/24(even if extra addresses are included), find the first bit where00000001₂(1) and00000100₂(4) differ (the 4s bit) →200.1.0.0/21. - Don't forget: a
/nblock still loses 2 addresses (first = network, last = directed broadcast) if used as a single LAN, so usable hosts = 2³²⁻ⁿ − 2.
Memory Hook
Size 2ʰ must start at a multiple of 2ʰ — you can't park a 4-slot bus starting at slot #1!
Connect the Dots
With CIDR and route aggregation, a router might have both a broad summary route like 200.1.0.0/16 AND a specific exception route like 200.1.2.0/24 in its table. Next question (3.1.5): When a packet matches BOTH entries, which one does the router choose?
Self-Test
- NAT
How many total IPv4 addresses are contained in a /19 CIDR block?
Write your answer before opening the key.
- MCQ
Which of the following is a VALID CIDR block (satisfies the alignment rule)?
- 192.168.6.0/22
- 192.168.8.0/21
- 192.168.4.0/21
- 192.168.18.0/20
- MCQ
Four contiguous blocks 198.16.0.0/24, 198.16.1.0/24, 198.16.2.0/24, and 198.16.3.0/24 are aggregated into a single CIDR block. What is the aggregated prefix?
- 198.16.0.0/20
- 198.16.0.0/21
- 198.16.0.0/22
- 198.16.0.0/26
- NAT
What is the minimum number of CIDR prefixes needed to represent the exact set of addresses in the three blocks 10.0.1.0/24, 10.0.2.0/24, and 10.0.3.0/24?
Write your answer before opening the key.
- MSQ
Which of the following statements about the CIDR block 172.16.32.0/20 are TRUE?
- Its subnet mask is 255.255.240.0.
- Its last address is 172.16.47.255.
- It contains 4096 total addresses.
- It contains the address 172.16.48.1.
Rule Card
- CIDR
a.b.c.d/n: n prefix bits, h = 32 − n host bits, block size N = 2ʰ. - Alignment rule: first address must be divisible by 2ʰ (for
/(24−k), 3rd octet must be divisible by 2ᵏ). - Supernetting: 2ᵏ contiguous, aligned
/nblocks merge into one/(n − k)block.
Concept Ledger
- CIDR
- slash notation /n
- prefix
- prefix length
- block size 2³²⁻ⁿ
- alignment rule
- supernetting
- route aggregation (summarisation)
Answer Vault
Try the questions first. Open when you are ready to check.
Warm-up answers
- 8 + 8 + 5 + 0 = 21 ones.
- Any organisation needing more than 254 hosts (Class C) was given a Class B block of 65,534 hosts, leaving >90% unused.
- 11 (since 2¹¹ = 2048).
Self-test answers
- 8192 — Host bits h = 32 − 19 = 13 → 2¹³ = 8192 addresses.
- B — For /21 (24 − 3), the 3rd octet must be a multiple of 2³ = 8. In 192.168.8.0/21, 8 is a multiple of 8.
- A: /22 requires a multiple of 4; 6 is not divisible by 4.
- C: /21 requires a multiple of 8; 4 is not divisible by 8.
- D: /20 requires a multiple of 16; 18 is not divisible by 16.
- C — Merging 4 = 2² aligned blocks of /24 reduces the prefix length by 2: /24 → /22 (198.16.0.0/22).
- A: /20 would be 16 blocks of /24.
- B: /21 would be 8 blocks of /24.
- D: /26 is subnetting (smaller), not supernetting.
- 2 — 10.0.2.0/24 and 10.0.3.0/24 merge into 10.0.2.0/23 (since 2 is even), while 10.0.1.0/24 remains separate. Total = 2 prefixes.
- ABC — /20 has 12 host bits → 2¹² = 4096 addresses (16 values in the 3rd octet: 32..47). Mask is 255.255.240.0, last address is 172.16.47.255.
- D: 172.16.48.1 belongs to the next /20 block (172.16.48.0/20).
Flashcards
- What are the 3 rules for a valid CIDR block /n?
Reveal answer
1. Contiguous addresses; 2. Size is 2³²⁻ⁿ; 3. Starting address is divisible by 2³²⁻ⁿ (last 32−n bits are 0). - When can 2ᵏ blocks of /n be aggregated into a single /(n−k) block?
Reveal answer
When they are contiguous AND the first block starts at an address aligned to /(n−k). - How many /24 blocks are inside a /20 block, and what is the 3rd-octet stride?
Reveal answer
2²⁴⁻²⁰ = 16 blocks of /24; 3rd-octet stride is 16.
Exam shortcuts
- 3rd-octet alignment check for /16../24: For prefix
/(24 − k), the 3rd octet must be a multiple of 2ᵏ (and 4th octet = 0). — checking CIDR alignment in 3 seconds on GATE. - Pairwise merge rule: Two blocks
X/nandY/nmerge intoX/(n−1)iffXis an even multiple of 2³²⁻ⁿ andYis the very next multiple. — simplifying a list of prefixes into the minimum number of routing entries.