0% found this document useful (0 votes)
2 views42 pages

Routing Algorithms

The document discusses various routing algorithms used in network layer design, focusing on their principles, types, and specific algorithms such as Dijkstra's and Bellman-Ford. It categorizes routing algorithms into adaptive and non-adaptive types, explaining their functionalities and applications. Additionally, it covers techniques like flooding and distance vector routing, highlighting their characteristics and use cases.

Uploaded by

t93402
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views42 pages

Routing Algorithms

The document discusses various routing algorithms used in network layer design, focusing on their principles, types, and specific algorithms such as Dijkstra's and Bellman-Ford. It categorizes routing algorithms into adaptive and non-adaptive types, explaining their functionalities and applications. Additionally, it covers techniques like flooding and distance vector routing, highlighting their characteristics and use cases.

Uploaded by

t93402
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 42

See discussions, stats, and author profiles for this publication at: https://www.researchgate.

net/publication/357226470

Routing Algorithms

Presentation · December 2021


DOI: 10.13140/RG.2.2.13778.07364

CITATIONS READS

0 5,020

1 author:

Husam K Salih
Al-Rasheed University College
39 PUBLICATIONS 89 CITATIONS

SEE PROFILE

All content following this page was uploaded by Husam K Salih on 21 December 2021.

The user has requested enhancement of the downloaded file.


Routing Algorithms
• Routing Algorithms Principle

• Shortest Path Routing

• Dijkstra Algorithm

• Flooding Outlines
• Distance Vector Routing

• Bellman-Ford Algorithm

• References
• The main function of the network layer is routing packets from
the source machine to the destination machine.

• Packets will require multiple hops to make the journey

• The algorithms that choose the routes and the data structures
that they use are a major area of network layer design.
Routing Algorithms
Principle
• The routing algorithm is that part of the network layer software
responsible for deciding which output line an incoming packet
should be transmitted on.

• certain properties are desirable in a routing algorithm;


correctness, simplicity, robustness, stability, fairness, and
optimality.
Routing Algorithms Principle

Types of Routing Algorithm

A routing algorithm is a procedure that lays down the route or path to transfer
data packets from source to the destination. They help in directing Internet traffic
efficiently. After a data packet leaves its source, it can choose among the many
different paths to reach its destination. Routing algorithm mathematically
computes the best path, i.e. “least – cost path” that the packet can be routed
through.

Routing algorithms can be broadly categorized into two types:

• Adaptive Routing Algorithms


• Non-adaptive Routing Algorithms.
Routing Algorithms Principle

Types of Routing Algorithm


Routing Algorithms Principle

Adaptive Routing Algorithms

• Adaptive routing algorithms, also known as dynamic routing algorithms, makes routing
decisions dynamically depending on the network conditions. It constructs the routing table
depending upon the network traffic and topology. They try to compute the optimized route
depending upon the hop count, transit time and distance.

• The three popular types of adaptive routing algorithms are:


• Centralized algorithm
• Isolated algorithm
• Distributed algorithm
Routing Algorithms Principle

Non–Adaptive Routing Algorithms

• Non-adaptive Routing algorithms, also known as static routing algorithms, construct a static
routing table to determine the path through which packets are to be sent. The static routing
table is constructed based upon the routing information stored in the routers when the
network is booted up.

• The two types of non – adaptive routing algorithms are:


• Flooding
• Random walks
• A technique that is widely used in many forms because it is
simple and easy to understand.

• The idea is to build a graph of the subnet, with each node of the
graph representing a router and each arc of the graph
representing a communication line (often called a link).
Shortest Path • To choose a route between a given pair of routers, the algorithm
Routing just finds the shortest path between them on the graph.

• One way of measuring path length is the number of hops, the


paths ABC and ABE in Figure 1 are equally long.

• Another metric is the geographic distance in kilometers, in which


case ABC is clearly much longer than ABE (assuming the figure is
drawn to scale).
Shortest Path Routing

Figure 1: The first five steps used in computing the shortest path
from A to D. The arrows indicate the working node.
• One algorithm for finding the shortest path from a
starting node to a target node in a weighted graph is
Dijkstra’s algorithm.

• Dijkstra’s algorithm, published in 1959 and named after


its creator Dutch computer scientist Edsger Dijkstra, can
be applied on a weighted graph.

Dijkstra Algorithm • The algorithm creates a tree of shortest paths from the
starting vertex, the source, to all other points in the
graph.

• This algorithm is used in GPS devices to find the shortest


path between the current location and the destination.
It has broad applications in industry, specially in
domains that require modeling networks.
Dijkstra Algorithm
Dijkstra Algorithm

Requirements

1. Dijkstra's Algorithm can only work with graphs that have positive weights.
This is because, during the process, the weights of the edges have to be
added to find the shortest path.

