IPv4 Address Classes
IPv4 Address Classes
IPv4 Address Classes
Once the packets arrive at their destination, they are handled differently depending on
which transport protocol is used in combination with IP. The most common transport
protocols are TCP and UDP.
The number of networks and the number of hosts per class can be derived by this formula −
When calculating hosts' IP addresses, 2 IP addresses are decreased because they cannot be
assigned to hosts, i.e. the first IP of a network is network number and the last IP is reserved
for Broadcast IP.
Class A Address
The first bit of the first octet is always set to 0 (zero). Thus the first octet ranges from 1 –
127, i.e.
Class A addresses only include IP starting from 1.x.x.x to 126.x.x.x only. The IP range
127.x.x.x is reserved for loopback IP addresses.
The default subnet mask for Class A IP address is 255.0.0.0 which implies that Class A
addressing can have 126 networks (27-2) and 16777214 hosts (224-2).
Class A IP address format is thus: 0NNNNNNN.HHHHHHHH.HHHHHHHH.HHHHHHHH
Class B Address
An IP address which belongs to class B has the first two bits in the first octet set to 10, i.e.
Class B IP Addresses range from 128.0.x.x to 191.255.x.x. The default subnet mask for Class
B is 255.255.x.x.
Class B has 16384 (214) Network addresses and 65534 (216-2) Host addresses.
Class B IP address format is: 10NNNNNN.NNNNNNNN.HHHHHHHH.HHHHHHHH
Class C Address
The first octet of Class C IP address has its first 3 bits set to 110, that is −
Class C IP addresses range from 192.0.0.x to 223.255.255.x. The default subnet mask for
Class C is 255.255.255.x.
Class C gives 2097152 (221) Network addresses and 254 (28-2) Host addresses.
Class C IP address format is: 110NNNNN.NNNNNNNN.NNNNNNNN.HHHHHHHH
Class D Address
Very first four bits of the first octet in Class D IP addresses are set to 1110, giving a range of
−
Class D has IP address range from 224.0.0.0 to 239.255.255.255. Class D is reserved for
Multicasting. In multicasting data is not destined for a particular host, that is why there is
no need to extract host address from the IP address, and Class D does not have any subnet
mask.
Class E Address
This IP Class is reserved for experimental purposes only for R&D or Study. IP addresses in
this class ranges from 240.0.0.0 to 255.255.255.254. Like Class D, this class too is not
equipped with any subnet mask.
Classful addressing divides the IPv4 address space (0.0.0.0-255.255.255.255) into 5 classes:
A, B, C, D, and E. However, only A, B, and C are used for network hosts. Class D, which
covers the 224.0.0.0-239.255.255.255 IP address range, is reserved for multicasting, and
class E (240.0.0.0-255.255.255.255) is reserved for “future use.”
The table below details the default network mask (subnet mask), IP address ranges, number
of networks, and number of addresses per network of each address class.
As we can see, Class A continues to use the first 8-bits of an address, and may be suitable
for very large networks. Class B is for networks much smaller than Class A, but still large in
their own right. Class C addresses are suitable for small networks.
The 28 bits after the leading “1110” in the IP address define the multicast group address.
The size of the Class D multicast address space is therefore 228 or 268,435,456 multicast
groups. There is no substructure that defines the use of these 28 bits; there is no specific
concept of a network ID and host ID as in classes A, B and C. However, certain portions of
the address space are set aside for specific uses. Table 48 and Figure 63 show the general
allocation of the Class D address space.
Private IP Addresses
Every class of IP, (A, B & C) has some addresses reserved as Private IP addresses. These IPs
can be used within a network, campus, company and are private to it. These addresses
cannot be routed on the Internet, so packets containing these private addresses are
dropped by the Routers.
In order to communicate with the outside world, these IP addresses must have to be
translated to some public IP addresses using NAT process, or Web Proxy server can be used.
The sole purpose to create a separate range of private addresses is to control assignment of
already-limited IPv4 address pool. By using a private address range within LAN, the
requirement of IPv4 addresses has globally decreased significantly. It has also helped
delaying the IPv4 address exhaustion.
IP class, while using private address range, can be chosen as per the size and requirement of
the organization. Larger organizations may choose class A private IP address range where
smaller organizations may opt for class C. These IP addresses can be further sub-netted and
assigned to departments within an organization.
Loopback IP Addresses
The IP address range 127.0.0.0 – 127.255.255.255 is reserved for loopback, i.e. a Host’s self-
address, also known as localhost address. This loopback IP address is managed entirely by
and within the operating system. Loopback addresses, enable the Server and Client
processes on a single system to communicate with each other. When a process creates a
packet with destination address as loopback address, the operating system loops it back to
itself without having any interference of NIC.
Data sent on loopback is forwarded by the operating system to a virtual network interface
within operating system. This address is mostly used for testing purposes like client-server
architecture on a single machine. Other than that, if a host machine can successfully ping
127.0.0.1 or any IP from loopback range, implies that the TCP/IP software stack on the
machine is successfully loaded and working.
Link-local Addresses
In case a host is not able to acquire an IP address from the DHCP server and it has not been
assigned any IP address manually, the host can assign itself an IP address from a range of
reserved Link-local addresses. Link local address ranges from 169.254.0.0 --
169.254.255.255.
Assume a network segment where all systems are configured to acquire IP addresses from a
DHCP server connected to the same network segment. If the DHCP server is not available,
no host on the segment will be able to communicate to any other. Windows (98 or later),
and Mac OS (8.0 or later) supports this functionality of self-configuration of Link-local IP
address. In absence of DHCP server, every host machine randomly chooses an IP address
from the above mentioned range and then checks to ascertain by means of ARP, if some
other host also has not configured itself with the same IP address. Once all hosts are using
link local addresses of same range, they can communicate with each other.
These IP addresses cannot help system to communicate when they do not belong to the
same physical or logical segment. These IPs are also not routable.
When a host sends an IP packet onto the network it cannot be larger than the maximum
size supported by that local network. This size is determined by the network’s data link and
IP Maximum Transmission Units (MTUs) which are usually the same. A typical
contemporary office, campus or data centre network provided over Ethernet will have 1500
byte MTUs.
However, packets that are initially transmitted over a network supporting one MTU may
need be routed across networks (such as a WAN or VPN tunnel) with a smaller MTU. In
these cases, if the packet size exceeds the lower MTU the data in the packet must be
fragmented (if possible). This means it is broken into pieces carried within new packets
(fragments) that are equal to or smaller than the lower MTU. This is called Fragmentation
and the data in these fragments is then typically reassembled when they reach their
destination.
"IHL (Internet Header Length)" field is 4-bits long binary number. This 4-bit IHL (Internet
Header Length) field gives the "length of IPv4 header" in 32-bit words. Since IHL (Internet
Header Length) is a 4-bit binary number, IHL field in IPv4 header can hold values from 0000
(0 in decimals) to 1111 (15 in decimals). Minimum required field size of IPv4 header is 20
bytes. Minimum required length of an IPv4 header is five 32-bit words (5*32 = 160 bits or 20
bytes). The length of required fields in IPv4 header is 20 bytes. Maximum possible is fifteen
32-bit words (15*32 = 480 bits or 60 bytes). The bit pattern of is IHL field in IPv4 header is
0101, which is equal to five in decimals.
Please refer below image to understand the meaning of 32-bit words of IPv4 header.
Numbered at right-side are the required fields of IPv4 header.
The 8-bit "Protocol" field indicates the protocol that will receive the data payload. For
example, ICMP (Internet Control Message Protocol) has a Protocol number of 1, TCP
(Transmission Control Protocol) has a Protocol number of 6, UDP (User Datagram Protocol)
has a Protocol number of 17, RDP (Reliable Data Protocol) has a Protocol number of 27, ESP
(Encapsulating Security Payload) has a Protocol number of 50 etc.
The Protocol field in IPv4 header is used to demultiplex an IPv4 packet to a Transport layer
(Layer 4) protocol. Following table lists important Protocol numbers. You may find latest
Protocol Number Assignments from IANA Protocol Number Assignments page.