0% found this document useful (0 votes)
29 views

Network Layer

network layer
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
29 views

Network Layer

network layer
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 52

NETWORK LAYER

PART-1
Introduction to Network Layer

• The network layer is responsible for the source-to-


destination delivery of a packet, possibly across multiple
networks (links).
• The network layer adds a header that includes the logical
addresses of the sender and receiver to the packet coming from
the upper layer.
• When independent networks or links are connected together to
create an internetwork, routers or switches route packets to
their final destination. Therefore, one of the functions of the
network layer is to provide a routing mechanism.
• Usually, computers communicate through the Internet.
• The packet transmitted by the sending computer may pass
through several LANs or WANs before reaching the
destination computer.
Cont..

• For this level of communication, we need a global addressing


scheme known as IP addressing.
• The Internet addresses are 32 bits in length; this gives us a
maximum of 232 addresses. These addresses are referred to as
IPv4 (IP version 4) addresses or simply IP addresses.
• An IPv4 address is a 32-bit address that uniquely and
universally defines the connection of a device (for example, a
computer or a router) to the Internet.
• IPv4 addresses are unique. They are unique in the sense that
each address defines one, and only one, connection to the
Internet. Two devices on the Internet can never have the same
address at the same time.
• The IPv4 addresses are universal in the sense that the
addressing system must be accepted by any host that wants to
be connected to the Internet.
Cont..
• Address Space:
• A protocol such as IPv4 that defines addresses has an address
space.
• An address space is the total number of addresses used by the
protocol.
• If a protocol uses N bits to define an address, the address space
is 2N because each bit can have two different values (0 or 1)
and N bits can have 2N values.
• IPv4 uses 32-bit addresses, which means that the address
space is 232 or 4,294,967,296 (more than 4 billion).
• This means that, theoretically, if there were no restrictions,
more than 4 billion devices could be connected to the Internet.
Cont..

• Notations:
• There are two prevalent notations to show an IPv4 address:
binary notation and dotted decimal notation.
• Binary Notation:
• In binary notation, the IPv4 address is displayed as 32 bits.
• Each octet is often referred to as a byte. So it is common to
hear an IPv4 address referred to as a 32-bit address or a 4-byte
address.
• The following is an example of an IPv4 address in binary
notation:
• 01110101 10010101 00011101 00000010
Cont..

• Dotted-Decimal Notation:
• To make the IPv4 address more compact and easier to read,
Internet addresses are usually written in decimal form with a
decimal point (dot) separating the bytes.
• The following is the dotted-decimal notation of the address
shown in the previous slide:
• 117.149.29.2
• Note that because each byte (octet) is 8 bits, each number in
dotted-decimal notation is a value ranging from 0 to 255 [As,
28 = 256].
Cont..
• Q. Find the error, if any, in the following IPv4 addresses.
• a. 111.56.045.78
• b. 221.34.7.8.20
• c. 75.45.301.14
• d. 11100010.23.14.67
• Solution:
• a. There must be no leading zero (045).
• b. There can be no more than four numbers in an IPv4 address.
• c. Each number needs to be less than or equal to 255 (301 is
outside this range).
• d. A mixture of binary notation and dotted-decimal notation is
not allowed.
Cont..

• Classful Addressing:
• IPv4 addressing, at its inception, used the concept of classes.
This architecture is called classful addressing.
• In classful addressing, the address space is divided into five
classes: A, B, C, D, and E. Each class occupies some part of
the address space.
• We can find the class of an address when given the address in
binary notation or dotted-decimal notation.
• If the address is given in binary notation, the first few bits
can immediately tell us the class of the address.
• If the address is given in decimal-dotted notation, the first
byte defines the class.
Cont..

First Second Third Fourth


byte byte byte byte
Class A 0-127

Class B 128-191

Class C 192-223

Class D 224-239

Class E 240-255

