Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

Unit 3-Network Layer

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

BCA III SEM COMPUTER NETWORK RIBS

UNIT II Introduction to network layer


Introduction to network layer
 Network layer is the third layer in the OSI model of computer networks. It’s main function
is to transfer network packets from the source to the destination. It is involved both at the
source host and the destination host.
 At the source, it accepts a packet from the transport layer, encapsulates it in a datagram
and then deliver the packet to the data link layer so that it can further be sent to the
receiver.
 At the destination, the datagram is decapsulated, the packet is extracted and delivered to
the corresponding transport layer.
Features :
1. Main responsibility of Network layer is to carry the data packets from the source to the
destination without changing or using it.
2. If the packets are too large for delivery, they are fragmented i.e., broken down into smaller
packets.
3. It decides the route to be taken by the packets to travel from the source to the destination
among the multiple routes available in a network (also called as routing).
4. The source and destination addresses are added to the data packets inside the network
layer.

Network Layer Services:


 Packetizing –
The process of encapsulating the data received from upper layers of the network(also called
as payload) in a network layer packet at the source and decapsulating the payload from the
network layer packet at the destination is known as packetizing.
 The source host adds a header that contains the source and destination address and some
other relevant information required by the network layer protocol to the payload received
from the upper layer protocol, and delivers the packet to the data link layer.
 The destination host receives the network layer packet from its data link layer, decapsulates
the packet, and delivers the payload to the corresponding upper layer protocol. The routers
in the path are not allowed to change either the source or the destination address. The
routers in the path are not allowed to decapsulate the packets
they receive unless they need to be fragmented.

PKM Page 1
BCA III SEM COMPUTER NETWORK RIBS

Routing and Forwarding:


Other duties of the network layer, which are as important as the first, are routing and forwarding,
which are directly related to each other.
Routing:
In a network, there are a number of routes available from the source to the destination. The
network layer specifies has some strategies which find out the best possible route. This process
is referred to as routing. There are a number of routing protocols which are used in this process
and they should be run to help the routers coordinate with each other and help in establishing
communication throughout the network.

Forwarding :
Forwarding can be defined as the action applied by each router when a packet arrives at one of
its 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, which
can be the destination address or a label, to find the corresponding output interface number in
the forwarding table.

Packet Switching:
It is a method of transferring the data to a network in form of packets. In order to transfer the file fast
and efficiently manner over the network and minimize the transmission latency, the data is broken into
small pieces of variable length, called Packet. At the destination, all these small parts (packets) have to
be reassembled, belonging to the same file. A packet composes of payload and various control
information. No pre-setup or reservation of resources is needed.

Packet Switching uses Store and Forward technique while switching the packets; while forwarding the
packet each hop first stores that packet then forward. This technique is very beneficial because packets
may get discarded at any hop due to some reason. More than one path is possible between a pair of
sources and destinations. Each packet contains Source and destination address using which they

PKM Page 2
BCA III SEM COMPUTER NETWORK RIBS

independently travel through the network. In other words, packets belonging to the same file may or
may not travel through the same path. If there is congestion at some path, packets are allowed to
choose different paths possible over an existing network .

NETWORK- LAYER PERFORMANCE


*** Same as the performance topic of UNIT 1***

Network Layer Protocols


The network layer contains following 4 protocols (Figure 19.1):
1)Internet Protocol (IP)
IP is the main protocol responsible for packetizing, forwarding, and delivery of a packet at the
network layer.
2) Internet Control Message Protocol (ICMP)
ICMP helps IP to handle some errors that may occur in the network-layer delivery.
3) Internet Group Management Protocol (IGMP)
IGMP is used to help IPv4 in multicasting.
4) Address Resolution Protocol (ARP)
ARP is used to glue the network and data-link layers in mapping network-layer addresses to
link-layer addresses.

PKM Page 3
BCA III SEM COMPUTER NETWORK RIBS

Internet Protocol (IP)


5.7.1 Internet Protocol (IP)
IP is main protocol responsible for packetizing, forwarding & delivery of a packet at network layer.
IP is an unreliable datagram protocol.
IP provides a best-effort delivery service.
The term best-effort means that the packets can be corrupted
be lost or
arrive out-of-order.
If reliability is important, IP must be paired with a TCP which is reliable transport-layer protocol.
IP is a connectionless protocol.
IP uses the datagram approach.
Each datagram is handled independently.
Each datagram can follow a different route to the destination. Datagrams may arrive out-of-order
at the destination.

