CN-Unit 1 Routing Algorithms
CN-Unit 1 Routing Algorithms
Topics to be discussed
The packet is stored there until it has fully arrived so the checksum can be verified. Then
it is forwarded to the next router along the path until it reaches the destination host,
where it is delivered.
2. Services Provided to the Transport Layer
The network layer services have been designed with the following
goals in mind.
• The services should be independent of the router technology.
• The transport layer should be shielded from the number, type, and
• The network addresses made available to the transport layer should use
If connectionless service :
datagram subnet
• Forwarding :
Is it fair to shut off the traffic between X and X’ to maximize the traffic
between A and A’ , B and B’ and C and C’ ?
Two classes of Routing Algorithms
r1 r2
I J K
r3
The set of optimal routes from all sources to a given destination form a tree
(a) A subnet. (b) A sink tree for router B. (metric is no. of hops)
The Optimality Principle
Note :
• The goal of all routing algorithms is to discover and use the sink
trees for all routers.
• Since a sink tree is a tree, it does not contain any loops
• Each packet will be delivered within a finite and bounded number
of hops
The Optimality Principle
PROBLEM:
• A node is labeled with its distance from the source node along the best
known path and the parent node label. <distance, parent>
• Initially , all nodes are labeled with infinity, As the algorithm proceeds and
paths are found, the labels may change, reflecting better paths
• When it is discovered that a label represents the shortest possible path from
the source to that node, it is made permanent
Shortest Path Routing
Dijkstra’s algorithm A→D The arrows indicate the working node.
Shortest Path Routing
PROBLEM:
Apply Dijkstra’s algorithm to find the shortest path from A to D
Shortest Path Routing
PROBLEM:
Apply Dijkstra’s algorithm to find the shortest path from A to G
Flooding ( static algorithm )
• if the packet is already seen by the router , then it simply discards the
packet.
Flooding ( static algorithm )
3. Selective flooding
• The routers do not send every incoming packet out on
every line
Applications of flooding
1. Military
• If a large number of routers are destroyed ,then information can
be propagated with the help of flooding .
3. Wireless networks,
• If all messages transmitted by a station can be received by all other
stations within its radio range
• Each router maintains a routing table indexed by, and containing one entry for,
Assuming that delay is used as a metric and that the router knows the delay to each
of its neighbors, the algorithm works as follows:
• Once every T msec each router sends to each neighbor a list of its estimated
delays to each destination. It also receives a similar list from each neighbor.
• Suppose that the router has received from X, Xi being X's estimate of how long
it takes to get to router i. If the router knows that the delay to X is m msec, it also
• By performing this calculation for each neighbor, a router can find out which
estimate seems the best and use that estimate and the corresponding line
Distance Vector Routing
(Bellman, 1957; Ford and Fulkerson, 1962)
Example
8 34 32 27
20 46 43 34
8
12 26 41 18 37
10 6
(a) A subnet. (b) Input from A, I, H, K, and the new routing table for J.
Distance Vector Routing
(Bellman, 1957; Ford and Fulkerson, 1962)
Reaction to the
good news
In a subnet whose longest path is of length N hops, within N exchanges everyone will
know about newly-revived lines and routers
Distance Vector Routing
(Bellman, 1957; Ford and Fulkerson, 1962)
At the first packet exchange , B thinks it can reach A via C, with a path length
Consider the following subnet Distance vector routing is used, and the following vectors
have just come in to router C: from B: (5, 0, 8, 12, 6, 2); from D: (16, 12, 6, 0, 9, 10); and
from E: (7, 6, 3, 9, 0, 4). The measured delays to B, D, and E, are 6, 3, and 5, respectively.
What is C's new routing table? Give both the outgoing line to use and the expected
delay.
Link State Routing
DV was used in the ARPANET. Two primary problems caused its demise
2. The delay metric was queue length. It did not take line bandwidth into
neighbors.
neighbours.
delay = RTT / 2 ;
Link State Routing
2. Measuring Line Cost
• If taken into account , the round-trip timer must be started when the
ECHO packet is queued.
• To ignore the load, the timer should be started when the ECHO packet
reaches the front of the queue
Link State Routing
2. Measuring Line Cost
• Including load in the delay measurements may cause routing tables to
oscillate wildly, leading to erratic routing and many potential problems.
• The next step is for each router to build a packet containing all the data
• The packet starts with the identity of the sender, followed by a sequence
number and age , and a list of neighbours
• Solutions
An example of data structure used by router B for the subnet shown below.
Each row here corresponds to a recently-arrived, but as yet not fully-
processed, LSP
Note
• The link state packet from A arrives directly, so it must be sent to C and F and
acknowledged to A, as indicated by the flag bits.
• The situation with the third packet, from E, is different. It arrived twice, once
via EAB and once via EFB, Consequently, it has to be sent only to C but
acknowledged to both A and F
• If a duplicate arrives while the original is still in the buffer, bits have to be
changed
Link State Routing
5. Computing the New Routes
• Once a router has accumulated a full set of link state packets, it can
construct the entire subnet graph because every link is represented
• Now Dijkstra's algorithm can be run locally to construct the shortest path to
• The results of this algorithm can be installed in the routing tables, and
them
Examples :
• At a certain point, it may not feasible for every router to have an entry for
• Each router knows how to route packets to destinations within its own
region, but knows nothing about the internal structure of other regions
• For huge networks , it may be necessary to group the regions into clusters,
the clusters into zones, the zones into groups, and so on,
Hierarchical Routing
• Example : A two-level hierarchy with five regions.
With hierarchal
routing a table
would require only
7 entries
Without hierarchal
routing a table would
require 17 entries
Hierarchical Routing
Note :
• The full routing table for router 1A has 17 entries, as shown . When routing
is done hierarchically, 1A has 7 entries
1. Simple Broadcasting :
• send a distinct packet to each destination
• wastes of bandwidth
• source should have a complete list of all destinations
Broadcast Routing
2. Flooding :
• It generates too many packets
• So consumes too much bandwidth.
Broadcast Routing
3. Multi-destination routing :
• Each packet contains a list of destinations .
• When a packet arrives at a router, the router checks all the destinations to
• The router generates a new copy of the packet for each output line to be used
and includes in each packet only those destinations that are to use the line.
• After a sufficient number of hops, each packet will carry only one destination and
Example - 1
C
D
BCDEFGHI E
E
H F
I I
Broadcast Routing
Multi-destination routing :
Example - 2
Broadcast Routing
4 1
3
2
Broadcast Routing
• If so, the broadcast packet itself followed the best route from the router
and is therefore the first copy to arrive at the router. the router forwards
copies of it onto all lines except the one it arrived on.
• If, however, the broadcast packet has not arrived on the preferred one for
reaching the source, the packet is discarded as a likely duplicate.
Broadcast Routing
(a) shows a subnet, part (b) shows a sink tree for router I of that
subnet, and part (c) shows how the reverse path algorithm works.