IP Version 4

IPv4
Internet Protocol version 4 is the fourth iteration of the Internet Protocol (IP) and it is the first version of the protocol to be widely deployed. IPv4 is the dominant network layer protocol on the Internet and apart from IPv6 it is the only standard internetwork-layer protocol used on the Internet.
It is described in IETF RFC 791 (September 1981) which made obsolete RFC 760 (January 1980). The United States Department of Defense also standardized it as MIL-STD-1777.
IPv4 is a data-oriented protocol to be used on a packet switched internetwork (e.g., Ethernet). It is a best effort protocol in that it does not guarantee delivery. It does not make any guarantees on the correctness of the data; It may result in duplicated packets and/or packets out-of-order. These aspects are addressed by an upper layer protocol (e.g., TCP, and partly by UDP).
The entire purpose of IP is to provide unique global computer addressing to ensure that two computers communicating over the Internet can uniquely identify one another.

Addressing

IPv4 uses 32-bit (4-byte) addresses, which limits the address space to 4,294,967,296 possible unique addresses. However, some are reserved for special purposes such as private networks (~18 million addresses) or multicast addresses (~1 million addresses). This reduces the number of addresses that can be allocated as public Internet addresses. As the number of addresses available are consumed, an IPv4 address shortage appears to be inevitable, however Network Address Translation (NAT) has significantly delayed this inevitability.
This limitation has helped stimulate the push towards IPv6, which is currently in the early stages of deployment and is currently the only contender to replace IPv4.

IPv4 Addressing Notation

An IPv4 address consists of four bytes (32 bits). These bytes are also known as octets.
For readability purposes, humans typically work with IP addresses in a notation called dotted decimal. This notation places periods between each of the four numbers (octets) that comprise an IP address. For example, an IP address that computers see as
00001010 00000000 00000000 00000001
is written in dotted decimal as
10.0.0.1
Because each byte contains 8 bits, each octet in an IP address ranges in value from a minimum of 0 to a maximum of 255. Therefore, the full range of IP addresses is from 0.0.0.0 through 255.255.255.255. That represents a total of 4,294,967,296 possible IP addreses.
IP ADDRESS STRUCTURE

IP Address Structure

Class A:

0nnnnnnn hhhhhhhh hhhhhhhh hhhhhhhh

netid (7bits), hostid (24 bits).

Class B:

10nnnnnn nnnnnnnn hhhhhhhh hhhhhhhh

netid (14 bits), hostid (16 bits).

Class C:

110nnnnn nnnnnnnn nnnnnnnn hhhhhhhh

netid (21-bits), hostid (8 bits).

Class D:

1110mmmm mmmmmmmm mmmmmmmm mmmmmmmm

Multicast group 28 bits.

Class E addresses are reserved for future use.

Subnet Masks

Subnet masks are used to separate an IP address into netid, subnetid and hostid by masking out the hostid. For example:

IP Address:

192.168.216.244

(0xC0A8D8F4)

Net Id:

192

(0xC0)

Subnet Mask:

255.255.255.0

(0xFFFFFF00)

Host Id:

244

(0x000000F4)

Subnet Id:

168.216

(0x00A8D800)

Another example:

IP Address:

192.168.216.244

(0xC0A8D8F4)

Net Id:

192

(0xC0)

Subnet Mask:

255.255.255.192

(0xFFFFFFC0)

Host Id:

52

(0x00000034)

Subnet Id:

168.216.192

(0x00A8D8C0)

Special Addresses

Address elements that resolve to all 1 bits are broadcast addresses.
Net Id 0 is reserved for BOOTP.

Limitations of IPv4

IPv4’s initial design did not anticipate the following:

The recent exponential growth of the Internet and the impending exhaustion of the IPv4 address space.
Because IPv4 addresses have become relatively scarce, some organizations have been forced to use NATs to map multiple private addresses to a single public IP address. NATs promote reuse of the private address space, but they do not support standards-based network-layer security or the correct mapping of all upper layer protocols. NATs can also create problems when they connect two organizations that use the private address space.
Additionally, the rising prominence of Internet-connected devices and appliances ensures that the public IPv4 address space will eventually be depleted.

The requirement for security at the Internet layer.
Private communication over a public medium such as the Internet requires encryption services that protect the data being sent from being viewed or modified in transit. IPSec provides security for IPv4 packets, but this standard is optional, and proprietary solutions prevail.

7The growth of the Internet and the ability of Internet backbone routers to maintain large routing tables.
Because of the way that IPv4 network IDs have been and are currently allocated, the routing tables of Internet backbone routers routinely contain more than 85,000 routes. The routing infrastructure of the IPv4 Internet combines both flat and hierarchical routing.

The need to better support real-time delivery of data — also called quality of service (QoS).
QoS standards exist for IPv4, but real-time traffic support relies on the IPv4 Type of Service (TOS) field and the identification of the payload, which is typically done using a UDP or TCP port. Unfortunately, the IPv4 TOS field has limited functionality, and various local interpretations developed over time. In addition, payload identification using a TCP and UDP port is not possible when the payload is encrypted.