Datagram Format
• IP uses the packets called datagrams.
• A datagram consist of 2 parts (Figure 19.2):
a)Payload b)Header

1) Payload
Payload (or Data) is the main reason for creating a datagram.
Payload is the packet coming from other protocols that use the service of IP.
2) Header
Header contains information essential to routing and delivery. IP header contains following fields:
1) Version Number (VER)
This field indicates version number used by the packet. Current version=4
2) Header Length (HLEN)

PKM Page 4
BCA III SEM COMPUTER NETWORK RIBS

This field specifies length of header.


When a device receives a datagram, the device needs to know
when the header stops and when the data starts.
3) Service Type
This field specifies priority of packet based on delay, throughput, reliability & cost requirements.
4) Total Length
This field specifies the total length of the datagram (header plus data). Maximum length=65535
bytes.
5) Identification, Flags, and Fragmentation Offset
These 3 fields are used for fragmentation and reassembly of the datagram.
Fragmentation occurs when the size of the datagram is larger than the MTU of the network.
6) Time-to-Live (TTL)
This field is indicates amount of time, the packet is allowed to remain in the network.
If TTL becomes 0 before packet reaches destination, the router
discards packet and
sends an error-message back to the source.
7) Protocol
This field specifies upper-layer protocol that is to receive the packet at the destination-host. For
example (Figure 19.3):
For TCP, protocol = 6 For UDP, protocol = 17
8) Header Checksum
This field is used to verify integrity of header only. If the verification process fails, packet is
discarded.
9) Source and Destination Addresses
These 2 fields contain the IP addresses of source and destination hosts.
10) Options
This field allows the packet to request special features such as security level route to be taken by
packet and timestamp at each router .This field can also be used for network testing and
debugging.
11) Padding
This field is used to make the header a multiple of 32-bit words.

ICMP: ICMP is a network-layer protocol.

PKM Page 5
BCA III SEM COMPUTER NETWORK RIBS

This is used to handle error and other control messages.


MESSAGES
ICMP messages are divided into 2 broad categories:
1.Error-Reporting Messages
These messages report problems that a router or a host may encounter during the processing of
datagram.
2) Query Messages
These messages help a host or a network manager get specific information from a router or
another host. For example:
Nodes can discover their neighbors.
Hosts can discover and learn about routers on their network. Routers can help a node redirect
the messages.

Mobile IP:
Mobile IP is the extension of IP protocol.
Mobile IP allows mobile computers to be connected to the Internet.
Addressing
In Mobile IP, the main problem that must be solved is addressing.
Stationary Hosts
The original IP addressing assumed that a host is stationary. A router uses an IP address to route an
IP datagram.
An IP address has two parts: a prefix and a suffix. The prefix associates a host with a network.
For example, the IP address 10.3.4.24/8 defines a host attached to the network 10.0.0.0/8.
• The address is valid only when the host is attached to the network. If the network changes, the
address is no longer valid.

Mobile Hosts
When a host moves from one network to another, the IP addressing structure needs to be modified.
The host has two addresses (Figure 19.12):
Home address & Care-of address

Home Address
Original address of host called the home address. The home address is permanent.
The home address associates the host with its home network. Home network is a network that is the
permanent home of the host.
2) Care-of-Address
The care-of address is temporary.
The care-of address changes as the mobile-host moves from one network to another. Care-of address
is associated with the foreign network.
Foreign network is a network to which the host moves.
When a mobile-host visits a foreign network, it receives its care-of address during the agent discovery
and registration phase.

PKM Page 6
BCA III SEM COMPUTER NETWORK RIBS

Agents

Two agents are required to make change of address transparent to rest of the Internet (Fig 19.13):
Home-agent and
Foreign-agent.

1) Home Agent
• The home-agent is a router attached to the home network.
• The home-agent acts on behalf of mobile-host when a remote-host sends a packet to mobile-host.
• The home-agent receives and delivers packets sent by the remote-host to the foreign-agent.

2) Foreign Agent
The foreign-agent is a router attached to the foreign network.
The foreign-agent receives and delivers packets sent by the home-agent to the mobile-host.
The mobile-host can also act as a foreign-agent i.e. mobile-host and foreign-agent can be the same.
However, to do this, a mobile-host must be able to receive a care-of address by itself.

