Download as pdf or txt
Download as pdf or txt
You are on page 1of 60

Module-4

Network Layer
Sunil Kumar Singh
SCOPE
Module 4

Contents
• Network layer’s Introduction
• IPv4
• Classful Addressing
• Subnetting
• IPv6
• Classless Addressing
• DHCP
• ARP and RARP
Module 4

Position of network layer


Module 4

IP as a Routed Protocol
IP is a connectionless,
unreliable, best-effort delivery
protocol.
IP accepts whatever data is
passed down to it from the
upper layers and forwards the
data in the form of IP Packets.
All the nodes are identified
using an IP address.
Packets are delivered from the
source to the destination using
IP address
Module 4

Packet Propagation
Module 4

IPv4 Address
IP address is for the INTERFACE of a host. Multiple
interfaces mean multiple IP addresses, i.e., routers.
32 bit IP address in dotted-decimal notation for ease
of reading, i.e., 193.140.195.66
Address 0.0.0.0, 127.0.0.1 and 255.255.255.255
carries special meaning.
IP address is divided into a network number and a
host number.
Also bits in Network or Host Address cannot be all 0
or 1.
Module 4

Classful addressing
• IP addresses, when started a few decades
ago, used the concept of classes
• In the mid-1990s, a new architecture, called
classless addressing, was introduced
• We will discuss classful addressing in this
section, first. Classless addressing will be
discussed in next section.
Module 4

IPv4 Address
Module 4

IPv4 Net-ID and Host-ID


Module 4

IPv4 Classes
Module 4

Finding the address class in IPv4


Module 4

IPv4 Classes
Class A : Address begins with bit 0. It has 8 bit
network number (range 0.0.0.0-to-127.255.255.255),
24 bit host number.
Class B : Address begins with bits 10. It has 16 bit
network number (range 128.0.0.0-to-
191.255.255.255), 16 bit host number.
Class C : Address begins with bits 110. It has 24 bit
network number (range 192.0.0.0-to-
223.255.255.255), 8 bit host number.
Class D : Begins with 1110, multicast addresses
(224.0.0.0-to-239.255.255.255)
Class E : Begins with 11110, unused
Module 4

IPv4 Class Ranges


Module 4

Binary Notation and Dotted-Decimal Notation


❑Binary notation

01110101 10010101 00011101 11101010

32 bit address, or a 4 octet address or a 4-byte


address

❑Decimal point notation


Module 4

Hexadecimal Notation of IPv4

• Hexadecimal Notation
0111 0101 1001 0101 0001 1101 1110 1010
75 95 1D EA

0x75951DEA

- 8 hexadecimal digits
- Used in network programming
Module 4

Examples
• Change the following IPv4 addresses from binary
notation to dotted-decimal notation
a. 10000001 00001011 00001011 11101111
b. 11000001 10000011 00011011 11111111
c. 11100111 11011011 10001011 01101111
d. 11111001 10011011 11111011 00001111

• Solution
We replace each group of 8 bits with its equivalent decimal
number (see Appendix B) and add dots for separation.
a. 129.11.11.239
b. 193.131.27.255
c. 231.219.139.111
d. 249.155.251.15
Module 4

Occupation of Address space (Five classes)


Module 4

Class A
• Only 1 byte in class A defines the netid
• The leftmost bit should be ‘0’
• Class A is divided into 27 = 128 blocks
• Each block in class A contains 16,777,216
addresses
Module 4

Blocks in Class A

Millions of class A addresses are


wasted.
Module 4

Class B
• 2 bytes in class B define the netid
• The two leftmost bits should be ‘10’
• Class B is divided into 214 = 16,384 blocks
• Each block in class B contains 65,536
addresses
Module 4

Blocks in Class B

Many class B addresses are wasted.


Module 4

Class C
• 3 bytes in class C define the netid
• The three leftmost bits should be ‘110’
• Class C is divided into 221 = 2,097,152
blocks
• Each block in class C contains 256
addresses
Module 4

Blocks Class C
Module 4

Class C

The number of addresses in class C is


smaller than the needs of most
organizations.
Module 4

The Single Block in Class D and E


• Class D
– Class D is designed for multicasting
– Used to define one group of hosts on the Internet

• Class E
– Reserved for future purposes
Module 4

Network addresses

In classful addressing, the network


address is the one that is assigned to
the organization.
Module 4

Example
Given the address 23.56.7.91, find the network address.

Solution:
The class is A. Only the first byte defines the netid. We can find the network
address by replacing the hostid bytes (56.7.91) with 0s. Therefore, the
network address is 23.0.0.0.

Given the address 132.6.17.85, find the network address.


Solution:
The class is B. The first 2 bytes defines the netid. We can find the network
address by replacing the hostid bytes (17.85) with 0s. Therefore, the
network address is 132.6.0.0.
Module 4

