Ask Your Question

How to get shortest path between two hosts?

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

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 -0700

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

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 -0700 )edit

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

subhash ( 2015-09-11 00:24:47 -0700 )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 -0700 )edit

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

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 -0700 )edit

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

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

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

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 -0700 )edit

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

karthik330 ( 2016-02-11 01:22:01 -0700 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

[hide preview]

Question Tools

1 follower


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

Seen: 550 times

Last updated: Feb 02 '16