IPv4: Wikis


Note: Many of our articles have direct quotes from sources you can cite, within the Wikipedia article! This article doesn't yet, but we're working on it! See more info or our list of citable articles.


From Wikipedia, the free encyclopedia

Internet Protocol version 4 (IPv4) is the fourth revision in the development of the Internet Protocol (IP) and it is the first version of the protocol to be widely deployed. Together with IPv6, it is at the core of standards-based internetworking methods of the Internet. IPv4 is still by far the most widely deployed Internet Layer protocol, as IPv6 is still in its infancy of deployment.

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 avoid duplicate delivery. These aspects, including data integrity, are addressed by an upper layer transport protocol (e.g., Transmission Control Protocol).

The Internet Protocol Suite
Application Layer
BGP · DHCP · DNS · FTP · GTP · HTTP · IMAP · IRC · Megaco · MGCP · NNTP · NTP · POP · RIP · RPC · RTP · RTSP · SDP · SIP · SMTP · SNMP · SOAP · SSH · Telnet · TLS/SSL · XMPP · (more)
Transport Layer
TCP · UDP · DCCP · SCTP · RSVP · ECN · OSPF · (more)
Internet Layer
IP (IPv4, IPv6) · ICMP · ICMPv6 · IGMP · IPsec · (more)
Link Layer
ARP/InARP · NDP · Tunnels (L2TP) · PPP · Media Access Control (Ethernet, DSL, ISDN, FDDI) · (more)



IPv4 uses 32-bit (four-byte) addresses, which limits the address space to 4,294,967,296 (232) possible unique addresses. However, some are reserved for special purposes such as private networks (~18 million addresses) or multicast addresses (~270 million addresses). This reduces the number of addresses that can potentially be allocated for routing on the public Internet. As addresses are being incrementally delegated to end users, an IPv4 address shortage has been developing, however network addressing architecture redesign via classful network design, Classless Inter-Domain Routing, and network address translation (NAT) has significantly delayed the inevitable exhaustion.

This limitation has stimulated the development of IPv6, which is currently in the early stages of deployment, and is the only long-term solution.

Address representations

IPv4 addresses are usually written in dot-decimal notation, which consists of the four octets of the address expressed in decimal and separated by periods. This is the base format used in the conversion in the following table:

Notation Value Conversion from dot-decimal
Dot-decimal notation N/A
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

Most of these formats should work in all browsers. Additionally, in dotted format, each octet can be of any of the different bases. For example, 192.0x00.0002.235 is a valid (though unconventional) equivalent to the above addresses.

A final form is not really a notation since it is rarely written in an ASCII string notation. That form is a binary form of the hexadecimal notation in binary. This difference is merely the representational difference between the string "0xCF8E83EB" and the 32-bit integer value 0xCF8E83EB. This form is used for assigning the source and destination fields in a software program.


Classful IP addressing

Originally, 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. Quickly this was 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 for allocated for multicast addressing and Class E was reserved for future applications.

Classless IP addressing


Around 1985, Subnets were introduced to allow classful network to be subdivided


Around 1987 , Variable Length Subnet mask (VLSM) was introduced . VLSM is used to implement subnets of different sizes . [1] [2]

CIDR and Supernetting

Around 1993, Classless Inter-Domain Routing was introduced. CIDR is used to implement supernetting.[3] Supernetting allow route aggregation[4]. CIDR introduced prefix notation which is also known as CIDR notation. Prefix/CIDR notation is now used in the three cases of classless IP addressing: subnetting, VLSM/subnets of different sizes, CIDR/supernetting.

The original system of IP adresses classes was replaced with (CIDR), and the class-based scheme was dubbed classful, by contrast. CIDR's primary advantage is to allow repartitioning of any address space so that smaller or larger blocks of addresses may be allocated to users.

The hierarchical structure created by CIDR and overseen by the Internet Assigned Numbers Authority (IANA) and its Regional Internet Registries (RIRs), manages the assignment of Internet addresses worldwide. Each RIR maintains a publicly-searchable WHOIS database that provides information about IP address assignments; information from these databases plays a central role in numerous tools that attempt to locate IP addresses geographically.

Special-use addresses