Network Mask
• Used to extract the network address from
the destination address of a packet
• Called a default mask
Module 4

Finding a Network Address using the Default Mask


Module 4

Example
A router receives a packet with the destination address
201.24.67.32. Show how the router finds the network address
of the packet.
Solution
Since the class of the address is C, we assume that the
router applies the default mask for class C, 255.255.255.0
to find the network address.
• Destination address -> 201 . 24 . 67 . 32

• Default mask -> 255 . 255 . 255 . 0

• Network address -> 201 . 24 . 67 . 0


Module 4

Default mask
In Dotted-
Class In Binary Using Slash
Decimal

A 11111111 00000000 00000000 00000000 255.0.0.0 /8

B 11111111 11111111 00000000 00000000 255.255.0.0 /16

C 11111111 111111111 11111111 00000000 255.255.255.0 /24

The network address can be found by applying the default


mask to any address in the block (including itself).
It retains the netid of the block and sets the hostid to 0s.
Module 4

A network with two levels of hierarchy

IP addresses are designed with two


levels of hierarchy.
Module 4

Subnetting
• The organization that was granted a block in class A or B
needed to divide its large network into several subnetworks
for better security and management.
• In subnetting, a network is divided into several smaller
subnetworks with each subnetwork having its own
subnetwork address.
• Three level of addressing.
Module 4

Three level of addressing


Module 4

Subnet mask
Module 4

Subnetting in two equal networks


Module 4

Subnetting in four equal networks


Module 4

4 Subnets
Module 4

Logical and Physical view


Module 4

Examples
An address in a block is given as 73.22.17.25. Find the
number of addresses in the block, the first address, and the
last address.

Solution
1. The number of addresses in this block is
N = 232-n = 224 = 16,777,216
2. To find the first address, we keep the left most 8 bits and
set the rightmost 24 bits all to 0s. The first address is
73.0.0.0/8 in which 8 is the value of n.
3. To find the last address, we keep the leftmost 8 bits and
set the rightmost 24 bits all to 1s. The last address is
73.255.255.255
Module 4

Variable length Subnetting


Module 4

Examples
Q1. What is the maximum number of IP addresses that can be assigned to
hosts on a local subnet that uses the 255.255.255.224 subnet mask?
Solution:
A /27 (255.255.255.224) is 3 bits on and 5 bits off. This provides 8 subnets,
each with 30 hosts.
Q2. You need to subnet a network that has 5 subnets, each with at least
16 hosts. Which classful subnet mask would you use?
Options:
A. 255.255.255.192
B. 255.255.255.224
C. 255.255.255.240
D. 255.255.255.248
Solution:
You need 5 subnets, each with at least 16 hosts. The mask 255.255.255.240
provides 16 subnets with 14 hosts-this will not work. The mask 255.255.255.224
provides 8 subnets, each with 30 hosts. This is the best answer.
Module 4

Problems
Question:
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 and second subnet, find-
1.Subnet Address
2.First Host ID
3.Last Host ID
4.Broadcast Address
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 = 27 = 128.
Module 4

Problems

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

For 2nd Subnet-

• Subnet Address = First IP Address = 172.16.0.128


• First Host ID = 172.16.0.129
• Last Host ID = 172.16.0.254
• Broadcast Address = Last IP Address = 172.16.0.255
Module 4

Classless Addressing
• Classful address did not solve the address depletion
problem
Distribution of addresses and the routing process more
difficult

• With the growth of the Internet, a larger address space


was needed as a long-term solution

• Although the long-range solution has already been


devised and is called IPv6, a short-term solution was
also devised to use the same address space but to
change the distribution of addresses
Classless addressing
Module 4

Classless adressing
• Classless Addressing is an improved IP Addressing system.
• It makes the allocation of IP Addresses more efficient.
• It replaces the older classful addressing system based on
classes.
• It is also known as Classless Inter Domain Routing (CIDR).

CIDR Block-
When a user asks for specific number of IP Addresses,
• CIDR dynamically assigns a block of IP Addresses based on certain rules.
• This block contains the required number of IP Addresses as demanded by the
user.
• This block of IP Addresses is called as a CIDR block.
Module 4

Rules for Classless Address


Rules For Creating CIDR Block-
A CIDR block is created based on the following 3 rules-
Rule-01:
All the IP Addresses in the CIDR block must be contiguous.
Rule-02:
The size of the block must be presentable as power of 2.
• Size of the block is the total number of IP Addresses contained in the block.
• Size of any CIDR block will always be in the form 21, 22, 23, 24, 25 and so on.
Rule-03:
First IP Address of the block must be divisible by the size of the block.
Module 4

