1. Computer Communication Networks-17EC64 Module 4
Edited by: Prof. Krishnananda L, Dept of ECE, Govt SKSJTI, Bengaluru Page 1
CHAPTER 20 ROUTING PROTOCOLS-INTRODUCTION
The goal of the network layer is to deliver a datagram from its source to a
destination or destinations. If a datagram is destined for only one destination,
(one-to-one delivery), we have unicast routing. If the datagram is destined for
several destinations (one-to-many delivery), we have multicast routing.
Routing can be possible if a router has a forwarding table to forward a packet
to the appropriate next node on its way to the final destination or destinations.
To make the forwarding tables of the router, the Internet needs routing
protocols that will be active all the time in the background and update the
forwarding tables.
Unicast routing in the Internet can be done only by using hierarchical routing
with different routing algorithms. In this section, we first discuss the general
concept of unicast routing in an internet (general internetwork)
20.1.1 General Idea of Routing
In unicast routing, a packet is routed (hop by hop) from its source to its destination
with the help of forwarding tables. Routing means, routing the packet from a source
router (the default router of the source host) to a destination router (the router
connected to the destination network). There are several routes that a packet can
take to travel from the source to the destination. So, the routing protocol task is to
determine which route the packet should take, based on some “metrics”.
Routing Algorithm Requirements
Responsiveness to changes
Topology or bandwidth changes, congestion
Rapid convergence of routers to consistent set of routes
Freedom from persistent loops
Optimality
Resource utilization, path length
Robustness
Continues working under high load, congestion, faults, equipment failures etc
Simplicity
Efficient software implementation, reasonable processing load
Routing Metrics
Means for measuring desirability of a path
Path Length = sum of costs or distances
Possible metrics
Hop count: rough measure of resources used
Reliability: link availability; BER
Delay: sum of delays along path; complex & dynamic
Bandwidth: “available capacity” in a path
Load: Link & router utilization along path
Cost: $$$
Which is “best”?
Min delay? Min hop? Max bandwidth? Min cost? Max reliability?
2. Computer Communication Networks-17EC64 Module 4
Edited by: Prof. Krishnananda L, Dept of ECE, Govt SKSJTI, Bengaluru Page 2
An internet as a Graph
To find the best route, an internet can be modeled as a graph. A graph is a set of
nodes and edges (lines) that connect the nodes. In an internet, each router is a node
and each network or links between a pair of routers as an edge. An internet is, in fact,
modeled as a weighted graph, in which each edge is associated with a cost. If there is
no edge between the nodes, the cost is infinity.
20.1.2 Least-Cost Routing
One of the ways to interpret the best route from the source router to the destination
router is to find the least cost between the two. In Fig 20.1, the best route between A
and E is A-B-E, with the cost of 6. So, each router needs to find the least-cost route
between itself and all the other routers to be able to route a packet using this criteria.
Least-Cost Trees
If there are N routers in an internet, there are (N − 1) least-cost paths from each
router to any other router. So, we need N × (N − 1) least-cost paths for the whole
internet. A better way to visualize is to combine them in a least-cost tree. A least-
cost tree is a tree with the source router as the root that spans the whole graph
(visits all other nodes) and in which the path between the root and any other node is
the shortest. Fig 20.2 shows the seven least-cost trees for the internet in Fig 20.1.
3. Computer Communication Networks-17EC64 Module 4
Edited by: Prof. Krishnananda L, Dept of ECE, Govt SKSJTI, Bengaluru Page 3
20.2 ROUTING ALGORITHMS
Many routing algorithms have been designed. They differ in the way they interpret
the least “cost” (cost can be: delay, distance, no. of hops, bandwidth, cost, reliability
etc) and the way they create the least-cost tree for each node.
20.2.1 Distance-Vector Routing (DVR)
In DV routing, each node creates its own least cost trees, using the
information about its immediate neighbours.
Incomplete trees are exchanged between the immediate neighbours to
complete the tree and to represent the whole internet.
A router continuously tells all its neighbours what it knows about the whole
internet.
Bellman –ford equation is used to find the least cost.
DV algorithm is also known as Bellman-Ford algorithm
Bellman-Ford equation enables us to build a new least-cost path from
previously established least-cost paths
1) Bellman-Ford Equation
Bellman-Ford 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, . .
.). The general equation is:
… (1)
Where Dij is the shortest distance and cij is the cost between nodes i and j.
To update an existing least cost through an intermediate node z, the equation is:
… (2)
Fig 20.3 shows the idea graphically for both cases.
Routing
Algorithms
Dynamic
(Adaptive)
Routing Alg
Distance Vector
Routing
(BellmanFord)
Link-State
Routing
(Dijkstra)
Path Vector
Routing
Static (Non-
adaptive)
Routing Alg
4. Computer Communication Networks-17EC64 Module 4
Edited by: Prof. Krishnananda L, Dept of ECE, Govt SKSJTI, Bengaluru Page 4
2) Distance Vectors
A least-cost tree is a combination of least-cost paths from the root of the tree to all
destinations. These paths are graphically glued together to form the tree. Distance-
vector routing unglues these paths and creates a distance vector, a one-
dimensional array to represent the tree. Fig. 20.4 shows the tree for node A in the
internet in Fig. 20.1 and the corresponding distance vector.
Note that the name of the distance vector defines the root, the indexes define the
destinations, and the value of each cell defines the least cost from the root to the
destination.
A distance vector does not give the path to the destinations as the least-cost tree
does; it gives only the least costs to the destinations.
3) DVR Operation:
a) Initializing DV tables:
Each node when it is booted, sends some greeting messages and discovers the
identity of the immediate neighbors and the distance between itself and each
neighbour. It then creates a very rudimentary distance vector by inserting the
discovered distances in the corresponding cells and fills the value of other cells as
infinity. Fig.20.5 shows initial Distance vector for complete internet when all nodes
are booted. This table cannot be used to forward a packet since many cells have
value as ∞. So, we need to update the tables.
(value of ∞ means cost to that node is unknown or its not the immediate neighbour
or the link is broken).
5. Computer Communication Networks-17EC64 Module 4
Edited by: Prof. Krishnananda L, Dept of ECE, Govt SKSJTI, Bengaluru Page 5
Fig.20.5 Initial DV for an internet after booting
b) Updating DV tables
After each node has created its vector, it sends a copy of the vector to all its
immediate neighbors. After a node receives a DV from a neighbor, it updates its
distance vector using the Bellman-Ford eqn (2). We need to update N DVs if there are
N nodes. This can be implemented using an iterative program, like “for loop”.
Conceptually, we can show the whole vector for each update, instead of N separate
equations, as in Fig. 20.6.
In the first event, node A has sent its vector to node B. Node B updates its
vector using the cost cBA = 2. So, its least cost to node D has changed from
infinity to 5 (via node A).
6. Computer Communication Networks-17EC64 Module 4
Edited by: Prof. Krishnananda L, Dept of ECE, Govt SKSJTI, Bengaluru Page 6
In the second event, node E has sent its vector to node B. Node B updates its
vector using the cost cEA = 4. Now, its least cost to node F has changed from
infinity to 6 (via node E).
In distance vector routing, each node shares its routing table with its
immediate neighbors periodically and when there is a change
In this iterative way, the DVs are exchanged and finally the system stabilizes
with no ∞ value in any cell.
Finally, we get the least cost path from any node x to all other nodes.
4) DVR Algorithm
Table gives a pseudo code for DVR algorithm. Each node runs this independently and
asynchronously.
Note: Lines 4 to 11 initialize the vector for the node. Lines 14 to 23 show how the
vector can be updated after receiving a vector from the immediate neighbor. The for
loop in lines 17 to 20 allows all entries (cells) in the vector to be updated after
receiving a new vector. The node sends its vector in line 12, after being initialized,
and in line 22, after it is updated.
7. Computer Communication Networks-17EC64 Module 4
Edited by: Prof. Krishnananda L, Dept of ECE, Govt SKSJTI, Bengaluru Page 7
Issues in DVR:
1) Slow Convergence - take long time to converge/stabilize
2) Another problem with DVR is that any decrease in cost (good news) propagates
quickly, but any increase in cost (bad news) will propagate slowly. If a link is broken
(cost becomes infinity), every other router should know about it immediately; but, in
DVR, it takes several updates before the cost for a broken link is recorded as infinity
by all routers This problem is referred to as count to infinity.
Ex: Two-Node Loop (Instability) Problem
To understand this, lets us look at the scenario in Fig. 20.7 with 3 nodes A, B and
X. At the beginning, both nodes A and B know how to reach node X. But, say, the
link between A and X fails. Node A changes its table. If A sends its table to B
immediately, everything is fine, since now B knows that it cant reach X via A.
However, let’s say, B sends its DV to A before receiving A’s table. Node A receives
the update and, assuming that B has found a way to reach X, immediately updates
its forwarding table. Now A sends its new update to B. Now B thinks that
something has been changed around A and updates its forwarding table. This
way, the tables are exchanged and the cost of reaching X increases gradually until
it reaches infinity.
So, after a long time, both A and B know that X cannot be reached. However,
during this time the system is not stable. Node A thinks that the route to X is via
B; node B thinks that the route to X is via A. If A receives a packet destined for X,
the packet goes to B and then comes back to A; same happens at B. Packets
bounce between A and B, creating a two-node loop problem.
8. Computer Communication Networks-17EC64 Module 4
Edited by: Prof. Krishnananda L, Dept of ECE, Govt SKSJTI, Bengaluru Page 8
Solution to two-node instability (count-to-infinity) problem:
1) Split Horizon
One solution to instability is called split horizon. In this strategy, instead of flooding
the table through each interface, each node sends only part of its table through each
interface. If node B thinks that the optimum route to reach X is via A, it need not send
this information to A; the information has come from A itself. (A already knows).
Taking information from node A, modifying it, and sending it back to node A is the
reason for this problem.
So, node B eliminates that row of its table with route to X (which has come from A)
and then sends it to A. In this case, node A keeps the value of infinity as the distance
to X. Later, when node A sends its forwarding table to B, node B also corrects its
forwarding table. The system becomes stable after the first update: both node A and
node B know that X is not reachable.
Do not report route to a destination to the neighbor from which route was learned
2) Poison Reverse
When node B eliminates the route to X from its advertisement to A, node A cannot
guess whether this is due to the split-horizon strategy (the source of information was
A) or because B has not received any news about X recently.
In the poison reverse strategy, B can still advertise the value for X, but if the source
of information is A, it can replace the distance with infinity as a warning: “Do not use
this value; what I know about this route has come from you.”
Report route to a destination to the neighbor from which route was learned, but with
infinite distance
Breaks erroneous direct loops immediately
9. Computer Communication Networks-17EC64 Module 4
Edited by: Prof. Krishnananda L, Dept of ECE, Govt SKSJTI, Bengaluru Page 9
20.2.2 Link-State Routing (LSR)
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.
1) Link-State Database (LSDB)
To create a least-cost tree, each node needs to have a complete map of the network,
i.e., each node needs to know the state of each link. The collection of states for all
links is called the link-state database (LSDB). There is only one LSDB for the whole
internet; each node needs to have a copy of it to be able to create the least-cost tree.
Fig 20.8 shows an example of an LSDB for the graph in Fig. 20.1. The LSDB can be
represented as a two-dimensional array(matrix) in which the value of each cell
defines the cost of the corresponding link.
2) How to create LSDB?
This is be done by a process called flooding. Each node can send some greeting
messages to all its immediate neighbors to collect two pieces of information: the
identity of the node and the cost of the link. The combination of these two is called
the Link-State packet (LSP); the LSP is sent out of each interface as in Fig. 20.9.
Fig.20.9 LSPs created and sent out by each node to build LSDB
10. Computer Communication Networks-17EC64 Module 4
Edited by: Prof. Krishnananda L, Dept of ECE, Govt SKSJTI, Bengaluru Page 10
3) LSR Operation:
When a node receives an LSP from one of its interfaces, it compares the LSP with the
copy it is having. If the newly arrived LSP is older than the one it has (found by
checking the sequence number), it discards this LSP. If it is newer or the first one
received, the node discards the old LSP and keeps the received one. It then sends a
copy this LSP, out of each interface except the one from which the packet arrived.
This guarantees that flooding stops somewhere in the network. After receiving all
new LSPs, each node creates the comprehensive LSDB as shown in Fig 20.9. A node
can make the whole map of the internet using this LSDB.
Note: In DVR algorithm, each router tells its neighbors what it knows about the
whole internet; in LSR algorithm, each router tells the whole internet what it knows
about its neighbors.
4) Formation of Least-Cost Trees
To create a least-cost tree for itself (using the shared LSDB) each node needs to run
the Dijkstra Algorithm. This iterative algorithm uses the following steps:
i. The node chooses itself as the root of the tree, creating a tree with a single
node, and sets the total cost of each node based on the information in the LSDB.
ii. The node selects one node, among all nodes not in the tree, which is closest to
the root, and adds this to the tree. After this node is added to the tree, the cost
of all other nodes not in the tree needs to be updated because the paths may
have been changed.
iii. The node repeats step 2 until all nodes are added to the tree.
Table 20.2 shows a simplified version of Dijkstra’s algorithm. Lines 4 to 13
implement step 1 in the algorithm. Lines 16 to 23 implement step 2 in the algorithm.
Step 2 is repeated until all nodes are added to the tree.
To remember: Basic idea: two step procedure
a) Each source node gets a map of all nodes and link state of the entire network
b) Find the shortest path from the source node to all destination nodes
Broadcast of link-state information
Every node i in the network broadcasts to every other node in the network:
ID’s of its neighbors (Ni) and Distances to its neighbors: {Cij | j ∈Ni}
Flooding is a popular method of broadcasting packets
.
12. Computer Communication Networks-17EC64 Module 4
Edited by: Prof. Krishnananda L, Dept of ECE, Govt SKSJTI, Bengaluru Page 12
Fig 20.10 shows the formation of the least-cost tree for the graph in Fig. 20.8 using
Dijkstra’s algorithm.
Dijkstra Algorithm (for understanding program implementation)
1. Start with the local node (router): the
root of the tree.
2. Assign a cost of 0 to this node and make
it the first permanent node.
3. Examine each neighbor node of the node
that was the last permanent node.
4. Assign a cumulative cost to each node and
make it tentative.
5. Among the list of tentative nodes
5.1. Find the node with the smallest
cumulative cost and make it permanent.
5.2. If a node can be reached from more
than one direction
5.2.1. Select the direction with the
shortest cumulative cost.
6.Repeat steps 3 to 5 until every node
becomes permanent.
13. Computer Communication Networks-17EC64 Module 4
Edited by: Prof. Krishnananda L, Dept of ECE, Govt SKSJTI, Bengaluru Page 13
Shortest Path Routing
The first 5 steps used in computing the shortest path from A to D.
The arrows indicate the working node.
14. Computer Communication Networks-17EC64 Module 4
Edited by: Prof. Krishnananda L, Dept of ECE, Govt SKSJTI, Bengaluru Page 14
Distance-Vector Routing (DVR) Link-State Routing (LSR)
Based on Bellman-Ford/ Ford-Fulkerson
Algorithms
Based on (Dijkstra) Shortest-path Algorithms
Its Distributed, Asynchronous routing alg:
Each router sends routing information to only
its neighbors
It’s a centralized, dynamic routing algorithm
involving all links and routers. Each router
sends routing information to all other routers
Complete routing table is sent from router to
router on a periodic basis/when there is
update, only to its neighbors
Each node/router broadcasts the identities
and costs (i.e., only “link-state” information)
to its directly attached neighbors
The receiving router picks the neighbor
advertising the lowest cost to a network and
then adds that entry into its routing table for
readvertisement
Information is collected and stored in a
topological database (LSDB) and the SPF
algorithm is applied. Routing tables show the
best path for any destination on the network
Information is sent on regular periodic basis
i.e., updates are periodic and complete
information of routing tables are exchanged
Information is sent when changes occur
(i.e., updates are event triggered). Once
converged, LSAs containing only changes
rather than copies of the entire routing table
are sent
convergence is Slow, easy to configure and
administer
More reliable, faster convergence, easy to
debug and less bandwidth-sensitive
More susceptible to Routing loops and routing
errors, two-node instability problems
Less susceptible to routing loops and errors
Suitable for flat, non-hierarchical networks Suitable for large, hierarchical networks
CPU Usage: Less processing requirements
since only neighbours of a node are involved
CPU Usage: more processing requirements
compared to DVR since entire topology
information is needed
Memory usage is moderate Memory usage is high
Only gives least cost to all nodes Support for multiple paths to a destination
Any one metric is optimized Support for Precise metrics and multiple
metrics (cost, delay, throughput, reliability,
distance etc)
Protocol Examples using DVR: RIP, BGP Protocol Examples using LSR: OSPF, IS-IS
15. Computer Communication Networks-17EC64 Module 4
Edited by: Prof. Krishnananda L, Dept of ECE, Govt SKSJTI, Bengaluru Page 15
20.2.3 Path Vector Routing (PVR)
Both link-state and distance-vector routing are based on the least-cost goal. It won’t
consider any other parameter such as: security of datagrams, Reliability/Trust level
of the router/network, reachability of the destination etc., So, LSR or DVR does not
allow a sender to apply specific policies to the route a packet may take. To respond to
these demands, a routing algorithm, called path-vector (PV) routing has been
designed. The best route is determined by the source using the policy it imposes on
the route. i.e., the source can control the path. PVR is mostly designed to route a
packet between ISPs.
1) Spanning Trees
In path-vector routing, the path from a source to all destinations is determined
by the best spanning tree. Spanning tree is a graph in which there is no loop.
i.e., creating a topology in which each node can be reached from any other
node through only one path. (no loop). In PVR, the links are not associated with
cost/weights.
The best spanning tree is the tree determined by the source when it imposes
its own policy. A source may apply several policies at the same time. The
common policies are: i) use minimum number of nodes to be visited to reach
the destination, ii) to avoid some nodes as the middle node in a route.
Fig. 20.11 shows a small internet with five nodes. Each source has created its
own spanning tree that meets its policy. The spanning tree selected by A and E
is such that the communication does not pass through D as a middle node.
Similarly, the spanning tree selected by B is such that the communication does
not pass through C as a middle node.
16. Computer Communication Networks-17EC64 Module 4
Edited by: Prof. Krishnananda L, Dept of ECE, Govt SKSJTI, Bengaluru Page 16
2) Creation of Spanning Trees
Path-vector routing is an asynchronous and distributed routing algorithm. The
spanning trees are made gradually and asynchronously, by each node.
When a node is booted, it sends greeting messages to its immediate neighbors,
gets some information and creates a path vector. Fig 20.12 shows the path
vectors for the internet in Fig 20.11. All of these tables are not created
simultaneously; they are created when each node is booted.
After creating initial path vector (PV), each node sends it to all its immediate
neighbors (shown using arrows in Fig). Whenever a node receives a PV from a
neighbor, it updates its PV using an equation similar to the Bellman-Ford, but
applying its own policy instead of least cost. We can define this equation as
Where , the operator (+) means to add x to the beginning of the path
The policy is defined by selecting the best of multiple paths. If Path (v, y) includes x,
that path is discarded to avoid a loop in the path.
Fig. 20.13 shows the path vector of node C after two events. In the first event, node C
receives a copy of B’s vector, which improves its vector: now it knows how to reach
node A. In the second event, node C receives a copy of D’s vector, which does not
change its vector.
17. Computer Communication Networks-17EC64 Module 4
Edited by: Prof. Krishnananda L, Dept of ECE, Govt SKSJTI, Bengaluru Page 17
3) Path-Vector Algorithm
A simplified version of the path vector algorithm is shown in Table 20.3. Lines 4 to
12 show the initialization for the node. Lines 17 to 24 show how the node updates its
vector after receiving a vector from the neighbour.