blob: 9943255e29f507f90e7f90113e26032feaac478e [file] [log] [blame]
hyunmin no97174182016-12-13 21:14:30 +09001/*
Brian O'Connora09fe5b2017-08-03 21:12:30 -07002 * Copyright 2015-present Open Networking Foundation
hyunmin no97174182016-12-13 21:14:30 +09003 *
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/**
18 * Chordal topology simulator.
19 */
20public class ChordalTopologySimulator extends TopologySimulator {
21
22 @Override
23 protected void processTopoShape(String shape) {
24 super.processTopoShape(shape);
25 deviceCount = (topoShape.length > 1) ? Integer.parseInt(topoShape[1]) : deviceCount;
26 hostCount = (topoShape.length > 2) ? Integer.parseInt(topoShape[2]) : hostCount;
27 }
28
29 @Override
30 protected void createLinks() {
31 for (int i = 0, n = deviceCount; i < n; i++) {
32 for (int j = 1; j <= n / 2; j = 2 * j) {
33 createLink(i % deviceCount, (i + j) % deviceCount,
34 (i + j) % deviceCount, i % deviceCount);
35 }
36 }
37 }
38
39 @Override
40 protected void createHosts() {
41 for (int i = 0; i < deviceCount; i++) {
42 createHosts(deviceIds.get(i), hostCount);
43 }
44 }
45
46}