Internet Protocol Version 4 (Pv4)
IPv4 (Internet Protocol Version 4) is the 4th version of the Internet Protocol and the foundation of modern internet communication. It provides a unique numerical address to every device connected to a network (computer, mobile, server, router, IoT device, etc.). Without IPv4, devices cannot identify each other and cannot communicate.
IPv4 Address Format
An IPv4 Address is a 32-bit number used to identify devices on a network. It is divided into 4 parts (called Octets) and each octet contains 8 bits.
So any IPv4 address looks like:
A.B.C.D
A - Octer 1
B - Octer 2
C - Octer 3
D - Octer 4
Where A, B, C, and D are numbers between 0–255.
0.0.0.0 → 255.255.255.255
A -> 0 - 255
B -> 0 - 255
C -> 0 - 255
D -> 0 - 255
So we can make addresses like
0.1.2.3
10.0.0.255
255.255.255.255
192.168.1.2
192.168.1.10
Each octet is stored internally as binary (0s and 1s) but shown to users in decimal.
IPv4 address: 192.168.1.10
Binary
192 = 11000000
168 = 10101000
1 = 00000001
10 = 00001010
Full binary form:
11000000.10101000.00000001.00001010
Why 0 to 255?
Because each octet contains 8 bits, and the maximum value of 8 bits is:
11111111 (binary) = 255 (decimal)
The total number of possible IPv4 addresses is:
232= 4,294,967,296 (around 4.3 billion addresses)
IPv4 Address Representation
We can represent IPv4 addresses in two ways:
- Classful Addressing.
- Classless Addressing.
Classful Addressing
Classful addressing is the old method of assigning IPv4 addresses, where the IP space is divided into fixed classes (A, B, C, D, E) based on the first octet. Each class has a fixed default subnet mask, so the network part and host part are decided automatically
IPv4 addresses are divided into five classes (A, B, C, D, and E) to make it easier to organize, manage, and assign the large number of IP addresses available on the internet. Each class has a different range and purpose.
| class | range | mask | usage |
|---|---|---|---|
| Class A | 1 – 126 | 255.0.0.0 | Large networks |
| Class B | 128 – 191 | 255.255.0.0 | Medium networks |
| Class C | 192 – 223 | 255.255.255.0 | Small networks |
| Class D | 224 – 239 | N/A | Reserve for multitasking |
| Class E | 240 – 255 | N/A | Reserved for Research and development |
Classless Addressing (CIDR)
Classless addressing is the modern method of assigning IPv4 addresses, called CIDR (Classless Inter-Domain Routing). In this method, we do not depend on Class A, B, C. Instead, we explicitly specify how many bits are used for the network.
IPv4 address is written as:
Example: 192.168.1.10/24, 10.0.0.5/16, 172.16.5.20/20
Characteristics of IPv4
- Uses a 32-bit address (e.g. 192.168.1.1)
- Written in dotted decimal format (4 octets, each 0–255)
- Total addresses ≈ 2³² ≈ 4.3 billion
- Supports unicast, broadcast, and multicast communication
- Supports classful and classless (CIDR) addressing
- Supports subnetting using subnet mask or prefix (e.g. /24)
- Provides connectionless, best-effort packet delivery (no guarantee)
- IPv4 header size is 20–60 bytes and includes fields like source IP, destination IP, TTL
Advantages of IPv4 Limitations of IPv4
- Easy to Understand and Configure: IPv4 addresses are simple (e.g., 192.168.1.1) and easy for humans and systems to work with.
- Widely Supported: Almost every device, router, OS, and application in the world supports IPv4 by default.
- Efficient Routing with CIDR: Classless addressing (CIDR) reduces routing table size and improves network performance.
- NAT Support (Network Address Translation): Allows many devices to share a single public IP, reducing IP shortages. Example: Home Wi-Fi: 10 devices → 1 Public IP
- Simple Packet Structure: IPv4 has a light header (20 bytes), making routing and packet processing faster.
- Supports Different Types of Addressing: Unicast Broadcast, Multicast.
- Flexible Subnetting: Helps in dividing large networks into smaller, manageable segments.
Limitations of IPv4
- Limited Number of Addresses (≈ 4.29 Billion): Increasing devices caused IPv4 exhaustion → Not enough unique IPs.
- Security Was Not Built-In: IPv4 was designed without: IPsec, Authentication, Encryption. This makes it less secure compared to IPv6.
- No Auto-Configuration (Without DHCP): Devices cannot configure themselves without DHCP, unlike IPv6 (which supports SLAAC).
- Broadcast Traffic Increases Network Load: IPv4 uses broadcast, which creates unnecessary traffic.
- Fragmentation at Routers: IPv4 packets can be fragmented by routers → reduces performance.
- NAT Causes Problems: NAT extends IPs but
- Breaks end-to-end communication
- Causes issues in VoIP, gaming, P2P apps
- Adds overhead on routers