Siksha Sarovar

Siksha Sarovar (sikshasarovar.com) is a free educational web application that helps students in India learn programming and prepare for academic and competitive exams. The platform offers structured coding courses (C, C++, Python, Java, HTML, CSS, PHP, Power BI, AI, Machine Learning, Data Science), complete university curriculum notes for BCA/MCA students with previous year question papers, Class 10 and Class 12 CBSE/HBSE school notes, and dedicated preparation material for SSC, UPSC, Banking, Railway and other government exams. Browsing the site is completely free and requires no account. Users may optionally sign in with Google solely to save their learning progress, quiz scores and personal preferences across devices.

Privacy Policy | Terms of Service | Contact Siksha Sarovar | About Siksha Sarovar

v4.0.9 · PWA
Siksha Sarovar logo
Siksha Sarovar
Your Learning Universe

Siksha Sarovar is a free e-learning platform for coding courses, BCA university notes and competitive exam preparation. Optional Google sign-in saves your learning progress across devices.

Initializing knowledge base…
Compiling modules 0%

IPv4/IPv6 Addressing, Subnetting & CIDR

Lesson 11 of 15 in the free Computer Networks notes on Siksha Sarovar, written by Rohit Jangra.

IPv4/IPv6 Addressing, Subnetting & CIDR

---

1. IPv4 Addressing

An IPv4 address is a 32-bit number, typically written in dotted-decimal notation (4 octets separated by dots):

192.168.10.50 = 11000000.10101000.00001010.00110010

IPv4 Address Classes (Classful — Legacy)

ClassFirst Octet RangeDefault Subnet MaskNetwork BitsHost BitsTypical Use
A1–126255.0.0.0 (/8)824Large ISPs
B128–191255.255.0.0 (/16)1616Universities
C192–223255.255.255.0 (/24)248Small offices
D224–239N/AMulticastGroup messaging
E240–255N/AReservedResearch

Special note: 127.x.x.x is reserved for loopback (localhost testing).

---

2. Subnet Mask and CIDR Notation

A subnet mask identifies which bits of an IP address belong to the network and which to the host:

  • Binary 1 bits = network portion
  • Binary 0 bits = host portion

CIDR notation (Classless Inter-Domain Routing) uses /prefix-length to indicate the number of network bits:

  • 192.168.1.0/24 = subnet mask 255.255.255.0
  • 10.0.0.0/8 = subnet mask 255.0.0.0
  • 172.16.0.0/12 = subnet mask 255.240.0.0

---

3. Subnetting Worked Example

Problem: A company has the network 192.168.10.0/24 and needs 4 equal subnets. Find:

  1. The new subnet mask
  2. The subnet addresses
  3. The usable host range for each subnet
  4. The broadcast address for each subnet

Solution:

Step 1: We need 4 subnets. Since 2^n ≥ 4, we need n = 2 additional subnet bits.

  • Original prefix: /24 → New prefix: /24 + 2 = /26
  • New subnet mask: /26 = 255.255.255.192

Step 2: Block size = 256 − 192 = 64 (the last octet increments by 64 for each subnet)

Step 3: Calculate the 4 subnets:

SubnetSubnet AddressUsable Host RangeBroadcast AddressUsable Hosts
1192.168.10.0192.168.10.1 – .62192.168.10.6362
2192.168.10.64192.168.10.65 – .126192.168.10.12762
3192.168.10.128192.168.10.129 – .190192.168.10.19162
4192.168.10.192192.168.10.193 – .254192.168.10.25562

Formula: Usable hosts per subnet = 2^(host bits) − 2 = 2^6 − 2 = 62 (Subtract 2 for network address and broadcast address)

Exam Tip: The subnetting formula: Hosts = 2^h − 2 where h = number of host bits. Subnets = 2^s where s = number of borrowed bits. Always subtract 2 from hosts (network ID + broadcast). Very common exam question — practice until it's automatic.

---

4. Private IP Address Ranges (RFC 1918)

RangeCIDRUse
10.0.0.0 – 10.255.255.25510.0.0.0/8Large enterprises
172.16.0.0 – 172.31.255.255172.16.0.0/12Medium enterprises
192.168.0.0 – 192.168.255.255192.168.0.0/16Home / small office

Private addresses are not routable on the public internet — they require NAT to communicate outside their network.

---

5. IPv6 Addressing

IPv6 Address Format

128 bits, written as 8 groups of 4 hexadecimal digits separated by colons:

2001:0db8:85a3:0000:0000:8a2e:0370:7334

Simplification rules:

  1. Leading zeros: Remove within each group → 2001:db8:85a3:0:0:8a2e:370:7334
  2. Consecutive all-zero groups: Replace with :: (only once) → 2001:db8:85a3::8a2e:370:7334

IPv6 Address Types

TypePrefixDescription
Global Unicast2000::/3Publicly routable (like public IPv4)
Link-LocalFE80::/10Only valid on local link (auto-assigned)
Loopback::1/128Equivalent to IPv4 127.0.0.1
MulticastFF00::/8One-to-many delivery
Unspecified::/128Unassigned address
IPv6 has no broadcast — replaced by multicast (e.g., FF02::1 = all hosts on link).

SLAAC (Stateless Address Autoconfiguration)

IPv6 hosts can configure their own global address without DHCP:

  1. Generate a link-local address (FE80:: + EUI-64 from MAC)
  2. Receive Router Advertisement with network prefix from router
  3. Combine prefix + interface identifier → global unicast address

---

6. ARP (Address Resolution Protocol)

ARP maps a known IP address to an unknown MAC address within the same subnet.

StepAction
1Host wants to send to IP 192.168.1.5 but doesn't know its MAC
2Host broadcasts ARP Request: "Who has 192.168.1.5? Tell 192.168.1.10"
3Host with IP 192.168.1.5 replies: "I have that IP, my MAC is XX:XX:XX:XX:XX:XX"
4Requestor caches {IP → MAC} in its ARP cache
5Sends frame using cached MAC address

ARP Cache: Entries expire after a timeout (typically 2–20 minutes). arp -a displays the cache.

Gratuitous ARP: A host announces its own IP-to-MAC mapping proactively (used for duplicate detection and cache update after IP change).

---

Study Deep: Subnetting in Practice

  • VLSM (Variable-Length Subnet Masking): Allows different subnets within the same network to have different sizes — assign /30 (2 hosts) to router-to-router links, /24 (254 hosts) to workstation LANs, etc. More efficient than equal-size subnetting.
  • Route summarisation: Contiguous subnets can be summarised into a single routing table entry, reducing router memory and CPU usage — critical for scalability.
  • IPv6 transition: Dual-stack (both IPv4 and IPv6 running simultaneously) and tunnelling (encapsulating IPv6 in IPv4 packets) are the main transition mechanisms. Most major internet sites now support both.