[ONOS-5625] Null-Provides: Implement the chordal topology
Change-Id: I4142694e2762ecbbfd6f776131d5269e412e86c3
diff --git a/providers/null/src/main/java/org/onosproject/provider/nil/ChordalTopologySimulator.java b/providers/null/src/main/java/org/onosproject/provider/nil/ChordalTopologySimulator.java
new file mode 100644
index 0000000..5d0ced9
--- /dev/null
+++ b/providers/null/src/main/java/org/onosproject/provider/nil/ChordalTopologySimulator.java
@@ -0,0 +1,46 @@
+/*
+ * Copyright 2015-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.provider.nil;
+/**
+ * Chordal topology simulator.
+ */
+public class ChordalTopologySimulator extends TopologySimulator {
+
+ @Override
+ protected void processTopoShape(String shape) {
+ super.processTopoShape(shape);
+ deviceCount = (topoShape.length > 1) ? Integer.parseInt(topoShape[1]) : deviceCount;
+ hostCount = (topoShape.length > 2) ? Integer.parseInt(topoShape[2]) : hostCount;
+ }
+
+ @Override
+ protected void createLinks() {
+ for (int i = 0, n = deviceCount; i < n; i++) {
+ for (int j = 1; j <= n / 2; j = 2 * j) {
+ createLink(i % deviceCount, (i + j) % deviceCount,
+ (i + j) % deviceCount, i % deviceCount);
+ }
+ }
+ }
+
+ @Override
+ protected void createHosts() {
+ for (int i = 0; i < deviceCount; i++) {
+ createHosts(deviceIds.get(i), hostCount);
+ }
+ }
+
+}
\ No newline at end of file
diff --git a/providers/null/src/main/java/org/onosproject/provider/nil/NullProviders.java b/providers/null/src/main/java/org/onosproject/provider/nil/NullProviders.java
index 5d65caf..65686a9 100644
--- a/providers/null/src/main/java/org/onosproject/provider/nil/NullProviders.java
+++ b/providers/null/src/main/java/org/onosproject/provider/nil/NullProviders.java
@@ -367,6 +367,8 @@
return new GridTopologySimulator();
} else if (topoShape.matches("fattree([,].*|$)")) {
return new FatTreeTopologySimulator();
+ } else if (topoShape.matches("chordal([,].*|$)")) {
+ return new ChordalTopologySimulator();
} else if (topoShape.matches("custom([,].*|$)")) {
return new CustomTopologySimulator();
} else {