4-Network Layer-1
4-Network Layer-1
4-Network Layer-1
NETWORK
LAYER
Introduction ........
• It is Responsible for the host-to-host
delivery of datagrams.
• It provides services to the transport
layer and receives services from the
data-link layer.
• Here are some services provided by
NETWORK LAYER.
Services Provided by Network Layer
• PACKETIZING
• ROUTING
• FORWARDING
• ERROR CONTROL
• FLOW CONTROL
• CONGESTION CONTROL
• QUALITY OF SERVICE
• SECURITY
Packetizing
• The first duty of the network layer is definitely
packetizing:
• Encapsulating the payload (data received from upper
layer) in a network-layer packet at the source and
decapsulating the payload from the network-layer
packet at the destination.
• The network layer is doing the service of a carrier
such as the postal office,
• Which is responsible for delivery of packages from a
sender to a receiver without changing or using the
contents.
Packetizing...........
The source host receives the payload, adds a header that
contains the source and destination addresses and some other
information and delivers the packet to the data-link layer.
The source is not allowed to change the content of the payload
unless it is too large for delivery and needs to be fragmented.
The destination host receives the packet from its data-link
layer, Decapsulates the packet, and delivers the payload to the
corresponding upper-layer protocol.
If the packet is fragmented at the source or at routers along
the path, the network layer is responsible for waiting until all
fragments arrive, reassembling them, and delivering them to
the upper-layer protocol.
Routing
The network layer is responsible for routing the packet
from its source to the destination.
A physical network is a combination of networks (LANs
and WANs) and routers that connect them.
This means that there is more than one route from the
source to the destination.
The network layer is responsible for finding the best
one among these possible routes.
The network layer needs to have some specific
strategies for defining the best route [using routing
protocols].
Forwarding
Forwarding can be defined as the action applied by
e a c h ro u t e r w h e n a p a c ke t a rr i v e s a t o n e o f i t s
interfaces.
The decision-making table a router normally uses for
applying this action is sometimes called the forwarding
table and sometimes the routing table.
When a router receives a packet from one of its
attached networks, it needs to forward the packet to
another attached network.
To make this decision, the router uses a piece of
information in the packet header, Destination address
or a label.
Error Control
It ensures that packet traveling from source to
destination should be error free.
Although error control also can be implemented in
the network layer,
The designers of the network layer in the Internet
ignored this issue for the data being carried by the
network layer.
One reason for this decision is the fact that the
packet in the network layer may be fragmented at
each router, which makes error checking at this
layer inefficient.
Flow Control
Flow control regulates the amount of data a
source can send without overwhelming the
receiver.
If the upper layer at the source computer
produces data faster than the upper layer at
the destination computer can consume it, the
receiver will be overwhelmed with data.
To control the flow of data, the receiver needs
to send some feedback to the sender to inform
the latter that it is overwhelmed with data.
Congestion Control
Another issue in a network-layer protocol is congestion control.
Congestion in the network layer is a situation in which too many
datagrams are present in an area of the Internet.
Congestion may occur if the number of datagrams sent by source
computers is beyond the capacity of the network or routers.
In this situation, some routers may drop some of the datagrams.
However, as more datagrams are dropped, the situation may
become worse because,
Due to the error control mechanism at the upper layers, the sender
may send duplicates of the lost packets.
If the congestion continues, sometimes a situation may reach a
point where the system collapses and no datagrams are delivered.
Quality of Service
Choke Packet
Choke Packet
A choke packet is a packet sent by a node to the source to
inform it of congestion.
Note the difference between the backpressure and choke-
packet methods.
In backpressure, the warning is from one node to its
upstream node, although the warning may eventually reach
the source station.
In the choke-packet method, the warning is from the router,
which has encountered congestion, directly to the source
station.
The intermediate nodes through which the packet has
traveled are not warned.
Implicit Signaling
In implicit signaling, there is no communication
between the congested node and the source.
T h e s o u rc e g u e s s e s t h a t t h e re i s c o n g e s t i o n
somewhere in the network from other symptoms.
For example, when a source sends several packets
and there is no acknowledgment for a while, one
assumption is that the network is congested.
The delay in receiving an acknowledgment is
interpreted as congestion in the network
Explicit Signaling
The node that experiences congestion can explicitly
send a signal to the source or destination.
The explicit-signaling method, however, is different
from the choke-packet method.
In the choke-packet method, a separate packet is
used for this purpose.
In the explicit-signaling method, the signal is
included in the packets that carry data.
Explicit signaling can occur in either the forward or
the backward direction.
IPV4 ADDRESSES
The identifier used to identify the connection
of each device to the Internet is called the
Internet address or IP address.
A n I P v 4 a d d re s s i s a 3 2 - b i t a d d re s s t h a t
uniquely and universally defines the connection
of a host or a router to the Internet.
The IP address is the address of the connection,
not the host or the router, because if the device
is moved to another network, the IP address
may be changed.
Address Space
A protocol like IPv4 that defines addresses has an
address space.
An address space is the total number of addresses
used by the protocol.
IPv4 uses 32-bit addresses, which means that the
address space is 2^32 or 4,294,967,296 (more than
four billion).
4,294,967,296
Notation
IPv6 Address Space : The 128 bits of IPv6 addresses mean the size of the IPv6 address
space is, quite literally, astronomical; like the numbers that describe the number of stars in
a galaxy or the distance to the furthest pulsars, the number of addresses that can be
supported in IPv6 is mind-boggling.
Notation
IP addresses are displayed in dotted decimal notation, and appear as four
numbers separated by dots.
Each number of an IP address is made from eight individual bits known as
Octet.
Each octet can create number value from 0 to 255.
An IP address would be 32 bits long in binary divided into the two
components, network component and host component.
Network component is used to identify the network that the packet is
intend for, and host component is used to identify the individual host on
network.
IP addresses are broken into the two components:
Network component :- Defines network segment of device.
Host component :- Defines the specific device on a particular network
segment
Addressing [example phone no]
Classful Addressing
Classful Addressing
The whole address space was divided into five
classes (class A, B, C, D, and E), as shown in Figure.
This scheme is referred to as classful addressing.
CLASS A
In class A, the network length is 8 bits, but since the
first bit, which is 0, defines the class.
We can have only seven bits as the network
identifier.
This means there are only 2^7 = 128 networks in
the world that can have a class A address.
Classful Addressing
CLASS B
In class B, the network length is 16 bits, but
since the first two bits, which are 10, define the
class.
We can have only 14 bits as the network
identifier.
This means there are only 2^14 = 16,384
networks in the world that can have a class B
address.
Classful Addressing
CLASS C
All addresses that start with 110 belong to
class C.
In class C, the network length is 24 bits, but
since three bits define the class.
We can have only 21 bits as the network
identifier.
This means there are 2^21 = 20,97,152
networks in the world that can have a class C
address.
Classful Addressing
CLASS D
Class D address start with 1110 and it is not divided
into prefix and suffix.
It is used for multicast addresses.
CLASS E
All addresses that start with 1111 in binary belong to
class E.
As in Class D, Class E is not divided into prefix and
suffix and is used as reserve.
Subnetting
To alleviate address depletion, two strategies
were proposed and, to some extent,
implemented :
Subnetting and Supernetting.
Subnetting is a process of breaking large
network in small networks known as subnets.
Subnetting happens when we extend default
boundary of subnet mask.
Basically we borrow host bits to create
networks.
Advantages of Subnetting
S u b n e t t i n g b re a k s l a rg e n e t w o r k i n s m a l l e r
networks and smaller networks are easier to
manage.
Subnetting reduces network traffic by removing
collision and broadcast traffic, that overall improve
performance.
Subnetting allows you to apply network security
polices at the interconnection between subnets.
Subnetting allows you to save money by reducing
requirement for IP range.
Subnetting ......... Example
CIDR [Classless inter domain routing]
CIDR is a slash notation of subnet mask. CIDR tells us
number of on bits in a network address.
Class A has default subnet mask 255.0.0.0.
That means first octet of the subnet mask has all on
bits.
In slash notation it would be written as /8, means
address has 8 bits on.
Class A -----------> /8
Class B -----------> /16
Class C -----------> /24
What is subnet mask for given address?
Find the subnet mask of address 188.25.45.48/20?
This address belong to class B and class B has default
subnet mask 255.255.0.0[ /16 in CIDR ].
We borrowed 4 bits from hosts portion.
As you know subnetting move from left to right and it
cannot skip any network bit.
So this subnet mask in binary would be
11111111.11111111.11110000.00000000
First two octet have default value so its decimal value
would be 255.255 and third octet decimal value is 240.
Our answer subnet mask would be 255.255.240.0
ROUTING ALGORITHMS
Several routing algorithms have been designed
in the past.
The differences between these methods are in
the way they interpret the least cost and the
way they create the least-cost tree for each
node.
They are
Distance-Vector Routing
Link-State Routing
Path-Vector Routing
Distance-Vector Routing
The distance-vector (DV) routing is used to find
the best route.
In distance-vector routing, the first thing each
node creates is its own least-cost tree [about its
immediate neighbors].
The incomplete trees are exchanged between
immediate neighbors to make the trees complete.
We can say that in distance-vector routing, a
router continuously tells all of its neighbors what
it knows about the network.
Bellman-Ford Equation
The heart of distance-vector routing is the Bellman-Ford
equation.
This equation is used to find the least cost (shortest
distance) between a source node, x, and a destination
node, y, through some intermediary nodes (a, b, c, . . . ).
When the costs between the source and the intermediary
nodes and the least costs between the intermediary nodes
and the destination are given.
Lets Dxy is the shortest distance and Cxy is the cost
between nodes x and y.
Dxy = min { (cxa + Day ), (cxb + Dby ), (cxc + Dcy ), (cxd + Ddy)... }
Distance Vectors
THE FIRST DISTANCE VECTOR
UPDATING DISTANCE VECTOR
Link-State Routing
A routing algorithm that directly follows the discussion
for creating least-cost trees and forwarding tables is
link-state (LS) routing.
This method uses the term link-state to define the
characteristic of a link (edge).
In this algorithm the cost associated with an edge
defines the state of the link.
Links with lower costs are preferred to links with
higher costs.
if the cost of a link is infinity, it means that the link
does not exist or has been broken.
Step 1 : Create Link-State Database (LSDB)
68
Figure 7.2 Position of ARP and RARP in TCP/IP protocol suite
69
Figure 7.3 ARP operation
70
Figure 7.4 ARP packet
Hardware
Type - Ethernet
is type 1
Protocol Type-
IPv4=x0800
Hardware
Length:length of
Ethernet
Address (6)
Protocol
Length:length of
IPv4 address (4)
71
Figure 7.5 Encapsulation of ARP packet
75
Figure 7.10 RARP operation
76
Figure 7.11 RARP packet
RIP
OSPF
BGP
INTRA- AND INTER-DOMAIN ROUTING
• Today, an Internet can be so large that one routing protocol
cannot handle the task of updating the routing tables of all
routers.
• For this reason, an Internet is divided into autonomous systems.
• An autonomous system (AS) is a group of networks and routers
under the authority of a single administration.
• Routing inside an autonomous system is referred to as intra-
domain routing.
• Routing between autonomous systems is referred to as inter-
domain routing.
• Each autonomous system can choose one or more intradomain
routing protocols to handle routing inside the autonomous system.
• However, only one interdomain routing protocol handles routing
between autonomous systems.
Classification
• Several intra-domain and inter-domain routing
protocols are in use.
• Routing Information Protocol (RIP) is the
implementation of the distance vector protocol.
• Open Shortest Path First (OSPF) is the
implementation of the link state protocol.
• Border Gateway Protocol (BGP) is the
implementation of the path vector protocol.
• RIP and OSPF are interior routing protocols;
• BGP is an exterior routing protocol.
Routing Protocols
RIP [ROUTING INFORMATION PROTOCOL]
A notification message is
sent by a router whenever an
error condition is detected or
a router wants to close the
connection.