Ask is moving to Stack Overflow and! Please use the "opendaylight" tag on either of these sites. This site is now in Read-Only mode


How to get shortest path between two hosts?

asked 2015-09-10 22:11:21 -0800

karthik330 gravatar image

Hi all, I need to find shortest and best optimal path between two hosts. I dont find any API for that. I found that Dijkstra's algorithm is used in ODL. Can anyone help me to find the REST API call which will return the shortest Path?

edit retag flag offensive close merge delete

3 answers

Sort by ยป oldest newest most voted

answered 2015-09-10 23:26:31 -0800

updated 2015-09-10 23:28:56 -0800

You can try to explore the l2-switch code. The loopremover module has the code related to implementation of Dijkstra algorithm but currently it is disabled.

edit flag offensive delete publish link more


Thnx subhas,I checked.Its there disabled.And 1.How to create my Own REST api?which calls the Dijkstra's function and return the shortest path. How to do that?

karthik330 ( 2015-09-10 23:45:19 -0800 )edit

follow some sample application (e.g. toaster) to define your rest api.

subhash ( 2015-09-11 00:24:47 -0800 )edit

yes ! by modifying l2switch code we can get the shortest path between two hosts !! I got it .

karthik330 ( 2016-03-21 05:48:28 -0800 )edit

answered 2016-02-02 23:32:57 -0800

jayaprakash gravatar image

I could get the shortest path between two hosts with ODL topology REST API & Python Networkx module. I used mininet simulator and created a custom network topology with multipath.

  1. From ODL network topology REST api response, extracted hosts, switch & links details. You can even use ODL python client SDK python-odl to get the topology information

  2. With the links details, i generated a Graph using python networkx module.

      import networkx as nx
      graph = nx.Graph()
  3. Then by using Dijkstra's Algorithm, can find the shortest path between any two hosts in the topology

     path = nx.dijkstra_path(graph, source_node, dest_node)

Even we can find the list of shortest paths available for a set of hosts

     nx.all_shortest_paths(graph, source=source, target=dest)

Please share your comments on this approach.


edit flag offensive delete publish link more


Hi @jayaprakash , Good to know that you found the path . I also developed a java application which will find the path between 2 hosts from the topology details. But Now i am trying to do the same as MD-SAL application which will be shown as restconf API

karthik330 ( 2016-02-11 01:19:19 -0800 )edit

Hi @jayaprakash can i have your email to ask some questions ?

yarombeh.toa ( 2017-03-06 02:21:23 -0800 )edit

Hi @jayaprakash, how are you pushing the shortest path information (using your java code) back to the controller?

rajat04 ( 2017-07-15 09:57:48 -0800 )edit

Hi@jayaprakash,how did you use the link details to generate a graph??

Harika285 ( 2017-07-19 03:28:55 -0800 )edit

answered 2015-09-10 23:14:26 -0800

Ashwini_Mhatre gravatar image

Hi, I think there is no rest api present at odl which will give you shortest path. u need to write application for that by consuming dijkstra's algorithm.

Regards, Ashwini

edit flag offensive delete publish link more


Thnx Ashwini

karthik330 ( 2015-09-10 23:45:42 -0800 )edit

Hi @Ashwini_Mhatre@subhash , Can you answer for this question?

karthik330 ( 2016-02-11 01:22:01 -0800 )edit
Login/Signup to Answer

Question Tools

1 follower


Asked: 2015-09-10 22:11:21 -0800

Seen: 1,373 times

Last updated: Feb 02 '16