Skip to content
Snippets Groups Projects
Commit d4c978ab authored by Srinivasan Ramasubramanian's avatar Srinivasan Ramasubramanian
Browse files

Use the same destination rooted tree for broadcast purpose.

parent 167ff62a
No related branches found
No related tags found
No related merge requests found
......@@ -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;
}
......
......@@ -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 = {
......
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