You are on page 1of 29

UNICAST

ROUTING
M U K E S H C H I N TA
A S S I S TA N T P R O F E S S O R , C S E , V R S E C
GENERAL IDEA
In Unicast routing, a packet is routed , hop-by-hop from its source to its destination
by the help of forwarding tables. M
Routing is the process of selecting the optimum path for the packet to travel from u
k
e
source to destination from the available routes. s
h

C
A graph in computer science is a set of nodes and edges (lines) that connect the h
i
n
nodes. To model an internet as a graph, we can think of each router as a node and t
a,
each network between a pair of routers as an edge.
C
An internet is, modeled as a weighted graph, in which each edge is associated with S
E,
a cost. V
R
S
E
C

2
LEAST COST ROUTING
Least Cost routing can be interpreted as the source router choosing a route to the destination
router in such a way that the total cost for the route is the least cost among all possible M
u
routes. k
e
A least-cost tree is a tree with the source router as the root that spans the whole graph s
h
(visits all other nodes) and in which the path between the root and any other node is the
shortest. Only one shortest path tree for each node exists. C
h
i
n
t
a,

C
S
E,

The least-cost route from X to Y in X's V


tree is the inverse of the least-cost R
S
route from Y to X in Y's tree; the cost E
in both directions is the same. C

Instead of travelling from X to Z using


X's tree, we can travel from X to Y
using X's tree and continue from Y to Z
using Y's tree. 3
ROUTING
ALGORITHMS
4
In the distance-vector(DV) routing, the first thing each node creates is its own
Ieast-cost tree with the rudimentary information it has about its immediate M
u
k
neighbors. e
s
The incomplete trees are exchanged between immediate neighbors to make the h

trees more and more complete and to represent the whole internet. C
h
i
The heart of distance-vector routing is the famous Bellman-Ford equation. This n
t

equation is used to find the least cost (shortest distance) between a source node, a,

C
x, and a destination node, y, through some intermediary nodes (a, b, c, ... ) when the S
E,
costs between the source and the intermediary nodes and the least costs between V
the intermediary nodes and the destination are given. R
S
E
The following shows the general case in which Dij is the shortest distance and cij is C

the cost between nodes i and j.


Dxy = min{(cxa + Day), (cxb + Dby), (cxc + Dcy), ... }
5
M
u
k
e
s
h

The concept of a distance vector is the rationale for the name distance-vector C
h
routing. i
n
Distance-vector routing uses the least cost paths and creates a distance vector, a t
a,
one-dimensional array to represent the least cost tree of a given node. C
S
E,

V
R
S
E
C

6
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.

The above rudimentary vectors are created asynchronously when the node is first booted
up and would be of no help for the internet to effectively forward a packet.
Mukesh Chinta, Asst Prof, CSE, VRSEC 7
To improve the individual vectors, the nodes in the internet need to help each other by
exchanging information. After each node has created its vector, it sends a copy of the vector
to all its immediate neighbors.
M
After a node receives a distance vector from a neighbor, it updates its distance vector using u
k
the Bellman-Ford equation. e
s
h

C
h
i
n
t
a,

C
S
E,

V
R
After the first event, node B has one improvement in its vector: its least cost to node D has S
E
changed from infinity to 5 (via node A). After the second event, node B has one more C
improvement in its vector; its least cost to node F has changed from infinity to 6 (via Node E).
Exchanging vectors with one another eventually stabilizes the system and allows all nodes to
find the ultimate least cost between themselves and any other node.
8
Distance_Vector_Routing()
{

D[myself] = 0 M
for (y = 1 to N) u
k
{ e
s
if (y is a neighbor) h
D[y] = c[myself][y]
C
else h
D[y] = i
n
} t
send vector {D[l], D[2], ... , D[N]} to all neighbors a,

C
S
repeat (forever) E,
{
V
wait (for a vector Dw from a neighbor w or any change in the link) R
for (y = 1 to N) S
E
{ C
D[y] = min [D[y], (c[myself][w] + Dw[Y])]
}
if(any change in the vector)
send vector {D[l], D[2], ... , D[N]} to all neighbors }
} 9
Bellman-Ford equation
M
u
k
e
s
h

C
h
i
n
t
a,

C
S
E,

V
R
S
E
C

10
M
u
A k
e
s
n h

C
h
E i
n
x t
a,

a C
S
m E,

p V
R
l Assume that the shortest distance between nodes a, b, c, and d to node y and the S
E

e costs from node x to nodes a, b, c, and d are given below: C

