CN Unit-IV Notes
CN Unit-IV Notes
UNIT IV
ROUTING
WHAT IS Routing?
Most of the traffic on the internet and intranets known as unicast data or unicast traffic is sent
with specified destination. Routing unicast data over the internet is called unicast routing. It is
the simplest form of routing because the destination is already known.
1. Distance Vector Routing: Distance-Vector routers use a distributed algorithm to compute their
routing tables.
2. Link-State Routing: Link-State routing uses link-state routers to exchange messages that allow
each router to learn the entire network topology.
3. Path-Vector Routing: It is a routing protocol that maintains the path that is updated
dynamically.
Bellman Ford Basics – Each router maintains a Distance Vector table containing the
distance between itself and ALL possible destination nodes. Distances,based on a
chosen metric, are computed using information from the neighbors’ distance vectors.
Information kept by DV router -
Distance to itself = 0
Distance to ALL other routers = infinity number.
The Distance vector routing algorithms operate by having each router maintain a table (i.e., a
vector), giving the best-known distance to each destination and which path to use to get there.
CS3591 COMPUTER NETWORKS
GNANAMANI COLLEGE OF TECHNOLOGY
DEPARTMENT OF AI&DS
These tables are updated by exchanging information with the neighbors.
The three keys to understanding the working of the Distance Vector Routing Algorithm are:
1. Distance Metric
2. Routing Table
3. Bellman-Ford Algorithm
In this protocol, a routing table is maintained by each router, and it contains only one entry for
each router. It consists of two parts: one is a preferred outgoing line for that destination, and the
other is an estimate of time or delay.
The tables are updated by exchanging the information with the connected adjacent nodes( or
neighbor's nodes).
Each router knows the time delay in reaching its neighbors(or connected nodes).
Routing tables are exchanged with each of their neighbors periodically by routers.
Consider the following network; three routers are there: A, B, and C with AB=1, BC=2, and CA=5.
Each router shares its routing table with every neighbor in this distance vector routing network.
As A will share its routing table with neighbors B and C, neighbors B and C will share their
routing table with A.
Routing table A:
CS3591 COMPUTER NETWORKS
GNANAMANI COLLEGE OF TECHNOLOGY
DEPARTMENT OF AI&DS
Step 2:
If the path via a neighbor has a lower cost, the router updates its local table to forward packets to
the neighbor. In this table, router A will be updated.
Routing table A:
Routing table B:
CS3591 COMPUTER NETWORKS
GNANAMANI COLLEGE OF TECHNOLOGY
DEPARTMENT OF AI&DS
Routing table C:
Step 3:
The following are the final routing table for all the routers A, B, and C with lower cost distance
vector routing protocols.
In the network shown below, there are three routers, A, B, and C, with the following weights − AB
=2, BC =3 and CA =5.
CS3591 COMPUTER NETWORKS
GNANAMANI COLLEGE OF TECHNOLOGY
DEPARTMENT OF AI&DS
Step 1 − In this DVR network, each router shares its routing table with every neighbor. For
example, A will share its routing table with neighbors B and C and neighbors B and C will share
their routing table with A.
Step 2 − If the path via a neighbor has a lower cost, then the router updates its local table to forward
packets to the neighbor. In this table, the router updates the lower cost for A and C by updating the
new weight from 4 to 3 in router A and from 4 to 3 in router C.
CS3591 COMPUTER NETWORKS
GNANAMANI COLLEGE OF TECHNOLOGY
DEPARTMENT OF AI&DS
Step 3 − The final updated routing table with lower cost distance vector routing protocol for all
routers A, B, and C is given below –
CS3591 COMPUTER NETWORKS
GNANAMANI COLLEGE OF TECHNOLOGY
DEPARTMENT OF AI&DS
RIP
Routing Information Protocol (RIP) is a dynamic routing protocol that uses hop count as a
routing metric to find the best path between the source and the destination network. It is a
distance-vector routing protocol that has an AD value of 120 and works on the Network layer of the
OSI model. RIP uses port number 520.
CS3591 COMPUTER NETWORKS
GNANAMANI COLLEGE OF TECHNOLOGY
DEPARTMENT OF AI&DS
Hop Count
Hop count is the number of routers occurring in between the source and destination network.
The path with the lowest hop count is considered as the best route to reach a network and
therefore placed in the routing table. RIP prevents routing loops by limiting the number of hops
allowed in a path from source and destination. The maximum hop count allowed for RIP is 15 and a
hop count of 16 is considered as network unreachable.
Features of RIP
Routing Information Protocol (RIP) is a distance vector protocol that uses hop count as its primary
metric. RIP defines how routers should share information when moving traffic among an
interconnected group of local area networks.
In the enterprise, Open Shortest Path First (OSPF) routing has largely replaced RIP as the most
widely used Interior Gateway Protocol. RIP has been supplanted mainly due to its simplicity
and inability to scale to very large and complex networks. Border Gateway Protocol (BGP) is
another distance vector protocol that is now used to transfer routing information across
autonomous systems on the internet.
Versions of RIP
1. RIPv1
2. RIPv2
3. RIPng
In the first example, there are eight routers connected to a network where router 1 wants to send
data to router 3. If the network is configured with RIP, it will choose the route with the least hop
count. In other words, it will choose the shortest path.
CS3591 COMPUTER NETWORKS
GNANAMANI COLLEGE OF TECHNOLOGY
DEPARTMENT OF AI&DS
In this network, we have three possible routes to deliver the data from R1 to R4:
Route 1:
Route 2:
Route 3:
To find the shortest path, each node needs to run the famous Dijkstra algorithm. Let us understand
how can we find the shortest path using an example.
Illustration
To understand the Dijkstra Algorithm, let’s take a graph and find the shortest path from the
source to all nodes.
Note: We use a boolean array sptSet[] to represent the set of vertices included in SPT. If a value
sptSet[v] is true, then vertex v is included in SPT, otherwise not. Array dist[] is used to store the
shortest distance values of all vertices.Consider the below graph and src = 0
STEP 1: The set sptSet is initially empty and distances assigned to vertices are {0, INF, INF, INF,
INF, INF, INF, INF} where INF indicates infinite. Now pick the vertex with a minimum distance
value. The vertex 0 is picked and included in sptSet. So sptSet becomes {0}. After including 0 to
sptSet, update the distance values of its adjacent vertices. Adjacent vertices of 0 are 1 and 7. The
distance values of 1 and 7 are updated as 4 and 8.
The following subgraph shows vertices and their distance values. Vertices included in SPT are
included in GREEN color.
CS3591 COMPUTER NETWORKS
GNANAMANI COLLEGE OF TECHNOLOGY
DEPARTMENT OF AI&DS
CS3591 COMPUTER NETWORKS
GNANAMANI COLLEGE OF TECHNOLOGY
DEPARTMENT OF AI&DS
CS3591 COMPUTER NETWORKS
GNANAMANI COLLEGE OF TECHNOLOGY
DEPARTMENT OF AI&DS
In this blog, we will learn what the OSPF protocol is and how it works. We will also learn
about the different states of the OSPF protocol. In the end, we will also discuss the
advantages and disadvantages of the protocol.
CS3591 COMPUTER NETWORKS
GNANAMANI COLLEGE OF TECHNOLOGY
DEPARTMENT OF AI&DS
What is the OSPF Protocol?
Open Shortest Path First (OSPF) is an Interior Gateway Protocol (IGP) that has an algorithm type
of Link-State.
several state:
Before establishing a neighbor relationship, OSPF routers need to go through several state changes.
These states are explained below.
1. Init state – a router has received a Hello message from the other OSPF router
2. 2-way state – the neighbor has received the Hello message and replied with a Hello message of
his own
3. Exstart state – beginning of the LSDB exchange between both routers. Routers are starting to
exchange link state information.
4. Exchange state – DBD (Database Descriptor) packets are exchanged. DBDs contain LSAs
headers. Routers will use this information to see what LSAs need to be exchanged.
5. Loading state – one neighbor sends LSRs (Link State Requests) for every network it doesn’t
know about. The other neighbor replies with the LSUs (Link State Updates) which contain
information about requested networks. After all the requested information have been received, other
neighbor goes through the same process
6. Full state – both routers have the synchronized database and are fully adjacent with each other.
OSPFTerms
1. Router Id – It is the highest active IP address present on the router. First, the highest loopback
address is considered. If no loopback is configured then the highest active IP address on the interface
of the router is considered.
2. Router priority – It is an 8-bit value assigned to a router operating OSPF, used to elect DR and
BDR in a broadcast network.
3. Designated Router (DR) – It is elected to minimize the number of adjacencies formed. DR
distributes the LSAs to all the other routers. DR is elected in a broadcast network to which all the
CS3591 COMPUTER NETWORKS
GNANAMANI COLLEGE OF TECHNOLOGY
DEPARTMENT OF AI&DS
other routers share their DBD. In a broadcast network, the router requests for an update to DR, and
DR will respond to that request with an update.
4. Backup Designated Router (BDR) – BDR is a backup to DR in a broadcast network. When DR
goes down, BDR becomes DR and performs its functions.
5. DR and BDR election – DR and BDR election takes place in the broadcast network or multi-access
network. Here are the criteria for the election:
o The router having the highest router priority will be declared as DR.
o If there is a tie in router priority then the highest router I’d be considered. First, the highest
loopback address is considered. If no loopback is configured then the highest active IP
address on the interface of the router is considered.
A path-vector routing protocol is a network routing protocol which maintains the path
information that gets updated dynamically. Updates that have looped through the network and
returned to the same node are easily detected and discarded.
The protocol can connect together any internetwork of autonomous system using an arbitrary
topology. The only requirement is that each AS have at least one router that is able to run BGP and
that is router connect to at least one other AS’s BGP router. BGP’s main function is to exchange
network reach-ability information with other BGP systems. Border Gateway Protocol constructs an
autonomous systems’ graph based on the information exchanged between BGP routers.
1. The first function consist of initial peer acquisition and authentication. both the peers
established a TCP connection and perform message exchange that guarantees both sides
have agreed to communicate.
2. The second function mainly focus on sending negative or positive reach-ability
information.
3. The third function verifies that the peers and the network connection between them are
functioning correctly.
Route Storage: Each BGP stores information about how to reach other networks.
Route Update: In this task, Special techniques are used to determine when and how to use
the information received from peers to properly update the routes.
Route Selection: Each BGP uses the information in its route databases to select good
routes to each network on the internet network.
Route advertisement: Each BGP speaker regularly tells its peer what is known about
various networks and methods to reach them.
DVMRP
The Distance Vector Multicast Routing Protocol (DVMRP), defined in RFC 1075, is a routing
protocol used to share information between routers to facilitate the transportation of IP
multicast packets among networks. It formed the basis of the Internet's historic multicast
backbone, Mbone.
Distance Vector Multicast Routing Protocol (DVMRP) is an efficient Interior Gateway Protocol
routing mechanism that combines Routing Information Protocol features with a truncated
reverse path broadcasting algorithm for IP multitask data sharing between connectionless
autonomous systems.
Version
Type
Subtype: Response, request, non-membership report or non-membership cancellations
Checksum: Complete message sum of 16-bit ones, not including IP headers. Requires 16-
bit alignment. Checksum computation field is zero.
Multicast (PIM)?
Protocol Independent Multicast (PIM) is a collection of multicast routing protocols, each
optimized for a different environment.
There are two main PIM protocols, PIM Sparse Mode and PIM Dense Mode. A third PIM
protocol, Bi-directional PIM, is less widely used.
Typically, either PIM Sparse Mode or PIM Dense Mode will be used throughout a multicast
domain. However, they may also be used together within a single domain, using Sparse Mode for
some groups and Dense Mode for others. This mixed-mode configuration is known as Sparse-
Dense Mode. Similarly, Bi-directional PIM may be used on its own, or it may be used in
conjunction with one or both of PIM Sparse Mode and PIM Dense Mode.
All PIM protocols share a common control message format. PIM control messages are sent as raw
IP datagrams (protocol number 103), either multicast to the link-local ALL PIM ROUTERS
multicast group, or unicast to a specific destination.
PIM Sparse Mode (PIM-SM) is a multicast routing protocol designed on the assumption that
recipients for any particular multicast group will be sparsely distributed throughout the network. In
other words, it is assumed that most subnets in the network will not want any given multicast
CS3591 COMPUTER NETWORKS
GNANAMANI COLLEGE OF TECHNOLOGY
DEPARTMENT OF AI&DS
packet. In order to receive multicast data, routers must explicitly tell their upstream neighbors about
their interest in particular groups and sources. Routers use PIM Join and Prune messages to join and
leave multicast distribution trees.
PIM-SM by default uses shared trees, which are multicast distribution trees rooted at some selected
node (in PIM, this router is called the Rendezvous Point, or RP) and used by all sources sending to
the multicast group. To send to the RP, sources must encapsulate data in PIM control messages and
send it by unicast to the RP. This is done by the source's Designated Router (DR), which is a router
on the source's local network. A single DR is elected from all PIM routers on a network, so that
unnecessary control messages are not sent.
PIM Dense Mode (PIM-DM) is a multicast routing protocol designed with the opposite assumption
to PIM-SM, namely that the receivers for any multicast group are distributed densely throughout
the network. That is, it is assumed that most (or at least many) subnets in the network will want any
given multicast packet. Multicast data is initially sent to all hosts in the network. Routers that do not
have any interested hosts then send PIM Prune messages to remove themselves from the tree.
Bi-directional PIM
Bi-directional PIM (BIDIR-PIM) is a third PIM protocol, based on PIM-SM. The main way BIDIR-
PIM differs from PIM-SM is in the method used to send data from a source to the RP. Whereas in
PIM-SM data is sent using either encapsulation or a source-based tree, in BIDIR-PIM the data
flows to the RP along the shared tree, which is bi-directional - data flows in both directions along
any given branch.