b. Dotted-decimal notation
Cont..
• Q. Find the class of each address.
• a. 00000001 00001011 00001011 11101111
• b. 11000001 10000011 00011011 11111111
• c. 14.23.120.8
• d. 252.5.15.111
• Solution:
• a. The first bit is 0. This is a class A address.
• b. The first 2 bits are 1; the third bit is 0. This is a class C
address.
• c. The first byte is 14 (between 0 and 127); the class is A.
• d. The first byte is 252 (between 240 and 255); the class is E.
Cont..
• The IPv4 address is divided into two parts:
• Network ID: A network ID or NetID is the fragment of IP
address that classifies the network for a specified host i.e., it
tells us which network the host belongs to
• Host ID: It is the fragment of an IP address that uniquely
classifies a host on a specified TCP/IP network.
• The class of IP address is used to determine the bits used for
network ID and host ID and the number of total networks and
hosts possible in that particular class.
Cont..
• Class A:
• IP addresses belonging to class A are assigned to the networks that contain
a large number of hosts.
• The network ID is 8 bits long.
• The host ID is 24 bits long.
• The higher-order bit of the first octet in class A is always set to 0.
• The remaining 7 bits in the first octet are used to determine network
ID.
• The 24 bits of host ID are used to determine the host in any network.
• The default subnet mask for Class A is 255.x.x.x. Therefore, class A has a
total of:
• 2^7= 128 network ID and 2^24 – 2 = 16,777,214 host ID. (Here 2
address is subtracted because 0.0.0.0 and 127.x.y.z are special address.)
Cont..

• Mask (or default/subnet mask):


• It is a a 32-bit number made of contiguous 1s followed by
contiguous 0s.
• The masks for classes A, B, and C are shown below.
• The concept does not apply to classes D and E.
• The mask can help us to find the Netid and the Hostid. For
example, the mask for a class A address has eight 1s, which
means the first 8 bits of any address in class A define the
Netid; the next 24 bits define the Hostid.
Cont..
• Class B:
• IP address belonging to class B is assigned to networks that range from
medium-sized to large-sized networks.
• The network ID is 16 bits long.
• The host ID is 16 bits long.
• The higher-order bits of the first octet of IP addresses of class B are always
set to 10. The remaining 14 bits are used to determine the network ID.
• The 16 bits of host ID are used to determine the host in any network.
• The default subnet mask for class B is 255.255.x.x. Therefore, Class B
has a total of:
• 2^14 = 16384 network address
• 2^16 – 2 = 65534 host address
Cont..
• Class C:
• IP addresses belonging to class C are assigned to small-sized networks.
• The network ID is 24 bits long.
• The host ID is 8 bits long.
• The higher-order bits of the first octet of IP addresses of class C is always
set to 110. The remaining 21 bits are used to determine the network ID.
• The 8 bits of host ID are used to determine the host in any network.
• The default subnet mask for class C is 255.255.255.x. Therefore, Class C
has a total of:
• 2^21 = 2097152 network address
• 2^8 – 2 = 254 host address
Cont..

• Class D:
• IP address belonging to class D is reserved for multi-casting.
• The higher-order bits of the first octet of IP addresses
belonging to class D is always set to 1110.
• The remaining bits are for the address that interested hosts
recognize.
• Class D does not possess any subnet mask.
• IP addresses belonging to class D range from 224.0.0.0 –
239.255.255.255.
Cont..
• Class E:
• IP addresses belonging to class E are reserved for
experimental and research purposes.
• IP addresses of class E range from 240.0.0.0 –
255.255.255.254.
• This class doesn’t have any subnet mask.
• The higher-order bits of the first octet of class E are always set
to 1111.
Cont..
Numerical on IP Addressing
• Q. Consider the IP address: 201.20.30.40. Calculate Network
ID, 4th Host ID, Last Host ID, Broadcast address.

