OpenDaylight Q&A Forum - Individual question feedhttps://ask.opendaylight.org/questions/OpenDaylight question and answer forumenWed, 19 Jul 2017 03:28:55 -0700How to get shortest path between two hosts?https://ask.opendaylight.org/question/5312/how-to-get-shortest-path-between-two-hosts/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?
Thu, 10 Sep 2015 22:11:21 -0700https://ask.opendaylight.org/question/5312/how-to-get-shortest-path-between-two-hosts/Answer by Ashwini_Mhatre for <p>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?</p>
https://ask.opendaylight.org/question/5312/how-to-get-shortest-path-between-two-hosts/?answer=5314#post-id-5314Hi,
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,
AshwiniThu, 10 Sep 2015 23:14:26 -0700https://ask.opendaylight.org/question/5312/how-to-get-shortest-path-between-two-hosts/?answer=5314#post-id-5314Comment by karthik330 for <p>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.</p>
<p>Regards,
Ashwini</p>
https://ask.opendaylight.org/question/5312/how-to-get-shortest-path-between-two-hosts/?comment=5317#comment-5317Thnx AshwiniThu, 10 Sep 2015 23:45:42 -0700https://ask.opendaylight.org/question/5312/how-to-get-shortest-path-between-two-hosts/?comment=5317#comment-5317Comment by karthik330 for <p>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.</p>
<p>Regards,
Ashwini</p>
https://ask.opendaylight.org/question/5312/how-to-get-shortest-path-between-two-hosts/?comment=11313#comment-11313Hi @Ashwini_Mhatre @subhash , Can you answer for this question?
https://ask.opendaylight.org/question/7896/how-to-use-add-repo/Thu, 11 Feb 2016 01:22:01 -0800https://ask.opendaylight.org/question/5312/how-to-get-shortest-path-between-two-hosts/?comment=11313#comment-11313Answer by subhash for <p>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?</p>
https://ask.opendaylight.org/question/5312/how-to-get-shortest-path-between-two-hosts/?answer=5315#post-id-5315You can try to explore the `l2-switch` code. The [`loopremover` module](https://github.com/opendaylight/l2switch/blob/9cdd1ad6b045604b3924ec0cb652d84b317548f5/loopremover/implementation/src/main/java/org/opendaylight/l2switch/loopremover/topology/NetworkGraphImpl.java) has the code
related to implementation of Dijkstra algorithm but currently it is disabled.
Thu, 10 Sep 2015 23:26:31 -0700https://ask.opendaylight.org/question/5312/how-to-get-shortest-path-between-two-hosts/?answer=5315#post-id-5315Comment by karthik330 for <p>You can try to explore the <code>l2-switch</code> code. The <a href="https://github.com/opendaylight/l2switch/blob/9cdd1ad6b045604b3924ec0cb652d84b317548f5/loopremover/implementation/src/main/java/org/opendaylight/l2switch/loopremover/topology/NetworkGraphImpl.java"><code>loopremover</code> module</a> has the code
related to implementation of Dijkstra algorithm but currently it is disabled.</p>
https://ask.opendaylight.org/question/5312/how-to-get-shortest-path-between-two-hosts/?comment=5316#comment-5316Thnx 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?Thu, 10 Sep 2015 23:45:19 -0700https://ask.opendaylight.org/question/5312/how-to-get-shortest-path-between-two-hosts/?comment=5316#comment-5316Comment by subhash for <p>You can try to explore the <code>l2-switch</code> code. The <a href="https://github.com/opendaylight/l2switch/blob/9cdd1ad6b045604b3924ec0cb652d84b317548f5/loopremover/implementation/src/main/java/org/opendaylight/l2switch/loopremover/topology/NetworkGraphImpl.java"><code>loopremover</code> module</a> has the code
related to implementation of Dijkstra algorithm but currently it is disabled.</p>
https://ask.opendaylight.org/question/5312/how-to-get-shortest-path-between-two-hosts/?comment=5320#comment-5320follow some sample application (e.g. toaster) to define your rest api.Fri, 11 Sep 2015 00:24:47 -0700https://ask.opendaylight.org/question/5312/how-to-get-shortest-path-between-two-hosts/?comment=5320#comment-5320Comment by karthik330 for <p>You can try to explore the <code>l2-switch</code> code. The <a href="https://github.com/opendaylight/l2switch/blob/9cdd1ad6b045604b3924ec0cb652d84b317548f5/loopremover/implementation/src/main/java/org/opendaylight/l2switch/loopremover/topology/NetworkGraphImpl.java"><code>loopremover</code> module</a> has the code
related to implementation of Dijkstra algorithm but currently it is disabled.</p>
https://ask.opendaylight.org/question/5312/how-to-get-shortest-path-between-two-hosts/?comment=11598#comment-11598yes ! by modifying l2switch code we can get the shortest path between two hosts !! I got it .Mon, 21 Mar 2016 05:48:28 -0700https://ask.opendaylight.org/question/5312/how-to-get-shortest-path-between-two-hosts/?comment=11598#comment-11598Answer by jayaprakash for <p>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?</p>
https://ask.opendaylight.org/question/5312/how-to-get-shortest-path-between-two-hosts/?answer=11263#post-id-11263I 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
GET http://192.168.1.124:8181/restconf/operational/network-topology:network-topology
2. With the links details, i generated a Graph using python networkx module.
import networkx as nx
graph = nx.Graph()
graph.add_edges_from(graph_links)
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.
Thanks.Tue, 02 Feb 2016 23:32:57 -0800https://ask.opendaylight.org/question/5312/how-to-get-shortest-path-between-two-hosts/?answer=11263#post-id-11263Comment by karthik330 for <p>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. </p>
<ol>
<li><p>From ODL network topology REST api response, extracted hosts, switch & links details. You can even use ODL python client SDK <strong>python-odl</strong> to get the topology information</p>
<pre><code> GET http://192.168.1.124:8181/restconf/operational/network-topology:network-topology
</code></pre></li>
<li><p>With the links details, i generated a Graph using python networkx module. </p>
<pre><code> import networkx as nx
graph = nx.Graph()
graph.add_edges_from(graph_links)
</code></pre></li>
<li><p>Then by using Dijkstra's Algorithm, can find the shortest path between any two hosts in the topology</p>
<pre><code> path = nx.dijkstra_path(graph, source_node, dest_node)
</code></pre></li>
</ol>
<p>Even we can find the list of shortest paths available for a set of hosts</p>
<pre><code> nx.all_shortest_paths(graph, source=source, target=dest)
</code></pre>
<p>Please share your comments on this approach. </p>
<p>Thanks.</p>
https://ask.opendaylight.org/question/5312/how-to-get-shortest-path-between-two-hosts/?comment=11312#comment-11312Hi @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 APIThu, 11 Feb 2016 01:19:19 -0800https://ask.opendaylight.org/question/5312/how-to-get-shortest-path-between-two-hosts/?comment=11312#comment-11312Comment by yarombeh.toa for <p>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. </p>
<ol>
<li><p>From ODL network topology REST api response, extracted hosts, switch & links details. You can even use ODL python client SDK <strong>python-odl</strong> to get the topology information</p>
<pre><code> GET http://192.168.1.124:8181/restconf/operational/network-topology:network-topology
</code></pre></li>
<li><p>With the links details, i generated a Graph using python networkx module. </p>
<pre><code> import networkx as nx
graph = nx.Graph()
graph.add_edges_from(graph_links)
</code></pre></li>
<li><p>Then by using Dijkstra's Algorithm, can find the shortest path between any two hosts in the topology</p>
<pre><code> path = nx.dijkstra_path(graph, source_node, dest_node)
</code></pre></li>
</ol>
<p>Even we can find the list of shortest paths available for a set of hosts</p>
<pre><code> nx.all_shortest_paths(graph, source=source, target=dest)
</code></pre>
<p>Please share your comments on this approach. </p>
<p>Thanks.</p>
https://ask.opendaylight.org/question/5312/how-to-get-shortest-path-between-two-hosts/?comment=14380#comment-14380Hi @jayaprakash can i have your email to ask some questions ?Mon, 06 Mar 2017 02:21:23 -0800https://ask.opendaylight.org/question/5312/how-to-get-shortest-path-between-two-hosts/?comment=14380#comment-14380Comment by rajat04 for <p>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. </p>
<ol>
<li><p>From ODL network topology REST api response, extracted hosts, switch & links details. You can even use ODL python client SDK <strong>python-odl</strong> to get the topology information</p>
<pre><code> GET http://192.168.1.124:8181/restconf/operational/network-topology:network-topology
</code></pre></li>
<li><p>With the links details, i generated a Graph using python networkx module. </p>
<pre><code> import networkx as nx
graph = nx.Graph()
graph.add_edges_from(graph_links)
</code></pre></li>
<li><p>Then by using Dijkstra's Algorithm, can find the shortest path between any two hosts in the topology</p>
<pre><code> path = nx.dijkstra_path(graph, source_node, dest_node)
</code></pre></li>
</ol>
<p>Even we can find the list of shortest paths available for a set of hosts</p>
<pre><code> nx.all_shortest_paths(graph, source=source, target=dest)
</code></pre>
<p>Please share your comments on this approach. </p>
<p>Thanks.</p>
https://ask.opendaylight.org/question/5312/how-to-get-shortest-path-between-two-hosts/?comment=20312#comment-20312Hi @jayaprakash, how are you pushing the shortest path information (using your java code) back to the controller?Sat, 15 Jul 2017 09:57:48 -0700https://ask.opendaylight.org/question/5312/how-to-get-shortest-path-between-two-hosts/?comment=20312#comment-20312Comment by Harika285 for <p>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. </p>
<ol>
<li><p>From ODL network topology REST api response, extracted hosts, switch & links details. You can even use ODL python client SDK <strong>python-odl</strong> to get the topology information</p>
<pre><code> GET http://192.168.1.124:8181/restconf/operational/network-topology:network-topology
</code></pre></li>
<li><p>With the links details, i generated a Graph using python networkx module. </p>
<pre><code> import networkx as nx
graph = nx.Graph()
graph.add_edges_from(graph_links)
</code></pre></li>
<li><p>Then by using Dijkstra's Algorithm, can find the shortest path between any two hosts in the topology</p>
<pre><code> path = nx.dijkstra_path(graph, source_node, dest_node)
</code></pre></li>
</ol>
<p>Even we can find the list of shortest paths available for a set of hosts</p>
<pre><code> nx.all_shortest_paths(graph, source=source, target=dest)
</code></pre>
<p>Please share your comments on this approach. </p>
<p>Thanks.</p>
https://ask.opendaylight.org/question/5312/how-to-get-shortest-path-between-two-hosts/?comment=20821#comment-20821Hi@jayaprakash,how did you use the link details to generate a graph??Wed, 19 Jul 2017 03:28:55 -0700https://ask.opendaylight.org/question/5312/how-to-get-shortest-path-between-two-hosts/?comment=20821#comment-20821