Network Layer
Network Layer
PART-1
Introduction to Network Layer
• 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..
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..
• 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.
• 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
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..
• 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
• Mask:
• 11111111.11111111.11111100.00000000
• 255.255.252.0
25 24 23 22 21 20