2. If there is a negative weight in the graph, then the algorithm will not work
properly. Once a node has been marked as "visited", the current path to that
node is marked as the shortest path to reach that node. And negative
weights can alter this if the total weight can be decremented after this step
has occurred.
Dijkstra Algorithm
1. Mark all nodes unvisited. Create a set of all the unvisited nodes called the unvisited set.
2. Assign to every node a tentative distance value: set it to zero for our initial node and to infinity for
all other nodes. The tentative distance of a node v is the length of the shortest path discovered so
far between the node v and the starting node. Since initially no path is known to any other vertex
than the source itself (which is a path of length zero), all other tentative distances are initially set
to infinity. Set the initial node as current.
3. For the current node, consider all of its unvisited neighbors and calculate their tentative distances
through the current node. Compare the newly calculated tentative distance to the current assigned
value and assign the smaller one. For example, if the current node A is marked with a distance of
6, and the edge connecting it with a neighbor B has length 2, then the distance to B through A will
be 6 + 2 = 8. If B was previously marked with a distance greater than 8 then change it to 8.
Otherwise, the current value will be kept.
4. When we are done considering all of the unvisited neighbors of the current node, mark the current
node as visited and remove it from the unvisited set. A visited node will never be checked again.
5. If the destination node has been marked visited (when planning a route between two specific
nodes) or if the smallest tentative distance among the nodes in the unvisited set is infinity (when
planning a complete traversal; occurs when there is no connection between the initial node and
remaining unvisited nodes), then stop. The algorithm has finished.
6. Otherwise, select the unvisited node that is marked with the smallest tentative distance, set it as
the new current node, and go back to step 3.
Dijkstra Algorithm

Example 1
Dijkstra Algorithm

Example 1
Dijkstra Algorithm

Example 1
Dijkstra Algorithm

Example 1
Dijkstra Algorithm

Example 1
Dijkstra Algorithm

Example 1
Dijkstra Algorithm

Example 1
Dijkstra Algorithm

Example 1
Dijkstra Algorithm

Example 1
Dijkstra Algorithm

Example 1
Dijkstra Algorithm

Example 1
0 1 2 3 4 5 6

0 ∞ ∞ ∞ ∞ ∞ ∞
0 - 2 6 ∞ ∞ ∞ ∞
1 - - - 7 ∞ ∞ ∞
2 - - - 14 ∞ ∞ ∞
3 - - - - 17 22 ∞
4 - - - - - 23 19
5 - - - - - - 29
6 - - - - - - 19 {0,1,3,4,6} = 19
Dijkstra Algorithm

Example 1

0 1 3 4 6 = 19
Dijkstra Algorithm

Home Work 3
Find the shortest path of the following Graph using Dijkstra Algorithm.
• Another static algorithm is flooding, in which every incoming
packet is sent out on every outgoing line except the one it
arrived on.

• Flooding obviously generates vast numbers of duplicate


packets, in fact, an infinite number unless some measures are
taken to damp the process.

Flooding • If the sender does not know how long the path is, it can
initialize the counter to the worst case, namely, the full
diameter of the subnet.

• Flooding is not practical in most applications, but it does have


some uses. For example, in military applications, where large
numbers of routers may be blown to bits at any instant, the
tremendous robustness of flooding is highly desirable.
• Modern computer networks generally use dynamic routing
algorithms rather than the static.

• Two dynamic algorithms in particular, distance vector routing


and link state routing, are the most popular.

• Distance vector routing algorithms operate by having each


Distance Vector router maintain a table (i.e, a vector) giving the best known
Routing distance to each destination and which line to use to get there.
These tables are updated by exchanging information with the
neighbors.

• The distance vector routing algorithm is sometimes called by


other names, most commonly the distributed Bellman-Ford
routing algorithm and the Ford-Fulkerson algorithm
Distance Vector Routing

• In distance vector routing, each router maintains a routing table indexed by, and
containing one entry for, each router in the subnet. This entry contains two parts;
the preferred outgoing line to use for that destination and an estimate of the time
or distance to that destination.

• The metric used might be number of hops, time delay in milliseconds, total number
of packets queued along the path, or something similar.

• The router is assumed to know the ''distance'' to each of its neighbors. If the metric
is hops, the distance is just one hop.

• If the metric is queue length, the router simply examines each queue. If the metric
is delay, the router can measure it directly with special ECHO packets that the
receiver just timestamps and sends back as fast as it can.
• The researchers who developed it (Bellman, 1957; and
Ford and Fulkerson, 1962).

• It was the original ARPANET routing algorithm and was


also used in the Internet under the name RIP.

Bellman-Ford • Bellman Ford Algorithm is dynamic programming


Algorithm algorithm which is used to find the shortest path of any
vertex computed from a vertex treated as starting
vertex.

• This algorithm is better as it can handle edge’s with


negative weights. Though the algorithm is slower than
Dijkstra’s algorithm, it is a better one as it handles more
versatile type of graphs.
Bellman-Ford Algorithm

Algorithm
Bellman-Ford Algorithm

Example 2
Bellman-Ford Algorithm

Example 2
Bellman-Ford Algorithm

Example 2
Bellman-Ford Algorithm

Example 2
Bellman-Ford Algorithm

Example 2
Bellman-Ford Algorithm

Example 2
Bellman-Ford Algorithm

Example 2
Bellman-Ford Algorithm

Home Work 4
Find the shortest path of the following Graph using Bellman-Ford Algorithm.
[1] Behrouz A. Forouzan, ' Data Communications And Networking', 5th
Edition.

[2] Andrew S. Tanenbaum, ' Computer Networks', 4th Edition.

[3] James F Kurose, Keith W Ross, ' Computer Networking A Top Down
REFERENCES Approach', 6th Edition.
View publication stats

You might also like