4.3.8Computer Networks

IPv4 — address format, classes, subnetting, CIDR notation

2,250 words10 min readdifficulty · medium

1. Address Format — WHAT an IPv4 address actually is

WHY dotted decimal? 32 raw bits (11000000101010000000000100000001) are unreadable. We split into 4 groups of 8 bits and write each group in decimal. 192.168.0.1192.168.0.1 is just human-friendly packaging.


2. Network vs Host — the key idea behind everything

The split is defined by a mask: the leftmost nn bits are network, the rest are host.


3. Classful Addressing — the OLD (rigid) split

WHY the "2-2"? In any network the all-zeros host = the network address itself, and the all-ones host = the broadcast address. Neither can be assigned to a real machine.


4. Subnetting — borrowing host bits

Figure — IPv4 — address format, classes, subnetting, CIDR notation

5. CIDR Notation — the modern, classless system


6. Reserved / special ranges (know these)



Recall Feynman: explain to a 12-year-old

Imagine every computer is a house and its address is a long number. The first part of the number is the street name (the network) and the last part is the house number (the host). The mailman (router) only needs to know streets, not every house — so he just reads the front part. A /24 means "the first 24 digits are the street, the rest are houses." When a street has too many houses, we split it into smaller streets by treating a few more digits as part of the street name — that's subnetting. CIDR just lets us cut the street/house line anywhere we want instead of at fixed spots, so we don't waste house numbers.


How many bits is an IPv4 address?
32 bits, written as 4 octets (dotted decimal), each 0–255.
Total number of IPv4 addresses?
2324.292^{32} \approx 4.29 billion.
Formula for usable hosts in a /n network?
232n22^{32-n} - 2 (subtract network + broadcast).
Why subtract 2 from host count?
All-zeros host = network address, all-ones host = broadcast; neither is assignable.
Leading bits of Class A, B, C, D, E?
0, 10, 110, 1110, 1111.
First-octet range of Class C?
192–223.
What does /n mean in CIDR?
n = number of network (mask) bits; first n bits are network, rest are host.
Subnet mask for /26?
255.255.255.192 (last octet 11000000 = 192).
Number of subnets when borrowing s bits?
2s2^s.
Hosts per subnet with h host bits?
2h22^h - 2.
Block size for /27 in the last octet?
23227=322^{32-27} = 32, so boundaries 0,32,64,...
Does a larger prefix mean a larger network?
No — larger /n = more network bits = fewer host bits = smaller network.
What range is 127.0.0.0/8 used for?
Loopback (127.0.0.1 = localhost).
Three private IPv4 ranges (RFC 1918)?
10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16.
What is CIDR aggregation/supernetting?
Combining contiguous networks sharing a prefix into one shorter-prefix route to shrink routing tables (e.g. two /24s → one /23).
Network address of 10.20.30.45/27?
10.20.30.32 (block size 32; 32 ≤ 45 < 64).

Connections

  • IPv6 — addressing and notation (128-bit successor solving IPv4 exhaustion)
  • Subnet Mask and ANDing (how routers extract the network part)
  • NAT — Network Address Translation (why private ranges work on the Internet)
  • Routing Tables and Longest Prefix Match (why CIDR aggregation matters)
  • DHCP and APIPA (link-local 169.254.0.0/16)
  • Binary and Positional Number Systems (foundation for octet conversion)

Concept Map

has only

written as

drives

divided into

defined by

rigid version

causes

motivates

motivates

borrows from

removes 2 via

IPv4 32-bit address

~4.3 billion addresses

Dotted-decimal a.b.c.d

Network part + Host part

Mask - leftmost n bits

Classful addressing A B C

Address waste - fixed sizes

Subnetting - borrow host bits

CIDR notation

All-zeros + all-ones reserved

Hinglish (regional understanding)

Intuition Hinglish mein samjho

Dekho, IPv4 address basically ek 32-bit number hai jo har device ko Internet par unique pehchaan deta hai — bilkul ghar ke address jaisa. Hum ise padhne layak banane ke liye 4 octets mein todte hain (192.168.0.1), aur har octet 0 se 255 tak hota hai kyunki 8 bits ka max 281=2552^8-1 = 255 hota hai. Pura address 2322^{32} yaani lagभग 4.3 billion combinations deta hai — aur yahi scarcity poori kahani ka root hai.

Address ke do hisse hote hain: network part (kaunsa network) aur host part (us network ke andar kaunsa device). Router sirf network part dekh kar route karta hai, isliye usse har device yaad rakhne ki zaroorat nahi padti. Pehle classes (A, B, C) fixed split dete the, lekin wo bahut waste karte the — 2000 hosts ke liye poori Class B (65k) leni padti thi. Isliye CIDR aaya, jisme aap /n likh kar network/host line kahin bhi kaat sakte ho.

Subnetting ka funda simple hai: ek bade network se kuch host bits udhaar lo network banane ke liye. Agar ss bits borrow karo to 2s2^s subnets bante hain, aur agar hh host bits bachein to har subnet mein 2h22^h - 2 usable hosts (minus 2 isliye kyunki all-zeros = network address aur all-ones = broadcast, ye dono kisi machine ko nahi de sakte). Block size =2h= 2^h ko yaad rakho — subnet ki network addresses hamesha is block size ke multiples par hi aati hain, isse boundaries instantly mil jaati hain. Exam aur real networking dono mein yahi 80/20 trick kaam aati hai.

Go deeper — visual, from zero

Test yourself — Computer Networks