IPv4 Quick Guide
IPv4 - Quick Guide
Section titled “IPv4 - Quick Guide”IPv4 - Overview
Section titled “IPv4 - Overview”We live in an age dominated by digital technology, where computers and networked devices have fundamentally transformed our lives. The ability to connect these devices allows for the instantaneous sharing of data and information across the globe.
What is a Network?
Section titled “What is a Network?”In computing, a network is a collection of interconnected devices (hosts) that can exchange data. This connection can be established through wired media (like Ethernet cables or fiber optics) or wireless media (like Wi-Fi or cellular data). Networks enable hosts to share resources and communicate. They vary in scale, from a Local Area Network (LAN) in an office, to a Metropolitan Area Network (MAN) across a city, or a Wide Area Network (WAN) spanning countries and continents.
A computer network can be as simple as two devices linked by a cable or as complex as the global Internet, connecting billions of devices. As networks grow, they incorporate various components to achieve their primary goal of data exchange. Here’s a brief overview of key network components:
- Hosts: Devices at the network’s edge that originate or consume data. A host can be a user’s PC, smartphone, a web server, a database server, an IoT device, etc.
- Media: The physical or wireless path for data transmission. Wired media includes copper cables (Twisted Pair, Coaxial) and fiber optic cables. Wireless media uses radio frequencies (e.g., Wi-Fi, Bluetooth, Cellular).
- Hub (Largely Obsolete): A basic Layer-1 device that repeats signals to all connected ports in a LAN segment. Hubs are rarely used today due to inefficiency and collision issues, having been replaced by switches.
- Switch: A Layer-2 device (Data Link Layer) that intelligently forwards data frames only to the destination port based on MAC addresses. Switches are fundamental to modern LANs, providing higher speeds and efficiency than hubs. Some advanced switches (Layer-3 switches) can also perform routing functions.
- Router: A Layer-3 device (Network Layer) that connects different networks and makes routing decisions to forward data packets between them based on IP addresses. Routers form the backbone of the Internet and larger private networks.
- Gateway: A device or software that enables communication between networks using different protocols or addressing schemes. Often, a router acts as a default gateway for hosts in a LAN to reach external networks.
- Firewall: A security device (hardware or software) that monitors and controls incoming and outgoing network traffic based on predefined security rules. Firewalls establish a barrier between a trusted internal network and untrusted external networks (like the Internet).
All network components ultimately facilitate communication between hosts.
Host Addressing
Section titled “Host Addressing”For hosts to communicate, they must be able to identify each other. On a single local network segment (like an Ethernet LAN), hosts can communicate directly using their MAC (Media Access Control) addresses.
A MAC address is a unique 48-bit hardware address burned into the network interface card (NIC) by the manufacturer. While MAC addresses work for local communication, connecting to a host on a different network (e.g., across the internet) requires a logical addressing scheme. This is provided by the Internet Protocol (IP). An IP address is a logical address assigned to each host connected to an IP-based network, enabling unique identification and routing across diverse networks.
IPv4 - OSI Model
Section titled “IPv4 - OSI Model”The International Organization for Standardization (ISO) developed the Open Systems Interconnection (OSI) model. This 7-layer model provides a conceptual framework for how different network protocols and devices should interact to enable communication between systems. Each layer has a specific role, and protocols at each layer handle distinct aspects of the communication process. For example, the Physical layer deals with the tangible aspects of data transmission, such as cables, wireless frequencies, electrical voltages, and encoding of bits.
The OSI Model consists of the following seven layers, from top (user-facing) to bottom (hardware-facing):
- Application Layer (Layer-7): Interacts with user applications (e.g., HTTP for web, SMTP for email).
- Presentation Layer (Layer-6): Handles data formatting, encryption, and compression (e.g., SSL/TLS, JPEG).
- Session Layer (Layer-5): Manages connections (sessions) between applications (e.g., NetBIOS).
- Transport Layer (Layer-4): Provides end-to-end data delivery, segmentation, and reliability (e.g., TCP, UDP).
- Network Layer (Layer-3): Responsible for logical addressing (IP addresses) and routing packets (e.g., IPv4, IPv6). Routers operate here.
- Data Link Layer (Layer-2): Manages physical addressing (MAC addresses) and local network data transfer (e.g., Ethernet, Wi-Fi). Switches operate here.
- Physical Layer (Layer-1): Defines physical and electrical specifications for data transmission (e.g., cables, radio waves, voltages).
Network Layer in Detail
Section titled “Network Layer in Detail”The Network Layer is responsible for delivering data packets from one host to another across different networks. It assigns logical addresses (IP addresses) to hosts for unique identification and determines the paths (routes) packets take to reach their destination. Routers operate at this layer, making decisions to forward packets.
IPv4 - TCP/IP Model
Section titled “IPv4 - TCP/IP Model”Most of the internet and modern networks operate using the TCP/IP protocol suite, also known as the Internet Protocol Suite. It’s a set of communication protocols used for the internet and similar computer networks. While the OSI model is a comprehensive reference, the TCP/IP model is a more practical, descriptive model that predates OSI and aligns more closely with the implementation of internet protocols. It typically has four or five layers, depending on the interpretation.
A common representation of the TCP/IP model and its approximate mapping to the OSI model is as follows:
- Application Layer (TCP/IP): Combines OSI’s Application, Presentation, and Session layers. It includes protocols like HTTP, FTP, SMTP, DNS.
- Transport Layer (TCP/IP): Corresponds to OSI’s Transport Layer. Key protocols are TCP and UDP.
- Internet Layer (TCP/IP): Corresponds to OSI’s Network Layer. Key protocols are IP (IPv4, IPv6), ICMP, and ARP.
- Network Access Layer (or Link Layer) (TCP/IP): Combines OSI’s Data Link and Physical layers. It deals with how data is physically sent through the network, including MAC addresses and device drivers (e.g., Ethernet, Wi-Fi).
The TCP/IP model is designed to be independent of the underlying hardware (Physical Layer technology). This flexibility has allowed it to be implemented across a vast array of network technologies.
Internet Protocol Version 4 (IPv4)
Section titled “Internet Protocol Version 4 (IPv4)”Internet Protocol (IP) is a core protocol in the TCP/IP suite, operating at the Internet Layer (OSI Network Layer). IPv4 is responsible for identifying hosts using a logical addressing scheme and for routing data packets across networks. It provides a ‘best-effort’ delivery service, meaning it doesn’t guarantee packet delivery, order, or integrity; these are typically handled by transport layer protocols like TCP. IPv4 uses a 32-bit logical address.
IPv4 - Packet Structure
Section titled “IPv4 - Packet Structure”IPv4, as a Network Layer protocol, takes data segments from the Transport Layer (e.g., TCP or UDP segments) and encapsulates them into IP packets. This process involves adding an IP header to the Transport Layer data (which becomes the IP payload).
The IP header contains crucial information for delivering the packet. A textual representation of the standard IPv4 header (20 bytes, without options) is often depicted as:
Visualizing the IPv4 Header (Simplified):
Imagine the header as a series of fields. The first row might contain Version, IHL, DSCP, ECN, and Total Length. The second, Identification, Flags, and Fragment Offset. The third, Time To Live, Protocol, and Header Checksum. The fourth is the Source IP Address, and the fifth is the Destination IP Address. If options are present, they follow the Destination Address.
Key fields in the IPv4 header include:
- Version (4 bits): Specifies the IP version, which is 4 for IPv4.
- IHL (Internet Header Length, 4 bits): Length of the IP header in 32-bit words (minimum 5, meaning 20 bytes).
- DSCP (Differentiated Services Code Point, 6 bits): Used for Quality of Service (QoS) to classify packets.
- ECN (Explicit Congestion Notification, 2 bits): Provides notification of network congestion without dropping packets.
- Total Length (16 bits): Length of the entire IP packet (header + payload) in bytes.
- Identification (16 bits): Used to identify fragments of an original IP packet if fragmentation occurs.
- Flags (3 bits): Control flags related to fragmentation (e.g., Don’t Fragment - DF, More Fragments - MF).
- Fragment Offset (13 bits): Indicates where a particular fragment belongs in the original IP packet.
- Time to Live (TTL, 8 bits): Limits the lifespan of a packet. Decremented by each router; if it reaches zero, the packet is discarded to prevent routing loops.
- Protocol (8 bits): Identifies the protocol of the encapsulated data (payload), e.g., TCP (6), UDP (17), ICMP (1).
- Header Checksum (16 bits): A checksum calculated over the header fields to detect errors in the header.
- Source Address (32 bits): The IPv4 address of the sender.
- Destination Address (32 bits): The IPv4 address of the intended receiver.
- Options (variable length): Optional field, used for features like security, route recording, or timestamping. If present, IHL will be greater than 5.
IPv4 - Addressing
Section titled “IPv4 - Addressing”IPv4 supports several addressing modes:
Unicast Addressing Mode:
Section titled “Unicast Addressing Mode:”Data is sent from one source host to a single destination host. The Destination Address field in the IP packet contains the specific 32-bit IP address of the recipient. This is the most common form of IP communication. For example, when your computer requests a webpage from a web server.
Broadcast Addressing Mode:
Section titled “Broadcast Addressing Mode:”Data is sent from one source host to all hosts on a specific network segment. The Destination Address field contains a special broadcast address (e.g., the directed broadcast for a subnet, like 192.168.1.255 for the 192.168.1.0/24 network, or the limited broadcast address 255.255.255.255). All hosts on the targeted network segment are expected to process the packet. Used for services like DHCP discovery or ARP requests.
Multicast Addressing Mode:
Section titled “Multicast Addressing Mode:”Data is sent from one or more sources to a group of interested destination hosts. Hosts join a multicast group by subscribing to a specific multicast IP address (from the Class D range, 224.0.0.0 to 239.255.255.255). Only hosts that have joined the group will process these packets. Used for applications like streaming video/audio to multiple recipients or online gaming.
Every network typically has two reserved IP addresses: one for the network address itself (representing the network, e.g., 192.168.1.0) and one for the broadcast address (representing all hosts in that network, e.g., 192.168.1.255 for a /24 network). These cannot be assigned to individual hosts.
Hierarchical Addressing Scheme
Section titled “Hierarchical Addressing Scheme”IPv4 uses a hierarchical addressing scheme. A 32-bit IP address is divided into two main parts: a network portion (NetID) and a host portion (HostID). This structure allows for efficient routing, as routers primarily look at the network portion to forward packets.
For example, an IP address might be conceptually seen as: Network_Portion.Host_Portion. With subnetting, it can be further refined: Network_Portion.Subnet_Portion.Host_Portion. This hierarchy enables a large network to be broken down into smaller, manageable sub-networks.
Subnet Mask
Section titled “Subnet Mask”A subnet mask is a 32-bit number used to distinguish the network portion from the host portion of an IP address. Routers and hosts use the subnet mask to determine if a destination IP address is on the local network or a remote network. When an IP address is logically ANDed with its subnet mask, the result is the network address.
Example: IP Address: 192.168.1.152, Subnet Mask: 255.255.255.0
In binary:
IP Address: 11000000.10101000.00000001.10011000
Subnet Mask: 11111111.11111111.11111111.00000000
AND Result (Network Address): 11000000.10101000.00000001.00000000 (which is 192.168.1.0)
This indicates that 192.168.1.0 is the network address, and .152 is the host portion on that network. The subnet mask 255.255.255.0 is often represented in CIDR notation as /24, meaning the first 24 bits are for the network portion.
Binary Representation
Section titled “Binary Representation”An IPv4 address is 32 bits long, commonly written as four decimal numbers (octets) separated by dots (e.g., 192.168.1.1). Each octet is 8 bits. To convert an octet from binary to decimal, sum the positional values of the bits set to ‘1’.
The positional values in an 8-bit octet (from left, Most Significant Bit, to right, Least Significant Bit) are: 128, 64, 32, 16, 8, 4, 2, 1.
Example: Binary octet 11000000. The ‘1’s are in the 128 and 64 positions. So, 128 + 64 = 192.
Example: Binary octet 10101000. 128 + 0 + 32 + 0 + 8 + 0 + 0 + 0 = 168.
Some common patterns: 00000000 = 0; 11111111 = 255; 10000000 = 128; 00000001 = 1.
IPv4 - Address Classes (Historical Context)
Section titled “IPv4 - Address Classes (Historical Context)”Historically, IPv4 addresses were divided into five classes (A, B, C, D, E), determined by the first few bits of the first octet. While classful addressing is largely superseded by Classless Inter-Domain Routing (CIDR), understanding classes provides historical context and helps in understanding some older network configurations or reserved ranges.
The Internet Corporation for Assigned Names and Numbers (ICANN), through its IANA function and Regional Internet Registries (RIRs), manages IP address allocation.
The first octet is the leftmost in the dotted-decimal notation (e.g., in A.B.C.D, ‘A’ is the first octet).
Key characteristics of historical classes (before CIDR became dominant):
- Two IP addresses in each assignable network (the network address itself and the broadcast address) cannot be assigned to hosts.
Class A Address
Section titled “Class A Address”First bit of the first octet is ‘0’. Range: 1.0.0.0 to 126.255.255.255. (0.x.x.x is reserved, 127.x.x.x is loopback). Default subnet mask: 255.0.0.0 (/8). Designed for very large networks with many hosts. Network format: 0NNNNNNN.HHHHHHHH.HHHHHHHH.HHHHHHHH (N=Network, H=Host).
Class B Address
Section titled “Class B Address”First two bits of the first octet are ‘10’. Range: 128.0.0.0 to 191.255.255.255. Default subnet mask: 255.255.0.0 (/16). For medium to large-sized networks. Network format: 10NNNNNN.NNNNNNNN.HHHHHHHH.HHHHHHHH.
Class C Address
Section titled “Class C Address”First three bits of the first octet are ‘110’. Range: 192.0.0.0 to 223.255.255.255. Default subnet mask: 255.255.255.0 (/24). For small networks. Network format: 110NNNNN.NNNNNNNN.NNNNNNNN.HHHHHHHH.
Class D Address
Section titled “Class D Address”First four bits of the first octet are ‘1110’. Range: 224.0.0.0 to 239.255.255.255. Reserved for IP Multicasting. There’s no concept of a subnet mask or network/host portions in the same way as Classes A, B, C for unicast.
Class E Address
Section titled “Class E Address”First four bits of the first octet are ‘1111’. Range: 240.0.0.0 to 255.255.255.255 (255.255.255.255 is a broadcast address). Reserved for experimental/future use; not used on the public internet.
Note: Classful addressing’s rigid structure led to inefficient IP address use. CIDR was introduced to allow for more flexible allocation.
IPv4 - Subnetting with CIDR
Section titled “IPv4 - Subnetting with CIDR”Classful addressing had fixed subnet masks for each class, leading to a predefined number of networks and hosts. This often resulted in wasted IP addresses. Classless Inter-Domain Routing (CIDR) was introduced to provide more flexibility. CIDR allows network administrators to ‘borrow’ bits from the host portion of an IP address to create more network bits, effectively creating smaller sub-networks (subnets) within a larger allocated block. This is denoted by a slash followed by the number of bits in the network prefix (e.g., 192.168.1.0/24).
Subnetting allows a single IP address block (like a traditional Class A, B, or C range, or a CIDR block) to be divided into multiple smaller, manageable logical networks. This improves network organization, security, and traffic management.
How CIDR Subnetting Works:
Section titled “How CIDR Subnetting Works:”With CIDR, you specify the network prefix length. For example, a /25 network has 25 bits for the network portion and 32 - 25 = 7 bits for the host portion. This allows for 2^7 - 2 = 126 usable host addresses.
Example: Subnetting a /24 network (e.g., 192.168.1.0/24, which has 254 usable hosts):
- If we want to create two subnets, we can borrow 1 bit from the host portion, making the prefix /25. This creates two /25 subnets: 192.168.1.0/25 (hosts 1-126) and 192.168.1.128/25 (hosts 129-254). Each /25 subnet has 2^(32-25) - 2 = 126 usable host IPs. The subnet mask becomes 255.255.255.128.
- If we borrow 2 bits, making the prefix /26, we create four /26 subnets. Each /26 subnet has 2^(32-26) - 2 = 62 usable host IPs. The subnet mask becomes 255.255.255.192. The subnets would be 192.168.1.0/26, 192.168.1.64/26, 192.168.1.128/26, and 192.168.1.192/26.
The number of subnets created by borrowing ‘n’ bits is 2^n. The number of hosts per subnet with ‘h’ host bits is 2^h - 2 (subtracting the network address and the broadcast address).
Representing Subnet Masks:
Instead of full subnet mask tables from classful days, CIDR uses prefix lengths. Here are some common examples for what were traditionally Class C ranges:
- /24: 255.255.255.0 (1 subnet, 254 hosts)
- /25: 255.255.255.128 (2 subnets, 126 hosts each)
- /26: 255.255.255.192 (4 subnets, 62 hosts each)
- /27: 255.255.255.224 (8 subnets, 30 hosts each)
- /28: 255.255.255.240 (16 subnets, 14 hosts each)
- /29: 255.255.255.248 (32 subnets, 6 hosts each)
- /30: 255.255.255.252 (64 subnets, 2 hosts each - typically for point-to-point links)
Remember, the first IP in a subnet is the network ID, and the last is the broadcast IP; neither can be assigned to hosts. A /31 prefix (1 host bit) is a special case used for point-to-point links where only two IPs are needed (RFC 3021), and a /32 prefix refers to a single host IP address.
For further practice, online subnet calculators and tutorials can be very helpful. Search for ‘CIDR subnetting examples’ or ‘IP subnet calculator’.
IPv4 - Variable Length Subnet Masking (VLSM)
Section titled “IPv4 - Variable Length Subnet Masking (VLSM)”Variable Length Subnet Masking (VLSM) is a technique that allows network administrators to subnet an IP address space using different subnet masks for different subnets. This is an advancement over older fixed-length subnetting methods (associated with pure classful thinking) where all subnets had to be the same size. VLSM, which is inherent in how CIDR works, enables much more efficient use of IP addresses by tailoring subnet sizes to specific needs.
Consider an administrator with the network block 192.168.1.0/24. They need to allocate IPs for departments with varying host counts: Sales (100 computers), Purchase (50 computers), Accounts (25 computers), and Management (5 computers). Using a single fixed subnet size for all would be wasteful.
VLSM allows for optimized allocation:
Step 1: Determine Host Requirements and Sort
Section titled “Step 1: Determine Host Requirements and Sort”List requirements in descending order of hosts needed (plus room for growth):
- Sales: 100 hosts (needs at least 126 available IPs, so a /25 subnet)
- Purchase: 50 hosts (needs at least 62 available IPs, so a /26 subnet)
- Accounts: 25 hosts (needs at least 30 available IPs, so a /27 subnet)
- Management: 5 hosts (needs at least 6 available IPs, so a /29 subnet)
Step 2: Allocate Largest Subnet First
Section titled “Step 2: Allocate Largest Subnet First”From the 192.168.1.0/24 block, allocate the largest requirement first.
Sales (100 hosts): Assign 192.168.1.0/25. This subnet uses IPs from 192.168.1.0 to 192.168.1.127. Network ID: 192.168.1.0. Broadcast ID: 192.168.1.127. Usable IPs: 192.168.1.1 - 192.168.1.126. Subnet mask: 255.255.255.128.
Remaining address space: 192.168.1.128 to 192.168.1.255.
Step 3: Allocate Next Largest Subnet
Section titled “Step 3: Allocate Next Largest Subnet”Purchase (50 hosts): From the remaining block (starting at 192.168.1.128), assign 192.168.1.128/26. This subnet uses IPs from 192.168.1.128 to 192.168.1.191. Network ID: 192.168.1.128. Broadcast ID: 192.168.1.191. Usable IPs: 192.168.1.129 - 192.168.1.190. Subnet mask: 255.255.255.192.
Remaining address space: 192.168.1.192 to 192.168.1.255.
Step 4: Allocate Next Largest Subnet
Section titled “Step 4: Allocate Next Largest Subnet”Accounts (25 hosts): From the remaining block (starting at 192.168.1.192), assign 192.168.1.192/27. This subnet uses IPs from 192.168.1.192 to 192.168.1.223. Network ID: 192.168.1.192. Broadcast ID: 192.168.1.223. Usable IPs: 192.168.1.193 - 192.168.1.222. Subnet mask: 255.255.255.224.
Remaining address space: 192.168.1.224 to 192.168.1.255.
Step 5: Allocate Smallest Subnet
Section titled “Step 5: Allocate Smallest Subnet”Management (5 hosts): From the remaining block (starting at 192.168.1.224), assign 192.168.1.224/29. This subnet uses IPs from 192.168.1.224 to 192.168.1.231. Network ID: 192.168.1.224. Broadcast ID: 192.168.1.231. Usable IPs: 192.168.1.225 - 192.168.1.230. Subnet mask: 255.255.255.248.
Remaining address space: 192.168.1.232 to 192.168.1.255 (which could be further subnetted or reserved).
VLSM, a core part of CIDR, minimizes IP address wastage by fitting subnet sizes to actual needs, unlike older fixed-size subnetting approaches.
IPv4 - Reserved Addresses
Section titled “IPv4 - Reserved Addresses”Certain IPv4 address ranges are reserved for special purposes and are not routable on the public internet. Using these addresses appropriately is crucial for network functionality and security.
Private IP Addresses (RFC 1918)
Section titled “Private IP Addresses (RFC 1918)”These ranges are designated for use within private networks (e.g., homes, offices, organizations) and are not unique globally. Routers on the public internet are configured to drop packets with private source or destination addresses. This allows organizations to use these IPs internally without needing globally unique addresses for every device.
The private IP address ranges are:
- 10.0.0.0 to 10.255.255.255 (10.0.0.0/8 prefix)
- 172.16.0.0 to 172.31.255.255 (172.16.0.0/12 prefix)
- 192.168.0.0 to 192.168.255.255 (192.168.0.0/16 prefix)
To communicate with the internet, devices using private IPs typically go through a Network Address Translation (NAT) device (often a router), which translates the private IP to a public IP, or use a proxy server.
Private addressing significantly reduced the demand for globally unique IPv4 addresses, helping to delay IPv4 address exhaustion. Organizations can choose a range based on their size and subnet it further internally.
Loopback IP Addresses
Section titled “Loopback IP Addresses”The range 127.0.0.0 to 127.255.255.255 (127.0.0.0/8 prefix) is reserved for loopback. The most commonly used loopback address is 127.0.0.1, often named ‘localhost’. When a host sends a packet to a loopback address, the operating system routes it back to the same host’s IP stack without sending it out on the network. This is used for testing network applications on a single machine (client and server on the same host) and to verify if the TCP/IP stack is functioning correctly.
Link-local Addresses (APIPA)
Section titled “Link-local Addresses (APIPA)”The range 169.254.0.0 to 169.254.255.255 (169.254.0.0/16 prefix) is reserved for link-local addressing, often known as Automatic Private IP Addressing (APIPA) in Windows environments (RFC 3927). If a host is configured for DHCP but cannot reach a DHCP server, it may automatically assign itself an IP address from this range. This allows devices on the same local network segment to communicate without manual IP configuration or a DHCP server, but these addresses are not routable and cannot be used to access the internet.
Other reserved ranges exist, such as those for documentation (RFC 5737) or multicast (Class D). For detailed lists, search for ‘IANA IPv4 Special-Purpose Address Registry’.
IPv4 - Example Communication Flow
Section titled “IPv4 - Example Communication Flow”This section illustrates how devices typically communicate on an IPv4 network.
Packet Flow in a Network
Section titled “Packet Flow in a Network”Hosts on an IPv4 network use unique IP addresses. When a host wants to send data to another host on the SAME local network, it needs the destination host’s physical (MAC) address. It uses Address Resolution Protocol (ARP): the source host broadcasts an ARP request containing the destination IP, asking ‘Who has this IP address? Tell me your MAC address.’ The host with that IP replies with its MAC address. The sender then sends the data encapsulated in frames with the destination MAC address.
If the destination IP is on a DIFFERENT network, the source host sends the packet to its configured default gateway (usually a router). The source host ARPs for the gateway’s MAC address if unknown. The gateway then routes the packet towards the destination network.
Key Protocols and Services Involved:
- MAC Address: A 48-bit hardware address, unique to each network interface, used for Layer 2 communication on a local segment.
- ARP (Address Resolution Protocol): Resolves an IP address to a MAC address on the local network.
- Proxy Server (Less common for general browsing today, but still used): An intermediary server that acts on behalf of clients. Historically used for web access control and caching. Modern security often uses transparent proxies or web gateways.
- DHCP (Dynamic Host Configuration Protocol): Automatically assigns IP addresses and other network configuration (subnet mask, gateway, DNS servers) to hosts, simplifying network administration.
- DNS (Domain Name System): Translates human-readable domain names (e.g., www.example.com) into IP addresses that computers use to connect.
- NAT (Network Address Translation): Allows multiple devices in a private network (using private IPs) to share one or a few public IP addresses to access the internet. Crucial for IPv4 address conservation.
Example Scenario: Accessing www.TutorialsPoint.com
A user wants to access www.TutorialsPoint.com from their PC connected to a home/office network with an internet connection.
Step 1: Acquiring an IP Address (DHCP)
Section titled “Step 1: Acquiring an IP Address (DHCP)”PC boots up and broadcasts a DHCPDISCOVER message. A DHCP server on the local network (often integrated into the router) responds with a DHCPOFFER (IP address, lease time, gateway IP, DNS server IP). PC sends a DHCPREQUEST for the offered IP. DHCP server confirms with a DHCPACK. Now the PC has an IP configuration. (Alternatively, static IP configuration can be used).
Step 2: DNS Query
Section titled “Step 2: DNS Query”User types www.w3.com into a browser. The PC needs the IP address for this domain. It sends a DNS query to the configured DNS server (obtained via DHCP). The DNS server (or a series of DNS servers) resolves the domain name and returns the corresponding IP address (e.g., 93.184.216.34 - this is an example IP).
Step 3: Establishing Connection (ARP and Routing)
Section titled “Step 3: Establishing Connection (ARP and Routing)”The PC determines the destination IP (e.g., 93.184.216.34) is on a remote network. It needs to send the packet to its default gateway. If the gateway’s MAC address isn’t in the PC’s ARP cache, the PC sends an ARP request for the gateway’s IP address. The gateway responds with its MAC address. The PC then creates an IP packet with its own IP as source, 93.184.216.34 as destination. This IP packet is encapsulated in an Ethernet frame with the PC’s MAC as source MAC and the gateway’s MAC as destination MAC. The packet is sent to the gateway.
The gateway router receives the frame, de-encapsulates the IP packet, checks its routing table, and forwards the packet to the next-hop router towards the destination. This process repeats across multiple routers on the internet. If NAT is involved at the user’s gateway, the source IP of the packet is translated from the private IP to the gateway’s public IP before being sent to the internet.
Throughout its journey across the internet, the source and destination IP addresses in the IP packet generally remain the same. However, the Layer 2 source and destination MAC addresses change at each hop (router to router).
IPv4 - Summary and Future Outlook
Section titled “IPv4 - Summary and Future Outlook”IPv4, with its 32-bit address space, was designed to allocate approximately 4.3 billion unique addresses. In the early days of the internet, this seemed like an ample supply. However, the explosive growth of internet users and internet-connected devices (PCs, smartphones, servers, IoT devices) has led to the exhaustion of available IPv4 addresses.
Global IPv4 address allocation is managed by the Internet Assigned Numbers Authority (IANA), which distributes blocks to Regional Internet Registries (RIRs). These RIRs then assign addresses to ISPs and large organizations in their respective regions. All RIRs have largely depleted their pools of freely available IPv4 addresses.
Measures to mitigate IPv4 exhaustion included:
- Private IP Addresses (RFC 1918): Allowing internal use of non-unique addresses, reducing public IP demand.
- NAT (Network Address Translation): Enabling multiple devices to share a single public IP address.
- Reclamation of unused public IP address blocks.
Despite these measures, the fundamental limitation is the 32-bit address space.
The Long-Term Solution: Internet Protocol v6 (IPv6)
Section titled “The Long-Term Solution: Internet Protocol v6 (IPv6)”The Internet Engineering Task Force (IETF) developed IPv6 to address the limitations of IPv4, primarily the address shortage. IPv6 uses a 128-bit address space, providing a virtually inexhaustible number of unique IP addresses (approximately 3.4 x 10^38 addresses). IPv6 also includes other improvements like simplified header formats, better support for security (IPsec is mandatory), and enhanced Quality of Service features.
Transitioning the entire internet from IPv4 to IPv6 is a gradual and complex process. For many years, IPv4 and IPv6 will coexist. Several mechanisms facilitate this coexistence and transition:
- Dual Stack: Devices and networks run both IPv4 and IPv6 protocol stacks simultaneously.
- Tunneling: Encapsulating IPv6 packets within IPv4 packets to traverse IPv4-only networks (e.g., 6to4, Teredo, ISATAP) or vice-versa.
- Translation Mechanisms: Allowing IPv6-only hosts to communicate with IPv4-only hosts/services (e.g., NAT64 in conjunction with DNS64).
While IPv4 will remain relevant for some time, the future of the internet is increasingly reliant on IPv6 adoption.