blob: f5f77d5adb0fed9e0d9b1bfc83f066875a99fb84 [file] [log] [blame]
Thomas Vachuska59da18d2015-07-07 17:44:21 -07001/*
Brian O'Connor5ab426f2016-04-09 01:19:45 -07002 * Copyright 2015-present Open Networking Laboratory
Thomas Vachuska59da18d2015-07-07 17:44:21 -07003 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16package org.onosproject.provider.nil;
17
18import static com.google.common.base.Preconditions.checkArgument;
19
20/**
21 * Simple triangle topology with multiple links between same devices.
22 */
23public class AggLinkTopologySimulator extends CentipedeTopologySimulator {
24
25 @Override
26 protected void processTopoShape(String shape) {
27 super.processTopoShape(shape);
28 infrastructurePorts = 2 * deviceCount - 1;
29 }
30
31 @Override
32 public void setUpTopology() {
33 checkArgument(deviceCount > 2, "There must be at least 3 devices");
34 super.setUpTopology();
35 }
36
37 @Override
38 protected void createLinks() {
39 int srcPortOffset = deviceCount + 1;
40 for (int i = 0, n = deviceCount; i < n; i++) {
41 int dstPortOffset = 1;
42 for (int j = 0; j <= i; j++) {
43 createLink(i, (i + 1) % n, srcPortOffset + j, dstPortOffset + j);
44 }
45 srcPortOffset = dstPortOffset + i + 1;
46 }
47 }
48
49}