Thomas Vachuska
Committed by Gerrit Code Review

Fixing a defect in simulated topology to make sure to use unique ports.

Change-Id: I6ae266e9347470722e4df31aed18e3141e3e84a4
...@@ -42,8 +42,10 @@ public class LinearTopologySimulator extends TopologySimulator { ...@@ -42,8 +42,10 @@ public class LinearTopologySimulator extends TopologySimulator {
42 42
43 @Override 43 @Override
44 protected void createLinks() { 44 protected void createLinks() {
45 + int portOffset = 1;
45 for (int i = 0, n = deviceCount - 1; i < n; i++) { 46 for (int i = 0, n = deviceCount - 1; i < n; i++) {
46 - createLink(i, i + 1); 47 + createLink(i, i + 1, portOffset, 1);
48 + portOffset = 2;
47 } 49 }
48 } 50 }
49 51
......
...@@ -25,7 +25,7 @@ public class RerouteTopologySimulator extends LinearTopologySimulator { ...@@ -25,7 +25,7 @@ public class RerouteTopologySimulator extends LinearTopologySimulator {
25 @Override 25 @Override
26 protected void processTopoShape(String shape) { 26 protected void processTopoShape(String shape) {
27 super.processTopoShape(shape); 27 super.processTopoShape(shape);
28 - infrastructurePorts = 3; 28 + infrastructurePorts = 5;
29 deviceCount = (topoShape.length == 1) ? deviceCount : Integer.parseInt(topoShape[1]); 29 deviceCount = (topoShape.length == 1) ? deviceCount : Integer.parseInt(topoShape[1]);
30 } 30 }
31 31
...@@ -37,13 +37,15 @@ public class RerouteTopologySimulator extends LinearTopologySimulator { ...@@ -37,13 +37,15 @@ public class RerouteTopologySimulator extends LinearTopologySimulator {
37 37
38 @Override 38 @Override
39 protected void createLinks() { 39 protected void createLinks() {
40 + int portOffset = 1;
40 for (int i = 0, n = deviceCount - 2; i < n; i++) { 41 for (int i = 0, n = deviceCount - 2; i < n; i++) {
41 - createLink(i, i + 1); 42 + createLink(i, i + 1, portOffset, 1);
43 + portOffset = 2;
42 } 44 }
43 int middle = (deviceCount - 1) / 2; 45 int middle = (deviceCount - 1) / 2;
44 int alternate = deviceCount - 1; 46 int alternate = deviceCount - 1;
45 - createLink(middle - 1, alternate); 47 + createLink(middle - 1, alternate, 3, 1);
46 - createLink(middle, alternate); 48 + createLink(middle, alternate, 3, 2);
47 } 49 }
48 50
49 @Override 51 @Override
......
...@@ -187,15 +187,27 @@ public abstract class TopologySimulator { ...@@ -187,15 +187,27 @@ public abstract class TopologySimulator {
187 deviceIds.add(id); 187 deviceIds.add(id);
188 } 188 }
189 189
190 +// /**
191 +// * Creates simulated link between two devices on port 1 and port 2.
192 +// *
193 +// * @param i index of one simulated device
194 +// * @param j index of another simulated device
195 +// */
196 +// protected void createLink(int i, int j) {
197 +// createLink(i, j, 1, 2);
198 +// }
199 +
190 /** 200 /**
191 * Creates simulated link between two devices. 201 * Creates simulated link between two devices.
192 * 202 *
193 - * @param i index of one simulated device 203 + * @param i index of one simulated device
194 - * @param j index of another simulated device 204 + * @param j index of another simulated device
205 + * @param pi port number of i-th device
206 + * @param pj port number of j-th device
195 */ 207 */
196 - protected void createLink(int i, int j) { 208 + protected void createLink(int i, int j, int pi, int pj) {
197 - ConnectPoint one = new ConnectPoint(deviceIds.get(i), PortNumber.portNumber(1)); 209 + ConnectPoint one = new ConnectPoint(deviceIds.get(i), PortNumber.portNumber(pi));
198 - ConnectPoint two = new ConnectPoint(deviceIds.get(j), PortNumber.portNumber(2)); 210 + ConnectPoint two = new ConnectPoint(deviceIds.get(j), PortNumber.portNumber(pj));
199 linkProviderService.linkDetected(new DefaultLinkDescription(one, two, DIRECT)); 211 linkProviderService.linkDetected(new DefaultLinkDescription(one, two, DIRECT));
200 linkProviderService.linkDetected(new DefaultLinkDescription(two, one, DIRECT)); 212 linkProviderService.linkDetected(new DefaultLinkDescription(two, one, DIRECT));
201 } 213 }
......
...@@ -55,14 +55,16 @@ public class TreeTopologySimulator extends TopologySimulator { ...@@ -55,14 +55,16 @@ public class TreeTopologySimulator extends TopologySimulator {
55 55
56 @Override 56 @Override
57 protected void createLinks() { 57 protected void createLinks() {
58 + int portOffset = 1;
58 for (int t = 1; t < tierOffset.length; t++) { 59 for (int t = 1; t < tierOffset.length; t++) {
59 int child = tierOffset[t]; 60 int child = tierOffset[t];
60 for (int parent = tierOffset[t - 1]; parent < tierOffset[t]; parent++) { 61 for (int parent = tierOffset[t - 1]; parent < tierOffset[t]; parent++) {
61 for (int i = 0; i < tierMultiplier[t]; i++) { 62 for (int i = 0; i < tierMultiplier[t]; i++) {
62 - createLink(parent, child); 63 + createLink(parent, child, i + portOffset, 1);
63 child++; 64 child++;
64 } 65 }
65 } 66 }
67 + portOffset = 2; // beyond first tier, allow for up-links
66 } 68 }
67 } 69 }
68 70
......