TCP-IP Part-1
TCP-IP Part-1
Network Layer
The network layer is responsible for carrying data from one
host to another. It provides means to allocate logical addresses
to hosts, and identify them uniquely using the same. Network
layer takes data units from Transport Layer and cuts them in
to smaller unit called Data Packet.
Network layer defines the data path, the packets should follow
to reach the destination. Routers work on this layer and
provides mechanism to route data to its destination.
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.
Binary Representation
The positional value method is the simplest form of converting
binary from decimal value. IP address is 32 bit value which is
divided into 4 octets. A binary octet contains 8 bits and the
value of each bit can be determined by the position of bit value
'1' in the octet.
Positional value of bits is determined by 2 raised to power
(position 1), that is the value of a bit 1 at position 6 is 2^(6-
1) that is 2^5 that is 32. The total value of the octet is
determined by adding up the positional value of bits. The value
of 11000000 is 128+64 = 192. Some examples are shown in
the table below:
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.
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.
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 C Address
The first octet of Class C IP address has its first 3 bits set to
110, that is:
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 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.
Class B Subnets
By default, using Classful Networking, 14 bits are used as
Network bits providing (214) 16384 Networks and (216-2)
65534 Hosts. Class B IP Addresses can be subnetted the same
way as Class A addresses, by borrowing bits from Host bits.
Below is given all possible combination of Class B subnetting:
Class C Subnets
Class C IP addresses are normally assigned to a very small
size network because it can only have 254 hosts in a network.
Given below is a list of all possible combination of subnetted
Class B IP address:
Internet Service Providers may face a situation where they
need to allocate IP subnets of different sizes as per the
requirement of customer. One customer may ask Class C
subnet of 3 IP addresses and another may ask for 10 IPs. For
an ISP, it is not feasible to divide the IP addresses into fixed
size subnets, rather he may want to subnet the subnets in
such a way which results in minimum wastage of IP addresses.
Step - 1
Make a list of Subnets possible.
Step - 2
Sort the requirements of IPs in descending order (Highest to
Lowest).
Sales 100
Purchase 50
Accounts 25
Management 5
Step - 3
Allocate the highest range of IPs to the highest requirement,
so let's assign 192.168.1.0 /25 (255.255.255.128) to the
Sales department. This IP subnet with Network number
192.168.1.0 has 126 valid Host IP addresses which satisfy the
requirement of the Sales department. The subnet mask used
for this subnet has 10000000 as the last octet.
Step - 4
Allocate the next highest range, so let's assign
192.168.1.128 /26 (255.255.255.192) to the Purchase
department. This IP subnet with Network number
192.168.1.128 has 62 valid Host IP Addresses which can be
easily assigned to all the PCs of the Purchase department. The
subnet mask used has 11000000 in the last octet.
Step - 5
Allocate the next highest range, i.e. Accounts. The
requirement of 25 IPs can be fulfilled with 192.168.1.192 /27
(255.255.255.224) IP subnet, which contains 30 valid host IPs.
The network number of Accounts department will be
192.168.1.192. The last octet of subnet mask is 11100000.
Step - 6
Allocate the next highest range to Management. The
Management department contains only 5 computers. The
subnet 192.168.1.224 /29 with the Mask 255.255.255.248 has
exactly 6 valid host IP addresses. So this can be assigned to
Management. The last octet of the subnet mask will contain
11111000.
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.
Loopback IP Addresses
The IP address range 127.0.0.0 127.255.255.255 is reserved
for loopback, i.e. a Hosts 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.
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.
In case the IP does not belong to the local subnet, the data is
sent to the destination by means of Gateway of the subnet. To
understand the packet flow, we must first understand the
following components:
The sudden growth in internet users and its wide spread use
has exponentially increased the number of devices which
needs real and unique IP to be able to communicate.
Gradually, an IPS is required by almost every digital equipment
which were made to ease human life, such as Mobile Phones,
Cars and other electronic devices. The number of devices
(other than computers/routers) expanded the demand for
extra IP addresses, which were not considered earlier.
Private IPs: Few blocks of IPs were declared for private use
within a LAN so that the requirement for public IP addresses
can be reduced.
NAT: Network address translation is a mechanism by which
multiple PCs/hosts with private IP addresses are enabled to
access using one or few public IP addresses.
Dual IP Stack
Hop Count
Bandwidth
Delay
Unicast routing
Most of the traffic on the internet and intranets known as unicast
data or unicast traffic is sent with specified destination. Routing
unicast data over the internet is called unicast routing. It is the
simplest form of routing because the destination is already
known. Hence the router just has to look up the routing table
and forward the packet to next hop.
Broadcast routing
Multicast Routing
Anycast Routing
Routing Algorithms
Shortest Path
Dijkstra's algorithm