diff --git a/src/main/java/net/floodlightcontroller/topologymanager/TopologyInstance.java b/src/main/java/net/floodlightcontroller/topologymanager/TopologyInstance.java index fd9834db206ba9a939b005a0540e1806157a3642..cc6edd53c4777e13ad1a1891b3f4873c481f87b9 100644 --- a/src/main/java/net/floodlightcontroller/topologymanager/TopologyInstance.java +++ b/src/main/java/net/floodlightcontroller/topologymanager/TopologyInstance.java @@ -82,10 +82,10 @@ public class TopologyInstance { // Step 1: Compute clusters ignoring broadcast domain links // Create nodes for clusters in the higher level topology identifyClusters(); - + // Step 1.1: Add links to clusters addLinksToClusters(); - + // Step 2. Compute shortest path trees in each cluster for // unicast routing. The trees are rooted at the destination. // Cost for tunnel links and direct links are the same. @@ -131,7 +131,7 @@ public class TopologyInstance { } } } - + /** * @author Srinivasan Ramasubramanian * @@ -326,7 +326,7 @@ public class TopologyInstance { } } - private BroadcastTree dijkstra(Cluster c, Long dst, Map<Link, Integer> linkCost) { + protected BroadcastTree dijkstra(Cluster c, Long dst, Map<Link, Integer> linkCost) { HashMap<Long, Link> nexthoplinks = new HashMap<Long, Link>(); HashMap<Long, Long> nexthopnodes = new HashMap<Long, Long>(); HashMap<Long, Integer> cost = new HashMap<Long, Integer>(); @@ -380,23 +380,23 @@ public class TopologyInstance { } } + protected void calculateBroadcastTreeInClusters() { + for(Cluster c: clusters) { + // c.id is the smallest node that's in the cluster + BroadcastTree tree = destinationRootedTrees.get(c.id); + clusterBroadcastTrees.put(c.id, tree); + } + } + protected void calculateBroadcastNodePortsInClusters() { + clusterBroadcastTrees.clear(); - // Make every tunnel link have a weight that's more than the - // number of switches in the network. - Map<Link, Integer> linkCost = new HashMap<Link, Integer>(); - int tunnel_weight = switchPorts.size() + 1; - - for(NodePortTuple npt: tunnelPorts) { - for(Link link: switchPortLinks.get(npt)) { - if (link == null) return; - linkCost.put(link, tunnel_weight); - } - } + + calculateBroadcastTreeInClusters(); for(Cluster c: clusters) { // c.id is the smallest node that's in the cluster - BroadcastTree tree = dijkstra(c, c.id, linkCost); + BroadcastTree tree = clusterBroadcastTrees.get(c.id); clusterBroadcastTrees.put(c.id, tree); //log.info("Broadcast Tree {}", tree); @@ -412,7 +412,6 @@ public class TopologyInstance { nptSet.add(npt2); } clusterBroadcastNodePorts.put(c.id, nptSet); - //log.info("Broadcast ports in cluster {}: {}", new Long(c.id), nptSet); } } @@ -540,7 +539,7 @@ public class TopologyInstance { long clusterId = getSwitchClusterId(sw); return clusterBroadcastNodePorts.get(clusterId); } - + public Set<Long> getSwitches() { return switches; } diff --git a/src/test/java/net/floodlightcontroller/topologymanager/TopologyInstanceTest.java b/src/test/java/net/floodlightcontroller/topologymanager/TopologyInstanceTest.java index 45054c2d701f422e01c8c84a03835a9c58acc8db..4b20e33b601640e01cbd2170cc6511a35b348aff 100644 --- a/src/test/java/net/floodlightcontroller/topologymanager/TopologyInstanceTest.java +++ b/src/test/java/net/floodlightcontroller/topologymanager/TopologyInstanceTest.java @@ -66,7 +66,7 @@ public class TopologyInstanceTest { } } - private void verifyExpectedBroadcastPortsInClusters(int [][][] ebp) { + protected void verifyExpectedBroadcastPortsInClusters(int [][][] ebp) { NodePortTuple npt = null; Set<NodePortTuple> expected = new HashSet<NodePortTuple>(); for(int i=0; i<ebp.length; ++i) { @@ -265,7 +265,7 @@ public class TopologyInstanceTest { public void testLoopDetectionWithIslands() throws Exception { // +-------+ +-------+ - // | | | | + // | | TUNNEL | | // | 1 1|-------------|1 2 | // | 2 | | 2 | // +-------+ +-------+ @@ -279,7 +279,7 @@ public class TopologyInstanceTest { // // // +-------+ - // | 1 | + // | 1 | TUNNEL // | 4 2|----------------+ // | 3 | | // +-------+ | @@ -292,15 +292,15 @@ public class TopologyInstanceTest { // +-------+ +-------+ { int [][] linkArray = { - {1, 1, 2, 1, DIRECT_LINK}, - {2, 1, 1, 1, DIRECT_LINK}, + {1, 1, 2, 1, TUNNEL_LINK}, + {2, 1, 1, 1, TUNNEL_LINK}, {1, 2, 3, 1, DIRECT_LINK}, {3, 1, 1, 2, DIRECT_LINK}, {2, 2, 3, 2, DIRECT_LINK}, {3, 2, 2, 2, DIRECT_LINK}, - {4, 2, 6, 2, DIRECT_LINK}, - {6, 2, 4, 2, DIRECT_LINK}, + {4, 2, 6, 2, TUNNEL_LINK}, + {6, 2, 4, 2, TUNNEL_LINK}, {4, 3, 5, 1, DIRECT_LINK}, {5, 1, 4, 3, DIRECT_LINK}, {5, 2, 6, 1, DIRECT_LINK}, @@ -321,8 +321,9 @@ public class TopologyInstanceTest { verifyClusters(expectedClusters); verifyExpectedBroadcastPortsInClusters(expectedBroadcastPorts); } + // +-------+ +-------+ - // | | | | + // | | TUNNEL | | // | 1 1|-------------|1 2 | // | 2 | | 2 | // +-------+ +-------+ @@ -333,10 +334,11 @@ public class TopologyInstanceTest { // | 3 2|-----------------+ // | 3 | // +-------+ - // | + // | + // | TUNNEL // | // +-------+ - // | 1 | + // | 1 | TUNNEL // | 4 2|----------------+ // | 3 | | // +-------+ | @@ -347,10 +349,11 @@ public class TopologyInstanceTest { // | 5 2|-------------|1 6 | // | | | | // +-------+ +-------+ + { int [][] linkArray = { - {3, 3, 4, 1, DIRECT_LINK}, - {4, 1, 3, 3, DIRECT_LINK}, + {3, 3, 4, 1, TUNNEL_LINK}, + {4, 1, 3, 3, TUNNEL_LINK}, }; int [][] expectedClusters = {