CIDR Notation
CIDR IP Addresses look like-
a.b.c.d / n
• They end with a slash followed by a number called as IP network prefix.
• IP network prefix tells the number of bits used for the identification of
network.
• Remaining bits are used for the identification of hosts in the network.

Example-

An example of CIDR IP Address is-


182.0.1.2 / 28
It suggests-
• 28 bits are used for the identification of network.
• Remaining 4 bits are used for the identification of hosts in the network.
Module 4

Examples
Question:
Given the CIDR representation 20.10.30.35 / 27. Find the range of IP
Addresses in the CIDR block.
Solution-

Given CIDR representation is 20.10.30.35 / 27.


It suggests-
•27 bits are used for the identification of network.
•Remaining 5 bits are used for the identification of hosts in the network.
Given CIDR IP Address may be represented as-
00010100.00001010.00011110.00100011 / 27
So,
•First IP Address = 00010100.00001010.00011110.00100000 = 20.10.30.32
•Last IP Address = 00010100.00001010.00011110.00111111 = 20.10.30.63

Thus, Range of IP Addresses = [ 20.10.30.32 , 20.10.30.63]


Module 4

Special addresses
• In classful addressing some addresses were
reserved for special purposes. The classless
addressing scheme inherits some of these
special addresses from classful addressing
• Special block
All-Zero Address
All-One Address
Loopback Address
Private Address
Multicast Address
• Special address in each block
Network Address
Direct broadcast address
Module 4

IP Datagram
Module 4

▪ Version---Indicates the version of IP currently used.


▪ IP Header Length (IHL)---Indicates the datagram header length in 32-bit words.
▪ Type-of-Service---Assigns datagrams various levels of importance.
▪ Total Length---Specifies the length, in bytes, of the entire IP packet.
▪ Identification---Contains an integer that identifies the current datagram.
▪ Flags---The two low-order (least-significant) bits control fragmentation. The low-order bit
specifies whether the packet can be fragmented. The middle bit specifies whether the packet is
the last fragment in a series of fragmented packets. The third or high-order bit is not used.
▪ Fragment Offset---Indicates the position of the fragment's data relative to the beginning of the
data in the original datagram.
▪ Time-to-Live---Maintains a counter that gradually decrements down to zero, at which point the
datagram is discarded. This keeps packets from looping endlessly.
▪ Protocol---Indicates which upper-layer protocol receives incoming packets after IP processing is
complete.
▪ Header Checksum---Helps ensure IP header integrity.
▪ Source Address---Specifies the sending node.
▪ Destination Address---Specifies the receiving node.
▪ Options---Allows IP to support various options, such as security.
▪ Data---Contains upper-layer information.
Module 4

IPv6 Specification (RFC1883)


• IP version 6 (IPv6) is a new version of the Internet Protocol, designed as a successor to IP
version 4 (IPv4) [RFC-791]. The changes from IPv4 to IPv6 fall primarily into the following
categories:
• Expanded Addressing Capabilities IPv6 increases the IP address size from 32 bits to 128 bits, to
support more levels of addressing hierarchy, a much greater number of addressable nodes, and
simpler auto-configuration of addresses.
• The scalability of multicast routing is improved by adding a "scope" field to multicast addresses.
• And a new type of address called an "anycast address" is defined, used to send a packet to any
one of a group of nodes.
• Header Format Simplification Some IPv4 header fields have been dropped or made optional, to
reduce the common-case processing cost of packet handling and to limit the bandwidth cost of
the IPv6 header.
• Improved Support for Extensions and Options Changes in the way IP header options are encoded
allows for more efficient forwarding, less stringent limits on the length of options, and greater
flexibility for introducing new options in the future.
• Flow Labeling Capability A new capability is added to enable the labeling of packets belonging
to particular traffic "flows" for which the sender requests special handling, such as non-default
quality of service or "real-time" service.
• Authentication and Privacy Capabilities Extensions to support authentication, data integrity, and
(optional) data confidentiality are specified for IPv6.
Module 4

IPv6
Internet Protocol

IPv6 frame format


Internet Protocol
Internet Protocol

IP Configuration of an Interface
Static DHCP
Internet Protocol

ARP
ARP (Address Resolution Protocol) is used in
Ethernet Networks to find the MAC address of a
node given its IP address.
Source node (say 192.168.2.32) sends broadcast
message (ARP Request) on its subnet asking ``Who
is 192.168.2.33’’.
All computers on subnet receive this request
Destination responds (ARP Reply) since it has
192.168.2.33
Provides its MAC address in response
Internet Protocol

ARP Process
Internet Protocol

IPv6
IPv6 uses 128 bit address instead of 32 bit address.
The IPv6 addresses are being distributed and are
supposed to be used based on geographical
location.

You might also like