CN Notes
IPv4, or Internet Protocol version 4, is the fourth version of the Internet Protocol and the most widely used protocol for routing traffic across the...
What is IPv4?
IPv4, or Internet Protocol version 4, is the fourth version of the Internet Protocol and the most widely used protocol for routing traffic across the internet. Developed in the early 1980s, IPv4 has been the backbone of internet communication for over four decades. Every device connected to the internet — your phone, laptop, smart TV, web server — needs an IPv4 address to communicate.
An IPv4 address is a 32-bit number that uniquely identifies a device on a network. It is written in dotted decimal notation as four numbers separated by dots, like 192.168.10.1. Each number (called an octet) ranges from 0 to 255. Together, the 32 bits provide approximately 4.3 billion unique addresses — a number that seemed impossibly large in 1981 but has since been exhausted by the explosive growth of internet-connected devices.
IPv4 Address Format
Each IPv4 address is exactly 32 bits long, divided into four groups of 8 bits called octets. Understanding the binary representation is essential for subnetting, network design, and troubleshooting.
Binary to Decimal Conversion Example:
| Binary | 11000000.10101000.00000001.00000001 |
| Decimal | 192 .168 .1 .1 |
| Each octet | 8 bits = values from 00000000 (0) to 11111111 (255) |
| Example | 192 in binary |
Practice converting these addresses to verify your understanding:
- 10.0.0.1 → 00001010.00000000.00000000.00000001
- 172.16.0.1 → 10101100.00010000.00000000.00000001
- 255.255.255.0 → 11111111.11111111.11111111.00000000
Network and Host Portions
An IPv4 address is logically divided into two parts by the subnet mask:
Network portion: Identifies which network the device belongs to. All devices on the same network share identical network bits.
Host portion: Identifies the specific device within that network. Each device on the same network has a unique host portion.
| IP Address | 192.168.1.100 |
| Subnet Mask | 255.255.255.0 |
| Network bits | 192.168.1.___ (first 24 bits) |
| Host bits | ___.___.___.100 (last 8 bits) |
| All devices on this network | 192.168.1.1 through 192.168.1.254 |
| Network address | 192.168.1.0 |
| Broadcast | 192.168.1.255 |
When a router receives a packet, it performs a bitwise AND between the destination IP address and the subnet mask to extract the network portion. It then looks up that network in its routing table to determine the next hop.
IPv4 Address Classes
The original IPv4 design divided addresses into five classes based on the first few bits:
| Class | First Bits | First Octet Range | Default Mask | Networks | Hosts per Network |
|---|---|---|---|---|---|
| A | 0... | 1-126 | 255.0.0.0 (/8) | 128 | 16,777,214 |
| B | 10... | 128-191 | 255.255.0.0 (/16) | 16,384 | 65,534 |
| C | 110... | 192-223 | 255.255.255.0 (/24) | 2,097,152 | 254 |
| D | 1110... | 224-239 | Multicast | - | - |
| E | 1111... | 240-255 | Experimental | - | - |
Note: Classful addressing is largely obsolete today. Modern networks use CIDR (Classless Inter-Domain Routing) which allows subnet masks of any length. However, understanding classes helps you recognize common address patterns and is still tested in exams and interviews.
Special IPv4 Addresses
Certain IPv4 addresses are reserved and cannot be assigned to regular hosts:
| Address | Purpose | Example |
|---|---|---|
| Network Address | Identifies the network itself (all host bits = 0) | 192.168.1.0 |
| Broadcast Address | Sends to all hosts on subnet (all host bits = 1) | 192.168.1.255 |
| Loopback | Device sends packets to itself (testing) | 127.0.0.1 |
| Link-Local | Auto-assigned when DHCP fails | 169.254.x.x |
| Default Route | Represents "all networks" in routing | 0.0.0.0 |
| Limited Broadcast | Broadcast to local network only | 255.255.255.255 |
The loopback address (127.0.0.1) is used to test the network stack on a device. When you ping 127.0.0.1, the packet never leaves the device — it loops back internally. Any address in the 127.0.0.0/8 range is loopback, though 127.0.0.1 is used by convention.
Link-local addresses (169.254.0.0/16) are automatically assigned when a device cannot reach a DHCP server. If you see a 169.254.x.x address on your machine, it means DHCP configuration has failed.
Private IPv4 Addresses
Three ranges are designated for private (internal) use. These addresses are NOT routable on the public internet:
| Range | Class | Addresses Available | Common Use |
|---|---|---|---|
| 10.0.0.0 – 10.255.255.255 | A | 16,777,216 | Large enterprises |
| 172.16.0.0 – 172.31.255.255 | B | 1,048,576 | Medium organizations |
| 192.168.0.0 – 192.168.255.255 | C | 65,536 | Home networks, small offices |
Why private addresses exist: With only 4.3 billion public IPv4 addresses and billions of devices needing connectivity, NAT (Network Address Translation) allows thousands of devices within an organization to share a single public IP address. Internal devices use private addresses, and the NAT device translates between private and public addresses at the network boundary.
Your home router typically assigns addresses in the 192.168.0.x or 192.168.1.x range to your devices, while presenting a single public IP address to the internet.
IPv4 Header Structure
Every IPv4 packet begins with a header containing routing and control information:
Source IP Address
| Version | IHL | ToS/DSCP | Total Length |
|---|---|---|---|
| Identification | Flags | Fragment Offset | |
| Time to Live | Protocol | Header Checksum |
Critical fields:
- TTL (Time to Live): Decremented by each router. Packet discarded at 0. Prevents infinite loops.
- Protocol: Identifies the transport layer protocol (6 = TCP, 17 = UDP, 1 = ICMP)
- Source/Destination IP: 32 bits each — the sender and intended recipient
IPv4 Exhaustion and Solutions
The Internet Assigned Numbers Authority (IANA) allocated the last block of IPv4 addresses on February 3, 2011. Regional Internet Registries subsequently exhausted their allocations.
Short-term solutions:
- NAT (Network Address Translation): Allows millions of devices to share one public IP
- CIDR: More efficient allocation than classful addressing
- IPv4 address markets: Organizations buy/sell unused address blocks
Long-term solution:
- IPv6: 128-bit addresses providing 3.4 × 10³⁸ unique addresses — enough for every atom on Earth to have its own IP address
Key Formulas for Subnetting
| Formula | Purpose |
|---|---|
| 2ⁿ - 2 | Usable hosts (n = host bits, subtract network + broadcast) |
| 2ⁿ | Number of subnets (n = borrowed bits) |
| 256 - subnet_mask_octet | Block size / increment |
| 32 - prefix_length | Number of host bits |
Example: For 192.168.1.0/26:
- Host bits = 32 - 26 = 6
- Usable hosts = 2⁶ - 2 = 62
- Number of subnets = 2² = 4 (borrowed 2 bits from /24)
- Block size = 256 - 192 = 64
- Subnets: .0, .64, .128, .192
Understanding IPv4 thoroughly is essential for network engineering, even as the world transitions to IPv6, because IPv4 will remain in active use for many years to come.
Exam Focus
Revise definitions, diagrams, examples, and short-answer points for IPv4 Addressing.
Interview Use
Prepare one clear explanation, one practical example, and one common mistake for this Computer Networks topic.
Search Terms
computer-network-master, computer networks, computer, network, master, addressing, ipv4, ipv4 addressing
Related Computer Networks Topics