IDRASAcademic OS
100% Self-Contained Notes
Unit 3: Network Layer & Addressing50 mins deep studyINTERMEDIATE

IPv4 Subnetting, CIDR Prefix Allocation & VLSM Design

The 32-bit IPv4 address space (4,294,967,296 total addresses) is finite and mathematically constrained. Classless Inter-Domain Routing (CIDR, RFC 1519) and Variable Length Subnet Masking (VLSM) prevent global routing table explosion and allow engineers to allocate precisely sized subnets with minimal wasted host space.

Worked Examples
2 Solved
Practice Drill
5 Questions
Part 1: Target Learning Outcomes
What You Will Master:
  • Convert fluently between Dotted-Decimal Netmasks and CIDR prefix notation (/n).
  • Compute Network Address, Broadcast Address, and First/Last Usable Host IP using bitwise AND algebra.
  • Design multi-department VLSM hierarchical address allocations without overlap.
  • Calculate wildcard masks and route summarization supernets for router ACLs and OSPF/BGP routing protocols.
Required Prerequisites:
  • Binary place-value arithmetic (powers of 2: 128, 64, 32, 16, 8, 4, 2, 1).
  • Bitwise Boolean operations: AND (&), OR (|), NOT (~).
  • Understanding of OSI Layer 3 (IP) vs Layer 2 (MAC) packet routing.
Part 2: Why This Exists (Intuition & Motivation)

The Problem: Allows organizations to size subnets to their exact host counts, prolonging IPv4 viability and keeping global BGP routing tables compact.

Historical Context: In the early 1990s, classful addressing (Class A = 16 million hosts, Class B = 65,536 hosts, Class C = 254 hosts) caused massive waste. A company needing 500 IP addresses was forced to take an entire Class B block, leaving 65,000 addresses unused. CIDR eliminated classes and permitted arbitrary prefix masks like /23 (510 hosts).

Mental Analogy: Country Codes, Postal Pincodes, and Apartment Numbers

Think of an IPv4 address like a full postal address. The Network ID prefix is the city and street name. The Host ID suffix is the apartment number inside the building. The Subnet Mask is a stencil: holding the stencil over the address reveals which characters tell the delivery truck which building to drive to (routing), and which characters tell the mail carrier which specific mailbox to drop the letter into.

Limitations of Analogy: Physical buildings can have any arbitrary number of apartments (e.g. 13 apartments). Subnets MUST strictly adhere to binary powers of 2 (2, 4, 8, 16, 32, 64, 128, 256...).
Part 3: Hinglish Peer-Mentor Bridge (100% Humanized Explanation)
Senior Engineering Mentor

Seedhi bhasha mein: IPv4 address 32 bits ka hota hai, jisko hum 4 octets mein likhte hain (jaise 192.168.1.100). Har address do hisson se banta hai: Network ID (mohalla/colony) aur Host ID (house number). Subnet mask ka kaam ye batana hai ki kahan tak Network ID hai aur kahan se Host ID shuru hota hai. CIDR notation `/24` ka matlab pehle 24 bits 1s hain (network), aur bache hue 8 bits 0s hain (hosts). Subnet mein Total Hosts = 2^h hote hain, lekin Usable Hosts hamesha 2^h - 2 hote hain, kyunki pehla address Network ID hota hai aur aakhri address Broadcast ID hota hai—ye dono kisi computer ko assign nahi ho sakte!

💡 Concept Rule: Golden Rule of VLSM: Hamesha sabse bade department ko pehle address do, fir usse chhote ko, aur sabse aakhri mein point-to-point router links (/30) ko. Agar ulta karoge toh beech mein address space tukdon mein toot jayega (fragmentation).
Part 4: Formal Academic Specification
Classless Inter-Domain Routing (CIDR) is an IP addressing allocation methodology defined in RFC 1519/RFC 4632 that replaces classful network boundaries by allowing variable-length network prefixes designated by a slash suffix (/n), where n in [0, 32] denotes the number of contiguous leading bits of the network identifier.
Governing Mathematical Equation:
N_usable = 2^(32 - n) - 2, where n is the CIDR prefix length
Part 5: Deep Internal Working & Dataflow

Every IPv4 router inspects arriving IP packets and performs a bitwise AND between the destination IP address and its interface netmasks to perform Longest Prefix Match (LPM) lookups in the forwarding information base (FIB). The boundary between network and host can fall at any bit position, not just octet boundaries.

Step-by-Step Execution Sequence:
11. Router receives an IP packet with destination address D (e.g. 192.168.10.77).
22. Routing table contains multiple CIDR entries (e.g. 192.168.0.0/16, 192.168.10.0/24, 192.168.10.64/26).
33. Router applies netmask of each candidate route to D: (192.168.10.77 & 255.255.255.192) = 192.168.10.64.
44. Router selects the route with the highest prefix length n (Longest Prefix Match: /26 wins over /24).
55. Packet forwarded out the specific egress interface mapped to the winning prefix.
Mathematical Derivation & Proof:Given Prefix /27: Host bits h = 32 - 27 = 5 bits. Block Size = 2^5 = 32 addresses. Usable Hosts = 2^5 - 2 = 30 hosts. Netmask in binary: 11111111.11111111.11111111.11100000 = 255.255.255.224. Subnets on 192.168.1.0/27 increment by 32: .0, .32, .64, .96, .128, .160, .192, .224.
Part 9: Common Student Misconceptions & Traps
❌ False Belief: “Assigning Network or Broadcast Address to a Host NIC”
Why It Fails: OS socket layers and routing stacks reject all-zeros or all-ones host bit configurations.
Correct Model: The all-zeros host address designates the entire network wire itself; the all-ones address is reserved for link broadcast.
Counterexample: Attempting `ip addr add 192.168.1.0/24 dev eth0` will fail with 'cannot assign requested address'.
❌ False Belief: “Assuming Subnet Masks Must Fall on Byte (.0 or .255) Boundaries”
Why It Fails: Legacy classful thinking makes students believe netmasks only end in .0 or .255.
Correct Model: CIDR netmasks divide at any bit position from /0 to /32. Common masks end in 128, 192, 224, 240, 248, 252.
Counterexample: /26 yields netmask 255.255.255.192, splitting the final octet into 4 subnets of 64 addresses each.
Part 10: Comparative Analysis & Decision Matrix
MetricClassful (Legacy)CIDR (RFC 1519)VLSM (Subnetting)
Mask FlexibilityRigid (/8, /16, /24)Arbitrary prefix (/0 to /32)Different mask per subnet
Address Waste> 90% in Class B< 10% wasteNear zero waste
Routing Table ImpactExplosive growthAggregated SupernetsHierarchical internal summarization
Protocol SupportRIPv1, IGRP (No mask sent)BGP-4, OSPFv2, EIGRPOSPF, IS-IS, EIGRP

CIDR and VLSM trade routing protocol complexity for near-perfect IPv4 utilization and compact BGP forwarding tables.

Part 14: Academic Reference Attribution (Enrichment Only)Core Content Taught 100% In-Platform
[1]
Computer Networks: A Systems Approach — Larry L. Peterson & Bruce S. Davie (6th Edition).Academic Role: Chapter 3: Internetworking — Global Addresses and CIDR Prefix Routing.
[2]
RFC 1519 / RFC 4632: Classless Inter-domain Routing (CIDR) — Internet Engineering Task Force (IETF).Academic Role: The official internet standards specification for CIDR address assignment and route aggregation.