PKM Page 7
BCA III SEM COMPUTER NETWORK RIBS

In addition, the mobile-host needs the necessary software to allow it to communicate with the home-
agent and to have two addresses: i) its home address and ii) its care-of address.
This dual addressing must be transparent to the application programs.
Collocated Care-of-Address
When the mobile-host and the foreign-agent are the same, the care-of-address is called a collocated
care-of-address.
Advantage:
mobile-host can move to any network w/o worrying about availability of a foreign-agent.
Disadvantage:
The mobile-host needs extra software to act as its own foreign-agent.
Three Phases
To communicate with a remote-host, a mobile-host goes through 3 phases (Figure 19.14):
Agent Discovery: involves the mobile-host, the foreign-agent, and the home-agent.
Registration: involves the mobile-host, the foreign-agent, and the home-agent.
Data Transfer: Here, the remote-host is also involved.

Agent Discovery
Agent discovery consists of two subphases:
A mobile-host must discover (learn the address of) a home-agent before it leaves its home network.
A mobile-host must also discover a foreign-agent after it has moved to a foreign network.
This discovery consists of learning the care-of address as well as the foreign-agent‟s address. Two
types of messages are used: i) advertisement and ii) solicitation.
1) Agent Advertisement
• When a router advertises its presence on a network using an ICMP router advertisement, it can
append an agent advertisement to the packet if it acts as an agent.

PKM Page 8
BCA III SEM COMPUTER NETWORK RIBS

• Various fields are (Figure 19.15):


1) Type
This field is set to 16.
2) Length
This field defines the total length of the extension message.
3) Sequence Number
This field holds the message number.
The recipient can use the sequence number to determine if a message is lost.
4) Lifetime
This field defines the number of seconds that the agent will accept requests. If the value is a string of
1s, the lifetime is infinite.
5) Code
This field is a flag in which each bit is set (1) or unset (0) (Table 19.1).

6) Care-of Addresses
This field contains a list of addresses available for use as care-of addresses. The mobile-host can
choose one of these addresses.The selection of this care-of address is announced in the registration
request.

Agent Solicitation
When a mobile-host has moved to a new network and has not received agent advertisements, it can
initiate an agent solicitation.
It can use the ICMP solicitation message to inform an agent that it needs assistance
Registration
After a mobile-host has moved to a foreign network and discovered the foreign-agent, it must
register. Four aspects of registration:
The mobile-host must register itself with the foreign-agent.

PKM Page 9
BCA III SEM COMPUTER NETWORK RIBS

The mobile-host must register itself with its home-agent. This is normally done by the foreign-agent
on behalf of the mobile-host.
The mobile-host must renew registration if it has expired.
The mobile-host must cancel its registration (deregistration) when it returns home.
Request & Reply
To register with the foreign-agent and the home-agent, the mobile-host uses a registration request
and a registration reply.
1) Registration Request
A registration request is sent from the mobile-host to the foreign-agent to register its care-of address
and to announce its home address and home-agent address.
Foreign-agent, after receiving and registering the request, relays the message to the home-agent.
The home-agent now knows the address of the foreign-agent because the IP packet that is used for
relaying has the IP address of the foreign-agent as the source address.

Data Transfer
• After agent discovery & registration, a mobile-host can communicate with a remote-host

Here we have 4 cases (Figure 19.18):


1) From Remote-host to Home Agent
When a remote-host wants to send a packet to the mobile-host, the remote-host uses address of
itself as the source address and
home address of the mobile-host as the destination address.
In other words, the remote-host sends a packet as though the mobile-host is at its home network.
The packet is intercepted by the home-agent, which pretends it is the mobile-host.
This is done using the proxy ARP technique (Path 1 of Figure 19.18).
2) From Home Agent to Foreign Agent

PKM Page 10
BCA III SEM COMPUTER NETWORK RIBS

After receiving the packet, the home-agent sends the packet to the foreign-agent, using the tunneling
concept. The home-agent encapsulates the whole IP packet inside another IP packet using its address
as the source and the foreign-agent‟s address as the destination. (Path 2 of Figure 19.18).
3) From Foreign Agent to Mobile Host
When the foreign-agent receives the packet, it removes the original packet.
However, since the destination address is the home address of the mobile-host, the foreign-agent
consults a registry table to find the care-of address of the mobile-host. (Otherwise, the would just be
sent back to the home network.)
The packet is then sent to the care-of address (Path 3 of Figure 19.18).
4) From Mobile Host to Remote Host
When a mobile-host wants to send a packet to a remote-host (for example, a response to the packet
it has received), it sends as it does normally.
The mobile-host prepares a packet with its home address as the source, and the address of the
remote-host as the destination.
Although the packet comes from the foreign network, it has the home address of the mobile-host .

