Skip to content
Snippets Groups Projects
Commit a899e3c3 authored by Munish Mehta's avatar Munish Mehta
Browse files

[#28380339] -- changes in topology to enhance dijkstra

parent 74776081
No related branches found
No related tags found
No related merge requests found
...@@ -17,6 +17,10 @@ ...@@ -17,6 +17,10 @@
package net.floodlightcontroller.routing; package net.floodlightcontroller.routing;
import net.floodlightcontroller.core.web.serializers.DPIDSerializer;
import org.codehaus.jackson.annotate.JsonProperty;
import org.codehaus.jackson.map.annotate.JsonSerialize;
import org.openflow.util.HexString; import org.openflow.util.HexString;
public class Link { public class Link {
...@@ -32,17 +36,24 @@ public class Link { ...@@ -32,17 +36,24 @@ public class Link {
this.dstPort = dstPort; this.dstPort = dstPort;
} }
@JsonProperty("src-switch")
@JsonSerialize(using=DPIDSerializer.class)
public long getSrc() { public long getSrc() {
return src; return src;
} }
@JsonProperty("src-port")
public short getSrcPort() { public short getSrcPort() {
return srcPort; return srcPort;
} }
@JsonProperty("dst-switch")
@JsonSerialize(using=DPIDSerializer.class)
public long getDst() { public long getDst() {
return dst; return dst;
} }
@JsonProperty("dst-port")
public short getDstPort() { public short getDstPort() {
return dstPort; return dstPort;
} }
......
...@@ -63,7 +63,22 @@ public class TopologyInstance { ...@@ -63,7 +63,22 @@ public class TopologyInstance {
this.blockedPorts = new HashSet<NodePortTuple>(); this.blockedPorts = new HashSet<NodePortTuple>();
this.blockedLinks = new HashSet<Link>(); this.blockedLinks = new HashSet<Link>();
} }
public TopologyInstance(Map<Long, Set<Short>> switchPorts,
Map<NodePortTuple, Set<Link>> switchPortLinks)
{
this.switches = new HashSet<Long>(switchPorts.keySet());
this.switchPorts = new HashMap<Long, Set<Short>>(switchPorts);
this.switchPortLinks = new HashMap<NodePortTuple,
Set<Link>>(switchPortLinks);
this.broadcastDomainPorts = new HashSet<NodePortTuple>();
this.tunnelPorts = new HashSet<NodePortTuple>();
this.blockedPorts = new HashSet<NodePortTuple>();
this.blockedLinks = new HashSet<Link>();
clusters = new HashSet<Cluster>();
switchClusterMap = new HashMap<Long, Cluster>();
}
public TopologyInstance(Map<Long, Set<Short>> switchPorts, public TopologyInstance(Map<Long, Set<Short>> switchPorts,
Set<NodePortTuple> blockedPorts, Set<NodePortTuple> blockedPorts,
Map<NodePortTuple, Set<Link>> switchPortLinks, Map<NodePortTuple, Set<Link>> switchPortLinks,
...@@ -409,7 +424,9 @@ public class TopologyInstance { ...@@ -409,7 +424,9 @@ public class TopologyInstance {
} }
} }
protected BroadcastTree dijkstra(Cluster c, Long dst, Map<Link, Integer> linkCost) { protected BroadcastTree dijkstra(Cluster c, Long root,
Map<Link, Integer> linkCost,
boolean isDstRooted) {
HashMap<Long, Link> nexthoplinks = new HashMap<Long, Link>(); HashMap<Long, Link> nexthoplinks = new HashMap<Long, Link>();
//HashMap<Long, Long> nexthopnodes = new HashMap<Long, Long>(); //HashMap<Long, Long> nexthopnodes = new HashMap<Long, Long>();
HashMap<Long, Integer> cost = new HashMap<Long, Integer>(); HashMap<Long, Integer> cost = new HashMap<Long, Integer>();
...@@ -423,8 +440,8 @@ public class TopologyInstance { ...@@ -423,8 +440,8 @@ public class TopologyInstance {
HashMap<Long, Boolean> seen = new HashMap<Long, Boolean>(); HashMap<Long, Boolean> seen = new HashMap<Long, Boolean>();
PriorityQueue<NodeDist> nodeq = new PriorityQueue<NodeDist>(); PriorityQueue<NodeDist> nodeq = new PriorityQueue<NodeDist>();
nodeq.add(new NodeDist(dst, 0)); nodeq.add(new NodeDist(root, 0));
cost.put(dst, 0); cost.put(root, 0);
while (nodeq.peek() != null) { while (nodeq.peek() != null) {
NodeDist n = nodeq.poll(); NodeDist n = nodeq.poll();
Long cnode = n.getNode(); Long cnode = n.getNode();
...@@ -434,7 +451,14 @@ public class TopologyInstance { ...@@ -434,7 +451,14 @@ public class TopologyInstance {
seen.put(cnode, true); seen.put(cnode, true);
for (Link link: c.links.get(cnode)) { for (Link link: c.links.get(cnode)) {
Long neighbor = link.getSrc(); Long neighbor;
if (isDstRooted == true) neighbor = link.getSrc();
else neighbor = link.getDst();
// links directed toward cnode will result in this condition
// if (neighbor == cnode) continue;
if (linkCost == null || linkCost.get(link)==null) w = 1; if (linkCost == null || linkCost.get(link)==null) w = 1;
else w = linkCost.get(link); else w = linkCost.get(link);
...@@ -469,7 +493,7 @@ public class TopologyInstance { ...@@ -469,7 +493,7 @@ public class TopologyInstance {
for(Cluster c: clusters) { for(Cluster c: clusters) {
for (Long node : c.links.keySet()) { for (Long node : c.links.keySet()) {
BroadcastTree tree = dijkstra(c, node, linkCost); BroadcastTree tree = dijkstra(c, node, linkCost, true);
destinationRootedTrees.put(node, tree); destinationRootedTrees.put(node, tree);
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment