Escolar Documentos
Profissional Documentos
Cultura Documentos
PROJECT REPORT
ON
“ROUTING ALGORITHM”
SUBMITTED TO
BHILAI (INDIA)
BACHELOR OF ENGINEERING
IN
INFORMATION TECHNOLOGY
BY
AKSHAY AGRAWAL
SESSION – 2014-15
Page | 1
A
PROJECT REPORT
ON
“ROUTING ALGORITHM”
SUBMITTED TO
BHILAI (INDIA)
BACHELOR OF ENGINEERING
IN
INFORMATION TECHNOLOGY
BY
AKSHAY AGRAWAL
SESSION – 2014-15
Page | 2
DECLARATION
We the undersigned solemnly declare that the report of the project work entitled
“ROUTING ALGORITHM”, is based on our own work carried out during the course
of study under the supervision of Mr. Ashutosh Bhensle .
Akshay Agrawal
Page | 3
CERTIFICATE
This is to certify that the report of the project submitted is an outcome of the project
work entitled “ROUTING ALGORITHM” carried out by
The project work as mentioned above is hereby being recommended and forwarded
for examination and evaluation.
Page | 4
CERTIFICATE BY THE EXAMINERS
Submitted by
Has been examined by the undersigned as a part of the examination for the award of
Bachelor of Engineering degree in Information Technology Engineering of
Chhattisgarh Swami Vivekananda Technical University, Bhilai
Date: Date:
Page | 5
ACKNOWLEDGEMENT
Working on this project has been a great learning experience for us.
There were moments of anxiety, which we could not solve a problem for several
days & there were moments when we could solve a problem after struggling for
several days. But we have enjoyed every bit of the process and we are thankful to all
people associated with us during this period.
We would also like to express our deep gratitude to Mrs. Jaspal Bagga
Mam for her ever helping and support. We also pay special for her helpful solutions
& comments enriched by her experience, which improved our ideas for the
betterment of project.
(Signature of Candidate)
Akshay Agrawal
Page | 6
ABSTRACT
The report is concerned with the shortest path problem, its theoretical approach,
Implementation and application. First a historical background of SP algorithms
is given and basic concepts of network analysis in connection with traffic issues
are explored for the later use. The report concentrates on two SP algorithms.
The first algorithm finds one shortest path in a network with time dependent
costs of links in O(n + m) time, where n is the number of nodes, m is the
number of links in the network. The second algorithm designed for the purpose
of the group project is a combination of the first algorithm and the Dijkstra
algorithm, it also runs in O(n + m) time. Both algorithms are presented in the
context of public transport networks and implemented in Java. At the end of the
report the author’s results are discussed and ideas for the further work are given.
Page | 7
TABLE OF CONTENTS
2. Literature Summary
3. Problem Identification………………………………. 18
4. Project Analysis
4.1 Hardware Requirement………………………………….. 20
5. Methodology
5.1 Theoritical Background………………………………….. 22
7. Conclusion……………………………………………… 34
8. Bibliography……………………………………………. 37
Page | 8
CHAPTER- 1
INTRODUCTION
Page | 9
1.1 Project Description
This project deals with algorithms that find the fastest route from your position
to chosen destination. These algorithms are based on the Graph theory. Traffic
network is transformed into graph and some graph algorithm for finding the
fastest/shortest route is applied. Resulting route is relayed to the driver. It may seem
simple at the first glance but several issues arise. First of them is that graph generated
from traffic network would be too large. Generally navigations are small and not
tooled for computational power.It is necessary to separate such a big graph to smaller
ones. This is done by partitioning (see e.g. [1]). Graph representing traffic network is
divided into several smaller subgraphs which contain roads of the same level (for
example motorways, 1st class roads, 2nd class roads etc.) Connected by some
boundary graph. This allows searching on relatively smaller sub graphs. Search is first
done on higher level roads which are faster and then moves to lower levels as faster
roads usually do not lead to hotels, places of business etc. Also some heuristics can be
added to solve this problem. Second issue, which is main motivation for this thesis, is
what graph algorithm for finding fastest/shortest route to use.
The basic function of a data network is very simple: delivering data from one
network node to another. Achieving this goal requires many network components,
including physical computers and links, signalling protocols between computers, and
data packaging protocols. This project addresses one such component, routing, and
the process that logically connects network nodes by calculating paths between nodes
so that data sent by one node traverses the calculated path to its destination.
1.1 Purpose
Routing is the process of selecting best paths in a network. In the past, the
term routing was also used to mean forwarding network traffic among networks.
However this latter function is much better described as simply forwarding. Routing
is performed for many kinds of networks, including the telephone network (circuit
switching), electronic data networks (such as the Internet), and transportation
networks. This article is concerned primarily with routing in electronic data networks
using packet switching technology.
In packet switching networks, routing directs packet forwarding (the transit of
logically addressed network packets from their source toward their ultimate
destination) through intermediate nodes. Intermediate nodes are typically network
hardware devices such as routers, bridges, gateways, firewalls, or switches. General-
purpose computers can also forward packets and perform routing, though they are not
specialized hardware and may suffer from limited performance. The routing process
usually directs forwarding on the basis of routing tables which maintain a record of
the routes to various network destinations. Thus, constructing routing tables, which
are held in the router's memory, is very important for efficient routing. Most routing
algorithms use only one network path at a time. Multipath routing techniques enable
the use of multiple alternative paths.
In case of overlapping/equal routes, the following elements are considered in
order to decide which routes get installed into the routing table (sorted by priority):
The single pair shortest path problem in real-world road networks, also known
as route planning, has many important everyday applications. There are two most
significant variants of the problem – static and dynamic route planning. In the static
variant, a road network is fixed during the computation of optimal routes (query).
Static route planning received a lot of attention during the last decades. On the other
hand, in the dynamic variant a road network is subject to change in time – some new
roads are built, some other are closed, traffic jams or car accidents happen, some
routes must be avoided due to turn angle limits, and so on. Clearly, the latter is a more
realistic scenario. Actually, even time-dependent cost functions can be modeled in
dynamic route planning to some extent.
Classical algorithms such as Dijkstra’s or A* and their dynamic adaptions are not well
suitable neither for static nor for dynamic variants becauseof huge road networks size.
Thus, a feasible solution lies in computing suitable auxiliary data of the road network
(pre-processing) in order to improve both time and space complexity of subsequent
queries. This technique led to several very interesting static approaches in the last
decade, see extensive surveys, for instance, in. Some of these algorithms such as
highway-hierarchies, ALT or, for example, geometric containers were proved to work
fine also
In the next part of this thesis we define all theoretical terms that we use in this
thesis. These include definitions from the Graph theory, mathematical analysis, and
descriptions of some basic graph algorithms like graph searches and basic Dijkstra
algorithm. We will also describe here Ant colony algorithms which we will use later.
After theoretical terms follows part that is about making static graphs dynamic. We
will show some representations of time in dynamic graph and discuss their
advantages. Then we will decide which one we will use for our algorithms.After that
we will describe proposed algorithms. We will present their features and talk about
their implementation. They will be demonstrated on some simple examples solved by
our implemented algorithms and then manually for comparison of results. Next part
comprises of analyze and comparison of proposed algorithms. We will test all
presented algorithms on real data obtained from local traffic network and do thorough
analysis. Results of this analysis will be discussed and cons and pros of each
algorithm presented. In the final part we will summarize our results and achievements.
This part will be followed by appendix containing proposed algorithms implemented
in Mat lab programming language.
Page | 12
CHAPTER - 2
LITERATURE SUMMARY
Shortest/fastest path problem is studied since 1950s. One of the first and one
of the most well-known was developed by Dijkstra and so is called Dijkstra’s
Page | 13
algorithm. On this algorithm is based another widely used algorithm that is called A*.
It adds heuristic function which estimates cost of the route from current node to the
destination. If the estimation satisfies some conditions it can be used to effectively
find shortest route.
This was practiced for example by Chen and Xu. There were a lot of research
activity on behalf of the dynamic graphs and routing on them. Harary and Gupta layed
down some basics of dynamic graphs and outlined some applications for them. They
also study them as extension of static graphs. Kali nowski and Wenk present model
where navigation receives periodic updates and computes only shortest path to the
next update. It works on base of A* algorithm. This algorithm tries to be at high
degree node when update comes so it has a lot of possibilities to react on the change
in graph. They also show that these computations can be done locally on navigation or
on some central computer connected to navigation. Demetrescu, Finocchi and Italiano
have come up with similar approach. Dynamism is also represented by some periodic
updates to the edges. Their all pairs shortest path recomputes only shortest path which
were invalidated by update. After the update they are recomputed by Dijkstra
algorithm and by observation that shortest route is composed of other shortest routes.
These approaches are unsuitable for our problem because they are not good at
modeling periodical processes.
Useful insights are also provided by Tong andWong. They point to the
problem that updates of edge value must be done even when a car is already travelling
on the updated edge and the algorithm must consider this change. Not considering it
can provide results that are very different from the reality on long roads. This is
because traffic is changing continuously even when you are driving on a road without
exits or ramps. Flinsberg [2004] in her dissertation used modified A* algorithm in
conjunction with daily traffic speed profiles representing time dependence of the
graph. However she computed speed on an edge as constant. Ant’s colony
optimization (ACO) and its application on problem of finding the shortest route was
also discussed in some papers like Angus and Hendtlass. They show that ACO can
compete with deterministic algorithms but has several weaknesses of stochastic
algorithms as well. Most important one is that they are not even guarateed to produce
some solution.
As mentioned earlier, a graph can be used to represent a map where the cities
are represented by vertices and the routes or roads are represented by edges within the
graph. In this section, a graph representation of a map is explained further, and brief
descriptions and implementations of the four shortest path algorithms being studied
are presented.
Page | 14
2.1 An Overview of ROUTING ALGORTHM
Personally, what I find interesting is how those algorithms evolved through time.
Sorry for punctual technical details.
1959: Dijkstra
Edgard Dijkstra is Dutch.
He is one of the big names in computer science. He is know for his handwriting and
quotes such as:
Simplicity is prerequisite for reliability
The question of whether Machines Can Think... is about as relevant as the question of
whether Submarines Can Swim
1987: Tarjan
The weakness of Dijkstra’s algorithm is its priority queue that returns what node to
visit next. An article from 1987 by Tarjan (an other reference in the world of graphs) brings
us to the “modern” Dijkstra’s algorithm.
Page | 15
2008: consolidation with the Contraction Hierarchies
After this phase of exuberant creativity, we could extract the core substance to make
the algorithm that will probably become the new reference: the contraction hierarchies.
Page | 16
CHAPTER - 3
PROBLEM IDENTIFICATION
Problem Identification
An algorithm by Cooke and Halsey (1966) finds the shortest path from one
source to one destination in a network with time dependent link costs. The algorithm
is based on the Bellman approach (the paper was also submitted by Bellman). The
algorithm works out but unfortunately is inefficient. The description of the algorithm
is complicated and not clear. The algorithm was revised by Dreyfus (1969) who
pointed out the inefficiency of the algorithm and proposed his solution to the problem.
F. le Clercq published his paper in 1972 in which he proposed an algorithm for public
transport. The algorithm does not use timetables which is the main requirement for the
group project, the algorithm proposed by F. le Clercq uses frequencies of bus lines
instead. The algorithm is vaguely described without emphasis of main ideas and firm
specification of the algorithm. The paper does not report the time complexity and
memory requirements.
Page | 18
CHAPTER - 4
PROJECT ANALYSIS
Hard Disk : - 40 GB
Page | 19
RAM : - 512 MB
Page | 20
CHAPTER - 5
METHODOLOGY
5 Theoretical background
Page | 21
5.1.1 Undirected Graph
Definition 5.1 Undirected graph is an ordered pair G = (V,E) comprising a
set V of vertices or nodes together with a set E of edges or lines, which are 2-
element subsets of V .
5.1.3 Walk
Definition 5.3 A walk in a graph G is such sequence of edges a vertices
(v0, e1, v1, e2, v2, ..., en, vn) , that ei has adjacent vertices vi−1 and vi for
each i = 1, 2, 3, ..., n. Such walk is called a (v0, vn) walk.
5.1.4 Trail
Definition 5.4 Draw is special kind of walk, in which no edge is repeated. We
call it a (v0, vn) trail.
5.1.5 Path
Definition 5.5 Path is a trail, in which no vertex is repeated. We call it a (v0,
vn)-path.
Page | 22
Dijkstra's algorithm, conceived by computer scientist Edsger Dijkstra in
1956 and published in 1959,[1][2] is a graph search algorithm that solves the single-
source shortest path problem for a graph with non-negative edge path costs, producing
ashortest path tree. This algorithm is often used in routing and as a subroutine in other
graph algorithms.
For a given source vertex (node) in the graph, the algorithm finds the path
with lowest cost (i.e. the shortest path) between that vertex and every other
vertex[3]:196–206 (although Dijkstra originally only considered the shortest path between
a given pair of nodes[4]). It can also be used for finding costs of shortest paths from a
single vertex to a single destination vertex by stopping the algorithm once the shortest
path to the destination vertex has been determined. For example, if the vertices of the
graph represent cities and edge path costs represent driving distances between pairs of
cities connected by a direct road, Dijkstra's algorithm can be used to find the shortest
route between one city and all other cities. As a result, the shortest path algorithm is
widely used in network routing protocols, most notably IS-IS and OSPF (Open
Shortest Path First).
Dijkstra's original algorithm does not use a min-priority queue and runs
in time (where is the number of vertices). The idea of this algorithm is
also given in (Leyzorek et al. 1957). The implementation based on a min-priority
queue implemented by a Fibonacci heap and running in
(where is the number of edges) is due to (Fredman & Tarjan 1984). This
is asymptotically the fastest known single-source shortest-path algorithm for
arbitrary directed graphs with unbounded non-negative weights.
Note that graphs under special cases such as integer and/or bounded weights,
can be improved further in complexity. See the following section on running time.
ALGORITHM
Page | 23
Let the node at which we are starting be called the initial node. Let the distance
of node Y be the distance from the initial node to Y. Dijkstra's algorithm will assign
some initial distance values and will try to improve them step by step.
1. Assign to every node a tentative distance value: set it to zero for our initial node and
to infinity for all other nodes.
2. Set the initial node as current. Mark all other nodes unvisited. Create a set of all the
unvisited nodes called the unvisited set.
3. For the current node, consider all of its unvisited neighbors and calculate
their tentative distances. Compare the newly calculatedtentative 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, keep
the current value.
4. When we are done considering all of the neighbors of the current node, mark the
current node as visited and remove it from theunvisited 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. Select the unvisited node that is marked with the smallest tentative distance, and set it
as the new "current node" then go back to step 3.
DESCRIPTION
between two intersections on a city map, a starting point and a destination.
The order is conceptually simple: to start, mark the distance to every intersection on
the map with infinity. This is done not to imply there is an infinite distance, but to
note that intersection has not yet been visited; some variants of this method simply
leave the intersection unlabeled. Now, at each iteration, select a currentintersection.
For the first iteration, the current intersection will be the starting point and the
distance to it (the intersection's label) will be zero. For subsequent iterations (after the
first), the current intersection will be the closest unvisited intersection to the starting
point—this will be easy to find.
From the current intersection, update the distance to every unvisited
intersection that is directly connected to it. This is done by determining the sum of the
Page | 24
distance between an unvisited intersection and the value of the current intersection,
and relabeling the unvisited intersection with this value if it is less than its current
value. In effect, the intersection is relabeled if the path to it through the current
intersection is shorter than the previously known paths. To facilitate shortest path
identification, in pencil, mark the road with an arrow pointing to the relabeled
intersection if you label/relabel it, and erase all others pointing to it. After you have
updated the distances to each neighboring intersection, mark the current intersection
as visited and select the unvisited intersection with lowest distance (from the starting
point) – or the lowest label—as the current intersection. Nodes marked as visited are
labeled with the shortest path from the starting point to it and will not be revisited or
returned to.
Continue this process of updating the neighboring intersections with the
shortest distances, then marking the current intersection as visited and moving onto
the closest unvisited intersection until you have marked the destination as visited.
Once you have marked the destination as visited (as is the case with any visited
intersection) you have determined the shortest path to it, from the starting point, and
can trace your way back, following the arrows in reverse.
Of note is the fact that this algorithm makes no attempt to direct "exploration"
towards the destination as one might expect. Rather, the sole consideration in
determining the next "current" intersection is its distance from the starting point. This
algorithm, therefore "expands outward" from the starting point, interactively
considering every node that is closer in terms of shortest path distance until it reaches
the destination. When understood in this way, it is clear how the algorithm necessarily
finds the shortest path, however, it may also reveal one of the algorithm's weaknesses:
its relative slowness in some topologies.
Path selection
Path selection involves applying a routing metric to multiple routes, in order to
select (or predict) the best route. In computer networking, the metric is computed by a
routing algorithm, and can cover information such as bandwidth, network delay, hop
count, path cost, load, MTU, reliability, and communication cost (see e.g. this
survey for a list of proposed routing metrics). The routing table stores only the best
possible routes, while link-state or topological databases may store all other
information as well.
Because a routing metric is specific to a given routing protocol, multi-protocol
routers must use some external heuristic in order to select between routes learned
from different routing protocols. Cisco routers, for example, attribute a value known
as the administrative distance to each route, where smaller administrative distances
indicate routes learned from a supposedly more reliable protocol.
Page | 25
A local network administrator, in special cases, can set up host-specific routes
to a particular device which provides more control over network usage, permits
testing and better overall security. This can come in handy when debugging network
connections or routing tables.
Multiple agents
In some networks, routing is complicated by the fact that no single entity is
responsible for selecting paths; instead, multiple entities are involved in selecting
paths or even parts of a single path. Complications or inefficiency can result if these
entities choose paths to optimize their own objectives, which may conflict with the
objectives of other participants.
A classic example involves traffic in a road system, in which each driver picks
a path which minimizes their own travel time. With such routing,
the equilibrium routes can be longer than optimal for all drivers. In particular, Braess
paradox shows that adding a new road can lengthen travel times for all drivers.
In another model, for example, used for routing automated guided
vehicles (AGVs) on a terminal, reservations are made for each vehicle to prevent
simultaneous use of the same part of an infrastructure. This approach is also referred
to as context-aware routing.[2]
The Internet is partitioned into autonomous systems (ASs) such as internet
service providers (ISPs), each of which has control over routes involving its network,
at multiple levels. First, AS-level paths are selected via the BGP protocol, which
produces a sequence of ASs through which packets will flow. Each AS may have
multiple paths, offered by neighboring ASs, from which to choose. Its decision often
involves business relationships with these neighboring ASs,[3] which may be unrelated
to path quality or latency. Second, once an AS-level path has been selected, there are
often multiple corresponding router-level paths, in part because two ISPs may be
connected in multiple locations. In choosing the single router-level path, it is common
practice for each ISP to employ hot-potato routing: sending traffic along the path that
minimizes the distance through the ISP's own network—even if that path lengthens
the total distance to the destination.
Consider two ISPs, A and B, which each have a presence in New York,
connected by a fast link with latency 5 ms; and which each have a presence
in London connected by a 5 ms link. Suppose both ISPs have trans-Atlantic links
connecting their two networks, but A's link has latency 100 ms and B's has latency
120 ms. When routing a message from a source in A's London network to a
destination in B's New York network, A may choose to immediately send the message
to B in London. This saves A the work of sending it along an expensive trans-Atlantic
Page | 26
link, but causes the message to experience latency 125 ms when the other route would
have been 20 ms faster.
A 2003 measurement study of Internet routes found that, between pairs of
neighboring ISPs, more than 30% of paths have inflated latency due to hot-potato
routing, with 5% of paths being delayed by at least 12 ms. Inflation due to AS-level
path selection, while substantial, was attributed primarily to BGP's lack of a
mechanism to directly optimize for latency, rather than to selfish routing policies. It
was also suggested that, were an appropriate mechanism in place, ISPs would be
willing to cooperate to reduce latency rather than use hot-potato routing.
Such a mechanism was later published by the same authors, first for the case
of two ISPs and then for the global case.
Route analytics
As the Internet and IP networks become mission critical business tools, there
has been increased interest in techniques and methods to monitor the routing posture
of networks. Incorrect routing or routing issues cause undesirable performance
degradation, flapping and/or downtime. Monitoring routing in a network is achieved
using route analytics tools and techniques.
Page | 27
CHAPTER - 6
RESULT AND DISCUSSION
6.1 Screenshots
Page | 29
Page | 30
Fig.: Window showing graph
Page | 31
Page | 32
CHAPTER - 7
CONCLUSION
Page | 33
CONCLUSION
The considered algorithms are efficient for the project application. In the
project application context only one best route is required and the algorithm provides
the solution in a very efficient time and with small memory requirements.
The route is combined of roads to traverse with a car and a bus (a timetable
mean in general). The form of the shortest path is strictly limited; only four kinds of a
shortest path can be found. Results of this kind are satisfying in most cases. However,
it may be necessary to get solutions of a different type. There are many other kinds of
output the program can provide which may be more useful for the user. The author
aimed at algorithms which are basic for the issue of the ‘home to work’ route finding
and which are a good starting point for the further research.
During the work on the two algorithms many ideas of the project and the
designed algorithms have occurred to be the best possible (as the time complexity
O(n + m)) or to be superior to the research done before. Of course in no way the work
presented here is completely finished or absolutely satisfying. This report presents
only a piece of work that with more available time could be extended to a better work
with solutions more realistic. However, this would be above the scope of a Final Year
Project and would require more time.
Future work
Sometimes the given algorithms may produce output that is of no use even
though it has been correctly generated. For example, there can be a path that will
require a car and one bus only to reach the destination after 30 minutes. However, the
algorithm may advise you to take a car and three times to take a bus which will take
25 minutes, 5 minutes less than the previous path. From the point of view of the
defined conditions the second path is better, but a more reasonable path is the first
one, though 5 minutes shorter. The first path is actually better because it is less
troublesome (it is easier to take one bus instead of three), more reliable (three buses
cause more risk than only one since each bus can break down, changing buses is risky
as opposed to sitting in the bus) and is cheaper. This example proves the need to
introduce different conditions for the shortest route.
The future research can go into two directions. First, well known algorithms
can be adapted into the public transport needs. For example, the algorithm for finding
second shortest path, third etc, paths for buses can be developed. More can be
proposed: finding the shortest path going through specific nodes, through specific
number of nodes or by the most reliable path.
Page | 35
CHAPTER – 8
BIBLIOGRAPHY
Page | 36
BIBLIOGRAPHY
Website Reference:
http://www.myprojects.com/sms.php
http://www.w3schools.com
http://www.wikipedia.org
Page | 37