IPv4 is described in IETF publication RFC 791 (September 1981), replacing an earlier definition (RFC 760, January 1980).
IPv4 is a connectionless protocol for use on packet-switched Link Layer networks (e.g., Ethernet). It operates on a best effort delivery model, in that it does not guarantee delivery, nor does it assure proper sequencing or avoidance of duplicate delivery. These aspects, including data integrity, are addressed by an upper layer transport protocol , such as the Transmission Control Protocol (TCP).
|Internet protocol suite|
 AddressingIPv4 uses 32-bit (four-byte) addresses, which limits the address space to 4294967296 (232) addresses. However, some address blocks are reserved for special purposes such as private networks (~18 million addresses) and multicast addresses (~270 million addresses). This reduces the number of addresses that may be allocated for routing on the public Internet. As addresses are assigned to end users, an IPv4 address shortage has been developing. Network addressing changes by classful network design, Classless Inter-Domain Routing, and network address translation (NAT) have contributed to delay significantly the inevitable exhaustion which occurred on February 3, 2011 when IANA allocated the last five blocks to the five regional Internet registries (RIRs).
This limitation stimulated the development of IPv6 in the 1990s, which has been in commercial deployment since 2006.
 Address representationsIPv4 addresses may be written in any notation expressing a 32-bit integer value, but for human convenience, they are most often written in dot-decimal notation, which consists of four octets of the address expressed individually in decimal and separated by periods.
The following table shows several representation formats:
|Notation||Value||Conversion from dot-decimal|
|Dotted Hexadecimal||0xC0.0x00.0x02.0xEB||Each octet is individually converted to hexadecimal form|
|Dotted Octal||0300.0000.0002.0353||Each octet is individually converted into octal|
|Hexadecimal||0xC00002EB||Concatenation of the octets from the dotted hexadecimal|
|Decimal||3221226219||The 32-bit number expressed in decimal|
|Octal||030000001353||The 32-bit number expressed in octal|
 AllocationOriginally, an IP address was divided into two parts, the network identifier represented in the most significant (highest order) octet of the address and the host identifier using the rest of the address. The latter was therefore also called the rest field. This enabled the creation of a maximum of 256 networks. This was quickly found to be inadequate.
To overcome this limit, the high order octet of the addresses was redefined to create a set of classes of networks, in a system which later became known as classful networking. The system defined five classes, Class A, B, C, D, and E. The Classes A, B, and C had different bit lengths for the new network identification. The rest of an address was used as previously to identify a host within a network, which meant that each network class had a different capacity to address hosts. Class D was allocated for multicast addressing and Class E was reserved for future applications.
Starting around 1985, methods were devised to allow IP networks to be subdivided. The concept of the variable-length subnet mask (VLSM) was introduced which allowed flexible subdivision into varying network sizes.
Around 1993, this system of classes was officially replaced with Classless Inter-Domain Routing (CIDR), and the class-based scheme was dubbed classful, by contrast.
CIDR was designed to permit repartitioning of any address space so that smaller or larger blocks of addresses could be allocated to users. The hierarchical structure created by CIDR is managed by the Internet Assigned Numbers Authority (IANA) and the regional Internet registries (RIRs). Each RIR maintains a publicly-searchable WHOIS database that provides information about IP address assignments.
 Special-use addresses
|CIDR address block||Description||Reference|
|0.0.0.0/8||Current network (only valid as source address)||RFC 1700|
|10.0.0.0/8||Private network||RFC 1918|
|172.16.0.0/12||Private network||RFC 1918|
|192.0.0.0/24||Reserved (IANA)||RFC 5735|
|192.0.2.0/24||TEST-NET-1, Documentation and example code||RFC 5735|
|184.108.40.206/24||IPv6 to IPv4 relay||RFC 3068|
|192.168.0.0/16||Private network||RFC 1918|
|198.18.0.0/15||Network benchmark tests||RFC 2544|
|198.51.100.0/24||TEST-NET-2, Documentation and examples||RFC 5737|
|203.0.113.0/24||TEST-NET-3, Documentation and examples||RFC 5737|
|220.127.116.11/4||Multicasts (former Class D network)||RFC 3171|
|240.0.0.0/4||Reserved (former Class E network)||RFC 1700|
 Private networksOf the approximately four billion addresses allowed in IPv4, three ranges of address are reserved for use in private networks. These ranges are not routable outside of private networks and private machines cannot directly communicate with public networks. They can, however, do so through network address translation.
The following are the three ranges reserved for private networks (RFC 1918):
|Name||Address range||Number of addresses||Classful description||Largest CIDR block|
|24-bit block||10.0.0.0–10.255.255.255||16777216||Single Class A||10.0.0.0/8|
|20-bit block||172.16.0.0–172.31.255.255||1048576||Contiguous range of 16 Class B blocks||172.16.0.0/12|
|16-bit block||192.168.0.0–192.168.255.255||65536||Contiguous range of 256 Class C blocks||192.168.0.0/16|
 Virtual private networksPackets with a private destination address are ignored by all public routers. Therefore, it is not possible to communicate directly between two private networks (e.g., two branch offices) via the public Internet. This requires the use of IP tunnels or a virtual private network (VPN).
