codingstuff.io
ExploreTutorialsProblemsCS Subjects
Get Started
ExploreTutorialsProblemsCS Subjects
Get Started
codingstuff.io

Master the art of building software through interactive tutorials, real-world problems, and guided projects.

Pune, Maharashtra, India

codingstuffmail@gmail.com

Product

  • Explore
  • Tutorials
  • Problems
  • CS Subjects

Company

  • About
  • Contact
  • Privacy Policy
  • Terms & Conditions
  • Sitemap

© 2026 codingstuff.io. All rights reserved.

Built with ❤️ for developers everywhere

/
/
All Subjects
🌐

Computer Networks

26 chapters

1Network Topologies & LAN/WAN2Network Devices (Hub, Switch, Router)3OSI Reference Model4OSI Model & TCP/IP Suite5TCP/IP Protocol Suite6Switching Techniques (Circuit, Packet)7Data Link: Framing & Error Detection8Error Correction (Hamming Code)9Flow Control (Stop-and-Wait, Sliding Window)10MAC: CSMA/CD & CSMA/CA11Network Layer & Routing12IP Addressing (IPv4, IPv6)13Subnetting & CIDR14Routing Algorithms (Distance Vector, Link State)15ARP, ICMP, and NAT16DHCP Protocol17Transport Layer Services18Transport Layer: UDP19Transport Layer: TCP & 3-Way Handshake20TCP Congestion Control21Application Layer: DNS & HTTP22Application Layer: SMTP & FTP23Socket Programming Basics24Wireless Networks & Wi-Fi Standards25VLANs & Spanning Tree Protocol26Network Security & Cryptography
SubjectsComputer Networks

IP Addressing (IPv4, IPv6)

Updated 2026-04-23
3 min read

IP Addressing (IPv4, IPv6)

While MAC addresses physically identify a specific Network Interface Card on a local LAN, the Network Layer (Layer 3) requires a logical addressing system to route packets across the globe. This is the IP (Internet Protocol) Address.

An IP address is hierarchical, meaning it contains information about both the specific network the device is on, and the specific device itself (much like a zip code and a house number).

1. IPv4 (Internet Protocol Version 4)

IPv4 is the dominant protocol of the Internet. An IPv4 address is a 32-bit binary number. To make it readable for humans, it is divided into four 8-bit bytes (octets) and written in Dotted-Decimal Notation.

  • Example: 192.168.1.5
  • Each octet ranges from 0 to 255.
  • Because it is 32 bits, there are exactly $2^32$ (approximately 4.3 billion) possible unique IPv4 addresses.

Classful Addressing (Obsolete but foundational)

Historically, the IPv4 space was rigidly divided into five classes based on the first few bits of the address:

  • Class A: For massive networks. (First octet 1-126). Supports 16 million hosts per network.
  • Class B: For medium networks. (First octet 128-191). Supports 65,534 hosts.
  • Class C: For small networks. (First octet 192-223). Supports 254 hosts.
  • Class D: Reserved for Multicasting. (First octet 224-239).
  • Class E: Reserved for experimental use.

Note: Classful addressing was incredibly wasteful and was replaced by CIDR (Classless Inter-Domain Routing) in the 1990s.

Special IPv4 Addresses

  • Loopback (Localhost): 127.0.0.1. A packet sent to this address never leaves the machine; it loops back directly to the local OS. Used for testing servers locally.
  • Broadcast: 255.255.255.255. A packet sent here is delivered to every single device on the local network.
  • Private IP Ranges: These addresses are not routable on the public Internet. You can use them freely inside your home/office network.
    • 10.0.0.0 to 10.255.255.255
    • 172.16.0.0 to 172.31.255.255
    • 192.168.0.0 to 192.168.255.255

2. IPv6 (Internet Protocol Version 6)

In the late 1980s, engineers realized that 4.3 billion IPv4 addresses would not be enough for the explosive growth of the Internet. In 2011, the global registry officially ran out of unassigned IPv4 addresses (IPv4 Exhaustion).

IPv6 was created to solve this. It uses a massive 128-bit address.

  • There are $2^128$ possible addresses. That is $3.4 \times 10^38$ (340 undecillion) addresses. Enough to assign a unique IP to every single atom on the surface of the Earth.

IPv6 Notation

Because 128 bits is too long for dotted-decimal, IPv6 is written as eight groups of four hexadecimal digits, separated by colons.

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

Zero Compression Rules: To make writing IPv6 addresses easier, you can abbreviate them:

  1. Leading zeros in any group can be omitted. (0db8 becomes db8).
  2. Consecutive sections of zeros can be replaced with a double colon :: (This can only be done once per address).
  • Abbreviated Example: 2001:db8:85a3::8a2e:370:7334

Advantages of IPv6 over IPv4

  • Infinite Address Space: Eliminates the need for NAT (Network Address Translation).
  • Simpler Header: The IPv6 header drops unnecessary fields (like the Header Checksum), making hardware routing substantially faster.
  • No Broadcasts: IPv6 relies entirely on Multicast, reducing network noise.
  • Built-in Security: IPsec (encryption and authentication) is a mandatory component of the IPv6 protocol suite.


PreviousNetwork Layer & RoutingNextSubnetting & CIDR

Recommended Gear

Network Layer & RoutingSubnetting & CIDR