Recall warm-up
- What are the network address and directed broadcast address of Class C network 195.1.1.0?
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 the result of bitwise AND between 11001010 and 11110000?
Stuck? Peek at 0.2.3 XOR, 1's complement addition and modulo-2 division
- AND (mask), OR, NOT (flip), XOR (1 where bits differ).
- a ⊕ a = 0, a ⊕ 0 = a, (a ⊕ k) ⊕ k = a.
- 1's complement = flip all bits; 1's-complement addition wraps the end carry back in.
- Modulo-2: + = − = XOR, no carries; bits ↔ polynomial.
- Mod-2 division: leading 1 → XOR divisor; leading 0 → XOR zeros; remainder = (divisor length − 1) bits.
- Does a router separate broadcast domains?
Stuck? Peek at 2.4.2 Ethernet efficiency; switched vs shared Ethernet
- Shared Ethernet efficiency η = 1/(1 + 5a) (course default); variants 1/(1 + 5.44a), 1/(1 + 6.44a).
- Switched full-duplex: no collisions, no CSMA/CD, full rate per link.
- Collision domains: hub = 1; switch/router = 1 per interface.
- Broadcast domains: only routers split them.
The Hook
Suppose a university gets one Class B block (150.100.0.0, 65,534 hosts), but has 30 departments in different buildings. Putting all 65,534 computers into one giant broadcast domain would drown the campus in broadcast traffic!
Subnetting solves this: the campus borrows a few bits from the host part to create a subnet-id. To the outside world it is still one network 150.100.0.0, but inside the campus, a 32-bit subnet mask tells local routers how many bits belong to the network + subnet.
Predict First
If you borrow 2 bits from an 8-bit Class C host field to identify subnets, how many subnets do you get, and how many host bits are left in each subnet?
,With 2 borrowed bits you get 2² = 4 subnets (00, 01, 10, 11), and each subnet has 8 − 2 = 6 host bits, giving 2⁶ − 2 = 62 usable hosts per subnet.
Core Concept
Three-level hierarchy & Borrowed Bits
Subnetting splits the original host part into two pieces: s borrowed subnet bits followed by h remaining host bits.
- Number of subnets = 2ˢ (where s is the number of bits borrowed from the host field).
- Addresses per subnet = 2ʰ, and usable hosts per subnet = 2ʰ − 2 (each subnet loses its own all-0s subnet address and all-1s subnet broadcast address!).
The Subnet Mask & Bitwise AND
How does a router know how many bits are network+subnet vs host? Every subnet has a 32-bit subnet mask consisting of contiguous 1s (for network + subnet bits) followed by contiguous 0s (for host bits).
Subnet Network Address = (IPv4 Address) BITWISE-AND (Subnet Mask)Finding the subnet broadcast address: Set all host bits (where mask has
0s) to 1.| Item | Dotted Decimal | Last Octet in Binary | Role |
|---|---|---|---|
| Host IP | 200.10.20.150 | 10010110 (150) | Host inside the 3rd subnet |
| Subnet Mask | 255.255.255.192 | 11000000 (192) | 26 ones (s=2 borrowed), 6 zeros (h=6) |
| IP AND Mask | 200.10.20.128 | 10000000 (128) | Subnet Network Address (host bits → 0) |
| Host bits → 1 | 200.10.20.191 | 10111111 (191) | Subnet Broadcast Address (128 + 63 = 191) |
The Magic-Number (Block-Stride) Method
You don't even need binary on exam day! In the octet where the mask is neither 255 nor 0 (the "interesting octet"), subtract the mask value from 256:
Subnets in that octet start at multiples of Δ:
0, Δ, 2Δ, 3Δ, …. The broadcast address of each subnet is (next multiple of Δ) − 1.Putting it together
- Subnetting borrows s host bits to create 2ˢ subnets, each with 2ʰ − 2 usable hosts.
- A subnet mask has contiguous leading 1s and trailing 0s; IP BITWISE-AND Mask gives the subnet network address.
- The magic stride Δ = 256 − (mask octet) lets you write down every subnet start and broadcast address by simple multiples of Δ.
Visual
| # of 1s in octet | Binary | Mask Octet | Stride Δ = 256 − Mask | Host bits left in octet |
|---|---|---|---|---|
| 1 | 10000000 | 128 | 128 | 7 |
| 2 | 11000000 | 192 | 64 | 6 |
| 3 | 11100000 | 224 | 32 | 5 |
| 4 | 11110000 | 240 | 16 | 4 |
| 5 | 11111000 | 248 | 8 | 3 |
| 6 | 11111100 | 252 | 4 | 2 |
| 7 | 11111110 | 254 | 2 | 1 |
| 8 | 11111111 | 255 | 1 | 0 |
Worked Examples
A Class C network 192.168.5.0 uses subnet mask 255.255.255.192. Find (a) borrowed bits s, (b) number of subnets, (c) usable hosts per subnet.
Show the full solution
192 = 11000000₂ → (a) s = 2 borrowed bits, leaving h = 6 host bits.
(b) Subnets = 2² = 4.
(c) Usable hosts per subnet = 2⁶ − 2 = 64 − 2 = 62.
For host IP 200.10.20.150 with subnet mask 255.255.255.192, find its subnet network address, directed broadcast address, first usable host, and last usable host.
Show the full solution
Stride Δ = 256 − 192 = 64. Multiples of 64 are 0, 64, 128, 192. Since 128 ≤ 150 < 192:
Subnet network address = 200.10.20.128.
Subnet broadcast address = 192 − 1 → 200.10.20.191.
First usable host = 200.10.20.129; Last usable host = 200.10.20.190.
A Class B network 172.16.0.0 is subnetted with mask 255.255.248.0. How many subnets are created, how many usable hosts exist per subnet, and do 172.16.21.5 and 172.16.25.5 belong to the same subnet?
Show the full solution
In the 3rd octet, 248 = 256 − 8 = 11111000₂ → s = 5 borrowed bits. Total host bits left = 3 (in 3rd octet) + 8 (in 4th octet) = 11 bits.
Subnets = 2⁵ = 32. Usable hosts per subnet = 2¹¹ − 2 = 2048 − 2 = 2046.
Stride in 3rd octet Δ = 256 − 248 = 8. Multiples of 8 are 0, 8, 16, 24, 32:
• 172.16.21.5 lies in block 16..23 (subnet 172.16.16.0).
• 172.16.25.5 lies in block 24..31 (subnet 172.16.24.0).
They are in different subnets!
GATE Traps
- Non-contiguous 1s: A subnet mask like
255.255.255.160(10100000₂) is INVALID under standard subnetting because the 1s are not contiguous. - Class B two-octet host trap: With mask
255.255.248.0, the broadcast address of subnet172.16.16.0is172.16.23.255(NOT172.16.16.255!), because all 11 host bits across both octets 3 and 4 become 1! - Same-subnet test: Host A sends directly to Host B only if
(IP_A & Mask_A) === (IP_B & Mask_A); otherwise A sends the frame to its default router.
Memory Hook
Stride Δ = 256 − Mask. Floor to a multiple of Δ for the network; stop 1 short of the next multiple for broadcast!
Connect the Dots
Subnetting let us divide a big classful block into smaller pieces using a mask of contiguous 1s. Next question (3.1.4): Why keep Classes A, B, and C at all? What if we throw away classes completely and just write the number of 1s in the mask after a slash, like /26?
Self-Test
- NAT
A Class C network is subnetted using mask 255.255.255.224. How many usable hosts per subnet are available?
Write your answer before opening the key.
- MCQ
What is the directed broadcast address of the subnet containing host 192.168.10.75 with subnet mask 255.255.255.240?
- 192.168.10.79
- 192.168.10.95
- 192.168.10.64
- 192.168.10.255
- NAT
An organisation has a Class B network and needs at least 50 subnets. What is the maximum number of usable hosts per subnet it can achieve?
Write your answer before opening the key.
- MSQ
With subnet mask 255.255.255.192, which of the following IPv4 addresses CANNOT be assigned to a host interface?
- 192.168.1.63
- 192.168.1.64
- 192.168.1.65
- 192.168.1.128
- MCQ
Which of the following is NOT a valid contiguous subnet mask?
- 255.255.255.248
- 255.255.252.0
- 255.255.255.200
- 255.254.0.0
Rule Card
- 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.
Concept Ledger
- subnet mask
- mask AND address
- subnetting
- subnet id
- borrowed bits
- number of subnets 2ˢ
- usable hosts 2ʰ − 2
- subnet network/broadcast address
Answer Vault
Try the questions first. Open when you are ready to check.
Warm-up answers
- Network: 195.1.1.0; Directed broadcast: 195.1.1.255.
- 11000000 (AND with 1 keeps the bit; AND with 0 clears the bit to 0).
- Yes — each interface of a router connects to a separate broadcast domain (a separate LAN/subnet).
Self-test answers
- 30 — 224 = 11100000₂ → 3 ones, 5 zeros (h = 5). Usable hosts = 2⁵ − 2 = 32 − 2 = 30.
- A — Stride Δ = 256 − 240 = 16. Multiples of 16: 0, 16, 32, 48, 64, 80. 75 is in 64..79 → subnet = .64, broadcast = 192.168.10.79.
- B: 95 is the broadcast of the next block (80..95).
- C: 64 is the subnet network address, not the broadcast address.
- D: .255 is the unsubnetted Class C broadcast.
- 1022 — To get ≥ 50 subnets, borrow s bits with 2ˢ ≥ 50 → minimum s = 6 bits (2⁶ = 64 subnets). Remaining host bits h = 16 − 6 = 10 → usable hosts = 2¹⁰ − 2 = 1022.
- ABD — Stride Δ = 64. Subnets start at .0, .64, .128, .192 (network addresses) and end at .63, .127, .191, .255 (broadcast addresses). Only .65 is a usable host.
- C: .65 is the first usable host of the .64 subnet.
- C — 200 = 128 + 64 + 8 = 11001000₂, which has non-contiguous 1s. Valid mask octets must come from {0, 128, 192, 224, 240, 248, 252, 254, 255}.
- A: 248 = 11111000₂ is valid.
- B: 252 = 11111100₂ is valid.
- D: 254 = 11111110₂ is valid.
Flashcards
- How do you compute the subnet network address from an IP and subnet mask?
Reveal answer
Bitwise AND: Subnet = IP & Mask. - If s bits are borrowed leaving h host bits, how many subnets and usable hosts per subnet?
Reveal answer
2ˢ subnets and 2ʰ − 2 usable hosts per subnet. - What is the stride Δ for mask octet 240, and where do the first three subnets start?
Reveal answer
Δ = 256 − 240 = 16; subnets start at 0, 16, 32 (broadcasts at 15, 31, 47). - List the 8 non-zero valid subnet mask octet values.
Reveal answer
128, 192, 224, 240, 248, 252, 254, 255.
Exam shortcuts
- Stride shortcut Δ = 256 − M: Subnet start =
⌊octet / Δ⌋ × Δ, Broadcast =subnet start + Δ − 1. — finding subnet and broadcast addresses in < 10 seconds without binary conversion. - Address loss cost of subnetting: Splitting a network into K subnets loses
2Kaddresses total (compared to 2 lost before subnetting). — questions asking "How many usable host addresses are lost when subnetting?" → 2(2ˢ − 1) additional addresses lost.