IPv4 (Internet Protocol Version 4)
IPv4
1. Historical Context and Design Philosophy
IPv4 was formalized in 1981 in RFC 791, during a time when networking was transitioning from isolated systems to interconnected networks.
It emerged from earlier protocols such as:
- NCP (Network Control Program) in ARPANET
- Early experimental internetworking protocols
The central problem IPv4 solves is:
How do we reliably deliver packets across multiple independent networks without requiring those networks to share internal structure?
This leads to the core design principle:
Best-Effort, Connectionless Delivery
IPv4 does not guarantee:
- Delivery
- Order
- Duplication avoidance
Instead, it provides:
- Logical addressing
- Packet forwarding
Reliability is delegated upward (e.g., TCP).
2. The Internet Layer in the TCP/IP Model
IPv4 operates at the Internet Layer of the TCP/IP model.
TCP/IP vs OSI Mapping
| TCP/IP Layer | OSI Equivalent |
|---|---|
| Application | Application / Presentation / Session |
| Transport | Transport |
| Internet | Network |
| Network Access | Data Link + Physical |
IPv4’s responsibilities:
- Logical addressing
- Routing
- Fragmentation
- Packet forwarding
3. IPv4 Addressing — Mathematical Foundation
An IPv4 address is a 32-bit unsigned integer.
This gives:
- Total possible addresses = 2³² = 4,294,967,296
Representation:
Decimal: 192.168.1.1
Binary: 11000000.10101000.00000001.00000001
4. Network vs Host — Formal Definition
An IPv4 address is divided into:
- Network prefix
- Host identifier
This division is defined by a prefix length (CIDR notation).
Example:
192.168.1.0/24
- First 24 bits → network
- Remaining 8 bits → hosts
Host Capacity Formula
Number of usable hosts:
2^h - 2
Where h = number of host bits
Why minus 2?
- Network address (all 0s)
- Broadcast address (all 1s)
5. CIDR — Classless Addressing
CIDR (RFC 4632) replaces inefficient classful addressing.
Key idea:
IP allocation is based on prefix length, not predefined classes.
Example:
10.0.0.0/13
- Flexible allocation
- Enables aggregation
Route Aggregation (Supernetting)
Multiple networks can be summarized:
192.168.0.0/24
192.168.1.0/24
→ 192.168.0.0/23
This reduces routing table size.
6. Subnetting — Network Engineering Tool
Subnetting divides a network into smaller logical segments.
Example
Original network:
192.168.1.0/24
Subnet into /26:
- Each subnet has 64 addresses
- 4 subnets total
Why Subnet?
- Reduce broadcast domains
- Improve performance
- Enhance security isolation
7. IPv4 Packet Structure (Deep Dive)
IPv4 transmits data in packets (datagrams).
Header Structure
| Field | Size | Purpose |
|---|---|---|
| Version | 4 bits | Always 4 |
| IHL | 4 bits | Header length |
| DSCP/ECN | 8 bits | QoS |
| Total Length | 16 bits | Packet size |
| Identification | 16 bits | Fragmentation |
| Flags | 3 bits | Fragment control |
| Fragment Offset | 13 bits | Reassembly |
| TTL | 8 bits | Loop prevention |
| Protocol | 8 bits | Next layer |
| Header Checksum | 16 bits | Error detection |
| Source IP | 32 bits | Sender |
| Destination IP | 32 bits | Receiver |
8. Fragmentation and MTU
Different networks support different MTU (Maximum Transmission Unit).
If a packet exceeds MTU:
- It is fragmented
Key Fields:
- Identification
- Fragment Offset
- MF (More Fragments flag)
Problem:
Fragmentation is inefficient:
- Overhead
- Packet loss amplification
Modern networks try to avoid it using:
- Path MTU Discovery
9. Routing — How Packets Actually Move
Routing is based on longest prefix match.
Routers maintain a routing table:
Example:
| Network | Next Hop |
|---|---|
| 192.168.1.0/24 | Router A |
| 192.168.0.0/16 | Router B |
If destination = 192.168.1.5 → choose /24 (more specific)
10. ARP — Mapping IP to MAC
IPv4 uses ARP (Address Resolution Protocol) to map:
IP → MAC address
Process:
- Broadcast ARP request
- Target responds with MAC
- Cached in ARP table
11. NAT — Extending IPv4 Life
Due to address exhaustion, NAT was introduced.
Types:
- Static NAT
- Dynamic NAT
- PAT (most used)
Key Concept:
Multiple private IPs → one public IP
Trade-offs:
Advantages:
- Conserves IP space
- Adds basic obfuscation
Disadvantages:
- Breaks end-to-end principle
- Complicates protocols (VoIP, P2P)
12. Special Address Spaces
Private Networks (RFC 1918)
- 10.0.0.0/8
- 172.16.0.0/12
- 192.168.0.0/16
Loopback
- 127.0.0.0/8
Link-Local (APIPA)
- 169.254.0.0/16
Multicast
- 224.0.0.0/4
13. Control Protocols Around IPv4
IPv4 does not work alone. It relies on supporting protocols:
- ICMP → error reporting
- ARP → address resolution
- DHCP → dynamic IP assignment
14. Scalability Problem — IPv4 Exhaustion
IPv4 exhaustion became critical around 2011.
Regional Internet Registries (RIRs):
- RIPE NCC
- ARIN
Solutions used:
- CIDR
- NAT
- Address reuse
15. Security Limitations
IPv4 lacks native:
- Encryption
- Authentication
Security is added via:
- IPSec
- Firewalls
- VPNs
16. IPv4 vs IPv6 — Engineering Perspective
| Feature | IPv4 | IPv6 |
|---|---|---|
| Address size | 32-bit | 128-bit |
| Header complexity | Variable | Simplified |
| NAT | Required | Not required |
| Configuration | Manual/DHCP | SLAAC + DHCPv6 |
IPv6 solves:
- Address exhaustion
- Routing efficiency
- Built-in security
17. Why IPv4 Still Dominates
Despite limitations:
- Massive legacy infrastructure
- Cost of migration
- NAT effectiveness
- IPv6 adoption barriers
Most networks today are:
Dual-stack (IPv4 + IPv6)
18. Real-World Architecture Example
Typical enterprise network:
- Internal: Private IPv4
- Edge: NAT gateway
- External: Public IPv4
- Routing: BGP + internal routing (OSPF)
19. Key Engineering Insights
If you want to think like a network engineer:
- IPv4 is not just addressing — it’s a compromise system
- NAT is a workaround, not a solution
- CIDR is what keeps the internet scalable
- Routing efficiency is more critical than address count
20. Final Summary
IPv4 is:
- A connectionless, best-effort protocol
- Based on 32-bit logical addressing
- Extended by CIDR and NAT to remain viable
- Limited by address exhaustion and lack of built-in security
Yet, it remains:
The operational backbone of today’s internet.
Frequently Asked Questions
If IPv4 is connectionless and best-effort, why is it still reliable enough for everyday use?
IPv4 is reliable as a delivery mechanism, not as an end-to-end reliability system. It provides addressing and routing, while transport protocols like TCP add acknowledgments, retransmissions, and ordering when needed. This separation keeps the network layer simple and scalable, and lets applications choose the level of reliability they actually require.
Why does a /24 network have 254 usable hosts instead of 256?
A /24 contains 256 total addresses because 8 host bits remain. Two addresses are reserved: the all-zeros address identifies the network itself, and the all-ones address is the broadcast address. That leaves 254 assignable host addresses for devices inside that subnet.
What is the practical advantage of CIDR over the old classful system?
CIDR lets network blocks be sized according to actual need instead of fixed Class A, B, or C boundaries. That reduces wasted address space and makes route aggregation possible, so multiple nearby networks can be represented by a single summary route. The result is smaller routing tables and more efficient allocation.
How does longest prefix match work when multiple routes overlap?
Routers compare all matching routes for a destination and choose the one with the most specific prefix, meaning the longest subnet mask. For example, if both /16 and /24 match an IP, the /24 wins because it identifies a narrower range. This is what allows route summaries and specific exceptions to coexist.
Why is IPv4 fragmentation considered inefficient, and when does it become a problem?
Fragmentation adds overhead because each fragment needs its own header, and losing one fragment can force the whole original packet to be discarded. It also increases processing work for routers and hosts. It becomes especially problematic on paths with small MTUs, which is why Path MTU Discovery is preferred.
Why does IPv4 still need ARP if it already has IP addresses?
An IPv4 address identifies the logical destination, but Ethernet and similar link layers deliver frames using MAC addresses. ARP bridges that gap on a local network by resolving an IP address to the correct MAC address before transmission. Without ARP, a host would know where to send logically, but not physically.