5 IPv4
5 IPv4
Internet Protocol version 4 (IPv4) is the fourth version in the development of the Internet Protocol (IP) and the
first version of the protocol to be widely deployed. IPv4 is described in IETF publication RFC 791 (September
1981), replacing an earlier definition (RFC 760, January 1980).
Host Addressing
Communication between hosts can happen only if they can identify each other on the network. In a single
collision domain (where every packet sent on the segment by one host is heard by every other host) hosts can
communicate directly via MAC address.
MAC address is a factory coded 48-bits hardware address (000a.959d.6816 ) which can also uniquely identify a
host. But if a host wants to communicate with a remote host, i.e. not in the same segment or logically not
connected, then some means of addressing is required to identify the remote host uniquely. A logical address is
given to all hosts connected to Internet and this logical address is called Internet Protocol Address.
IP provides a mechanism to uniquely identify hosts by an IP addressing scheme. IP uses best effort delivery, i.e. it
does not guarantee that packets would be delivered to the destined host, but it will do its best to reach the
destination. Internet Protocol version 4 uses 32-bit logical address.Internet Protocol being a layer-3 protocol
(OSI) takes data Segments from layer-4 (Transport) and divides it into packets. IP packet encapsulates data unit
received from above layer and add to its own header information
IP header includes many relevant information including Version Number, which, in this context, are 4. Other
details are as follows:
ECN: Explicit Congestion Notification; It carries information about the congestion seen in the route.
Identification: If IP packet is fragmented during the transmission, all the fragments contain same
identification number. to identify original IP packet they belong to.
Flags: As required by the network resources, if IP Packet is too large to handle, these ‘flags’ tells if they
can be fragmented or not. In this 3-bit flag, the MSB is always set to ‘0’.
Fragment Offset: This offset tells the exact position of the fragment in the original IP Packet.
Time to Live: To avoid looping in the network, every packet is sent with some TTL value set, which tells
the network how many routers (hops) this packet can cross. At each hop, its value is decremented by one
and when the value reaches zero, the packet is discarded.
Protocol: Tells the Network layer at the destination host, to which Protocol this packet belongs to, i.e. the
next level Protocol. For example protocol number of ICMP is 1, TCP is 6 and UDP is 17.
Header Checksum: This field is used to keep checksum value of entire header which is then used to check
if the packet is received error-free.
Source Address: 32-bit address of the Sender (or source) of the packet.
Destination Address: 32-bit address of the Receiver (or destination) of the packet.
Options: This is optional field, which is used if the value of IHL is greater than 5. These options may
contain values for options such as Security, Record Route, Time Stamp, etc.
Here a server sends packets which are entertained by more than one servers. Every network has one IP address
reserved for the Network Number which represents the network and one IP address reserved for the Broadcast
Address, which represents all the hosts in that network.
The network part will tell us to which “network” the IP address will belong, you can compare
this to the city or area code of a phone number. The “host” part uniquely identifies the network
device; these are like the last digits of your phone number.
Subnet Mask
The 32-bit IP address contains information about the host and its network. It is very necessary to distinguish
both. For this, routers use Subnet Mask, which is as long as the size of the network address in the IP address.
Subnet Mask is also 32 bits long. If the IP address in binary is ANDed with its Subnet Mask, the result yields the
Network address. For example, say the IP Address is 192.168.1.152 and the Subnet Mask is 255.255.255.0 then:
This way the Subnet Mask helps extract the Network ID and the Host from an IP Address. It can be identified now
that 192.168.1.0 is the Network number and 192.168.1.152 is the host on that network.
Internet Protocol hierarchy contains several classes of IP Addresses to be used efficiently in various situations as
per the requirement of hosts per network. Broadly, the IPv4 Addressing system is divided into five classes of IP
Addresses. All the five classes are identified by the first octet of IP Address.
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 IP 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 B IP 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 C IP 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 D IP 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 rage 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 IP 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.
There are a few reserved IPv4 address spaces which cannot be used on the internet. These addresses serve
special purpose and cannot be routed outside the Local Area Network.
Public IP address
A public IP address is the address that is assigned to a computing device to allow direct access over the
Internet. A web server, email server and any server device directly accessible from the Internet are
candidate for a public IP address. A public IP address is globally unique, and can only be assigned to an
unique device.
Private IP address
A private IP address is the address space allocated by InterNIC to allow organizations to create their own
private network. There are three IP blocks (1 class A, 1 class B and 1 class C) reserved for a private use. The
computers, tablets and smartphones sitting behind your home, and the personal computers within
organizations are usually assigned private IP addresses. A network printer residing in your home is
assigned a private address so that only your family can print to your local printer.
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.
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.
Static IP address
A static IP address is an address that is permanently assigned to you by your ISP, and does not
change even if your computer reboots.
A static IP address is usually assigned to a server hosting websites, and providing email, database
and FTP services. A static IP address is also assigned to a commercial leased line, or public
organization requiring same IP address each and every time. Since static IP address is assigned to
you, you'll have to manually configure your machine (router or server) to use the static IP address
assigned to you.
Static IP address Advantages
Address does not change - good for web servers, email servers and other Internet servers.
Use DNS to map domain name to IP address, and use domain name to address the static IP
address. Similar can be achieved with Dynamic DNS for dynamic IP address, but it's not as
clean as the static IP address.