Inefficiency in Mobile IP
Communication involving mobile IP can be inefficient. The inefficiency can be severe or moderate.
The severe case is called double crossing or 2X.
The moderate case is called triangle routing or dog-leg routing.

Double Crossing
Double crossing occurs when a remote-host communicates with a mobile-host that has moved to the
same network (or site) as the remote-host (Figure 19.19).
When the mobile-host sends a packet to the remote-host, there is no inefficiency; the communication
is local. However, when remote-host sends a packet to mobile-host, the packet crosses the Internet
twice.
Since a computer usually communicates with other local computers (principle of locality), the
inefficiency from double crossing is significant.

Triangle Routing
Triangle routing occurs when the remote-host communicates with a mobile-host that is not attached
to the same network (or site) as the mobile-host.
When the mobile-host sends a packet to the remote-host, there is no inefficiency.

However, when the remote-host sends a packet to the mobile-host, the packet goes from the remote-
host to the home-agent and then to the mobile-host.
The packet travels the two sides of a triangle, instead of just one side

PKM Page 11
BCA III SEM COMPUTER NETWORK RIBS

Routing algorithm
o In order to transfer the packets from source to the destination, the network layer must determine
the best route through which packets can be transmitted.
o Whether the network layer provides datagram service or virtual circuit service, the main job of
the network layer is to provide the best route. The routing protocol provides this job.
o The routing protocol is a routing algorithm that provides the best path from the source to the
destination. The best path is the path that has the "least-cost path" from source to the
destination.
o Routing is the process of forwarding the packets from source to the destination but the best route
to send the packets is determined by the routing algorithm.

Classification of a Routing algorithm

The Routing algorithm is divided into two categories:

o Adaptive Routing algorithm


o Non-adaptive Routing algorithm

Adaptive Routing algorithm

PKM Page 12
BCA III SEM COMPUTER NETWORK RIBS

o An adaptive routing algorithm is also known as dynamic routing algorithm.


o This algorithm makes the routing decisions based on the topology and network traffic.
o The main parameters related to this algorithm are hop count, distance and estimated transit time.

An adaptive routing algorithm can be classified into three parts:

o Centralized algorithm: It is also known as global routing algorithm as it computes the least-cost
path between source and destination by using complete and global knowledge about the
network. This algorithm takes the connectivity between the nodes and link cost as input, and this
information is obtained before actually performing any calculation. Link state algorithm is
referred to as a centralized algorithm since it is aware of the cost of each link in the network.
o Isolation algorithm: It is an algorithm that obtains the routing information by using local
information rather than gathering information from other nodes.
o Distributed algorithm: It is also known as decentralized algorithm as it computes the least-cost
path between source and destination in an iterative and distributed manner. In the decentralized
algorithm, no node has the knowledge about the cost of all the network links. In the beginning, a
node contains the information only about its own directly attached links and through an iterative
process of calculation computes the least-cost path to the destination. A Distance vector
algorithm is a decentralized algorithm as it never knows the complete path from source to the
destination, instead it knows the direction through which the packet is to be forwarded along with
the least cost path.

Non-Adaptive Routing algorithm

o Non Adaptive routing algorithm is also known as a static routing algorithm.


o When booting up the network, the routing information stores to the routers.
o Non Adaptive routing algorithms do not take the routing decision based on the network topology
or network traffic.

The Non-Adaptive Routing algorithm is of two types:

PKM Page 13
BCA III SEM COMPUTER NETWORK RIBS

Flooding: In case of flooding, every incoming packet is sent to all the outgoing links except the one from
it has been reached. The disadvantage of flooding is that node may contain several copies of a particular
packet.

Random walks: In case of random walks, a packet sent by the node to one of its neighbors randomly. An
advantage of using random walks is that it uses the alternative routes very efficiently.

Differences b/w Adaptive and Non-Adaptive Routing Algorithm

Basis Of Adaptive Routing algorithm Non-Adaptive Routing algorithm