VPNs establish tunneling connections across the public network such that the endpoints of the tunnel function as routers for packets from the private network. In this routing function the host encapsulates packets in a protocol layer with packet headers acceptable in the public network so that they may be delivered to the opposing tunnel end point where the additional protocol layer is removed and the packet is delivered locally to its intended destination.
Optionally, encapsulated packets may be encrypted to secure the data while it travels over the public network.
 Link-local addressingRFC 5735 defines an address block, 169.254.0.0/16, for the special use in link-local addressing. These addresses are only valid on the link, such as a local network segment or point-to-point connection, that a host is connected to. These addresses are not routable and like private addresses cannot be the source or destination of packets traversing the Internet. Link-local addresses are primarily used for address autoconfiguration (Zeroconf) when a host cannot obtain an IP address from a DHCP server or other internal configuration methods.
When the address block was reserved, no standards existed for mechanisms of address autoconfiguration. Filling the void, Microsoft created an implementation called Automatic Private IP Addressing (APIPA). Due to Microsoft's market power, APIPA has been deployed on millions of machines and has, thus, become a de facto standard in the industry. Many years later, the IETF defined a formal standard for this functionality, RFC 3927, entitled Dynamic Configuration of IPv4 Link-Local Addresses.
 LocalhostThe address range 127.0.0.0–127.255.255.255 (127.0.0.0/8 in CIDR notation) is reserved for localhost communication. Addresses within this range should never appear outside a host computer and packets sent to this address are returned as incoming packets on the same virtual network device (known as loopback).
 Addresses ending in 0 or 255Networks with subnet masks of at least 24 bits, i.e. Class C networks in classful networking, and networks with CIDR prefixes /24 to /32 (255.255.255.0–255.255.255.255) may not have an address ending in 0 or 255.
Classful addressing prescribed only three possible subnet masks: Class A, 255.0.0.0 or /8; Class B, 255.255.0.0 or /16; and Class C, 255.255.255.0 or /24. For example, in the subnet 192.168.5.0/255.255.255.0 (192.168.5.0/24) the identifier 192.168.5.0 commonly is used to refer to the entire subnet. To avoid ambiguity in representation, the address ending in the octet 0 is reserved.
A broadcast address is an address that allows information to be sent to all interfaces in a given subnet, rather than a specific machine. Generally, the broadcast address is found by obtaining the bit complement of the subnet mask and performing a bitwise OR operation with the network identifier. In other words, the broadcast address is the last address in the address range of the subnet. For example, the broadcast address for the network 192.168.5.0 is 192.168.5.255. For networks of size /24 or larger, the broadcast address always ends in 255.
However, this does not mean that every address ending in 0 or 255 cannot be used as a host address. For example, in the case of a /16 subnet 192.168.0.0/255.255.0.0, equivalent to the address range 192.168.0.0–192.168.255.255, the broadcast address is 192.168.255.255. However, one may assign 192.168.1.255, 192.168.2.255, etc. 192.168.0.0 is the network identifier which should not be assigned to an interface, but 192.168.1.0, 192.168.2.0, etc. may be assigned.
In the past, conflict between network addresses and broadcast addresses arose because some software used non-standard broadcast addresses with zeros instead of ones.
In networks smaller than /24, broadcast addresses do not necessarily end with 255. For example, a CIDR subnet 203.0.113.16/28 has the broadcast address 203.0.113.31.
 Address resolutionHosts on the Internet are usually known by names, e.g., www.example.com, not primarily by their IP address, which is used for routing and network interface identification. The use of domain names requires translating, called resolving, them to addresses and vice versa. This is analogous to looking up a phone number in a phone book using the recipient's name.
The translation between addresses and domain names is performed by the Domain Name System (DNS), a hierarchical, distributed naming system which allows for subdelegation of name spaces to other DNS servers. DNS is often described in analogy to the telephone system directory information systems in which subscriber names are translated to telephone numbers.
 Address space exhaustionSince the 1980s it was apparent that the pool of available IPv4 addresses was depleted at a rate that was not initially anticipated in the original design of the network address system. The apparent threat of exhaustion was the motivation for remedial technologies, such as the introduction of classful networks, the creation of Classless Inter-Domain Routing (CIDR) methods, and network address translation (NAT), and finally for the redesign of the Internet Protocol, based on a larger address format (IPv6).
Several market forces have driven the acceleration of IPv4 address exhaustion:
- Rapidly growing number of Internet users
- Always-on devices — ADSL modems, cable modems
- Mobile devices — laptop computers, PDAs, mobile phones
- Network address translation (NAT) is a technology that masquerades an entire, private network with a single public IP address, permitting the use of private addresses within the private network.
- Use of private networks
- Dynamic Host Configuration Protocol (DHCP)
- Name-based virtual hosting of web sites
- Tighter control by regional Internet registries over the allocation of addresses to local Internet registries
- Network renumbering to reclaim large blocks of address space allocated in the early days of the Internet
The accepted and standardized solution is the migration to Internet Protocol Version 6. The address size was increased in IPv6 to 128 bits, providing a vastly increased address space that also allows improved route aggregation across the Internet and offers large subnetwork allocations of a minimum of 264 host addresses to end-users. Migration to IPv6 is in progress but completion is expected to take considerable time.
 Packet structureAn IP packet consists of a header section and a data section.
 HeaderThe IPv4 packet header consists of 14 fields, of which 13 are required. The 14th field is optional (red background in table) and aptly named: options. The fields in the header are packed with the most significant byte first (big endian), and for the diagram and discussion, the most significant bits are considered to come first (MSB 0 bit numbering). The most significant bit is numbered 0, so the version field is actually found in the four most significant bits of the first byte, for example.
|0||Version||Header Length||Differentiated Services Code Point||Explicit Congestion Notification||Total Length|
|64||Time to Live||Protocol||Header checksum|
|96||Source IP Address|
|128||Destination IP Address|
|160||Options ( if Header Length > 5 )|