Routing Algorithms
Routing Algorithms
A report on different network layer protocols used in the Internet and their
comparison
(By : Babita Naagar & Surbhi Rathi)
Introduction
When a packet arrives at a router, it indexes a forwarding table and determines the
link interface to which the packet is to be directed.
Routing algorithms, operating in network routers exchange and compute information
that is used to configure these forwarding tables.
Figure 1.1 shows a typical router architecture
OUTPUT PORT
INPUT PORT
INPUT PORT
SWITCHING
FABRIC
INPUT PORT
OUTPUT PORT
OUTPUT PORT
ROUTING
PROCESSOR
Typically a host is attached directly to a router (called the default router or the first
hop router), so whenever the host transmits a packet, it it is transferred to the default
router and then passed on to reach the default router of the destination host.
The problem of routing algorithms is then simple : given a set of routers, with links
connecting the routers, find a good (least cost) path from source to destination.
Routing problems can be formulated using graphs. In a graph G = (N, E) N the set of
nodes can represent routers and E the set of edges can represent physical links
connecting the routers.
We are considering a non directed graph so that c(x,y) = c(y,x)
where
'c' is the cost function which may represent the physical length, monetary value etc of
the link or edge
and 'x' and 'y' represent nodes (routers)
An example network, represented using graph, has been shown below :
3
u
1
1
2
y
Figure 2
intervention
Link costs vary dynamically to reflect the Internet routing algorithms (such as RIP,
current level of congestion in the
OSPF, and BGP) are load-insensitive, as
underlying link.
a links cost does not explicitly reflect its
current level of congestion.
Ex: Used in ARPAnet earlier, but
presented some difficulties so no longer
followed.
1 Initialization:
2
N = {u}
3
for all nodes v
4
if v is a neighbor of u
5
then D(v) = c(u,v)
6
else D(v) =
7
8 Loop
9
find w not in N such that D(w) is a minimum
10
add w to N
11
update D(v) for each neighbor v of w and not in N:
12
D(v) = min( D(v), D(w) + c(w,v) )
13 /* new cost to v is either old cost to v or known
14 least path cost to w plus cost from w to v */
15 until N= N
N'
D(v),P(v)
D(w),P(w) D(x),P(x)
D(y),P(y)
D(z),P(z)
2,u
ux
2,u
4,x
2,x
uxy
2,u
3,y
4,y
uxyv
3,y
4,y
uxyvw
uxyvwz
1,u
4,y
Complexity : In first iteration, we have to look among 'n' nodes to find the node 'w',
not in N' that has the minimum link-cost. In second iteration we have to search
among n-1 nodes and so on. We get worst case complexity of order of O(N^2) but we
can reduce this to logarithmic order by implementing data structures like heaps.
Here, a problem of router oscillation may occur if link cost depends upon the traffic.
In the distributed, asynchronous algorithm, from time to time, each node sends
a copy of its distance vector to each of its neighbors. When a node x receives a
new distance vector from any of its neighbors v, it saves vs distance vector, and
then uses the Bellman-Ford equation to update its own distance vector as follows:
Dx(y)= min {c(x,v) + D v (y)}
for each node y in N
If node xs distance vector has changed as a result of this update step, node x will
then send its updated distance vector to each of its neighbors, which can in turn
update their own distance vectors.
3. The process of receiving updated distance vectors from neighbors, recomputing
routing table entries, and informing neighbors of changed costs of the least-cost path
to a destination continues until no update messages are sent. At this point, since no
update messages are sent, no further routing table calculations will occur and the
algorithm will enter a quiescent state; that is, all nodes will be performing the wait
in Lines 1011 of the DV algorithm. The algorithm remains in the quiescent state
until a link cost changes.
At each node, x:
1 Initialization:
2 for all destinations y in N:
3 D x (y) = c(x,y)
/* if y is not a neighbor then c(x,y) = */
4 for each neighbor w
5 D w (y) = ? for all destinations y in N
6 for each neighbor w
7 send distance vector D x = [D x (y): y in N] to w
8
9
loop
10 wait (until I see a link cost change to some neighbor w or
11 until I receive a distance vector from some neighbor w)
12
13 for each y in N:
14 D x (y) = min v {c(x,v) + D v (y)}
15
16 if D x (y) changed for any destination y
17 send distance vector D x = [D x (y): y in N] to all neighbors
18
19 forever
Routing Loop : When link-cost increase in a network, wrong least-cost routes may be
calculated and may result in a loop where a packet will bounce back and forth, until
all nodes correctly calculate the distance vector, which may take a lot of loops and so
this problem is often called count-to-infinity problem. A technique known as
poisoned reverse is used to tackle this.
Message Complexity
Link State
Distance Vector
Requires message
exchanges between directly
connected neighbors at
each iteration.
O(|N| 2 )
The DV algorithm can
Speed of
Convergence/complexit algorithm requiring O(|N| | converge slowly
E|)) messages
and can have routing loops
y
while the algorithm is
converging.
Robustness
If a router fails,
misbehaves or is
sabotaged...
Hierarchal Routing
1. To reduce complexity (and because of certain administrative autonomies), routers
Figure -3
Sending packets outside AS
IN THE INTERNET
Determine from
forwarding table the
interface I that leads
to least-cost gateway.
Enter (x,I) in
forwarding table.
RIP
1. RIP is a distance-vector protocol that operates in a manner very close to the
idealized DV protocol we examined previously.
2. The version of RIP specified in RFC 1058 uses hop count as a cost metric; that is,
each link has a cost of 1.In the DV algorithm for simplicity, costs were defined
between pairs of routers. In RIP (and also in OSPF), costs are actually from source
router to a destination subnet. RIP uses the term hop, which is the number of subnets
traversed along the shortest path from source router to destination subnet, including
the destination subnet.
3.The maximum cost of a path is limited to 15, thus limiting the use of RIP to
autonomous systems that are fewer than 15 hops in diameter. Recall that in DV
protocols, neighboring routers exchange distance vectors with each other. The
distance vector for any one router is the current estimate of the shortest path
distances from that router to the subnets in the AS. In RIP, routing updates
are exchanged between neighbors approximately every 30 seconds using a
RIP response message. The response message sent by a router or host contains
a list of up to 25 destination subnets within the AS, as well as the senders
distance to each of those subnets. Response messages are also known as RIP
advertisements.
OSPF
1. OSPF is a link-state protocol that uses flooding of link-state information and a
Dijkstra least-cost path algorithm. With OSPF, a router constructs a complete
topological map (that is, a graph) of the entire autonomous system. The router then
locally runs Dijkstras shortest-path algorithm to determine a shortest-path tree to all
subnets, with itself as the root node. Individual link costs are configured by the
network administrator.
2. With OSPF, a router broadcasts routing information to all other routers in the
autonomous system, not just to its neighboring routers. A router broadcasts linkstate information whenever there is a change in a links state (for example, a change
in cost or a change in up/down status). It also broadcasts a links state periodically
(at least once every 30 minutes), even if the links state has not changed.
3. Some improvements/ advantages OSPF has over RIP :
a) Security : Exchanges between OSPF routers (for example, link-state updates)
BGP
BGP provides each AS a means to
1. Obtain subnet reachability information from neighboring ASs.
2. Propagate the reachability information to all routers internal to the AS.
3. Determine good routes to subnets based on the reachability information and
on AS policy.
In BGP, pairs of routers exchange routing information over semipermanent
TCP connections using port 179. For each TCP connection, the two routers at the end
of the connection are called
BGP peers, and the TCP connection along with all the BGP messages sent over the
connection is called a BGP session. Furthermore, a BGP session that spans two ASs
is called an external BGP (eBGP) session, and a BGP session between routers in
the same AS is called an internal BGP (iBGP) session.
BGP allows each AS to learn which destinations are reachable via its neighboring
ASs. In BGP, destinations are not hosts but instead are CIDRized prefixes, with
each prefix representing a subnet or a collection of subnets.
node receives a broadcast packet, it duplicates the packet and forwards it to all of its
neighbors (except the neighbor from which it received the packet). Clearly, if the
graph is connected, this scheme will eventually deliver a copy of the broadcast
packet to all nodes in the graph.
If the graph has a cycle, this may lead to one or more copies of each broadcast packet
will cycle indefinitely. Something called broadcast storm may occur here, resulting
from the endless multiplication of broadcast packets, would eventually result in so
many broadcast packets being created that the network would be rendered useless.
CONTROLLED FLOODING
In sequence-number-controlled flooding, a source node puts its address (or
other unique identifier) as well as a broadcast sequence number into a broadcast
packet, then sends the packet to all of its neighbors. Each node maintains a list of
the source address and sequence number of each broadcast packet it has already
received, duplicated, and forwarded. When a node receives a broadcast packet, it
first checks whether the packet is in this list. If so, the packet is dropped, packet is
duplicated and forwarded to all the nodes neighbors (except the node from
which the packet has just been received).
SPANNING TREE BROADCAST
Another approach to providing broadcast is for the network nodes to first
construct a spanning tree. When a source node wants to send a broadcast packet, it
sends the packet out on all of the incident links that belong to the spanning tree. A
node receiving a broadcast packet then forwards the packet to all its neighbors in the
panning tree (except the neighbor from which it received the packet). Not only
does spanning tree eliminate redundant broadcast packets, but once in place, the
spanning tree can be used by any node to begin a broadcast.