Overview

IPv4: Internet Protocol version 4. Purpose: host identification and packet routing in the network layer. Address size: 32 bits, allowing ~4.3 billion unique addresses. Protocol type: connectionless, best-effort delivery. Standard: defined in RFC 791 (1981). Role: primary protocol for internet communication until gradual IPv6 adoption. Mechanisms: addressing, fragmentation, routing, and error handling.

"IPv4 remains the cornerstone protocol of the Internet despite address exhaustion concerns." -- J. Postel

IPv4 Addressing

Address Format

32-bit numeric address, expressed in dotted-decimal notation (four octets). Each octet: 8 bits, range 0-255. Example: 192.168.1.1. Purpose: uniquely identify network interfaces.

Address Types

Unicast: one-to-one communication. Broadcast: one-to-all in subnet. Multicast: one-to-many group communication. Anycast: one-to-nearest (based on routing metrics) among multiple interfaces.

Special Address Ranges

Loopback: 127.0.0.0/8 for self-testing. Private: 10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16 for internal networks. Link-local: 169.254.0.0/16 for automatic addressing when DHCP unavailable.

Header Format

Structure

Minimum 20 bytes length, variable up to 60 bytes with options. Fields: Version, IHL, Type of Service, Total Length, Identification, Flags, Fragment Offset, TTL, Protocol, Header Checksum, Source Address, Destination Address, Options.

Key Fields

Version: 4 for IPv4. IHL: Internet Header Length in 32-bit words. TTL: Time To Live, decremented at each hop, prevents infinite loops. Protocol: indicates upper-layer protocol (TCP=6, UDP=17).

Checksum

Header checksum verifies header integrity. Recalculated at each hop due to TTL decrement. Not calculated over payload.

FieldSize (bits)Description
Version4IP version number
IHL4Header length
Total Length16Packet size in bytes
TTL8Time to live
Protocol8Encapsulated protocol

Packet Structure

Data Encapsulation

IPv4 packet encapsulates upper-layer protocol data units (PDUs). Payload follows header. Packet size max: 65,535 bytes (2^16 -1). Fragmentation required if exceeds link MTU.

Fragmentation Fields

Identification: unique packet ID for fragmentation. Flags: 3 bits, include Don't Fragment (DF) and More Fragments (MF). Fragment Offset: position of fragment in original packet.

Packet Flow

Sender creates packet: header + payload. Router examines destination address, decrements TTL, forwards or drops. Destination reassembles fragments based on ID and offsets.

IPv4 Packet:+-------------------------------+| Header (20-60 bytes) |+-------------------------------+| Payload (Upper-layer data) |+-------------------------------+

Address Classes

Classful Addressing

Legacy method dividing IPv4 into classes A, B, C, D, E. Based on first octet bits. Determines network and host portions.

Class Ranges

ClassFirst Octet RangeDefault Subnet MaskPurpose
A1-126255.0.0.0Large networks
B128-191255.255.0.0Medium networks
C192-223255.255.255.0Small networks
D224-239N/AMulticast
E240-255N/AExperimental/Reserved

Limitations

Classful addressing inefficient, wastes addresses, leads to early exhaustion. Superseded by CIDR in modern networks.

Subnetting

Concept

Divides larger network into smaller subnetworks. Improves routing efficiency and security. Uses custom subnet masks to define network and host bits.

Subnet Mask

32-bit mask, binary ones for network bits, zeros for host bits. Example: 255.255.255.0 masks first 24 bits. Determines subnet size and number of hosts.

Calculation

Number of subnets = 2^n (n = borrowed bits)Number of hosts per subnet = 2^h - 2 (h = host bits)

CIDR Notation

Classless Inter-Domain Routing. Expresses mask as suffix: /24 for 255.255.255.0. Enables flexible allocation, reduces routing table size.

Routing in IPv4

Routing Basics

Packet forwarding based on destination IP. Routers maintain routing tables mapping IP prefixes to next hops. Algorithms: static, dynamic (e.g., RIP, OSPF).

Routing Table Entry

Destination Network | Subnet Mask | Next Hop | Interface | Metric

Longest Prefix Match

Routing decision: select route with longest subnet prefix matching destination IP. Ensures most specific route used.

Default Route

Fallback route for packets with no matching entry. Represented as 0.0.0.0/0.

Fragmentation and Reassembly

Purpose

Fragment packets exceeding link MTU. Allows transmission over networks with smaller payload limits.

Fragmentation Process

Router splits packet into fragments. Each fragment gets copy of header, adjusted length, and offset. Flags indicate more fragments.

Reassembly

Destination uses Identification and Offset fields to reassemble. Timeout discards incomplete fragments. Reassembly only at destination.

Fragmentation Flags

FlagBit PositionMeaning
Reserved0Must be zero
Don't Fragment (DF)1Packet must not be fragmented
More Fragments (MF)2More fragments follow

Network Address Translation (NAT)

Definition

Technique to map private IP addresses to public IP addresses for internet access. Mitigates IPv4 address exhaustion.

Types of NAT

Static NAT: fixed one-to-one mapping. Dynamic NAT: pool of public addresses dynamically assigned. PAT (Port Address Translation): multiple private hosts share single public IP using ports.

Operation

Modifies IP header source/destination addresses and port numbers. Maintains translation table for inbound/outbound traffic correlation.

Dynamic Host Configuration Protocol (DHCP)

Purpose

Automates IPv4 address assignment and network configuration. Eliminates manual IP configuration errors.

Process

Four-step: Discover, Offer, Request, Acknowledge (DORA). Client broadcasts Discover; server offers address; client requests; server acknowledges lease.

Parameters Provided

IP address, subnet mask, default gateway, DNS servers, lease duration.

Security Considerations

Lack of Built-in Security

IPv4 header lacks authentication/encryption. Vulnerable to spoofing, sniffing, and man-in-the-middle attacks.

Mitigation Techniques

Use IPsec for encryption and authentication. Firewalls and filtering at routers. Network Address Translation adds obscurity but not security.

Fragmentation Attacks

Packet fragmentation can be exploited for evasion or denial of service. Requires careful inspection and filtering.

IPv4 Limitations and Transition

Address Exhaustion

32-bit address space insufficient for global demand. Exhausted public IPv4 addresses since early 2010s.

Transition Mechanisms

Dual stack: IPv4 and IPv6 co-exist. Tunneling: IPv6 packets encapsulated in IPv4. Translation gateways: protocol conversion between IPv4 and IPv6.

IPv6 Advantages

128-bit addressing, simplified header, built-in IPsec, improved multicast and autoconfiguration.

References

  • J. Postel, "Internet Protocol," RFC 791, IETF, 1981, pp. 1-72.
  • D. E. Comer, "Internetworking with TCP/IP Vol. 1," Prentice Hall, 2006, pp. 375-410.
  • W. R. Stevens, "TCP/IP Illustrated, Volume 1," Addison-Wesley, 1994, pp. 45-67.
  • R. Hinden, S. Deering, "IP Version 6 Addressing Architecture," RFC 4291, IETF, 2006, pp. 1-29.
  • G. Malkin, "RIP Version 2," RFC 2453, IETF, 1998, pp. 1-37.