Day=5 Dby=6 Dcy=4 Ddy=3


cxa=2 cxb=l cxc=3 cxd=1
What is the shortest distance between node x and node y, Dxy, according to the
11
Bellman-Ford equation?
M
u
k
e
s
h

C
h
i
n
t
a,

C
S
E,

V
R
S
E
C

12
13
Convergence M
u
k
e
s
h

C
h
i
n
t
a,

C
S
E,

V
R
S
E

Node Bs distance vectors C

14
A
n
M
o u
k
t e
s
h
h
C
e h
i
r n
t
a,

C
E S
E,
x V
a R
S

m E
C

p
l
e
(a) A network. (b) Input from A, I, H, K, and the new routing table for J. 14
A problem with distance-vector routing is that any decrease in cost (good news)
propagates quickly, but any increase in cost (bad news) will propagate slowly. M
u
This problem also referred to as Count to Infinity problem happens when several k
e
updates are required before the cost of a broken link is recorded by all routers. s
h

C
h
i
n
t
a,

C
S
E,

V
R
S
E
C

The core of the problem is that when X tells Y that it has a path
somewhere,Y has no way of knowing whether it itself is on the path.
16
One solution to two node loop 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. M
u
k
e
s
h

C
h
i
n
t
a,
Router A advertises routes to Routers C, D, and E to Router B. In this example, C
Router A can reach Router C in 2 hops. When Router A advertises the route to S
E,
Router B, B imports it as a route to Router C through Router A in 3 hops. If Router V
B then re-advertised this route to Router A, A would import it as a route to Router R
S
C through Router B in 4 hops. However, the advertisement from Router B to Router E
C
A is unnecessary, because Router A can already reach the route in 2 hops.

The split horizon technique helps reduce extra traffic by eliminating


this type of route advertisement.
17
The poison reverse technique helps to optimize the transmission of
routing information and improve the time to reach network
M
convergence. u
k
If Router A learns about unreachable routes through one of its e
s

interfaces, it advertises those routes as unreachable (hop count of 16) h

C
out the same interface. h
i

Router A learns through one of its interfaces that n


t

routes to Routers C, D, and E are unreachable. Router


a,

C
A re-advertises those routes out the same interface S
E,

as unreachable. The advertisement informs Router B V

that Hosts C, D, and E are definitely not reachable


R
S
E
through Router A. C

The two-node instability can be avoided using split horizon combined


with poison reverse. However, if the instability is between three
nodes, stability cannot be guaranteed. 18
LINK STATE ROUTING ALGORITHM
The term Link State defines the characteristic of a link (an edge) that represents a M
u
network in the internet. k
e
The collection of states for all links is called the link-state database (LSDB) s
h
and there exists only one LSDB for the whole internet. Each node needs to have a C
duplicate of it to be able to create the least-cost tree. h
i
n
t
LSR replaced DSR in 1989 & variants of LSR (IS-IS & OSPF) are widely used today. a,

The idea behind link state routing is simple and can be stated as five parts. Each C
S
router must do the following: E,

V
1. Discover its neighbors and learn their network addresses. R
S
2. Measure the delay or cost to each of its neighbors. E
C

3. Construct a packet telling all it has just learned.


4. Send this packet to all other routers.
5. Compute the shortest path to every other router.
19
1. When a router is booted, its first task is to learn who its neighbors are. It accomplishes this goal
by sending a special HELLO packet on each point-to-point line. The router on the other end is
expected to send back a reply telling who it is.
M
u
2. A reasonable way of finding the delay to a nodes neighbors is to send over the line a special k
e
ECHO packet that the other side is required to send back immediately. By measuring the round- s
trip time and dividing it by two, the sending router can get a reasonable estimate of the delay. For h

even better results, the test can be conducted several times, and the average used. C
h
i
3. Once the information needed for the exchange has been collected, the next step is for each n
t
router to build a packet containing all the data. The packet starts with the identity of the sender, a,
followed by a sequence number and age, and a list of neighbors. For each neighbor, the delay to C
that neighbor is given. S
E,

4. Flooding is used to distributed the LSP to all routers. Routers keep track of all pairs (source, seq V
R
no) they see. Each receiving router compares the received LSP against the list of LSPs that it S
already has. If the sequence number of LSP is lower than the highest one seen, it is discarded. Or E
C
else, the router stores the new LSP & also forwards it via its neighboring interfaces.

5. After receiving all LSPs, the next step for a router is to compute the shortest path to every
possible destination using the Dijkstras algorithm & build the routing table.
20
M
u
k
e
s
h

