CCN Module II - 2
CCN Module II - 2
Module 2 - 2
ROUTING ALGORITHMS
Distance-Vector Routing
The distance-vector (DV) routing uses the
goal to find the best route.
In distance-vector routing, the first thing each
node creates is its own least-cost tree with the
rudimentary information it has about its
immediate neighbors.
The incomplete trees are exchanged between
immediate neighbors to make the trees more and
more complete and to represent the whole
internet.
We can say that in distance-vector routing, a
router continuously tells all of its neighbors what
it knows about the whole internet
Bellman-Ford Equation
The heart of distance-vector routing is the famous
Bellman-Ford equation.
This 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, . . .) when the costs between the
source and the intermediary nodes and the least
costs between the intermediary nodes and
the destination are given.
The following shows the general case in which Dij
is the shortest distance and cij is the cost
between nodes i and j.
In distance-vector routing, normally we want
to update an existing least cost with a least
cost through an intermediary node, such as z,
if the latter is shorter. In this case, the
equation becomes simpler, as shown below:
Distance-Vector Routing Algorithm
Distance_Vector_Routing ( )
{
// Initialize (create initial vectors for the node)
D[myself ] = 0
for (y = 1 to N)
{
if (y is a neighbor)
D[y] = c[myself ][y]
else
D[y] = ∞
}
send vector {D[1], D[2], …, D[N]} to all neighbors
// Update (improve the vector with the vector received from a
neighbor)
repeat (forever)
{
wait (for a vector Dw from a neighbor w or any change in the
link)
for (y = 1 to N)
{
D[y] = min [D[y], (c[myself ][w] + Dw[y ])]
// Bellman-Ford equation
}
if (any change in the vector)
send vector {D[1], D[2], …, D[N]} to all neighbors
}
} // End of Distance Vector
Link-State Routing
A routing algorithm that directly follows for
creating least-cost trees and forwarding
tables is link-state (LS) routing.
This method uses the term link-state to define
the characteristic of a link (an edge) that
represents a network in the internet.
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.
Link-State Database (LSDB)
To create a least-cost tree with this method,
each node needs to have a complete map of
the network, which means it 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 duplicate of it to
be able to create the least-cost tree.
LSDB contains information about the whole internet.
This can 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 for each neighboring node: the identity of
the node and the cost of the link.
The combination of these two pieces of information is
called the LS packet (LSP);
When a node receives an LSP from one of its interfaces,
it compares the LSP with the copy it may already have.
If the newly arrived LSP is older than the one it has
(found by checking he sequence number), it discards
the LSP.
If it is newer or the first one received, the node discards
the old LSP (if there is one) and keeps the received one.
It then sends a copy of it out of each interface
except the one from which the packet arrived.
This guarantees that flooding stops
somewhere in the network.
Formation of Least-Cost Trees
To create a least-cost tree for itself, using the shared
LSDB, each node needs to run the famous Dijkstra
Algorithm.
This iterative algorithm uses the following steps:
1. 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.
2. 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.
3. The node repeats step 2 until all nodes are added to
the tree.
Path-Vector Routing
The best route is determined by the source
using the policy it imposes on the route.
In other words, the source can control the
path.
Although path-vector routing is not actually
used in an internet, and is mostly designed to
route a packet between ISPs
Spanning Trees
In path-vector routing, the path from a source to all
destinations is also determined by the best spanning
tree.
The best spanning tree, however, is not the least-cost
tree; it is the tree determined by the source when it
imposes its own policy.
If there is more than one route to a destination, the
source can choose the route that meets its policy best.
A source may apply several policies at the same time.
One of the common policies uses the minimum
number of nodes to be visited.
Another common policy is to avoid some nodes as the
middle node in a route.
Creation of Spanning Trees
Path-vector routing, like distance-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 creates a path
vector based on the information it can obtain
about its immediate neighbor.
A node sends greeting messages to its
immediate neighbors to collect these pieces of
information.
Each node, after the creation of the initial
path vector, sends it to all its immediate
neighbors.
Each node, when it receives a path vector
from a neighbor, updates its path vector using
an equation