Reserved address blocks
CIDR address block Description Reference Current network (only valid as source address) RFC 1700 Private network RFC 1918 Loopback RFC 5735 Link-Local RFC 3927 Private network RFC 1918 Reserved (IANA) RFC 5735 TEST-NET-1, Documentation and example code RFC 5735 IPv6 to IPv4 relay RFC 3068 Private network RFC 1918 Network benchmark tests RFC 2544 TEST-NET-2, Documentation and examples RFC 5737 TEST-NET-3, Documentation and examples RFC 5737 Multicasts (former Class D network) RFC 3171 Reserved (former Class E network) RFC 1700 Broadcast RFC 919

Private networks

Of the approximately four billion addresses allowed in IPv4, three ranges of address are reserved for private networking use. 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– 16,777,216 Single Class A
20-bit block– 1,048,576 16 contiguous Class B blocks
16-bit block– 65,536 Contiguous range of 256 class C blocks

Virtual private networks

Packets addressed with private addresses are deliberately ignored by all public routers. Therefore, it is not possible to communicate between two private networks (e.g., two branch offices) via the public Internet without special facilities. This is accomplished with virtual private networks (VPNs).

VPNs establish tunneling connections across the public network such that the endpoints of the tunnel function as routers for private network packets. These routers encapsulate or package the privately addressed packets with headers in the routable public network so that they can be delivered to the opposing router, at the other end of the tunnel, via the public network and stripped of their public addressing headers and delivered locally to the destination.

Optionally, the encapsulated packet can be encrypted to secure the data while it travels over the public network.

Link-local addressing

RFC 5735 defines an address block,, 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.


