Routing Algorithms
M R Khandker, PhD
Professor
EEE, RU
Routing and Forwarding
• The routing algorithm is a part of the network layer software
responsible for deciding which output line an incoming packet
should be transmitted on.
• If the network uses datagram, this decision must be made anew
for every arriving data packet.
• If the subnet uses virtual circuits, routing decision are made only
when a new virtual circuit is established. Thereafter, data packets
just follow the previously established route. This is called session
routing.
• Routing
– taking decision of route for a session; updating the routing table.
• Forwarding
– forwarding a packet of that session on the decided output line when
arrives.
Routing: Classification
• Non-adaptive or static
– do not base their routing decisions on
measurements or estimates of the current traffic
and topology.
• Adaptive or dynamic
– change their routing decisions to reflect changes
in the topology, and usually the traffic as well.
Routing algorithm: Desirable Properties
• Correctness – must find the correct destination
• Simplicity: - less time
• Robustness:
– can accommodate changes in traffic and topology, failure or nodes
and links etc.
• Stability
– Converges quickly and stays in the equilibrium state
• Fairness
– Fare share of bandwidth to hosts; no starving
• Efficiency
– Maximize the throughput: consume less bandwidth, produce less
delay
Flooding
• Every incoming packet is sent out on every
outgoing line except the one it arrive on.
• Demerits:
– vast number of duplicate packets; infinite.
• Measures
– can be reduce using TTL like measure
– keep track of the flooding packet, not to entertain
such packet again.
– Selective flooding
Flooding: Illustration
R1
P1 P1
R3
R2 P2
P2 P2
P2 R6
P4
R4 R5
Optimality principle
• A general statement about optimal routes without
regard to network topology or traffic (R. Bellman)
– It states that if router J is on the optimal path from router I
to router K, then the optimal path from J to K also falls
along the same route.
– If a better route is found from J to K, then the old route
from I to K may updated.
– Over the optimal path, any segment is also optimal.
– What is the metrics of optimality??
Shortest Path Routing
• Build a graph of subnets, with each node of
the graph representing a router, and each arc
of the graph representing a communication
line.
• To choose a route between a given pair of
routes, the algorithm just finds the shortest
path between them on the graph.
• Dijkstra’s algorithm.
• Metrics
– Hop count
– Distance
– Delay
– Bandwidth etc.
• path: DHFEBA
Distance Vector Algorithm
• Bellman-Ford or Ford-Fulkerson algorithm
• It is iterative, asynchronous and distributed.
• Each node keeps a distance table. Node X’s distance
table entry, DX(Y,Z) is the sum of the cost of the direct
one hop link between X and Z, plus neighbor Z’s
currently known least cost path from itself to Y.
DX(Y,Z) = c(X,Z)+minw{DZ(Y,W)}
Distance Vector Algorithm
• Bellman-Ford or Ford-Fulkerson algorithm
• If all neighbors of node i know the shortest distance to node j,
then the shortest distance between node i and j can be found
by adding the distance between node i and each neighbor to
the neighbor’s shortest distance to node j and then select the
minimum.
A0 B0
To Cost Nxt To Cost Nxt
A 0 - A 7 -
B 7 - B 0 -
C 5 - C 4 -
D 3 - D
E E
C0 D0 E0
To Cost Nxt To Cost Nxt To Cost Nxt
A 5 - A 3 - A
B 4 - B B
C 0 - C C 4 -
D D 0 - D
E 4 - E E 0 -
B0 A0 A AB
To Cost Nxt To Cost Nxt To Cost Nxt To Cost Nxt
A 7 - A 0 - A 7+7 B A 0 -
B 0 - B 7 - B 7+0 B B 7 -
C 4 - C 5 - C 7+4 B C 5 -
D D 3 - D 7+ B D 3 -
E E E B E
A0 B0 B BA
To Cost Nxt To Cost Nxt To Cost Nxt To Cost Nxt
A 0 - A 7 - A 7+0 A A 7 -
B 7 - B 0 - B 7+7 A B 0 -
C 5 - C 4 - C 7+5 A C 4 -
D 3 - D D 7+3 A D 10 A
E E E 7+ A E
C0 AB A ABC
To Cost Nxt To Cost Nxt To Cost Nxt To Cost Nxt
A 5 - A 0 - A 5+5 C A 0 -
B 4 - B 7 - B 5+4 C B 7 -
C 0 - C 5 - C 5+0 C C 5 -
D D 3 - D 5+ C D 3 -
E 4 - E E 5+4 C E 9 C
A0 C0 C CA
To Cost Nxt To Cost Nxt To Cost Nxt To Cost Nxt
A 0 - A 5 - A 5+0 C A 5 -
B 7 - B 4 - B 5+7 C B 4 -
C 5 - C 0 - C 5+5 C C 0 -
D 3 - D D 5+3 C D 8 A
E E 4 - E 5+ C E 4 -
A0 D0 D DA
To Cost Nxt To Cost Nxt To Cost Nxt To Cost Nxt
A 0 - A 3 - A 3+0 A A 3 -
B 7 - B B 3+7 A B 10 A
C 5 - C C 3+5 A C 8 A
D 3 - D 0 - D 3+3 A D 0 -
E - E E 3+ A E
D0 ABC A ABCD
To Cost Nxt To Cost Nxt To Cost Nxt To Cost Nxt
A 3 - A 0 - A 3+3 D A 0 -
B B 7 - B 3+ D B 7 -
C C 5 - C 3+ D C 5 -
D 0 - D 3 - D 3+0 D D 3 -
E E 9 C E 3+ D E 9 C
C0 BA B BAC
To Cost Nxt To Cost Nxt To Cost Nxt To Cost Nxt
A 5 - A 7 - A 4+5 C A 7 -
B 4 - B 0 - B 4+4 C B 0 -
C 0 - C 4 - C 4+0 C C 4 -
D A D 10 A D 4+ C D 10 A
E 4 - E E 4+4 C E 8 C
B0 CA C CAB
To Cost Nxt To Cost Nxt To Cost Nxt To Cost Nxt
A 7 - A 5 - A 4+7 B A 5 -
B 0 - B 4 - B 4+0 B B 4 -
C 4 - C 0 - C 4+4 B C 0 -
D D 8 A D 4+ B D 8 A
E E 4 - E 4+ B E 4 -
E0 CAB C CABE
To Cost Nxt To Cost Nxt To Cost Nxt To Cost Nxt
A A 5 - A 4+ E A 5 -
B B 4 - B 4+ E B 4 -
C 4 - C 0 - C 4+0 E C 0 -
D D 8 A D 4+ E D 8 A
E 0 - E 4 - E 4+0 E E 4 -
C0 E0 E EC
To Cost Nxt To Cost Nxt To Cost Nxt To Cost Nxt
A 5 - A A 4+5 C A 9 C
B 4 - B B 4+4 C B 8 C
C 0 - C 4 - C 4+0 C C 4 -
D A D D 4+ C D
E 4 - E 0 - E 4+4 C E 0 -
ABCD A1
BAC B1
CABE C1
DA D1
EC E1
A1 D1 D D1A
To Cost Nxt To Cost Nxt To Cost Nxt To Cost Nxt
A 0 - A 3 - A 3+0 A A 3 -
B 7 - B 10 A B 3+7 A B 10 A
C 5 - C 8 A C 3+5 A C 8 A
D 3 - D 0 - D 3+3 A D 0 -
E 9 C E E 3+9 A E 12 A
Bellman-Ford Algorithm
Link State Routing
• Each router must do the following things to make it work:
– Discover its neighbors and learn their network addresses.
– Set the distance or cost metric to each of its neighbors.
– Construct a packet telling all it has just learned.
– Send this packet to and receive packets from all other routers.
– Compute the shortest path to every other router.
• In effect, the complete topology is distributed to every router.
Then Dijkstra’s algorithm can be run at each router to find the
shortest path to every other router
• OSPF is a LSR protocol
Address Resolution Protocol
• Maps IP to Physical Address (MAC address).
• ARP Broadcast
• ARP Cache
• Aging
• ARP Table
IP MAC Type
172.16.1.1 00e0.a315.1802 Static
172.16.1.2 000c.85b1.b32c dynamic
172.16.1.4 0090.21d4.c4ad dynamic
Reverse ARP
• MAC IP
DHCP
• Domain Host Configuration Protocol
• ARP makes the assumption that hosts are configured with
some basic information, such as their own IP addresses. How
do hosts get this information?
• Configuration file on each computer. Impossible!
• Dynamically configure each host
• When a computer is started
– broadcasts a request for an IP address: DHCP DISCOVER packet
– DHCP Server allocates a free IP address and sends it to the host in a
DHCP OFFER packet
– Host acknowledges by DHCP ACKNOWLEDG packet
• Lease Time, Pool, Static assignment