• Solution:
• Network ID: 201.20.30.0
• To calculate the Network ID, we have to perform the bitwise
AND operation of the IP address with its subnet mask. As this
IP address belongs to class C, therefore, the subnet mask will
be 255.255.255.0. Now, perform the bitwise AND operation:
• 201.20.30.40
• 255.255.255.0
• 201.20.30.0
Cont..
• 4th Host ID: 201.20.30.4
• As, the Host ID 201.20.30.0 cannot be assigned to any host
because as per rule the Host ID field cannot contains 0s.
Therefore, the first Host ID will be 201.20.30.1, second Host
ID will be 201.20.30.2, similarly 4th Host ID will be
201.20.30.4.

• Last Host ID: 201.20.30.254


• As, the last IP address of this network is 201.20.30.255,
therefore, you may think that this will be the last Host ID too.
But, the IP 201.20.30.255 (i.e. the last IP address of the
network) is reserved as broadcast address. Hence, the last
Host ID will be 201.20.30.254.
Cont..

• Broadcast address:
• There are two types of broadcast address. First is the Limited
broadcast address and the second is the Direct broadcast
address. Suppose, Node A wants to send a
E
• Limited BA: message to Nodes B, C, D, and E (i.e.,
all the nodes in the same network),
then it has to use the Limited BA
N/w - 1 which will be 255. 255. 255.255.
(N/w Add:
A 201.20.30.0 D

B C
Cont..
• Direst Broadcast Address:
E H
A D

N/w - 1 Router N/w - 2


(N/w Add: (N/w Add:
201.20.30.0 201.70.40.0

B C F G

Suppose, Node F wants to send a message to all the nodes of N/w - 1 (i.e., A, B, C,
and D), then it has to use Direct BA which will be the last IP address of N/w - 1, i.e.,
201.20.30.255.
Subnetting in Computer Networks
• In networking,
• The process of dividing a single network into multiple sub networks is
called as subnetting.
• The sub networks so created are called as subnets.

• Advantages-
• The two main advantages of subnetting a network are-
• It improves the security.
• The maintenance and administration of subnets is easy.

• Subnet ID-
• Each subnet has its unique network address known as its Subnet ID.
• The subnet ID is created by borrowing some bits from the Host ID part
of the IP Address.
• The number of bits borrowed depends on the number of subnets created.
Cont..

• Types of Subnetting-
• 1. Fixed Length Subnetting-
• Fixed length subnetting also called as classful
subnetting divides the network into subnets where-
• All the subnets are of same size.
• All the subnets have equal number of hosts.
• All the subnets have same subnet mask.
• 2. Variable Length Subnetting-
• Variable length subnetting also called as classless
subnetting divides the network into subnets where-
• All the subnets are not of same size.
• All the subnets do not have equal number of hosts.
• All the subnets do not have same subnet mask.
Cont..

• Q. We have a big single network having IP Address 200.1.2.0.


We want to do subnetting and divide this network into 2
subnets.
• Clearly, the given network belongs to class C.

• For creating two subnets and to represent their subnet IDs, we


require 1 bit.
• So, We borrow one bit from the Host ID part.
• After borrowing one bit, Host ID part remains with only 7 bits.
Cont..

• IP Address of the two subnets are-


• 200.1.2.00000000 = 200.1.2.0
• 200.1.2.10000000 = 200.1.2.128
Cont..
Cont..
• Q. We have a big single network having IP Address 200.1.2.0.
We want to do subnetting and divide this network into 4
subnets.
• Clearly, the given network belongs to class C.

• For creating four subnets and to represent their subnet IDs, we


require 2 bits.
• So, We borrow two bits from the Host ID part.
• After borrowing two bits, Host ID part remains with only 6
bits.
Cont..
• If borrowed bits = 00, then it represents the 1st subnet.
• If borrowed bits = 01, then it represents the 2nd subnet.
• If borrowed bits = 10, then it represents the 3rd subnet.
• If borrowed bits = 11, then it represents the 4th subnet.
• IP Address of the four subnets are-
• 200.1.2.00000000 = 200.1.2.0
• 200.1.2.01000000 = 200.1.2.64
• 200.1.2.10000000 = 200.1.2.128
• 200.1.2.11000000 = 200.1.2.192
Cont..
Cont..
Cont..
• Q. We have a big single network having IP Address 200.1.2.0.
We want to do subnetting and divide this network into 3
subnets.
• Here, the subnetting will be performed in two steps-
• Dividing the given network into 2 subnets
• Dividing one of the subnets further into 2 subnets

• Step-01: Dividing Given Network into 2 Subnets-


• The subnetting will be performed exactly in the same way as
performed in Slide 26.
• After subnetting, we have-
Cont..

• Step-02: Dividing One Subnet into 2 Subnets-


• We perform the subnetting of one of the subnets further into 2
subnets.
• Consider we want to do subnetting of the 2nd subnet having IP
Address 200.1.2.128.
Cont..
• For creating two subnets and to represent their subnet IDs, we
require 1 bit.
• So, We borrow one more bit from the Host ID part.
• After borrowing one bit, Host ID part remains with only 6 bits.
Cont..
• IP Address of the two subnets are-
• 200.1.2.10000000 = 200.1.2.128
• 200.1.2.11000000 = 200.1.2.192
Cont..
• For 1st Subnet-
• IP Address of the subnet = 200.1.2.0
• Total number of IP Addresses = 2 7 = 128
• Total number of hosts that can be configured = 128 – 2 = 126
• Range of IP Addresses = [200.1.2.00000000, 200.1.2.01111111] = [200.1.2.0,
200.1.2.127]
• Direct Broadcast Address = 200.1.2.01111111 = 200.1.2.127
• Limited Broadcast Address = 255.255.255.255

• For 2nd Subnet-


• IP Address of the subnet = 200.1.2.128
• Total number of IP Addresses = 2 6 = 64
• Total number of hosts that can be configured = 64 – 2 = 62
• Range of IP Addresses = [200.1.2.10000000, 200.1.2.10111111] =
[200.1.2.128, 200.1.2.191]
• Direct Broadcast Address = 200.1.2.10111111 = 200.1.2.191
• Limited Broadcast Address = 255.255.255.255
Cont..
• For 3rd Subnet-
• IP Address of the subnet = 200.1.2.192
• Total number of IP Addresses = 26 = 64
• Total number of hosts that can be configured = 64 – 2 = 62
• Range of IP Addresses = [200.1.2.11000000, 200.1.2.11111111] =
[200.1.2.192, 200.1.2.255]
• Direct Broadcast Address = 200.1.2.11111111 = 200.1.2.255
• Limited Broadcast Address = 255.255.255.255

• Disadvantages of Subnetting-
• Subnetting leads to loss of IP Addresses.
• One IP address is wasted for its network address.
• Other IP Address is wasted for its direct broadcasting address.
Cont..
• Q. Suppose a network with IP Address 192.16.0.0. is divided into 2
subnets, find number of hosts per subnet.
• Also for the first subnet, find-
• Subnet Address
• First Host ID
• Last Host ID
• Broadcast Address
• Solution:
• Solution-
• Given IP Address belongs to class C.
• So, 24 bits are reserved for the Net ID.
• The given network is divided into 2 subnets.
• So, 1 bit is borrowed from the host ID part for the subnet IDs.
• Then, Number of bits remaining for the Host ID = 7.
• Thus, Number of hosts per subnet = 2^7 - 2 = 126.
Cont..
• For 1st Subnet-
• Subnet Address = First IP Address = 192.16.0.00000000 =
172.16.0.0
• First Host ID = 192.16.0.00000001 = 192.16.0.1
• Last Host ID = 192.16.0.01111110 = 192.16.0.126
• Broadcast Address = Last IP Address = 192.16.0.01111111 =
172.16.0.127
Cont..
• Q. A class B network on the internet has a subnet mask of
255.255.240.0. What is the maximum number of hosts per
subnet?
• Solution:
• The given subnet mask is: 255.255.240.0 which is written in
binary notation as:
• 11111111 11111111 11110000 00000000
20 bits

• It is a class B network.For a class B network, the upper 16 bits


form the network address and lower 16 bits are subnet and host
fields.
• of the lower 16 bits most significant 4 bits are 1111.This leaves
12 bits for the host number.So,4096(212) host address exists.
• Thus, Number of hosts per subnet = 212 – 2 = 4094.
Cont..

• In class B, 16 bits are reserved for the network.


• So, Number of bits reserved for subnet ID = 20 – 16 = 4 bits.
• Number of subnets possible = 24 = 16.

• Q. There is a need to create a network that has 5 subnets, each


with at least 16 hosts. Which one is used as classful subnet
mask ?
• 255.255.255.192
• 255.255.255.248
• 255.255.255.240
• 255.255.255.224
Cont..
• In all the classfull subnet mask option first three
octet are same
• Difference in last octet:
• 192 represent in binary : 11000000
• 4 subnet and 62 host
• 248 represent in binary: 11111000
• 32 subnet and 6 host
• 240 represent in binary: 11110000
• 16 subnets and 14 hosts
• 224 represent in binary: 11100000
• 8 subnet and 30 hosts ( most suitable answer)
Cont..
• Q. Suppose an organization want 6 subnets, and each subnet
has at least 22 hosts. What subnet mask should the
organization use to fulfil the above condition?
• 255.255.255.128
• 255.255.255.224
• 255.255.255.240
• 255.255.255.255
• We see that the given subnet mask is of a class C IP address.
So the subnetting is done in the last octet.
• If the organization want 6 subnets, so the 3 bits are required
that is 23 = 8.
• The remaining bits in the last octet = 8 – 3 = 5.
• So the number of hosts = 25 – 2 = 30
Cont..
• But the organization won’t only 22 host, which is less than 30.
Hence the organization’s condition is fulfilled.
• Therefore the subnet mask is:

• Q. An organization has a class B nw and wishes to form


subnets for 64 departments. The subnet mask would be:
• In Class B 16 bits NID rest 16 bits host ID
• first 6 bits of the third octet will be used
Cont..

• Mask:
• 11111111.11111111.11111100.00000000
• 255.255.252.0

• Q. If a class B nw on the Internet has a subnet mask of


255.255.248.0. What is the maximum number of hosts per
subnet?
• The 'subnet mask 255.255.248.0' has binary representation as
'11111111.11111111.11111000.00000000'. Here in this '21 bits'
set in the subnet. So (32-21) = 11 bits are taken for host ids.
• Hence, the 'Total possible values of host ids' are '2^11 = 2048'.
• Total number of hosts per subnet = 2048 - 2 = 2046.
Cont..
• Subnetting the given network based on host’s
requirements:
• Steps:
Cont..
• Q. Subnet the IP address 216.21.5.0 into 30 hosts in each
subnet.

• As, 30 requires at least 5 bits for its representation in


binary, therefore, we are going to reserve 5 zeros in the
subnet mask from right to left (i.e., from LSB) and the
remaining bits will be 1.
• Therefore, the new subnet mask will be:
• 11111111 11111111 11111111 11100000
Cont..
• Now, the value of the subnet generator (SG) will be
calculated by: the position of the first 1, from right to left in
the new subnet mask, i.e.:
• 1 1 1 0 0 0 0 0

25 24 23 22 21 20

• 3. Therefore, the value of the SG will be 32. And the Octate


position ot the SG will be 4.

• NOTE: /27 is written because total number of 1’s in the new


subnet mask is 27.
Cont..
Cont..
• Q. Subnet the IP address 196.10.20.0 into 52 hosts in each
subnet.
Cont..
• Q. Subnet the IP address 150.15.0.0 into 500 hosts in each
subnet.

• Total number of hosts per subnetwork = 29 - 2 = 510 and total


subnetworks = 27 = 128.

You might also like