The address range– ( 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 255

It is a common misunderstanding that addresses ending in 255 or 0 can never be assigned to hosts. This is only true of networks with subnet masks of at least 24 bits — Class C networks in the old classful addressing scheme, or in CIDR, networks with masks of /24 to /32 (or–

In classful addressing (now obsolete with the advent of CIDR), there are only three possible subnet masks: Class A, or /8; Class B, or /16; and Class C, or /24. For example, in the subnet (or the identifier refers to the entire subnet, so it cannot also refer to an individual device in that subnet.

A broadcast address is an address that allows information to be sent to all machines on 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 range belonging to the subnet. In our example, the broadcast address would be, so to avoid confusion this address also cannot be assigned to a host. On a Class A, B, or C subnet, the broadcast address always ends in 255.

However, this does not mean that every addresses ending in 255 cannot be used as a host address. For example, in the case of a Class B subnet (or, equivalent to the address range–, the broadcast address is However, one can assign,, etc. (though this can cause confusion). Also, is the network identifier and so cannot be assigned, but,, etc. can be assigned (though this can also cause confusion).

With the advent of CIDR, broadcast addresses do not necessarily end with 255.

In general, the first and last addresses in a subnet are used as the network identifier and broadcast address, respectively. All other addresses in the subnet can be assigned to hosts on that subnet.

Address resolution

Hosts on the Internet are usually known not by IP addresses, but by names (e.g., www.wikipedia.org, www.whitehouse.gov, www.freebsd.org, www.berkeley.edu). The routing of IP packets across the Internet is not directed by such names, but by the numeric IP addresses assigned to such domain names. This requires translating (or resolving) domain names to addresses.

The Domain Name System (DNS) provides such a system for converting names to addresses and addresses to names. Much like CIDR addressing, the DNS naming is also hierarchical and allows for subdelegation of name spaces to other DNS servers.

The domain name system is often described in analogy to the telephone system directory information systems in which subscriber names are translated to telephone numbers.

Address space exhaustion

Since the 1980s it has been apparent that the number of available IPv4 addresses is being exhausted at a rate that was not initially anticipated in the design of the network.[citation needed] This was the driving factor for the introduction of classful networks, for the creation of CIDR addressing, and finally for the redesign of the Internet Protocol, based on a larger address format (IPv6).

Today, there are several driving forces for the acceleration of IPv4 address exhaustion[citation needed]:

The accepted and standardized solution is the migration to IPv6. The address size jumps dramatically from 32 bits to 128 bits, providing a vastly increased address space that allows improved route aggregation across the Internet and offers large subnet allocations of a minimum of 264 host addresses to end-users. Migration to IPv6 is in progress but is expected to take considerable time.

Methods to mitigate the IPv4 address exhaustion are:

As of April 2008, predictions of exhaustion date of the unallocated IANA pool seem to converge to between February 2010[5] and May 2011[6]

Network address translation

The rapid pace of allocation of the IPv4 addresses and the resulting shortage of address space since the early 1990s led to several methods of more efficient use. One method was the introduction of network address translation (NAT). NAT devices masquerade an entire, private network 'behind' a single public IP address, permitting the use of private addresses within the private network. Most mass-market consumer Internet access providers rely on this technique.

Packet structure

An IP packet consists of a header section and a data section.


The IPv4 packet header consists of 13 fields, of which 12 are required. The 13th 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. 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.

bit offset 0–3 4–7 8–15 16–18 19–31
0 Version Header length Differentiated Services Total Length
32 Identification Flags Fragment Offset
64 Time to Live Protocol Header Checksum
96 Source Address
128 Destination Address
160 Options ( if Header Length > 5 )
The first header field in an IP packet is the four-bit version field. For IPv4, this has a value of 4 (hence the name IPv4).
Internet Header Length (IHL) 
The second field (4 bits) is the Internet Header Length (IHL) telling the number of 32-bit words in the header. Since an IPv4 header may contain a variable number of options, this field specifies the size of the header (this also coincides with the offset to the data). The minimum value for this field is 5 (RFC 791), which is a length of 5×32 = 160 bits. Being a 4-bit value, the maximum length is 15 words (15×32 bits) or 480 bits.
Differentiated Services (DS)
Originally defined as the TOS field, this field is now defined by RFC 2474 for Differentiated services (DiffServ) and by RFC 3168 for Explicit Congestion Notification (ECN), matching IPv6. New technologies are emerging that require real-time data streaming and therefore will make use of the DS field. An example is Voice over IP (VoIP) that is used for interactive data voice exchange.
The original intention of the Type of Services (TOS) field was for a sending host to specify a preference for how the datagram would be handled as it made its way through an internet. For instance, one host could set its IPv4 datagrams' TOS field value to prefer low delay, while another might prefer high reliability. In practice, the TOS field was not widely implemented. However, a great deal of experimental, research and deployment work has focused on how to make use of these eight bits, resulting in the current DS field definition.
As defined in RFC 791, the following eight bits were allocated to a Type of Service (TOS) field:
  • bits 0–2: Precedence (111 - Network Control, 110 - Internetwork Control, 101 - CRITIC/ECP, 100 - Flash Override, 011 - Flash, 010 - Immediate, 001 - Priority, 000 - Routine)
  • bit 3: 0 = Normal Delay, 1 = Low Delay
  • bit 4: 0 = Normal Throughput, 1 = High Throughput
  • bit 5: 0 = Normal Reliability, 1 = High Reliability
  • bit 6: 0 = Normal Cost, 1 = Minimize Monetary Cost (defined by RFC 1349)
  • bit 7: never defined
Total Length 
This 16-bit field defines the entire datagram size, including header and data, in bytes. The minimum-length datagram is 20 bytes (20-byte header + 0 bytes data) and the maximum is 65,535 — the maximum value of a 16-bit word. The minimum size datagram that any host is required to be able to handle is 576 bytes, but most modern hosts handle much larger packets. Sometimes subnetworks impose further restrictions on the size, in which case datagrams must be fragmented. Fragmentation is handled in either the host or packet switch in IPv4 (see Fragmentation and reassembly).
This field is an identification field and is primarily used for uniquely identifying fragments of an original IP datagram. Some experimental work has suggested using the ID field for other purposes, such as for adding packet-tracing information to datagrams in order to help trace back datagrams with spoofed source addresses.
A three-bit field follows and is used to control or identify fragments. They are (in order, from high order to low order):
  • Reserved; must be zero. As an April Fools joke, proposed for use in RFC 3514 as the "Evil bit".
  • Don't Fragment (DF)
  • More Fragments (MF)
If the DF flag is set and fragmentation is required to route the packet then the packet will be dropped. This can be used when sending packets to a host that does not have sufficient resources to handle fragmentation.
When a packet is fragmented all fragments have the MF flag set except the last fragment, which does not have the MF flag set. The MF flag is also not set on packets that are not fragmented — an unfragmented packet is its own last fragment.
Fragment Offset 
The fragment offset field, measured in units of eight-byte blocks, is 13 bits long and specifies the offset of a particular fragment relative to the beginning of the original unfragmented IP datagram. The first fragment has an offset of zero. This allows a maximum offset of (213 – 1) × 8 = 65,528 which would exceed the maximum IP packet length of 65,535 with the header length included.
Time To Live (TTL) 
An eight-bit time to live (TTL) field helps prevent datagrams from persisting (e.g. going in circles) on an internet. This field limits a datagram's lifetime. It is specified in seconds, but time intervals less than 1 second are rounded up to 1. In latencies typical in practice, it has come to be a hop count field. Each packet switch (or router) that a datagram crosses decrements the TTL field by one. When the TTL field hits zero, the packet is no longer forwarded by a packet switch and is discarded. Typically, an ICMP message (specifically the time exceeded) is sent back to the sender that it has been discarded. The reception of these ICMP messages is at the heart of how traceroute works.
This field defines the protocol used in the data portion of the IP datagram. The Internet Assigned Numbers Authority maintains a list of Protocol numbers which was originally defined in RFC 790. Common protocols and their decimal values are shown below (see Data).
Header Checksum 
The 16-bit checksum field is used for error-checking of the header. At each hop, the checksum of the header must be compared to the value of this field. If a header checksum is found to be mismatched, then the packet is discarded. Note that errors in the data field are up to the encapsulated protocol to handle — indeed, both UDP and TCP have checksum fields.
Since the TTL field is decremented on each hop and fragmentation is possible at each hop then at each hop the checksum will have to be recomputed. The method used to compute the checksum is defined within RFC 1071:
The checksum field is the 16-bit one's complement of the one's complement sum of all 16-bit words in the header. For purposes of computing the checksum, the value of the checksum field is zero.
In other words, all 16-bit words are summed together using one's complement (with the checksum field set to zero). The sum is then one's complemented and this final value is inserted as the checksum field.
To validate a header's checksum the same algorithm may be used - the checksum of the header with the checksum field filled in should be a word containing all zeros (value 0).
Source address 
An IPv4 address is a group of four octets for a total of 32 bits. The value for this field is determined by taking the binary value of each octet and concatenating them together to make a single 32-bit value.
For example, the address would be 00001010000010010000100000000111.
This address is the address of the sender of the packet. Note that this address may not be the "true" sender of the packet due to network address translation. Instead, the source address will be translated by the NATing machine to its own address. Thus, reply packets sent by the receiver are routed to the NATing machine, which translates the destination address to the original sender's address.
Destination address 
Identical to the source address field but indicates the receiver of the packet.
Additional header fields may follow the destination address field, but these are not often used. Note that the value in the IHL field must include enough extra 32-bit words to hold all the options (plus any padding needed to ensure that the header contains an integral number of 32-bit words). The list of options may be terminated with an EOL (End of Options List, 0x00) option; this is only necessary if the end of the options would not otherwise coincide with the end of the header. The possible options that can be put in the header are as follows:
Field Size (bits) Description
Copied 1 Set to 1 if the options need to be copied into all fragments of a fragmented packet.
Option Class 2 A general options category. 0 is for "control" options, and 2 is for "debugging and measurement". 1, and 3 are reserved.
Option Number 5 Specifies an option.
Option Length 8 Indicates the size of the entire option (including this field). This field may not exist for simple options.
Option Data Variable Option-specific data. This field may not exist for simple options.
  • Note: If the Header Length is greater than 5, i.e. it is between 6-15, it means that the Options field is present and must be considered.
  • Note: the Copied, Option Class, and Option Number are sometimes referred to as a single eight-bit field - the Option Type.
The use of the LSRR and SSRR options (Loose and Strict Source and Record Route) is discouraged because they create security concerns; many routers block packets containing these options.[citation needed]


The last field is not a part of the header and, consequently, not included in the checksum field. The contents of the data field are specified in the protocol header field and can be any one of the transport layer protocols.

Some of the most commonly used protocols are listed below including their value used in the protocol field:

See List of IP protocol numbers for a complete list.

Fragmentation and reassembly

To make IPv4 more tolerant of different networks the concept of fragmentation was added so that, if necessary, a device could break up the data into smaller pieces. This is necessary when the maximum transmission unit (MTU) is smaller than the packet size.

For example, the maximum size of an IP packet is 65,535 bytes while the typical MTU for Ethernet is 1,500 bytes. Since the IP header consumes 20 bytes (without options) of the 1,500 bytes, 1,480 bytes are left for IP data per Ethernet frame (this leads to an MTU for IP of 1,480 bytes). Therefore, a 65,535-byte data payload (including 20 bytes of header information) would require 45 packets (65535-20)/1480 = 44.27, rounded up to 45.

The reason fragmentation was chosen to occur at the IP layer is that IP is the first layer that connects hosts instead of machines. If fragmentation were performed on higher layers (TCP, UDP, etc.) then this would make fragmentation/reassembly redundantly implemented (once per protocol); if fragmentation were performed on a lower layer (Ethernet, ATM, etc.) then this would require fragmentation/reassembly to be performed on each hop (could be quite costly) and redundantly implemented (once per link layer protocol). Therefore, the IP layer is the most efficient one for fragmentation.


When a device receives an IP packet it examines the destination address and determines the outgoing interface to use. This interface has an associated MTU that dictates the maximum data size for its payload. If the MTU is smaller than the data size then the device must fragment the data.

The device then segments the data into segments where each segment is less-than-or-equal-to the MTU less the IP header size (20 bytes minimum; 60 bytes maximum). Each segment is then put into its own IP packet with the following changes:

  • The total length field is adjusted to the segment size
  • The more fragments (MF) flag is set for all segments except the last one, which is set to 0
  • The fragment offset field is set accordingly based on the offset of the segment in the original data payload. This is measured in units of eight-byte blocks.
  • The header checksum field is recomputed.

For example, for an IP header of length 20 bytes and an Ethernet MTU of 1,500 bytes the fragment offsets would be: 0, (1480/8) = 185, (2960/8) = 370, (4440/8) = 555, (5920/8) = 740, etc.

By some chance if a packet changes link layer protocols or the MTU reduces then these fragments would be fragmented again.

For example, if a 4,500-byte data payload is inserted into an IP packet with no options (thus total length is 4,520 bytes) and is transmitted over a link with an MTU of 2,500 bytes then it will be broken up into two fragments:

# Total length More fragments (MF)
flag set?
Fragment offset
Header Data
1 2500 Yes 0
20 2480
2 2040 No 310
20 2020

Now, let's say the MTU drops to 1,500 bytes. Each fragment will individually be split up into two more fragments each:

# Total length More fragments (MF)
flag set?
Fragment offset
Header Data
1 1500 Yes 0
20 1480
2 1020 Yes 185
20 1000
3 1500 Yes 310
20 1480
4 560 No 495
20 540

Indeed, the amount of data has been preserved — 1480 + 1000 + 1480 + 540 = 4500 — and the last fragment offset plus data — 3960 + 540 = 4500 — is also the total length.

Note that fragments 3 & 4 were derived from the original fragment 2. When a device must fragment the last fragment then it must set the flag for all but the last fragment it creates (fragment 4 in this case). Last fragment would be set to 0 value.


When a receiver detects an IP packet where either of the following is true:

  • "more fragments" flag set
  • "fragment offset" field is non-zero

then the receiver knows the packet is a fragment. The receiver then stores the data with the identification field, fragment offset, and the more fragments flag. When the receiver receives a fragment with the more fragments flag set to 0 then it knows the length of the original data payload since the fragment offset plus the data length is equivalent to the original data payload size.

Using the example above, when the receiver receives fragment 4 the fragment offset (495 or 3960 bytes) and the data length (540 bytes) added together yield 4500 — the original data length.

Once it has all the fragments then it can reassemble the data in proper order (by using the fragment offsets) and pass it up the stack for further processing.

Assistive protocols

The Internet Protocol is the protocol that defines and enables internetworking at the Internet Layer and thus forms the Internet. It uses a logical addressing system. IP addresses are not tied in any permanent manner to hardware identifications and, indeed, a network interface can have multiple IP addresses. Hosts and routers need additional mechanisms to identify the relationship between device interfaces and IP addresses, in order to properly deliver an IP packet to the destination host on a link. The Address Resolution Protocol (ARP) perform this IP address to hardware address (MAC address) translation for IPv4. In addition the reverse correlation is often necessary, for example, when an IP host is booted or connected to a network it needs to determine its IP address, unless an address is preconfigured by an administrator. Protocols for such inverse correlations exist in the Internet Protocol Suite. Currently used methods are Dynamic Host Configuration Protocol (DHCP) and, infrequently, inverse ARP.

See also


External links

Address exhaustion:


Up to date as of January 15, 2010

Definition from Wiktionary, a free dictionary



Wikipedia has an article on:



  1. Internet Protocol version 4, current version in use.

See also

Got something to say? Make a comment.
Your name
Your email address