C
h
i
n
t
a,

C
S
E,

V
R
S
E
C

21
Dijkstra's Algorithm derived by a Dutch computer scientist Edsger Dijkstra in
1956 and published in 1959. M
u
Initially mark all nodes (except source) with infinite distance. k
e
working node = source node s
h
Sink node = destination node
C
h
While the working node is not equal to the sink i
n
1. Mark the working node as permanent. t
a,

2. Examine all adjacent nodes in turn C


If the sum of label on working node plus distance from working node to adjacent node S
E,
is less than current labeled distance on the adjacent node, this implies a shorter path. V
Re-label the distance on the adjacent node and label it with the node from which the R
probe was made. S
E
C

3. Examine all tentative nodes (not just adjacent nodes) and mark the node with the
smallest labeled value as permanent.This node becomes the new working node.
Reconstruct the path backwards from sink to source.
23
Shortest Path Algorithm
M
u
k
e
s
h

C
h
i
n
t
a,

C
S
E,

V
R
S
E
C

The first five steps used in computing the shortest path from A to D.
The arrows indicate the working node
24
M
u
k
e
s
h

C
h
i
n
t
a,

C
S
E,

V
R
S
E
C

25
Mukesh Chinta, Asst Prof, CSE, VRSEC 25
Distance Vector Routing Link State Routing
RIP, RIPv2, IGRP, EIGRP OSPF, IS-IS
Router communicate with neighbor routers Routers communicate with all other routers M
u
advertising networks as measures of exchanging link-state information to build a k
e
distance and vector topology of the entire network s
h
Distance = Metric Link-State = Interface connections or
C
Vector = Direction (Interface) links to other routers and networks h
i
Best for: Best for: n
t
Simple, flat design, non-hierarchical Large, hierarchical networks a,

networks Advanced administrator knowledge C


S
Minimum administrator knowledge Convergence time is crucial E,
Convergence time is not an issue V
R
Knowledge of the network is from directly Routers have a complete view of the S
E
connected neighbors network, knowledge of the entire topology C

Send periodic updates of entire routing Send triggered partial updates


table
Uses Bellman-Ford algorithm Uses Dijkstras algorithm
26
PATH-VECTOR ROUTING
Both DVR and LSR does not allow the source to apply any specific policies to the route a
M
packet may take. u
k
To overcome the above limitation, a third routing algorithm called path-vector routing e
s
algorithm which is not based on least cost routing has been devised. h

Here, the best route is determined by the source using the policy it imposes on the route. It C
h
also makes use of spanning trees and the best spanning tree is determined by the source i
n
when it imposes its own policy. t
a,
Of the multiple routes available, the source can select a route which meets its policy best. C
Common examples of policy would be least number of nodes, omitting a specific node as S
E,
part of the router etc. V
R
S
E
C

27
Path vector routing like DVR is asynchronous and distributed routing algorithm
When a node is booted, it creates a path vector based on the information it can obtain
about its immediate neighbor
M
Each node, after the creation of the initial path vector, sends it to all its immediate u
k
neighbors. e
s
Each node, when it receives a path vector from a neighbor, updates its path vector using an h

equation similar to the Bellman-Ford, but applying its own policy instead of looking for the C
h
i
least cost.We can define this equation as n
t
Path(x, y) = best (Path(x, y),[(x + Path(v, y)]) for all v's in the internet a,

C
The policy is defined by selecting the S
E,
best of multiple paths.
V
Path-vector routing also imposes one R
S
more condition on this equation: If Path E
C
(v, y) includes x, that path is discarded to
avoid a loop in the path.
In other words, x does not want to visit
itself when it selects a path to y.
28
Path_Vector_Routing()
{
//Initialization
for (y = I to N)
{ M
if (y is myself) u
k
Path[y] = myself e
else if (y is a neighbor) s
Path [y] = myself + neighbor node h
else C
Path [y] = empty h
} i
n
Send vector (Path[l], Path[2], ... , Path[y)) to all neighbors t
// Update a,
repeat (forever)
C
{ S
wait (for a vector Pathw from a neighbor w) E,
for (y = 1 to N)
V
{ R
if (Pathw includes myself) S
discard the path E
C
else
Path[y] = best (Path[y], (myself + Pathw[y]))
}
If(there is a change in the vector)
Send vector (Path[l], Path[2], ... , Path[y]) to all neighbors
} }// End of Path Vector
29

You might also like