├── docs ├── demo-topo.jpg └── link-latency-show.jpg ├── src └── main │ ├── bak │ ├── rest │ │ ├── package-info.java │ │ ├── MaoRestApplication.java │ │ ├── MaoRestLatency.java │ │ └── MaoRestResource.java │ ├── BUILD.bak │ └── webapp │ │ └── WEB-INF │ │ └── web.xml │ └── java │ └── com │ └── maojianwei │ └── link │ └── quality │ └── measurement │ ├── package-info.java │ ├── cli │ ├── package-info.java │ ├── MaoLinkQuality.java │ ├── MaoAllInitLinkQuality.java │ ├── MaoAllControlLinkQuality.java │ └── MaoDebugLinkQuality.java │ ├── impl │ ├── package-info.java │ ├── OsgiPropertyConstants.java │ └── MaoLinkQualityManager.java │ └── intf │ ├── package-info.java │ └── MaoLinkQualityService.java ├── BUILD ├── README.md ├── LICENSE └── modules.bzl__available_example /docs/demo-topo.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MaoJianwei/ONOS_Link_Quality_Measurement/HEAD/docs/demo-topo.jpg -------------------------------------------------------------------------------- /docs/link-latency-show.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MaoJianwei/ONOS_Link_Quality_Measurement/HEAD/docs/link-latency-show.jpg -------------------------------------------------------------------------------- /src/main/bak/rest/package-info.java: -------------------------------------------------------------------------------- 1 | ///** 2 | // * Created by Mao Link Quality Measurement on 2020.10.18. 3 | // */ 4 | //package com.maojianwei.link.quality.measurement.rest; 5 | -------------------------------------------------------------------------------- /BUILD: -------------------------------------------------------------------------------- 1 | COMPILE_DEPS = CORE_DEPS + CLI + [ 2 | "//core/common:onos-core-common", 3 | ] 4 | 5 | osgi_jar_with_tests( 6 | karaf_command_packages = ["com.maojianwei.link.quality.measurement.cli"], 7 | deps = COMPILE_DEPS, 8 | ) 9 | 10 | REQUIRE_APPS = [ 11 | ] 12 | 13 | onos_app( 14 | app_name = "com.maojianwei.link.quality.measurement", 15 | category = "Monitoring", 16 | description = "Mao Link Quality Measurement", 17 | required_apps = REQUIRE_APPS, 18 | title = "Mao Link Quality Measurement", 19 | url = "https://www.maojianwei.com", 20 | ) 21 | -------------------------------------------------------------------------------- /src/main/java/com/maojianwei/link/quality/measurement/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020-present Open Networking Foundation. 3 | * 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 | */ 16 | 17 | /** 18 | * Link Quality Measurement. 19 | */ 20 | package com.maojianwei.link.quality.measurement; 21 | -------------------------------------------------------------------------------- /src/main/java/com/maojianwei/link/quality/measurement/cli/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020-present Open Networking Foundation. 3 | * 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 | */ 16 | 17 | /** 18 | * Link Quality Measurement Commands. 19 | */ 20 | package com.maojianwei.link.quality.measurement.cli; 21 | -------------------------------------------------------------------------------- /src/main/java/com/maojianwei/link/quality/measurement/impl/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020-present Open Networking Foundation. 3 | * 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 | */ 16 | 17 | /** 18 | * Link Quality Measurement Implementation. 19 | */ 20 | package com.maojianwei.link.quality.measurement.impl; 21 | -------------------------------------------------------------------------------- /src/main/java/com/maojianwei/link/quality/measurement/intf/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020-present Open Networking Foundation. 3 | * 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 | */ 16 | 17 | /** 18 | * Link Quality Measurement Service Interface. 19 | */ 20 | package com.maojianwei.link.quality.measurement.intf; 21 | -------------------------------------------------------------------------------- /src/main/bak/BUILD.bak: -------------------------------------------------------------------------------- 1 | COMPILE_DEPS = CORE_DEPS + JACKSON + REST + CLI + [ 2 | "//core/common:onos-core-common", 3 | # "//drivers/default:onos-drivers-default", 4 | ] 5 | 6 | osgi_jar_with_tests( 7 | api_description = "BigMao Radio Station REST API v1.0, for link quality measurement", 8 | api_package = "com.maojianwei.link.quality.measurement", 9 | api_title = "BigMao Radio Station REST API v1.0", 10 | api_version = "/onos/v1/Mao", 11 | karaf_command_packages = ["com.maojianwei.link.quality.measurement.cli"], 12 | web_context = "/onos/Mao", 13 | deps = COMPILE_DEPS, 14 | ) 15 | 16 | REQUIRE_APPS = [ 17 | # "org.onosproject.proxyarp", 18 | ] 19 | 20 | onos_app( 21 | app_name = "com.maojianwei.link.quality.measurement", 22 | category = "Monitoring", 23 | description = "Mao Link Quality Measurement", 24 | required_apps = REQUIRE_APPS, 25 | title = "Mao Link Quality Measurement", 26 | url = "https://www.maojianwei.com", 27 | ) 28 | -------------------------------------------------------------------------------- /src/main/bak/rest/MaoRestApplication.java: -------------------------------------------------------------------------------- 1 | ///* 2 | // * Copyright 2016-present Open Networking Laboratory 3 | // * 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 | // */ 16 | //package com.maojianwei.link.quality.measurement.rest; 17 | // 18 | //import org.onlab.rest.AbstractWebApplication; 19 | // 20 | //import java.util.Set; 21 | // 22 | ///** 23 | // * Created by Mao Link Quality Measurement on 2020.10.18. 24 | // */ 25 | //public class MaoRestApplication extends AbstractWebApplication { 26 | // 27 | // @Override 28 | // public Set> getClasses() { 29 | // return getClasses(MaoRestResource.class); 30 | // } 31 | //} 32 | -------------------------------------------------------------------------------- /src/main/java/com/maojianwei/link/quality/measurement/impl/OsgiPropertyConstants.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020-present Open Networking Foundation. 3 | * 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 | */ 16 | package com.maojianwei.link.quality.measurement.impl; 17 | 18 | public final class OsgiPropertyConstants { 19 | private OsgiPropertyConstants() {} 20 | 21 | public static final String PROBE_INTERVAL = "probeInterval"; 22 | public static final int PROBE_INTERVAL_DEFAULT = 3000; // ms 23 | 24 | public static final String CALCULATE_INTERVAL = "calculateInterval"; 25 | public static final int CALCULATE_INTERVAL_DEFAULT = 3000; // ms 26 | 27 | public static final String LATENCY_AVERAGE_SIZE = "latencyAverageSize"; 28 | public static final int LATENCY_AVERAGE_SIZE_DEFAULT = 5; 29 | } 30 | -------------------------------------------------------------------------------- /src/main/java/com/maojianwei/link/quality/measurement/cli/MaoLinkQuality.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020-present Open Networking Foundation. 3 | * 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 | */ 16 | package com.maojianwei.link.quality.measurement.cli; 17 | 18 | import com.maojianwei.link.quality.measurement.intf.MaoLinkQualityService; 19 | import org.apache.karaf.shell.api.action.Command; 20 | import org.apache.karaf.shell.api.action.lifecycle.Service; 21 | import org.onosproject.cli.AbstractShellCommand; 22 | 23 | @Service 24 | @Command(scope = "onos", 25 | name = "link-latencies", 26 | description = "Show all latencies of all links.", 27 | detailedDescription = "Show all latencies of all links.") 28 | public class MaoLinkQuality extends AbstractShellCommand { 29 | 30 | @Override 31 | protected void doExecute() { 32 | MaoLinkQualityService service = getService(MaoLinkQualityService.class); 33 | print("====== Link Latencies ======"); 34 | service.getAllLinkLatencies().forEach((k, v) -> print("%s --- %dms", k.toString(), v)); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/main/java/com/maojianwei/link/quality/measurement/cli/MaoAllInitLinkQuality.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020-present Open Networking Foundation. 3 | * 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 | */ 16 | package com.maojianwei.link.quality.measurement.cli; 17 | 18 | import com.maojianwei.link.quality.measurement.intf.MaoLinkQualityService; 19 | import org.apache.karaf.shell.api.action.Command; 20 | import org.apache.karaf.shell.api.action.lifecycle.Service; 21 | import org.onosproject.cli.AbstractShellCommand; 22 | 23 | @Service 24 | @Command(scope = "onos", 25 | name = "link-latencies-init", 26 | description = "Show all init latencies of all links.", 27 | detailedDescription = "Show all init latencies of all links.") 28 | public class MaoAllInitLinkQuality extends AbstractShellCommand { 29 | 30 | @Override 31 | protected void doExecute() { 32 | MaoLinkQualityService service = getService(MaoLinkQualityService.class); 33 | print("====== Link Latencies (init) ======"); 34 | service.getAllInitLatencies().forEach((k, v) -> print("%s --- %dms", k.toString(), v)); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/main/java/com/maojianwei/link/quality/measurement/intf/MaoLinkQualityService.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020-present Open Networking Foundation. 3 | * 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 | */ 16 | 17 | package com.maojianwei.link.quality.measurement.intf; 18 | 19 | import org.onosproject.net.DeviceId; 20 | import org.onosproject.net.Link; 21 | 22 | import java.util.List; 23 | import java.util.Map; 24 | 25 | /** 26 | * Link Quality Measurement Service. 27 | */ 28 | public interface MaoLinkQualityService { 29 | 30 | /** 31 | * Get latency for one link. 32 | * @param link directional link. 33 | * @return the one-way latency of the specific link. 34 | */ 35 | int getLinkLatency(Link link); 36 | 37 | /** 38 | * Get latencies for all links. 39 | * 40 | * @return one-way latencies of all links. 41 | */ 42 | Map getAllLinkLatencies(); 43 | 44 | 45 | // ========== debug usages ========== 46 | Map getAllInitLatencies(); 47 | Map getAllControlLatencies(); 48 | 49 | Map> getDebugLinkLatancies(); 50 | } 51 | -------------------------------------------------------------------------------- /src/main/java/com/maojianwei/link/quality/measurement/cli/MaoAllControlLinkQuality.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020-present Open Networking Foundation. 3 | * 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 | */ 16 | package com.maojianwei.link.quality.measurement.cli; 17 | 18 | import com.maojianwei.link.quality.measurement.intf.MaoLinkQualityService; 19 | import org.apache.karaf.shell.api.action.Command; 20 | import org.apache.karaf.shell.api.action.lifecycle.Service; 21 | import org.onosproject.cli.AbstractShellCommand; 22 | 23 | @Service 24 | @Command(scope = "onos", 25 | name = "link-latencies-control", 26 | description = "Show all latencies of all control links.", 27 | detailedDescription = "Show all latencies of all control links.") 28 | public class MaoAllControlLinkQuality extends AbstractShellCommand { 29 | 30 | @Override 31 | protected void doExecute() { 32 | MaoLinkQualityService service = getService(MaoLinkQualityService.class); 33 | print("====== Link Latencies (control) ======"); 34 | service.getAllControlLatencies().forEach((k, v) -> print("%s --- %dms", k.toString(), v)); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # ONOS_Link_Quality_Measurement 2 | 3 | An active method to measure link quality: latency(delay) / jitter / packet loss ratio. Performed by ONOS controller. 4 | 5 | If you like this project, please click **Star** at the top-right corner, thanks for your support :) 6 | 7 | Discuss on ONOS mailing list: 8 | [Is there any app/module/manager that can detect the quality of network links?](https://groups.google.com/a/onosproject.org/g/onos-discuss/c/bMmLeMW7UyQ/m/M3gBxywwBQAJ) 9 | 10 | . 11 | 12 | ## Update Note 13 | 14 | **2020.10.18** Support link delay measurement, based on ONOS **2.5.0-SNAPSHOT** version, backed by Apache Karaf **4.2.9** & JDK **11**. 15 | 16 | . 17 | 18 | ## Demo 19 | ![demo-topo](https://raw.githubusercontent.com/MaoJianwei/ONOS_Link_Quality_Measurement/master/docs/demo-topo.jpg) 20 | ![link-latency-show](https://raw.githubusercontent.com/MaoJianwei/ONOS_Link_Quality_Measurement/master/docs/link-latency-show.jpg) 21 | ``` 22 | sudo tc qdisc add dev s1-eth2 root netem delay 100ms 23 | sudo tc qdisc add dev s2-eth3 root netem delay 300ms 24 | ``` 25 | . 26 | 27 | ## Latest Instruction to Compile 28 | 29 | 1. Embed me with ONOS codebase 30 | 2. Modify the **$ONOS_ROOT/tools/build/bazel/modules.bzl** file, refer to **modules.bzl__available_example** file 31 | 3. Build whole ONOS by bazel. 32 | (You can use my utility script for ONOS: https://github.com/MaoJianwei/SDN_Scripts/blob/master/ONOS/autoONOS_Bazel.sh) 33 | 34 | 35 | **Out-of-date:** 36 | ONOS does not support to be built and imported to IDE(Intellij IDEA) by Maven(pom.xml) anymore, we should use Bazel(BUILD). 37 | 38 | . 39 | 40 | ## Backward Compatibility 41 | 42 | You can find all milestone versions at [Release](https://github.com/MaoJianwei/ONOS_Link_Quality_Measurement/releases) page. 43 | 44 | . 45 | 46 | ## Community Support 47 | 48 | Long term support(LTS) from 2020.10.18, by: 49 | 50 | :) [Jianwei Mao @ BUPT FNLab](https://www.maojianwei.com/) - ONOS China Ambassador - MaoJianwei2012@126.com / MaoJianwei2020@gmail.com 51 | -------------------------------------------------------------------------------- /src/main/java/com/maojianwei/link/quality/measurement/cli/MaoDebugLinkQuality.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020-present Open Networking Foundation. 3 | * 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 | */ 16 | package com.maojianwei.link.quality.measurement.cli; 17 | 18 | import com.maojianwei.link.quality.measurement.intf.MaoLinkQualityService; 19 | import org.apache.karaf.shell.api.action.Command; 20 | import org.apache.karaf.shell.api.action.lifecycle.Service; 21 | import org.onosproject.cli.AbstractShellCommand; 22 | 23 | @Service 24 | @Command(scope = "onos", 25 | name = "link-latencies-debug", 26 | description = "Debug: Show all latencies of all links.", 27 | detailedDescription = "Debug: Show all latencies of all links.") 28 | public class MaoDebugLinkQuality extends AbstractShellCommand { 29 | 30 | @Override 31 | protected void doExecute() { 32 | MaoLinkQualityService service = getService(MaoLinkQualityService.class); 33 | print("====== Link Latencies ======"); 34 | service.getAllLinkLatencies().forEach((k, v) -> print("%s --- %dms", k.toString(), v)); 35 | print("====== Link Latencies (init) ======"); 36 | service.getAllInitLatencies().forEach((k, v) -> print("%s --- %dms", k.toString(), v)); 37 | print("====== Link Latencies (control) ======"); 38 | service.getAllControlLatencies().forEach((k, v) -> print("%s --- %dms", k.toString(), v)); 39 | print("====== Link Latencies (record) ======"); 40 | service.getDebugLinkLatancies().forEach((k, v) -> print("%s --- %s", k.toString(), v)); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /src/main/bak/rest/MaoRestLatency.java: -------------------------------------------------------------------------------- 1 | ///* 2 | // * Copyright 2016-present Open Networking Laboratory 3 | // * 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 | // */ 16 | //package com.maojianwei.link.quality.measurement.rest; 17 | // 18 | //import com.fasterxml.jackson.databind.node.ArrayNode; 19 | //import com.fasterxml.jackson.databind.node.ObjectNode; 20 | //import org.onosproject.net.device.DeviceService; 21 | //import org.onosproject.net.link.LinkService; 22 | //import org.onosproject.net.statistic.PortStatisticsService; 23 | //import org.onosproject.rest.AbstractWebResource; 24 | // 25 | //import javax.ws.rs.GET; 26 | //import javax.ws.rs.Path; 27 | //import javax.ws.rs.Produces; 28 | //import javax.ws.rs.core.MediaType; 29 | //import javax.ws.rs.core.Response; 30 | // 31 | ///** 32 | // * Mao Test Label. 33 | // * 34 | // * ONOS REST API Docs 35 | // * http://127.0.0.1:8181/onos/v1/docs/ 36 | // */ 37 | //@Path("Mao_Link_Quality_Measurement") 38 | //public class MaoRestLatency extends AbstractWebResource { 39 | // 40 | // // private MaoRoutingService maoRoutingService = get(MaoRoutingService.class); 41 | // private LinkService linkService = get(LinkService.class); 42 | // private PortStatisticsService portStatisticsService = get(PortStatisticsService.class); 43 | // private DeviceService deviceService = get(DeviceService.class); 44 | // 45 | // /** 46 | // * Hello world. 47 | // * Mao. 48 | // * 49 | // * REST API: 50 | // * http://127.0.0.1:8181/onos/mao/hello 51 | // * 52 | // * @return Beijing 53 | // */ 54 | // @GET 55 | // @Path("hello") 56 | // @Produces(MediaType.APPLICATION_JSON) 57 | // public Response hello() { 58 | // ObjectNode root = mapper().createObjectNode(); 59 | // root.put("Hello", 1080) 60 | // .put("Mao", 7181); 61 | // 62 | // ArrayNode array = root.putArray("RadioStation"); 63 | // array.add("192.168.1.1").add("127.0.0.1").add("10.3.8.211"); 64 | // 65 | // return ok(root.toString()).build(); 66 | // } 67 | //} 68 | -------------------------------------------------------------------------------- /src/main/bak/webapp/WEB-INF/web.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | -------------------------------------------------------------------------------- /src/main/bak/rest/MaoRestResource.java: -------------------------------------------------------------------------------- 1 | ///* 2 | // * Copyright 2016-present Open Networking Laboratory 3 | // * 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 | // */ 16 | //package com.maojianwei.link.quality.measurement.rest; 17 | // 18 | //import com.fasterxml.jackson.databind.node.ArrayNode; 19 | //import com.fasterxml.jackson.databind.node.ObjectNode; 20 | //import org.onosproject.net.ConnectPoint; 21 | //import org.onosproject.net.DeviceId; 22 | //import org.onosproject.net.device.DeviceService; 23 | //import org.onosproject.net.link.LinkService; 24 | //import org.onosproject.net.statistic.PortStatisticsService; 25 | //import org.onosproject.rest.AbstractWebResource; 26 | // 27 | //import javax.ws.rs.GET; 28 | //import javax.ws.rs.Path; 29 | //import javax.ws.rs.Produces; 30 | //import javax.ws.rs.core.MediaType; 31 | //import javax.ws.rs.core.Response; 32 | //import java.util.HashSet; 33 | //import java.util.Set; 34 | // 35 | ///** 36 | // * Mao Test Label. 37 | // * 38 | // * ONOS REST API Docs 39 | // * http://127.0.0.1:8181/onos/v1/docs/ 40 | // */ 41 | //@Path("ONOS_LoadBalance_Routing_Forward") 42 | //public class MaoRestResource extends AbstractWebResource { 43 | // 44 | //// private MaoRoutingService maoRoutingService = get(MaoRoutingService.class); 45 | // private LinkService linkService = get(LinkService.class); 46 | // private PortStatisticsService portStatisticsService = get(PortStatisticsService.class); 47 | // private DeviceService deviceService = get(DeviceService.class); 48 | // 49 | // /** 50 | // * Hello world. 51 | // * Mao. 52 | // * 53 | // * REST API: 54 | // * http://127.0.0.1:8181/onos/mao/hello 55 | // * 56 | // * @return Beijing 57 | // */ 58 | // @GET 59 | // @Path("hello") 60 | // @Produces(MediaType.APPLICATION_JSON) 61 | // public Response hello() { 62 | // ObjectNode root = mapper().createObjectNode(); 63 | // root.put("Hello", 1080) 64 | // .put("Mao", 7181); 65 | // 66 | // ArrayNode array = root.putArray("RadioStation"); 67 | // array.add("192.168.1.1").add("127.0.0.1").add("10.3.8.211"); 68 | // 69 | // return ok(root.toString()).build(); 70 | // } 71 | // 72 | // 73 | // /** 74 | // * Returns real-time links' load. 75 | // * 76 | // * REST API: 77 | // * http://127.0.0.1:8181/onos/mao/getLinksLoad 78 | // * 79 | // * @return . 80 | // */ 81 | // @GET 82 | // @Path("getLinksLoad") 83 | // @Produces(MediaType.APPLICATION_JSON) 84 | // public Response getLinksLoad() { 85 | // 86 | // Set linksList = new HashSet<>(); 87 | // 88 | // ObjectNode root = mapper().createObjectNode(); 89 | // ArrayNode capabilities = root.putArray("LinkCapability"); 90 | // 91 | // linkService.getLinks().forEach(link -> { 92 | // 93 | // 94 | // ConnectPoint linkSrcPort = link.src(); 95 | // ConnectPoint linkDstPort = link.dst(); 96 | // 97 | // if (isEnrolled(linksList, linkSrcPort.deviceId(), linkDstPort.deviceId())) { 98 | // return; 99 | // } 100 | // 101 | // long srcPortWireSpeed = getPortWireSpeed(linkSrcPort); 102 | // long dstPortWireSpeed = getPortWireSpeed(linkDstPort); 103 | // assert srcPortWireSpeed == dstPortWireSpeed; 104 | // 105 | // long srcPortLoadSpeed = getPortLoadSpeed(linkSrcPort); 106 | // long dstPortLoadSpeed = getPortLoadSpeed(linkDstPort); 107 | // 108 | // long srcPortRestSpeed = srcPortWireSpeed - srcPortLoadSpeed; 109 | // long dstPortRestSpeed = dstPortWireSpeed - dstPortLoadSpeed; 110 | // 111 | // 112 | // 113 | // long linkWireSpeed = srcPortWireSpeed; 114 | // long linkLoadSpeed = getLinkLoadSpeed(srcPortLoadSpeed, dstPortLoadSpeed); 115 | // long linkRestSpeed = getLinkRestSpeed(srcPortRestSpeed, dstPortRestSpeed); 116 | // 117 | // ObjectNode linkNode = mapper().createObjectNode(); 118 | // linkNode.put("Name", 119 | // (linkSrcPort.deviceId().toString() + "<->" + linkDstPort.deviceId().toString()).replace("0", "")); 120 | // linkNode.put("Wire", linkWireSpeed); 121 | // linkNode.put("Load", linkLoadSpeed); 122 | // linkNode.put("Rest", linkRestSpeed); 123 | // linkNode.put("Weight", 100 - linkRestSpeed * 1.0 / linkWireSpeed * 100); 124 | // 125 | // 126 | // 127 | // capabilities.add(linkNode); 128 | // }); 129 | // 130 | // return ok(root.toString()).build(); 131 | // } 132 | // 133 | // /** 134 | // * Unit: bps. 135 | // * @param port 136 | // * @return 137 | // */ 138 | // private long getPortLoadSpeed(ConnectPoint port) { 139 | // 140 | // //data source: Bps 141 | // return portStatisticsService.load(port).rate() * 8; 142 | // } 143 | // 144 | // /** 145 | // * Unit bps. 146 | // * @param port 147 | // * @return 148 | // */ 149 | // private long getPortWireSpeed(ConnectPoint port) { 150 | // 151 | // assert port.elementId() instanceof DeviceId; 152 | // 153 | // //data source: Mbps 154 | // return deviceService.getPort(port.deviceId(), port.port()).portSpeed() * 1000000; 155 | // } 156 | // 157 | // private long getLinkLoadSpeed(long src, long dst) { 158 | // return Math.max(src, dst); 159 | // } 160 | // 161 | // private long getLinkRestSpeed(long src, long dst) { 162 | // return Math.min(src, dst); 163 | // } 164 | // 165 | // private boolean isEnrolled(Set linkList, DeviceId a, DeviceId b) { 166 | // 167 | // if (linkList.contains(a.toString() + b.toString()) || 168 | // linkList.contains(b.toString() + a.toString())) { 169 | // return true; 170 | // } else { 171 | // linkList.add(a.toString() + b.toString()); 172 | // return false; 173 | // } 174 | // } 175 | //} 176 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "{}" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright {yyyy} {name of copyright owner} 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /src/main/java/com/maojianwei/link/quality/measurement/impl/MaoLinkQualityManager.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020-present Open Networking Foundation. 3 | * 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 | */ 16 | package com.maojianwei.link.quality.measurement.impl; 17 | 18 | import com.maojianwei.link.quality.measurement.intf.MaoLinkQualityService; 19 | import org.onlab.packet.Data; 20 | import org.onlab.packet.Ethernet; 21 | import org.onlab.util.Tools; 22 | import org.onosproject.cfg.ComponentConfigService; 23 | import org.onosproject.core.ApplicationId; 24 | import org.onosproject.core.CoreService; 25 | import org.onosproject.net.Device; 26 | import org.onosproject.net.DeviceId; 27 | import org.onosproject.net.Link; 28 | import org.onosproject.net.PortNumber; 29 | import org.onosproject.net.device.DeviceService; 30 | import org.onosproject.net.flow.DefaultFlowRule; 31 | import org.onosproject.net.flow.DefaultTrafficSelector; 32 | import org.onosproject.net.flow.DefaultTrafficTreatment; 33 | import org.onosproject.net.flow.FlowRule; 34 | import org.onosproject.net.flow.FlowRuleService; 35 | import org.onosproject.net.flow.TrafficSelector; 36 | import org.onosproject.net.flow.TrafficTreatment; 37 | import org.onosproject.net.link.LinkService; 38 | import org.onosproject.net.packet.DefaultOutboundPacket; 39 | import org.onosproject.net.packet.PacketContext; 40 | import org.onosproject.net.packet.PacketPriority; 41 | import org.onosproject.net.packet.PacketProcessor; 42 | import org.onosproject.net.packet.PacketService; 43 | import org.osgi.service.component.ComponentContext; 44 | import org.osgi.service.component.annotations.Activate; 45 | import org.osgi.service.component.annotations.Component; 46 | import org.osgi.service.component.annotations.Deactivate; 47 | import org.osgi.service.component.annotations.Modified; 48 | import org.osgi.service.component.annotations.Reference; 49 | import org.osgi.service.component.annotations.ReferenceCardinality; 50 | import org.slf4j.Logger; 51 | import org.slf4j.LoggerFactory; 52 | 53 | import java.nio.ByteBuffer; 54 | import java.util.ArrayList; 55 | import java.util.Collections; 56 | import java.util.Dictionary; 57 | import java.util.HashMap; 58 | import java.util.List; 59 | import java.util.Map; 60 | import java.util.Set; 61 | import java.util.concurrent.ConcurrentHashMap; 62 | import java.util.concurrent.ExecutorService; 63 | import java.util.concurrent.Executors; 64 | import java.util.concurrent.TimeUnit; 65 | 66 | import static com.maojianwei.link.quality.measurement.impl.OsgiPropertyConstants.*; 67 | 68 | @Component( 69 | immediate = true, 70 | service = {MaoLinkQualityService.class, }, 71 | property = { 72 | PROBE_INTERVAL + ":Integer=" + PROBE_INTERVAL_DEFAULT, 73 | CALCULATE_INTERVAL + ":Integer=" + CALCULATE_INTERVAL_DEFAULT, 74 | LATENCY_AVERAGE_SIZE + ":Integer=" + LATENCY_AVERAGE_SIZE_DEFAULT, 75 | } 76 | ) 77 | public class MaoLinkQualityManager implements MaoLinkQualityService { 78 | 79 | private final Logger log = LoggerFactory.getLogger(getClass()); 80 | 81 | private static final String PROBE_SPLITER = ";"; 82 | private static final short PROBE_ETHERTYPE = 0x3366; 83 | 84 | private static final String PROBE_SRC = "20:15:08:10:00:05"; 85 | private static final String PROBE_DST = "FF:FF:FF:FF:FF:FF"; 86 | 87 | 88 | /** Interval for sending probe. */ 89 | private int probeInterval = PROBE_INTERVAL_DEFAULT; 90 | 91 | /** Interval for calculating latency. */ 92 | private int calculateInterval = CALCULATE_INTERVAL_DEFAULT; // ms 93 | 94 | /** Number of buffered latency records. */ 95 | private int latencyAverageSize = LATENCY_AVERAGE_SIZE_DEFAULT; 96 | 97 | 98 | @Reference(cardinality = ReferenceCardinality.MANDATORY) 99 | protected PacketService packetService; 100 | 101 | @Reference(cardinality = ReferenceCardinality.MANDATORY) 102 | protected DeviceService deviceService; 103 | 104 | @Reference(cardinality = ReferenceCardinality.MANDATORY) 105 | protected LinkService linkService; 106 | 107 | @Reference(cardinality = ReferenceCardinality.MANDATORY) 108 | protected CoreService coreService; 109 | 110 | @Reference(cardinality = ReferenceCardinality.MANDATORY) 111 | protected ComponentConfigService cfgService; 112 | 113 | @Reference(cardinality = ReferenceCardinality.MANDATORY) 114 | protected FlowRuleService flowRuleService; 115 | 116 | 117 | private MaoProbeLinkQualityTask probeTask; 118 | private MaoCalculateLinkQualityTask calculateTask; 119 | private ExecutorService probeWorker; 120 | private MaoLinkProbeReceiver linkProbeReceiver; 121 | private ApplicationId appId; 122 | 123 | // hold last 5 records for averages. 124 | private final Map> linkLatencies = new ConcurrentHashMap<>(); 125 | private final Map initLinklatencies = new ConcurrentHashMap<>(); 126 | private final Map controlLinkLatencies = new ConcurrentHashMap<>(); 127 | 128 | @Activate 129 | private void activate(ComponentContext context) { 130 | log.info("Starting..."); 131 | cfgService.registerProperties(getClass()); 132 | loadConfiguration(context); 133 | appId = coreService.registerApplication("com.maojianwei.link.quality.measurement"); 134 | 135 | linkProbeReceiver = new MaoLinkProbeReceiver(); 136 | packetService.addProcessor(linkProbeReceiver, PacketProcessor.advisor(1)); 137 | requestPushPacket(); 138 | 139 | probeTask = new MaoProbeLinkQualityTask(); 140 | calculateTask = new MaoCalculateLinkQualityTask(); 141 | probeWorker = Executors.newCachedThreadPool(); 142 | probeWorker.submit(probeTask); 143 | probeWorker.submit(calculateTask); 144 | log.info("Started, {}", appId.id()); 145 | } 146 | 147 | @Deactivate 148 | private void deactivate() { 149 | log.info("Stopping..."); 150 | 151 | probeTask.requireShutdown(); 152 | calculateTask.requireShutdown(); 153 | 154 | probeWorker.shutdown(); 155 | try { 156 | log.info("waits thread pool to shutdown..."); 157 | probeWorker.awaitTermination(3, TimeUnit.SECONDS); 158 | log.info("thread pool shutdown ok."); 159 | } catch (InterruptedException e) { 160 | e.printStackTrace(); 161 | log.warn("thread pool shutdown timeout."); 162 | } 163 | 164 | cancelPushPacket(); 165 | packetService.removeProcessor(linkProbeReceiver); 166 | cfgService.unregisterProperties(getClass(), false); 167 | log.info("Stopped"); 168 | } 169 | 170 | @Modified 171 | private void modify(ComponentContext context) { 172 | loadConfiguration(context); 173 | } 174 | 175 | private void loadConfiguration(ComponentContext context) { 176 | Dictionary properties = context.getProperties(); 177 | 178 | probeInterval = Tools.getIntegerProperty(properties, PROBE_INTERVAL, PROBE_INTERVAL_DEFAULT); 179 | log.info("Configured. Probe Interval is configured to {} ms", probeInterval); 180 | 181 | calculateInterval = Tools.getIntegerProperty(properties, CALCULATE_INTERVAL, CALCULATE_INTERVAL_DEFAULT); 182 | log.info("Configured. Calculate Interval is configured to {} ms", calculateInterval); 183 | 184 | latencyAverageSize = Tools.getIntegerProperty(properties, LATENCY_AVERAGE_SIZE, LATENCY_AVERAGE_SIZE_DEFAULT); 185 | log.info("Configured. Latency Average Size is configured to {}", latencyAverageSize); 186 | } 187 | 188 | 189 | private void requestPushPacket() { 190 | TrafficSelector selector = DefaultTrafficSelector.builder().matchEthType(PROBE_ETHERTYPE).build(); 191 | packetService.requestPackets(selector, PacketPriority.HIGH, appId); 192 | } 193 | 194 | private void cancelPushPacket() { 195 | TrafficSelector selector = DefaultTrafficSelector.builder().matchEthType(PROBE_ETHERTYPE).build(); 196 | packetService.cancelPackets(selector, PacketPriority.HIGH, appId); 197 | } 198 | 199 | 200 | @Override 201 | public int getLinkLatency(Link link) { 202 | int sum = 0; 203 | List latencies = linkLatencies.getOrDefault(link, Collections.EMPTY_LIST); 204 | for (Integer l : latencies) { 205 | sum += l; 206 | } 207 | return sum / latencyAverageSize; 208 | } 209 | 210 | @Override 211 | public Map getAllLinkLatencies() { 212 | Map result = new HashMap<>(); 213 | linkLatencies.forEach((link, list) -> { 214 | int sum = 0; 215 | for (Integer l : list) { 216 | sum += l; 217 | } 218 | result.put(link, sum / latencyAverageSize); 219 | }); 220 | return Collections.unmodifiableMap(result); 221 | } 222 | 223 | @Override 224 | public Map getAllInitLatencies() { 225 | return Collections.unmodifiableMap(initLinklatencies); 226 | } 227 | 228 | @Override 229 | public Map getAllControlLatencies() { 230 | return Collections.unmodifiableMap(controlLinkLatencies); 231 | } 232 | 233 | @Override 234 | public Map> getDebugLinkLatancies() { 235 | return Collections.unmodifiableMap(linkLatencies); 236 | } 237 | 238 | 239 | private class MaoCalculateLinkQualityTask implements Runnable { 240 | 241 | private boolean toRun = true; 242 | 243 | public void requireShutdown() { 244 | toRun = false; 245 | } 246 | 247 | @Override 248 | public void run() { 249 | while (toRun) { 250 | initLinklatencies.forEach((link, latency) -> { 251 | latency -= controlLinkLatencies.getOrDefault(link.src().deviceId(), 0) / 2; 252 | latency -= controlLinkLatencies.getOrDefault(link.dst().deviceId(), 0) / 2; 253 | 254 | List records; 255 | if (!linkLatencies.containsKey(link)) { 256 | records = new ArrayList<>(); 257 | linkLatencies.put(link, records); 258 | } else { 259 | records = linkLatencies.get(link); 260 | } 261 | 262 | if (records.size() >= latencyAverageSize) { 263 | records.remove(0); 264 | } 265 | records.add(latency < 0 ? 0 : latency); 266 | }); 267 | try { 268 | Thread.sleep(calculateInterval); 269 | } catch (InterruptedException e) { 270 | break; 271 | } 272 | } 273 | log.info("Calculate latency task stopped."); 274 | } 275 | } 276 | 277 | private class MaoProbeLinkQualityTask implements Runnable { 278 | 279 | private boolean toRun = true; 280 | 281 | public void requireShutdown() { 282 | toRun = false; 283 | } 284 | 285 | @Override 286 | public void run() { 287 | while (toRun) { 288 | for (Device device : deviceService.getAvailableDevices()) { 289 | DeviceId deviceId = device.id(); 290 | 291 | // pushFlowrule(deviceId); 292 | 293 | TrafficTreatment treatmentAll = DefaultTrafficTreatment.builder() 294 | .setOutput(PortNumber.ALL).build(); 295 | TrafficTreatment treatmentController = DefaultTrafficTreatment.builder() 296 | .setOutput(PortNumber.CONTROLLER).build(); 297 | 298 | Ethernet probePkt = new Ethernet(); 299 | probePkt.setDestinationMACAddress(PROBE_DST); 300 | probePkt.setSourceMACAddress(PROBE_SRC); 301 | probePkt.setEtherType(PROBE_ETHERTYPE); 302 | 303 | byte[] probeData = (deviceId.toString() + PROBE_SPLITER + System.currentTimeMillis()).getBytes(); 304 | probePkt.setPayload(new Data(probeData)); 305 | packetService.emit(new DefaultOutboundPacket(deviceId, treatmentAll, 306 | ByteBuffer.wrap(probePkt.serialize()))); 307 | 308 | 309 | probeData = (deviceId.toString() + PROBE_SPLITER + System.currentTimeMillis()).getBytes(); 310 | probePkt.setPayload(new Data(probeData)); 311 | packetService.emit(new DefaultOutboundPacket(deviceId, treatmentController, 312 | ByteBuffer.wrap(probePkt.serialize()))); 313 | } 314 | try { 315 | Thread.sleep(probeInterval); 316 | } catch (InterruptedException e) { 317 | break; 318 | } 319 | } 320 | log.info("Probe latency task stopped."); 321 | } 322 | 323 | // Mao: useless now 324 | private void pushFlowrule(DeviceId deviceId) { 325 | 326 | TrafficSelector selector = DefaultTrafficSelector.builder().matchEthType(PROBE_ETHERTYPE).build(); 327 | 328 | TrafficTreatment treatment = DefaultTrafficTreatment.builder() 329 | .setOutput(PortNumber.ALL) 330 | .build(); 331 | 332 | FlowRule flowRule = DefaultFlowRule.builder() 333 | .withSelector(selector) 334 | .withTreatment(treatment) 335 | .forDevice(deviceId) 336 | .forTable(0) 337 | .fromApp(appId) 338 | .withPriority(60000) 339 | .makePermanent() 340 | .build(); 341 | flowRuleService.applyFlowRules(flowRule); 342 | } 343 | } 344 | 345 | private class MaoLinkProbeReceiver implements PacketProcessor { 346 | 347 | @Override 348 | public void process(PacketContext context) { 349 | long now = System.currentTimeMillis(); 350 | 351 | if (context.isHandled()) { 352 | return; 353 | } 354 | 355 | Ethernet pkt = context.inPacket().parsed(); 356 | if (pkt.getEtherType() == PROBE_ETHERTYPE) { 357 | byte[] probePacket = pkt.getPayload().serialize(); 358 | String[] deviceProbe = new String(probePacket).split(PROBE_SPLITER); 359 | 360 | DeviceId probeSrc = DeviceId.deviceId(deviceProbe[0]); 361 | long before = Long.parseLong(deviceProbe[1]); 362 | 363 | if (context.inPacket().receivedFrom().port().equals(PortNumber.CONTROLLER)) { 364 | controlLinkLatencies.put(context.inPacket().receivedFrom().deviceId(), (int) (now - before)); 365 | 366 | } else { 367 | Set links = linkService.getIngressLinks(context.inPacket().receivedFrom()); 368 | if (links.isEmpty()) { 369 | log.warn("link is not exist. {}", context.inPacket().receivedFrom()); 370 | return; 371 | } 372 | 373 | for (Link link : links) { // may >2 in broadcast network. 374 | if (link.src().deviceId().equals(probeSrc)) { 375 | initLinklatencies.put(link, (int) (now - before)); 376 | break; 377 | } 378 | } 379 | } 380 | context.block(); 381 | } 382 | } 383 | } 384 | } 385 | -------------------------------------------------------------------------------- /modules.bzl__available_example: -------------------------------------------------------------------------------- 1 | UTILS = [ 2 | "//utils/osgiwrap:osgi-jar", 3 | "//utils/osgi:onlab-osgi", 4 | "//utils/junit:onlab-junit", 5 | "//utils/misc:onlab-misc", 6 | "//utils/rest:onlab-rest", 7 | ] 8 | 9 | API = [ 10 | "//core/api:onos-api", 11 | ] 12 | 13 | CORE = UTILS + API + [ 14 | "//core/net:onos-core-net", 15 | "//core/common:onos-core-common", 16 | "//core/protobuf/models:onos-core-protobuf-models", 17 | "//core/protobuf/models/proto:onos-core-protobuf-models-proto", 18 | "//core/store/primitives:onos-core-primitives", 19 | "//core/store/serializers:onos-core-serializers", 20 | "//core/store/dist:onos-core-dist", 21 | "//core/store/persistence:onos-core-persistence", 22 | "//cli:onos-cli", 23 | "//drivers/utilities:onos-drivers-utilities", 24 | "//providers/general/device:onos-providers-general-device", 25 | "//web/api:onos-rest", 26 | ] 27 | 28 | FEATURES = [ 29 | "//tools/package/features:onos-thirdparty-base", 30 | "//tools/package/features:onos-thirdparty-web", 31 | "//tools/package/features:onos-api", 32 | "//tools/package/features:onos-core", 33 | "//tools/package/features:onos-cli", 34 | "//tools/package/features:onos-rest", 35 | ] 36 | 37 | # 38 | # ONOS Profile Maps 39 | # 40 | # To include a JAR or app in a specific profile, add the profile name 41 | # to the list in the maps below. If multiple profiles are listed, 42 | # then it will be included in each profile. Every item included in the 43 | # map will be included in the default profile (build with no profile 44 | # specified). 45 | # 46 | 47 | # 48 | # ONOS Protocols and Providers 49 | # 50 | 51 | PROTOCOL_MAP = { 52 | "//protocols/bgp/bgpio:onos-protocols-bgp-bgpio": [], 53 | "//protocols/bgp/api:onos-protocols-bgp-api": [], 54 | "//protocols/bgp/ctl:onos-protocols-bgp-ctl": [], 55 | "//protocols/lisp/api:onos-protocols-lisp-api": [], 56 | "//protocols/lisp/ctl:onos-protocols-lisp-ctl": [], 57 | "//protocols/lisp/msg:onos-protocols-lisp-msg": [], 58 | "//protocols/netconf/api:onos-protocols-netconf-api": [], 59 | "//protocols/netconf/ctl:onos-protocols-netconf-ctl": [], 60 | "//protocols/openflow/api:onos-protocols-openflow-api": ["seba", "sona"], 61 | "//protocols/openflow/ctl:onos-protocols-openflow-ctl": ["seba", "sona"], 62 | "//protocols/ovsdb/rfc:onos-protocols-ovsdb-rfc": ["sona"], 63 | "//protocols/ovsdb/api:onos-protocols-ovsdb-api": ["sona"], 64 | "//protocols/ovsdb/ctl:onos-protocols-ovsdb-ctl": ["sona"], 65 | "//protocols/p4runtime/api:onos-protocols-p4runtime-api": ["stratum"], 66 | "//protocols/p4runtime/model:onos-protocols-p4runtime-model": ["stratum"], 67 | "//protocols/rest/api:onos-protocols-rest-api": ["stratum", "tost"], 68 | "//protocols/rest/ctl:onos-protocols-rest-ctl": ["stratum", "tost"], 69 | "//protocols/restconf/client/api:onos-protocols-restconf-client-api": [], 70 | "//protocols/restconf/client/ctl:onos-protocols-restconf-client-ctl": [], 71 | "//protocols/snmp/api:onos-protocols-snmp-api": [], 72 | "//protocols/snmp/ctl:onos-protocols-snmp-ctl": [], 73 | "//protocols/tl1/api:onos-protocols-tl1-api": [], 74 | "//protocols/tl1/ctl:onos-protocols-tl1-ctl": [], 75 | "//protocols/xmpp/core/api:onos-protocols-xmpp-core-api": [], 76 | "//protocols/xmpp/core/ctl:onos-protocols-xmpp-core-ctl": [], 77 | } 78 | 79 | PROTOCOL_APP_MAP = { 80 | "//protocols/grpc:onos-protocols-grpc-oar": ["stratum", "tost", "sona"], 81 | "//protocols/gnmi:onos-protocols-gnmi-oar": ["stratum", "tost", "sona"], 82 | "//protocols/gnoi:onos-protocols-gnoi-oar": ["stratum", "tost"], 83 | "//protocols/p4runtime:onos-protocols-p4runtime-oar": ["stratum", "tost"], 84 | "//protocols/restconf/server:onos-protocols-restconf-server-oar": [], 85 | "//protocols/xmpp/core:onos-protocols-xmpp-core-oar": [], 86 | "//protocols/xmpp/pubsub:onos-protocols-xmpp-pubsub-oar": [], 87 | } 88 | 89 | PROVIDER_MAP = { 90 | "//providers/netconf/device:onos-providers-netconf-device": [], 91 | "//providers/openflow/device:onos-providers-openflow-device": ["seba", "sona"], 92 | "//providers/openflow/packet:onos-providers-openflow-packet": ["seba", "sona"], 93 | "//providers/openflow/flow:onos-providers-openflow-flow": ["seba", "sona"], 94 | "//providers/openflow/group:onos-providers-openflow-group": ["seba", "sona"], 95 | "//providers/openflow/meter:onos-providers-openflow-meter": ["seba", "sona"], 96 | "//providers/ovsdb/device:onos-providers-ovsdb-device": ["sona"], 97 | "//providers/ovsdb/tunnel:onos-providers-ovsdb-tunnel": ["sona"], 98 | "//providers/p4runtime/packet:onos-providers-p4runtime-packet": ["stratum"], 99 | "//providers/rest/device:onos-providers-rest-device": ["stratum"], 100 | "//providers/snmp/device:onos-providers-snmp-device": [], 101 | "//providers/lisp/device:onos-providers-lisp-device": [], 102 | "//providers/tl1/device:onos-providers-tl1-device": [], 103 | } 104 | 105 | PROVIDER_APP_MAP = { 106 | "//providers/general:onos-providers-general-oar": ["stratum", "tost", "sona"], 107 | "//providers/host:onos-providers-host-oar": ["seba", "stratum", "tost", "sona"], 108 | "//providers/hostprobing:onos-providers-hostprobing-oar": ["seba", "stratum", "tost", "sona"], 109 | "//providers/link:onos-providers-link-oar": ["stratum"], 110 | "//providers/lldp:onos-providers-lldp-oar": ["seba", "stratum", "tost", "sona"], 111 | "//providers/netcfghost:onos-providers-netcfghost-oar": ["seba", "stratum", "tost", "sona"], 112 | "//providers/netcfglinks:onos-providers-netcfglinks-oar": ["stratum"], 113 | "//providers/netconf:onos-providers-netconf-oar": ["stratum", "tost"], 114 | "//providers/null:onos-providers-null-oar": [], 115 | "//providers/openflow/app:onos-providers-openflow-app-oar": ["seba", "sona"], 116 | "//providers/openflow/base:onos-providers-openflow-base-oar": ["seba", "sona"], 117 | "//providers/openflow/message:onos-providers-openflow-message-oar": ["seba", "sona"], 118 | "//providers/ovsdb:onos-providers-ovsdb-oar": ["sona"], 119 | "//providers/ovsdb/host:onos-providers-ovsdb-host-oar": ["sona"], 120 | "//providers/ovsdb/base:onos-providers-ovsdb-base-oar": ["sona"], 121 | "//providers/p4runtime:onos-providers-p4runtime-oar": ["stratum", "tost"], 122 | "//providers/rest:onos-providers-rest-oar": ["stratum", "tost"], 123 | "//providers/snmp:onos-providers-snmp-oar": [], 124 | "//providers/lisp:onos-providers-lisp-oar": [], 125 | "//providers/tl1:onos-providers-tl1-oar": [], 126 | "//providers/xmpp/device:onos-providers-xmpp-device-oar": [], 127 | } 128 | 129 | # 130 | # ONOS Drivers 131 | # 132 | 133 | DRIVER_MAP = { 134 | "//drivers/default:onos-drivers-default-oar": ["minimal", "seba", "stratum", "tost", "sona"], 135 | "//drivers/arista:onos-drivers-arista-oar": [], 136 | "//drivers/bmv2:onos-drivers-bmv2-oar": ["stratum", "tost"], 137 | "//drivers/barefoot:onos-drivers-barefoot-oar": ["stratum", "tost"], 138 | "//drivers/ciena/waveserver:onos-drivers-ciena-waveserver-oar": [], 139 | "//drivers/ciena/c5162:onos-drivers-ciena-c5162-oar": [], 140 | "//drivers/ciena/c5170:onos-drivers-ciena-c5170-oar": [], 141 | "//drivers/ciena/waveserverai:onos-drivers-ciena-waveserverai-oar": [], 142 | "//drivers/cisco/netconf:onos-drivers-cisco-netconf-oar": [], 143 | "//drivers/cisco/rest:onos-drivers-cisco-rest-oar": [], 144 | "//drivers/corsa:onos-drivers-corsa-oar": [], 145 | "//drivers/czechlight:onos-drivers-czechlight-oar": [], 146 | "//drivers/flowspec:onos-drivers-flowspec-oar": [], 147 | "//drivers/fujitsu:onos-drivers-fujitsu-oar": [], 148 | "//drivers/gnmi:onos-drivers-gnmi-oar": ["stratum", "tost", "sona"], 149 | "//drivers/gnoi:onos-drivers-gnoi-oar": ["stratum", "tost"], 150 | "//drivers/hp:onos-drivers-hp-oar": [], 151 | "//drivers/juniper:onos-drivers-juniper-oar": [], 152 | "//drivers/lisp:onos-drivers-lisp-oar": [], 153 | "//drivers/lumentum:onos-drivers-lumentum-oar": [], 154 | "//drivers/mellanox:onos-drivers-mellanox-oar": ["stratum"], 155 | "//drivers/netconf:onos-drivers-netconf-oar": ["stratum", "tost"], 156 | "//drivers/odtn-driver:onos-drivers-odtn-driver-oar": ["stratum", "tost"], 157 | "//drivers/oplink:onos-drivers-oplink-oar": [], 158 | "//drivers/optical:onos-drivers-optical-oar": ["stratum", "tost"], 159 | "//drivers/ovsdb:onos-drivers-ovsdb-oar": ["sona"], 160 | "//drivers/p4runtime:onos-drivers-p4runtime-oar": ["stratum", "tost"], 161 | "//drivers/polatis/netconf:onos-drivers-polatis-netconf-oar": [], 162 | "//drivers/polatis/openflow:onos-drivers-polatis-openflow-oar": [], 163 | "//drivers/server:onos-drivers-server-oar": [], 164 | "//drivers/stratum:onos-drivers-stratum-oar": ["stratum", "tost"], 165 | "//drivers/zte:onos-drivers-zte-oar": [], 166 | } 167 | 168 | # 169 | # ONOS Apps and App API JARs 170 | # 171 | 172 | APP_JAR_MAP = { 173 | "//apps/cpman/api:onos-apps-cpman-api": [], 174 | "//apps/routing-api:onos-apps-routing-api": [], 175 | "//apps/dhcp/api:onos-apps-dhcp-api": [], 176 | "//apps/dhcp/app:onos-apps-dhcp-app": [], 177 | "//apps/imr/api:onos-apps-imr-api": [], 178 | "//apps/imr/app:onos-apps-imr-app": [], 179 | "//apps/dhcprelay/app:onos-apps-dhcprelay-app": [], 180 | "//apps/dhcprelay/web:onos-apps-dhcprelay-web": [], 181 | "//apps/fwd:onos-apps-fwd": [], 182 | "//apps/kafka-integration/api:onos-apps-kafka-integration-api": [], 183 | "//apps/kafka-integration/app:onos-apps-kafka-integration-app": [], 184 | "//apps/routing/common:onos-apps-routing-common": [], 185 | } 186 | 187 | APP_MAP = { 188 | "//apps/acl:onos-apps-acl-oar": [], 189 | "//apps/artemis:onos-apps-artemis-oar": [], 190 | "//apps/bgprouter:onos-apps-bgprouter-oar": [], 191 | "//apps/castor:onos-apps-castor-oar": [], 192 | "//apps/cfm:onos-apps-cfm-oar": [], 193 | "//apps/config:onos-apps-config-oar": ["stratum", "tost"], 194 | "//apps/cord-support:onos-apps-cord-support-oar": [], 195 | "//apps/cpman/app:onos-apps-cpman-app-oar": [], 196 | "//apps/dhcp:onos-apps-dhcp-oar": [], 197 | "//apps/dhcprelay:onos-apps-dhcprelay-oar": ["tost"], 198 | "//apps/drivermatrix:onos-apps-drivermatrix-oar": [], 199 | "//apps/events:onos-apps-events-oar": [], 200 | "//apps/faultmanagement:onos-apps-faultmanagement-oar": ["stratum", "tost"], 201 | "//apps/flowanalyzer:onos-apps-flowanalyzer-oar": [], 202 | "//apps/flowspec-api:onos-apps-flowspec-api-oar": [], 203 | "//apps/fwd:onos-apps-fwd-oar": [], 204 | "//apps/gangliametrics:onos-apps-gangliametrics-oar": [], 205 | "//apps/graphitemetrics:onos-apps-graphitemetrics-oar": [], 206 | "//apps/imr:onos-apps-imr-oar": [], 207 | "//apps/inbandtelemetry:onos-apps-inbandtelemetry-oar": ["tost"], 208 | "//apps/influxdbmetrics:onos-apps-influxdbmetrics-oar": [], 209 | "//apps/intentsync:onos-apps-intentsync-oar": [], 210 | "//apps/k8s-networking:onos-apps-k8s-networking-oar": ["sona"], 211 | "//apps/k8s-node:onos-apps-k8s-node-oar": ["sona"], 212 | "//apps/kafka-integration:onos-apps-kafka-integration-oar": [], 213 | "//apps/layout:onos-apps-layout-oar": [], 214 | "//apps/linkprops:onos-apps-linkprops-oar": [], 215 | "//apps/mappingmanagement:onos-apps-mappingmanagement-oar": [], 216 | "//apps/mcast:onos-apps-mcast-oar": ["seba", "tost"], 217 | "//apps/metrics:onos-apps-metrics-oar": [], 218 | "//apps/mfwd:onos-apps-mfwd-oar": [], 219 | "//apps/mlb:onos-apps-mlb-oar": [], 220 | "//apps/mobility:onos-apps-mobility-oar": [], 221 | "//apps/network-troubleshoot:onos-apps-network-troubleshoot-oar": [], 222 | "//apps/newoptical:onos-apps-newoptical-oar": [], 223 | "//apps/nodemetrics:onos-apps-nodemetrics-oar": [], 224 | "//apps/node-diagnosis:onos-apps-node-diagnosis-oar": [], 225 | "//apps/odtn/api:onos-apps-odtn-api-oar": ["stratum", "tost"], 226 | "//apps/odtn/service:onos-apps-odtn-service-oar": [], 227 | "//apps/ofagent:onos-apps-ofagent-oar": [], 228 | "//apps/onlp-demo:onos-apps-onlp-demo-oar": [], 229 | "//apps/onos-topo:onos-apps-onos-topo-oar": [], 230 | "//apps/openroadm:onos-apps-openroadm-oar": [], 231 | "//apps/openstacknetworking:onos-apps-openstacknetworking-oar": ["sona"], 232 | "//apps/openstacknetworkingui:onos-apps-openstacknetworkingui-oar": ["sona"], 233 | "//apps/openstacknode:onos-apps-openstacknode-oar": ["sona"], 234 | "//apps/openstacktelemetry:onos-apps-openstacktelemetry-oar": ["sona"], 235 | "//apps/openstacktroubleshoot:onos-apps-openstacktroubleshoot-oar": ["sona"], 236 | "//apps/openstackvtap:onos-apps-openstackvtap-oar": ["sona"], 237 | "//apps/optical-model:onos-apps-optical-model-oar": ["seba", "stratum", "tost", "sona"], 238 | "//apps/optical-rest:onos-apps-optical-rest-oar": [], 239 | "//apps/p4-tutorial/mytunnel:onos-apps-p4-tutorial-mytunnel-oar": [], 240 | "//apps/p4-tutorial/pipeconf:onos-apps-p4-tutorial-pipeconf-oar": [], 241 | "//apps/packet-stats:onos-apps-packet-stats-oar": [], 242 | "//apps/packet-throttle:onos-apps-packet-throttle-oar": [], 243 | "//apps/pathpainter:onos-apps-pathpainter-oar": [], 244 | "//apps/pim:onos-apps-pim-oar": [], 245 | "//apps/portloadbalancer:onos-apps-portloadbalancer-oar": ["seba", "tost"], 246 | "//apps/powermanagement:onos-apps-powermanagement-oar": [], 247 | "//apps/proxyarp:onos-apps-proxyarp-oar": [], 248 | "//apps/rabbitmq:onos-apps-rabbitmq-oar": [], 249 | "//apps/reactive-routing:onos-apps-reactive-routing-oar": [], 250 | "//apps/restconf:onos-apps-restconf-oar": [], 251 | "//apps/roadm:onos-apps-roadm-oar": [], 252 | "//apps/route-service:onos-apps-route-service-oar": ["seba", "tost"], 253 | "//apps/routeradvertisement:onos-apps-routeradvertisement-oar": ["tost"], 254 | "//apps/routing/cpr:onos-apps-routing-cpr-oar": [], 255 | "//apps/routing/fibinstaller:onos-apps-routing-fibinstaller-oar": [], 256 | "//apps/routing/fpm:onos-apps-routing-fpm-oar": ["tost"], 257 | "//apps/scalablegateway:onos-apps-scalablegateway-oar": [], 258 | "//apps/sdnip:onos-apps-sdnip-oar": [], 259 | "//apps/simplefabric:onos-apps-simplefabric-oar": [], 260 | "//apps/test/cluster-ha:onos-apps-test-cluster-ha-oar": [], 261 | "//apps/test/demo:onos-apps-test-demo-oar": [], 262 | "//apps/test/distributed-primitives:onos-apps-test-distributed-primitives-oar": [], 263 | "//apps/test/election:onos-apps-test-election-oar": [], 264 | "//apps/test/flow-perf:onos-apps-test-flow-perf-oar": [], 265 | "//apps/test/intent-perf:onos-apps-test-intent-perf-oar": [], 266 | "//apps/test/loadtest:onos-apps-test-loadtest-oar": [], 267 | "//apps/test/messaging-perf:onos-apps-test-messaging-perf-oar": [], 268 | "//apps/test/netcfg-monitor:onos-apps-test-netcfg-monitor-oar": [], 269 | "//apps/test/primitive-perf:onos-apps-test-primitive-perf-oar": [], 270 | "//apps/test/route-scale:onos-apps-test-route-scale-oar": [], 271 | "//apps/test/transaction-perf:onos-apps-test-transaction-perf-oar": [], 272 | "//apps/tunnel:onos-apps-tunnel-oar": ["sona"], 273 | "//apps/virtual:onos-apps-virtual-oar": [], 274 | "//apps/virtualbng:onos-apps-virtualbng-oar": [], 275 | "//apps/vpls:onos-apps-vpls-oar": [], 276 | "//apps/vrouter:onos-apps-vrouter-oar": [], 277 | "//apps/workflow/ofoverlay:onos-apps-workflow-ofoverlay-oar": [], 278 | "//apps/workflow:onos-apps-workflow-oar": [], 279 | "//apps/yang-gui:onos-apps-yang-gui-oar": [], 280 | "//apps/yang:onos-apps-yang-oar": ["stratum", "tost"], 281 | "//web/gui:onos-web-gui-oar": ["sona", "tost"], 282 | "//web/gui2:onos-web-gui2-oar": ["stratum", "tost"], 283 | 284 | "//apps/link-quality-measurement:onos-apps-link-quality-measurement-oar": [], 285 | } 286 | 287 | # 288 | # Pipelines and Models 289 | # 290 | 291 | PIPELINE_MAP = { 292 | "//pipelines/basic:onos-pipelines-basic-oar": ["stratum", "tost"], 293 | "//pipelines/fabric:onos-pipelines-fabric-oar": ["stratum", "tost"], 294 | } 295 | 296 | MODELS_MAP = { 297 | "//models/ietf:onos-models-ietf-oar": ["stratum", "tost"], 298 | "//models/common:onos-models-common-oar": [], 299 | "//models/openconfig:onos-models-openconfig-oar": ["stratum", "tost"], 300 | "//models/openconfig-infinera:onos-models-openconfig-infinera-oar": ["stratum", "tost"], 301 | "//models/openconfig-odtn:onos-models-openconfig-odtn-oar": ["stratum", "tost"], 302 | "//models/openroadm:onos-models-openroadm-oar": [], 303 | "//models/tapi:onos-models-tapi-oar": ["stratum", "tost"], 304 | "//models/polatis:onos-models-polatis-oar": [], 305 | "//models/ciena/waveserverai:onos-models-ciena-waveserverai-oar": [], 306 | } 307 | 308 | # 309 | # Convenience functions for processing profile maps 310 | # 311 | 312 | def filter(map, profile): 313 | all = not bool(profile) or profile == "all" 314 | return [k for k, v in map.items() if all or profile in v] 315 | 316 | def extensions(profile = None): 317 | return filter(PROTOCOL_MAP, profile) + filter(PROVIDER_MAP, profile) 318 | 319 | def apps(profile = None): 320 | return filter(PROTOCOL_APP_MAP, profile) + \ 321 | filter(PROVIDER_APP_MAP, profile) + \ 322 | filter(DRIVER_MAP, profile) + \ 323 | filter(APP_MAP, profile) + \ 324 | filter(APP_JAR_MAP, profile) + \ 325 | filter(PIPELINE_MAP, profile) + \ 326 | filter(MODELS_MAP, profile) 327 | 328 | # 329 | # Instantiate a config_setting for every profile in the list 330 | # 331 | def profiles(profiles): 332 | for p in profiles: 333 | native.config_setting( 334 | name = "%s_profile" % p, 335 | values = {"define": "profile=%s" % p}, 336 | ) 337 | --------------------------------------------------------------------------------