English

IPv4

Posted on Feb 24, 2025 by
330

What Is IP?

An IP address (Internet Protocol address) is a unique identifier assigned to each device connected to a network that uses the Internet Protocol for communication. It serves two main purposes:

  • Identification: It uniquely identifies devices on the network. The network part remains the same for every host on the network, but the host part must be different.

  • Location Addressing: It indicates the device's location on the network, enabling data routing.

IP is part of the Internet Protocol Suite, which also includes the Transmission Control Protocol. Together, they are referred to as TCP/IP. The Internet Protocol Suite defines the rules for packaging, addressing, transmitting, routing, and receiving data packets on the network.

What Is IPv4?

IPv4, the fourth version of the Internet Protocol, is one of the most widely used protocols today and provides the foundational framework for internet communication. IPv4 uses a 32-bit address to uniquely identify and locate devices, ensuring that data packets are correctly forwarded from one device to another, enabling basic network connectivity and communication. These addresses can also be represented in hexadecimal. The more common format (called dotted decimal or dotted quad) is xxxx, where each "x" can be any value between 0 and 255. For example, 185.107.80.231 is a valid IPv4 address. IPv4 is still responsible for routing most of today's internet traffic. The 32-bit address space limits the number of unique hosts to 2^32, meaning nearly 4.3 billion IPv4 addresses (exactly 4,294,967,296) are available globally.

IPv4

Core Technologies of IPv4

Classification of IPv4

We can distinguish five types of IPv4 addresses: A, B, C, D, and E. Each class has its own range of IP addresses. Let's take a look:

IPv4

  • Class A: The first bit is 0, and the address range is from 0.0.0.0 to 127.255.255.255. This class uses 8 bits for the network portion and 24 bits for the host portion, making it suitable for large networks.

  • Class B: Designed for medium to large networks, the first two bits are 10, and the address range is from 128.0.0.0 to 191.255.255.255. It has 16 bits for both the network and host portions.

  • Class C: This class is used for smaller local area networks (LANs). The network is defined by three octets. The address range is from 192.0.0.0 to 223.255.255.255, with 24 bits for the network and 8 bits for the host.

  • Class D: Used exclusively for multicast purposes, Class D addresses are not used for standard network functions. The first three bits are set to "1", and the fourth bit is set to "0". This class uses a 32-bit network address.

  • Class E: Reserved for experimental or research purposes, the address range spans from 240.0.0.0 to 255.255.255.255. The first four bits are set to binary "1" for Class E IP addresses.

Subnet Mask

A subnet mask is a 32-bit binary number used to divide an IPv4 address into its network and host portions. It works in conjunction with the IP address to form the IP network address, typically represented in the format IP address/subnet mask. By using subnet masks flexibly, you can divide a large network into smaller subnets, enabling efficient management and control of network traffic and security.

IPv4

Classless Inter-Domain Routing (CIDR) offers a flexible method for IP address allocation and routing. It dynamically allocates subnet mask bits as needed, optimizing IP address utilization. CIDR notation is used to indicate the IP address range and its corresponding subnet mask bits. For example, 192.168.1.1/26 represents an IP address range from 192.168.1.0 to 192.168.1.63, with a subnet mask of 255.255.255.192.

IPv4 Packet Structure

An IPv4 packet consists of a header and data (payload). The packet is similar to a physical package or envelope with source and destination addresses written on it. Some fields of the packet resemble delivery types in physical mail, such as first-class, standard, or priority mail. The IPv4 packet header is composed of 14 fields:

IPv4

  • Version: A 4-bit field indicating the version of the IP protocol used in the header. For IPv4, this equals 4.

  • Internet Header Length (IHL): A 4-bit field indicating the length of the header in 32-bit words. The header size depends on the optional 14th field (Options). The minimum value is 5 (160 bits or 20 bytes), and the maximum value is 15 (480 bits or 60 bytes). If the IHL field is greater than 5, the Options field must be considered.

  • Type of Service (ToS) or Differentiated Services (DS): Comprised of two fields that help routers determine the priority of traffic:

  • Total Length: A 16-bit field indicating the total length of the packet in bytes, including both the header and the payload. The minimum size for a packet with only the header is 20 bytes, and the maximum size is 65,535 bytes.

  • Identification: A 16-bit unique identifier for fragments of a single IP packet.

  • Flags: A 3-bit value used to control and identify fragments:

  • Fragment Offset: A 13-bit value that indicates the offset of a specific fragment relative to the start of the original unfragmented IP packet (in bytes). The offset of the first fragment is always 0, and other offsets are multiples of 8 because fragments are specified in 8-byte units. The maximum offset is 65,528 bytes.

  • Time to Live (TTL): An 8-bit value representing the maximum number of hops for the packet. The value is decremented by one each time the packet reaches a router. If TTL reaches 0, the router discards the packet. This prevents packets from endlessly circulating in the network and causing congestion.

  • Protocol: An 8-bit value that defines the protocol used in the packet’s payload.

  • Header Checksum: A 16-bit checksum for the IPv4 header used to detect errors in the header. When the packet reaches a router, the router computes the checksum and compares it with the checksum in the header. If the values do not match, the packet is discarded. Higher-level protocols check the payload when necessary. As the packet reaches the router, it decreases the TTL in the header, requiring a new checksum calculation.

  • Source Address: A 32-bit field identifying the IPv4 address of the packet sender.

  • Destination Address: A 32-bit field identifying the IPv4 address of the packet receiver.

  • Options: This field is rarely used. A common use is to record the route the packet takes to reach its destination or request a specific route to the destination. Also, the IP header must be a multiple of 32 bits. If the Options field is used and the header is not a multiple of 32 bits, the remaining portion of the Options field is padded with 0 bits to create a multiple of 32 bits.

IPv4 Fragmentation

IPv4 supports networks with varying quality, speeds, and MTUs. When transmitting data to networks with smaller MTUs, routers fragment packets by subtracting the IP header size from the MTU. The destination host then reassembles these fragments.

During fragmentation, routers adjust each fragment as follows:

  • Total Length: Updated to reflect the fragment's size.

  • More Fragments (MF) Flag: Set to 1 for all fragments except the last, which is set to 0.

  • Fragment Offset: Indicates the fragment’s position in 8-byte units (e.g., with a 1,600-byte MTU and 20-byte header, offsets would be 0, 200, 400, etc.).

  • Header Checksum: Recalculated for each fragment.

A packet is identified as fragmented if:

  • The MF flag is set to 1 (except for the final fragment).

  • The Fragment Offset field is non-zero.

To reassemble the packet, the receiver uses the source and destination addresses, protocol identifier, and identification field, ordering fragments by their offsets to reconstruct the payload.

Limitations of IPv4

While IPv4 has driven the growth of the Internet, its limitations have become evident as connectivity demands increase:

  • Insufficient Address Space: IPv4’s 32-bit addresses can theoretically provide 4.3 billion unique addresses, but factors like inefficient allocation limit the actual number. With nearly half of IPv4 addresses allocated in the U.S., regions like Europe and Asia-Pacific face shortages, restricting the growth of mobile and broadband technologies.

  • Security Shortcomings: Designed without robust security features, IPv4 cannot ensure end-to-end data protection, posing challenges in today’s cybersecurity landscape.

  • Limited Address Autoconfiguration: IPv4 lacks efficient address autoconfiguration. Network expansion or reconfiguration typically requires manual readdressing, increasing maintenance complexity.

  • Complex Routing Tables: Non-contiguous address allocations prevent route summarization, leading to larger routing tables that consume more memory and reduce forwarding efficiency. Device upgrades are often required to maintain performance.

These limitations have accelerated the adoption of IPv6, which offers enhanced scalability, efficiency, and security to support the future growth of the Internet. For more information, see What Is IPv6?

Videos
Global Delivery Service | FS
01:11
Jun 26, 2024
387
Global Delivery Service | FS