Comparison

Define Adaptive Routing algorithm is an algorithm that The Non-Adaptive Routing algorithm is an algorithm that
constructs the routing table based on the network constructs the static table to determine which node to send
conditions. the packet.

Usage Adaptive routing algorithm is used by dynamic routing. The Non-Adaptive Routing algorithm is used by static
routing.

Routing Routing decisions are made based on topology and Routing decisions are the static tables.
decision network traffic.

Categorization The types of adaptive routing algorithm, are The types of Non Adaptive routing algorithm are flooding
Centralized, isolation and distributed algorithm. and random walks.

Complexity Adaptive Routing algorithms are more complex. Non-Adaptive Routing algorithms are simple.

Unicast Routing Protocols

There are two kinds of routing protocols available to route unicast packets:
 Distance Vector Routing Protocol
Distance Vector is simple routing protocol which takes routing decision on the number of hops
between source and destination. A route with less number of hops is considered as the best route.
Every router advertises its set best routes to other routers. Ultimately, all routers build up their
network topology based on the advertisements of their peer routers,
For example Routing Information Protocol (RIP).
 Link State Routing Protocol
Link State protocol is slightly complicated protocol than Distance Vector. It takes into account the
states of links of all the routers in a network. This technique helps routes build a common graph
of the entire network. All routers then calculate their best path for routing purposes.for example,
Open Shortest Path First (OSPF) and Intermediate System to Intermediate System (ISIS).

PKM Page 14
BCA III SEM COMPUTER NETWORK RIBS

NEXT GENERATION IP
IPv6 Addressing
The main reason for migration from IPv4 to IPv6 is the small size of the address-space in IPv4. Size of
IPv6 address =128 bits (four times the address length in IPv4, which is 32 bits).
Representation
• Two notations can be used to represent IPv6 addresses: 1) binary and 2) colon hexadecimal.

Address Space
The address-space of IPv6 contains 2128 addresses.
Three Address Types
Three types of destination address: 1) Unicast 2) Anycast and 3) Multicast.
1) Unicast Address
A unicast address defines a single interface (computer or router).
The packet with a unicast address will be delivered to the intended recipient.
2) Anycast Address
An anycast address defines a group of computers that all share a single address. A packet with an
anycast address is delivered to only one member of the group. The member is the one who is first
reachable.
3) Multicast Address
A multicast address also defines a group of computers. Difference between anycasting and
multicasting.
In any casting, only one copy of the packet is sent to one of the members of the group. in multicasting
each member of the group receives a copy.

The IPv6 Protocol


IPv6 uses a new header format.
Options are separated from the base-header and inserted between the base-header and the data.
This speeds up the routing process (because most of the options do not need to be checked by
routers).
New Options
IPv6 has new options to allow for additional functionalities.
Extension
IPv6 is designed to allow the extension of the protocol if required by new technologies or
applications.
Resource Allocation
In IPv6,
type-of-service (TOS) field has been removed
two new fields: 1) traffic class and 2) flow label, are added to enable the source to request special
handling of the packet.
This mechanism can be used to support real-time audio and video.
Security
The encryption option provides confidentiality of the packet. The authentication option provides
integrity of the packet.
Packet Format

PKM Page 15
BCA III SEM COMPUTER NETWORK RIBS

IP header contains following fields (Figure 22.6):


Version
This specifies version number of protocol. For IPv6, version=6.
2) Traffic Class
This field is used to distinguish different payloads with different delivery requirements.
(Traffic class replaces the type-of-service field in IPv4).
3) Flow Label
This field is designed to provide special handling for a particular flow of data.
4) Payload Length
This indicates length of data (excluding header). Maximum length=65535 bytes.
The length of the base-header is fixed (40 bytes); only the length of the payload needs to be defined.
5) Next Header
This identifies type of extension header that follows the basic header.
6) Hop Limit
This specifies number of hops the packet can travel before being dropped by a router. (Hop limit
serves the same purpose as the TTL field in IPv4).
7) Source and Destination Addresses
These identify source host and destination host respectively.

8) Payload
The payload contains zero or more extension headers (options) followed by the data from other
protocols (UDP, TCP, and so on).
The payload can have many extension headers as required by the situation. Each extension header
has 2 mandatory fields: Next header and Length Two mandatory fields are followed by information
related to the particular option.

PKM Page 16

You might also like