4.3.9Computer Networks

Subnetting — subnet mask, network - host bits, VLSM

1,956 words9 min readdifficulty · medium1 backlinks

1. What an IP address really is

WHY contiguous? A router finds the network part by a bitwise AND of address & mask. For AND to cleanly "keep the left, zero the right," the 1s must be packed on the left — no gaps allowed.

Network address=IP  AND  Mask\text{Network address} = \text{IP} \;\text{AND}\; \text{Mask}


2. Network bits vs host bits — the core counting


3. Finding subnet, broadcast, host range (the worked drill)

Figure — Subnetting — subnet mask, network - host bits, VLSM

4. VLSM — Variable Length Subnet Masking


Recall Feynman: explain to a 12-year-old

Imagine a big apartment building (the network) with a street number and lots of flat numbers (hosts). The IP address writes both together. The subnet mask is a marker pen line that says "everything left of this line is the building, everything right is the flat number." Move the line right → more buildings but fewer flats per building. Two flat numbers are off-limits in every building: flat "0000" is the building's nameplate, and flat "1111" is the building loudspeaker (broadcast). VLSM is just smart building management: give big families big buildings and a couple sharing a hallway a tiny one, instead of identical buildings for everybody.


Flashcards

How many bits is an IPv4 address and how is it grouped?
32 bits, four 8-bit octets in dotted-decimal.
What does a bitwise AND of IP and mask give you?
The network (subnet) address.
Formula for usable hosts per subnet with h host bits?
2h22^h - 2 (minus network + broadcast).
Why subtract 2 from host count?
All-0 host bits = network address; all-1 host bits = broadcast; neither is assignable.
For a /26 mask, how many host bits and usable hosts?
6 host bits, 262=622^6-2 = 62 hosts.
What is the last-octet mask value for /26?
192 (128+64).
How do you compute block size from a mask octet?
256 − mask octet (e.g. 256−192 = 64).
In 192.168.10.130/26, what is the subnet address?
192.168.10.128 (130 falls in the 128–191 block).
In 192.168.10.130/26, what is the broadcast address?
192.168.10.191 (next boundary 192 minus 1).
What does VLSM stand for and mean?
Variable Length Subnet Masking — using different prefix lengths per subnet to size each to need.
What is VLSM's golden allocation rule?
Allocate the largest subnets first.
What prefix do you need for a 2-host point-to-point link?
/30 (222=22^2-2 = 2 usable hosts).
Relationship between network bits n and host bits h?
n + h = 32 (zero-sum trade).
Borrowing b host bits creates how many subnets?
2b2^b subnets.

Connections

  • IPv4 Addressing — the 32-bit structure subnetting operates on
  • CIDR and Supernetting — opposite move: merging networks, same prefix math
  • Routing Tables and Longest Prefix Match — why subnets shrink routing tables
  • Default Gateway and ARP — host uses mask to decide local vs remote delivery
  • Bitwise AND OR — the boolean operation behind network extraction
  • Network and Broadcast Addresses — the two reserved patterns

Concept Map

split into

split into

leftmost 1s mark

trailing 0s mark

bitwise AND with IP

defines

h = 32 - n

2^h minus 2

explains minus 2

borrow b bits

2^h in octet

steps boundaries

IPv4 address 32 bits

Network part

Host part

Subnet mask /n

Network address

Prefix length n

Host bits h

Usable hosts

All-0 and all-1 reserved

2^b subnets

Block size

VLSM right-sized blocks

Hinglish (regional understanding)

Intuition Hinglish mein samjho

Dekho, ek IPv4 address actually 32 bits ka hota hai, aur usme do cheezein chhupi hoti hain — "main kaunse network pe hoon" aur "us network pe main kaunsa host hoon". Subnet mask ek line khinchta hai: line ke left wale bits = network part, right wale bits = host part. Mask me jitne 1s, utne network bits (prefix /n), aur baaki 32−n host bits. Router network address nikalne ke liye IP aur mask ka bitwise AND karta hai — isiliye mask me 1s hamesha left side contiguous hote hain.

Host count ka formula simple hai: 2h22^h - 2, jahan hh = host bits. Minus 2 isliye kyunki all-0 host bits = network address (subnet ka naam) aur all-1 host bits = broadcast — ye dono kisi machine ko assign nahi kar sakte. Ek mast trick: block size = 256 − mask ka last octet. Jaise /26 me mask 255.255.255.192, block size = 256−192 = 64, to subnets 0, 64, 128, 192 pe shuru hote hain. Agar host .130 hai to wo 128–191 block me aata hai → network .128, broadcast .191, usable .129 se .190.

VLSM ka matlab hai har subnet ko alag size dena, uski zaroorat ke hisaab se. Fixed subnetting me sab equal size — jo bada group hai usko fit nahi hota ya chhote groups me addresses waste. VLSM me 100-host LAN ko /25 do, 2-host router link ko /30. Golden rule: sabse bade subnet pehle allocate karo, taaki blocks theek se align rahein aur baad me bade subnet ke liye jagah bache. Yaad rakho: n+h=32n + h = 32 — network bits badhao to host bits ghatega, ye ek zero-sum trade hai.

Go deeper — visual, from zero

Test yourself — Computer Networks

Connections