IPv4

IPv4 is Internet Protocol version 4, deployed for production in ARPANET in 1983. The latest IETF standard is defined by RFC 791. It is connectionless, best effort delivery protocol over packet-switched networks. It does not guarantee delivery, nor does it prevent the duplicates or out-of-order packets. It protects its header by a checksum but not the payload. The length of the packet may vary and the original packet may be fragmented if necessary into smaller packets, which in their turn might be further fragmented.

IPv4 packet structure:

Version (4 bits)Header Length (4 bits)!ToS (6 bits)ECN (2 bits)Total Length (16 bits)Id (16 bits)Flags (3 bits)Fragment Offset (13 bits)TTL (8 bits)Protocol (8 bits)Checksum (16 bits)Source IP (32 bits)Destination IP (32 bits)Options (0 - 128 bits)

ECN stands for Explicit Congestion Notification (RFC 3168), must be supported by both ends and only effective if underlying network supports it.

Id is used to identify a group of fragments belonging to the same IP datagram.

Flags are used for the fragmentation as well. Bit 0 is reserved and must to 0. Bit 1, if set, means Don’t Fragment. Bit 2, if set, means More Fragments to follow.

TTL is decremented by each router and the packet is dropped when its TTL = 0 with ICMP Time Exceeded message is usually sent to a sender. This feature is used by traceroute.

IPv4 addresses

Initially the first octet was used as a network identifier and the other 3 octets as host ones. This only allowed 256 networks. Then 5 network classes were defined:

Classes A, B and C are referred as classful networks. The scheme lacked the flexibility and to overcome IPv4 address pool exhaustion, Classless Interdomain Routing (CIDR) was created. It allows subnetworks of any size.

CIDR is managed by Internet Assigned Numbers Authority (IANA) and Regional Internet Registries (RIRs). Each RIR has its own publicly searchable WHOIS database of IP addresses assignments.

Special Addresses

Range Description
0.0.0.0/8Current Network (only valid as a source IP) - RFC 6890
10.0.0.0/8Private network (RFC 1918)
100.64.0.0/10Shared Address Space (RFC 6598)
128.0.0.0/8Loopback (RFC 6890)
169.254.0.0/16Link-local or Auto-configuration IPs (RFC 3927)
172.16.0.0/12Private network (RFC 1918)
192.0.0.0/24IETF Protocol Assignments (RFC 6890)
192.0.2.0/24TEST-NET-1, documentation and examples (RFC 5737)
192.88.99.0/24IPv6 to IPv4 relay (includes 2002::/16) (RFC 3068)
192.168.0.0/16Private network (RFC 1918)
198.18.0.0/15Network benchmark tests (RFC 2544)
198.51.100.0/24TEST-NET-2, documentation and examples RFC 5737)
203.0.113.0/24TEST-NET-3, documentation and examples (RFC 5737)
224.0.0.0/4IP multicast (former Class D network) - RFC 5771
240.0.0.0/4Reserved (former Class E network) - RFC1700
255.255.255.255Broadcast (RFC919)

Address Resolution

There are two types of IP addresses mapping: to 12-bit MAC addresses and to DNS names. ARP and RARP protocols are used for the first type and DNS - for the second.