Unit 3-Network Layer
Unit 3-Network Layer
Unit 3-Network Layer
PKM Page 1
BCA III SEM COMPUTER NETWORK RIBS
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 .
PKM Page 3
BCA III SEM COMPUTER NETWORK RIBS
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
PKM Page 5
BCA III SEM COMPUTER NETWORK RIBS
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
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
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.
PKM Page 12
BCA III SEM COMPUTER NETWORK RIBS
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.
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.
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.
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.
PKM Page 15
BCA III SEM COMPUTER NETWORK RIBS
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