Basics of IPv4 Addressing
Introduction to IPv4 Addressing
IPv4 (Internet Protocol version 4) is a fundamental networking protocol used for identifying and routing packets across networks. It works alongside TCP (Transmission Control Protocol) to establish reliable communication over the internet.
- TCP is an acronym for Transmission Control Protocol.
- IP is an acronym for Internet Protocol.
- IP is a Connection-less
- TCP provides a reliable delivery service.
Difference Between Host and Network Address
- Network Address: Identifies the entire network and is common to all devices within the network.
- Host Address: Uniquely identifies a device within the network.
- Host addresses cannot be all 0’s or all 1’s.
- All 0’s in the host portion represent the network address.
- All 1’s in the host portion represent the broadcast address.
Understanding IP Address Structure
- An IP address is 32 bits long, divided into four octets (8 bits each).
- Each octet has a maximum value of 255.
- An IP address consists of two main components:
- Network ID – Identifies the network segment.
- Host ID – Identifies a specific device within the network.
Classful vs. Classless IP Addressing
Classful IP Addressing
- Uses predefined classes (A, B, C, D, and E) with fixed subnet masks.
- Inefficient use of IP addresses due to fixed allocations.
- Used in legacy networking systems.
Classless IP Addressing (CIDR – Classless Inter-Domain Routing)
- Allows flexible subnetting by using variable-length subnet masks (VLSM).
- Optimizes IP address allocation and reduces waste.
- Used in modern networking.
CIDR Notation and Calculation
CIDR notation represents an IP address along with the number of network bits (prefix length).
- Example: 192.168.1.0/24 means the first 24 bits are the network portion, and the remaining 8 bits are for host addresses.
- Default Subnet Mask in CIDR Notation:
- Class A: /8 → 255.0.0.0
- Class B: /16 → 255.255.0.0
- Class C: /24 → 255.255.255.0
Example of Classful vs. Classless Addressing
- Classful Example: 192.168.1.0/24 (Default subnet mask: 255.255.255.0)
- Classless Example: 192.168.1.0/26 (Custom subnet mask: 255.255.255.192, allowing more subnets but fewer hosts per subnet)
IP Address Classes
There are five classes of IP addresses:
Class |
Address Range |
Default Subnet Mask |
Use Case |
A |
1.0.0.0 – 126.255.255.255 |
255.0.0.0 (/8) |
Large networks |
B |
128.0.0.0 – 191.255.255.255 |
255.255.0.0 (/16) |
Medium-sized networks |
C |
192.0.0.0 – 223.255.255.255 |
255.255.255.0 (/24) |
Small networks |
D |
224.0.0.0 – 239.255.255.255 |
N/A |
Multicasting |
E |
240.0.0.0 – 255.255.255.255 |
N/A |
Experimental |
Private IP Address Ranges
Certain IP ranges are reserved for private networks and cannot be routed on the public internet:
- Class A: 10.0.0.0 – 10.255.255.255
- Class B: 172.16.0.0 – 172.31.255.255
- Class C: 192.168.0.0 – 192.168.255.255
Loopback and Special Addresses
- 127.0.0.0 – 127.255.255.255 is reserved for Loopback testing.
- 0.0.0.0 is used as a default network route.
Default Gateway
- A default gateway is the device that routes traffic from a local network to external networks.
- It is typically assigned to routers within a network.
- Essential for communication between different networks.
- Example:
- PC’s IP Address: 192.168.1.10
- Subnet Mask: 255.255.255.0
- Default Gateway: 192.168.1.1 (Router’s IP Address)
Binary Representation of IP Classes
Class |
Binary Prefix |
A |
0xxxxxxx |
B |
10xxxxxx |
C |
110xxxxx |
D |
1110xxxx |
E |
1111xxxx |
Difference Between Default and Custom Subnet Masks
Default Subnet Mask
- Assigned based on the IP address class.
- Fixed for each class (A, B, and C) and does not allow subnetting.
Custom Subnet Mask
- Allows administrators to break networks into smaller subnets.
- Provides more efficient IP address allocation.
- Uses CIDR notation for flexibility.
Subnet Masking
A subnet mask determines the boundary between the network and host portions of an IP address.
- A subnet mask is always 32 bits long.
- Network bits are represented as 1s, while host bits are represented as 0s.
Default Subnet Masks
Class |
Default Subnet Mask |
A |
255.0.0.0 (/8) |
B |
255.255.0.0 (/16) |
C |
255.255.255.0 (/24) |
Subnet Masking Examples
IP Address |
Class |
Default Subnet Mask |
201.1.1.2 |
C |
255.255.255.0 |
128.3.2.4 |
B |
255.255.0.0 |
172.16.20.1 |
B (Private) |
255.255.0.0 |
12.38.5.2 |
A |
255.0.0.0 |
116.3.2.1 |
A |
255.0.0.0 |
193.6.3.98 |
C |
255.255.255.0 |
IP Addressing in Practice
- Class A supports 128 networks with 16.7 million hosts each.
- Class B supports 16,384 networks with 65,534 hosts each.
- Class C supports 2,097,152 networks with 254 hosts each.
- Class D and E are not used for standard host addressing.
Multicast and Reserved Addressing
- Class D (224.0.0.0 – 239.255.255.255) is used for Multicasting.
- Class E (240.0.0.0 – 255.255.255.255) is reserved for future use.
Conclusion
Understanding IPv4 addressing and subnetting is fundamental for designing and managing networks. Mastering subnet masks, IP classes, and classless addressing helps in efficient IP allocation and routing.