Routing Algorithms
Routing Algorithms
Routing in IP
Introduction
• Routers forward IP datagrams from one router
to another on the path from source towards
destination
• Routing protocols
—To decide on routes to be taken
• Routers must have idea of topology of internet
in order to pick best route to take
—Decisions are based on some least cost criteria
—May depend on the current conditions
Chapter 15 1
Interior Routing Protocols
A Sample Configuration of
Routers and Networks
• Link costs are at
the output of the
links
• There is cost of
putting data to
the network
• There is no cost
of getting data
from the
network
• For example, the
cost of the path
X-A-F-Y is
1+1+4=6
Routing Table
• One routing table is needed for each router
• One entry for each destination network
— Not for each destination host
— Once datagram reaches router attached to destination network,
that router can deliver to host
• Each entry shows next node on the route to destination
— Not whole route
• Routing tables may also exist in hosts
— If multiple routers attached to network, host needs table saying
which to use
— If the attached network has single router, then routing table is
not needed
• All traffic must go through that router (called the gateway)
Chapter 15 2
Interior Routing Protocols
Fixed Routing
• Single permanent route configured for each
source-destination pair
—Routes are fixed
—May change when topology changes (not so often)
• No dynamic updates
Chapter 15 3
Interior Routing Protocols
Adaptive Routing
• As conditions on internetwork change, routes
may change
—Failure
• of routers or networks
—Congestion
• If a particular section of the network is heavily congested, it
is better not to use that part and change the route
Chapter 15 4
Interior Routing Protocols
Classification of Adaptive
Routing Strategies
• Based on information sources
—Local
• E.g. route each datagram to network with shortest queue
– Balance loads on outgoing networks
– May not be heading in correct direction
• Rarely used
—Adjacent nodes
• Delay and outage info from adjacent nodes
• Distance vector algorithms
– Discussed later
—All nodes
• Link-state algorithms
– Discussed later
Chapter 15 5
Interior Routing Protocols
Flooding
• No network info required
• Packet sent by node to every neighbor
• Incoming packets retransmitted on every link
except incoming link
• Eventually a number of copies will arrive at
destination
• Each packet is uniquely numbered so duplicates
can be discarded at destination
Flooding
Example
Chapter 15 6
Interior Routing Protocols
Flooding- Improvements
• Precautions against unlimited grow in circulation
—Nodes can remember packets already forwarded to
keep network load within allowed limits
• called "Restricted Flooding"
—Include a hop count in packets.
• Set to a maximum value
• Decrease one at each hop
• Discard when 0
Properties of Flooding
• All possible routes are tried
—very robust
—can be used for emergency messaging
• At least one packet will use minimum hop count
route
—Can be used once to set up a route
• All nodes are visited
—Useful to distribute information (e.g. routing info)
Chapter 15 7
Interior Routing Protocols
Random Routing
• Node selects one outgoing path for
retransmission of incoming packet
• Selection is at random
—equally likely
• all outgoing links are utilized equally in the long-run
—can select outgoing path based on a probability
• e.g. probability based on data rate
– good traffic distribution
• No network info needed
• Route is typically neither least cost nor minimum
hop
Chapter 15 8
Interior Routing Protocols
Chapter 15 9
Interior Routing Protocols
Approaches to Routing –
Distance-vector
• Each router exchange information with neighboring routers
— Definition: Two nodes are said to be neighbors if both are directly
connected to each other or to the same network
• Each node keeps
— distance vector and next-hop vector (Routing table)
• One entry for each destination network
— a vector of link costs for each directly attached network
• First generation routing algorithm for ARPANET
• Used by Routing Information Protocol (RIP)
— will discuss later
• Requires transmission of information by each router to all
neighbors
— Distance vector that contains estimated path costs for all destination
networks
— Changes may take long time to propagate
Approaches to Routing –
Link-state
• Designed to overcome drawbacks of distance-vector
• When router initialized, it determines link cost on each interface
• Advertises set of link costs to all other routers in topology
— Not just neighboring routers
• After that, each router monitors its link costs
— If significant change, router advertises new set of link costs
• In this way, each router builds up a picture of the entire topology
— Can calculate shortest path to each destination
— Use an algorithm to determine shortest paths
• In practice, Dijkstra's algorithm
• Router constructs routing table, listing first hop to each destination
• Second generation routing algorithm for ARPANET
• Open shortest path first (OSPF) protocol uses link-state routing.
Chapter 15 10
Interior Routing Protocols
Approaches to Routing –
Path-vector
• Suitable approach for Exterior Router Protocols
• Provide information about which networks can
be reached by a given router and Autonomous
Systems crossed to get there
—Does not include distance or cost estimate
• BGP (Border Gateway Protocol) is an example to
path-vector routing protocol
Chapter 15 11
Interior Routing Protocols
Dijkstra's Algorithm
• Find shortest paths from a given node to all
other nodes, by developing paths in the order of
increasing path length (and increasing cost)
• Proceeds in stages
—At each stage shortest path from source to one node
is determined
—The nodes for which shortest path determined are
kept in a set called T
—At each iteration, node not in T but has the shortest
path from source added to T
—As each node added to T, path from source to the
nodes not in T are checked to see whether there is a
better path through this newly added node
Chapter 15 12
Interior Routing Protocols
Dijkstra's Algorithm –
Formal (1)
• N = set of nodes in the network
• s = source node
• T = set of nodes so far incorporated (shortest path
found)
• w(i, j) = link cost from node i to node j
w(i, i) = 0
w(i, j) = if nodes not directly connected
w(i, j) 0 if nodes are directly connected
• L(n) = cost of current least-cost path from s to n
— At the end of algorithm (actually as soon as n is added to T),
L(n) is the cost of least-cost path from s to n
Dijkstra's Algorithm –
Formal (2)
[Initialization]
T = {s}
i.e. set of nodes so far incorporated consists of only source node
L(n) = w(s, n) for all n ≠ s
i.e. initial path costs to neighboring nodes are link costs
Chapter 15 13
Interior Routing Protocols
Dijkstra's Algorithm –
Formal (3)
Repeat
• Non-negative weight
• BFS approach
• Greedy
Chapter 15 14
Interior Routing Protocols
Bellman-Ford Algorithm
• Iterative
1.find the shortest paths from a source to all possible
destinations using only one link
2.then using max. two links by adding appropriate links
to the paths of step 1
3.then using max. 3 links on top of paths with two links
4.so on .. until no improvement is gained by adding
more links
Bellman-Ford Algorithm –
Formal (1)
• s = source node
• w(i, j) = link cost from node i to node j
w(i, i) = 0
w(i, j) = if nodes are not directly connected
w(i, j) 0 if nodes directly connected
• h = maximum number of links in path at current
stage
• Lh(n) =cost of least-cost path from s to n such
that path contains no more than h links
Chapter 15 15
Interior Routing Protocols
Bellman-Ford Algorithm –
Formal (2)
[Initialization]
L0(n) = , for all n s
h=0
Bellman-Ford Algorithm –
Formal (3)
[Update]
Loop until no more improvements
For each n ≠ s, compute
min
L h1n
j
Lh j w j, n
Chapter 15 16
Interior Routing Protocols
RIP
Chapter 15 17
Interior Routing Protocols
35
Chapter 15 18
Interior Routing Protocols
RIP - History
• Late 1960s : Distance Vector
protocols were used in the ARPANET
• Mid-1970s: XNS (Xerox Network system) routing
protocol is the precursor of RIP in IP (and Novell’s
IPX RIP and Apple’s routing protocol)
• 1982 Release of routed for BSD Unix
• 1988 RIPv1 (RFC 1058)
- classful routing
• 1993 RIPv2 (RFC 1388)
- adds subnet masks with each route
entry
- allows classless routing
• 1998 Current version of RIPv2 (RFC 2453)
38
Chapter 15 19
Interior Routing Protocols
RIP - History
• Late 1960s : Distance Vector
protocols were used in the ARPANET
• Mid-1970s: XNS (Xerox Network system) routing
protocol is the precursor of RIP in IP (and Novell’s
IPX RIP and Apple’s routing protocol)
• 1982 Release of routed for BSD Unix
• 1988 RIPv1 (RFC 1058)
- classful routing
• 1993 RIPv2 (RFC 1388)
- adds subnet masks with each route
entry
- allows classless routing
• 1998 Current version of RIPv2 (RFC 2453)
39
1: request
2: response
Command Version Set to 00...0
2: for IP
address family Set to 00.00
0…0: request full rou-
one route entry
Chapter 15 20
Interior Routing Protocols
RIPv2
• RIPv2 is an extends RIPv1:
—Subnet masks are carried in the route information
—Authentication of routing messages
—Route information carries next-hop address
—Exploites IP multicasting
41
1: request
2: response
Command Version Set to 00...0
2: for IP
address family Set to 00.00
0…0: request full rou-
one route entry
Chapter 15 21
Interior Routing Protocols
(20 bytes)
Subnet mask for IP
address Subnet Mask
Next-Hop IP address
Identifies a better next-hop
metric (1-16)
address on the same
subnet than the advertising
router, if one exists Up to 24 more routes (each 20 bytes)
(otherwise 0….0)
43
32 bits
RIP Messages
• This is the operation of RIP in routed.
Dedicated port for RIP is UDP port 520.
44
Chapter 15 22
Interior Routing Protocols
45
Chapter 15 23
Interior Routing Protocols
Security
• Issue: Sending bogus routing updates to a
router
• RIPv1: No protection
• RIPv2: Simple authentication scheme
RIP Security
Password (Bytes 0 - 3)
Password (Bytes 4 - 7)
Chapter 15 24
Interior Routing Protocols
RIP Problems
49
An Example of RIP
Chapter 15 25
Interior Routing Protocols
Chapter 15 26
Interior Routing Protocols
Chapter 15 27
Interior Routing Protocols
Chapter 15 28