ONOS === ### APP Development Tutorial https://url.fit/Z0Q5t nosignal (nosignal@g2.nctu.edu.tw) ONOS/CORD Taiwan workshop 2017 --- ## For this slide, all the development will be happended at MacOSX --- ## Outline - Envirument Setup - Create your first ONOS app - Write a simple app handling ping --- ## Envirument Setup ---- ## Development tools :::info Git Java8 Maven 3.3.9 Buck IntelliJ IDEA CE ONOS source code ::: ---- ## Install Java Download JDK8 from official website ![JDK8](https://i.imgur.com/69WNH3T.png) ---- ## Install Maven ```shell= cd; mkdir Downloads Applications cd Downloads wget http://archive.apache.org/dist/maven/maven-3/3.3.9/binaries/apache-maven-3.3.9-bin.tar.gz tar -zxvf apache-maven-3.3.9-bin.tar.gz -C ../Applications/ ``` ---- ## Do not need to install Buck Buck will be downloaded once you download onos source ---- ## Install IntelliJ IDEA CE Download IntelliJ Commuity from official website ![IntelliJ](https://i.imgur.com/pKEfKNS.png) ---- ## Setup env with ONOS source ```shell= # Download source code cd; git clone https://github.com/opennetworkinglab/onos.git # Execute command or put these info your .bash_profile export JAVA_HOME=$(/usr/libexec/java_home -v 1.8) export ONOS_ROOT="/Users/$USER/onos" source $ONOS_ROOT/tools/dev/bash_profile # Execute .bash_profile if you put the above commands . ~/.bash_profile ``` ---- ### Import setting from ONOS source ![import setting](https://i.imgur.com/RUui1bK.png) ---- Path: $ONOS_ROOT/tools/dev/idea-setting.jar ![select setting](https://i.imgur.com/9iGpHxZ.png) --- ## Create your first ONOS app ---- ## Pre-create ```shell= # Publish the artifacts to local repository in ~/.m2 cd $ONOS_ROOT onos-buck-publish-local # Generate the onos-archetypes cd $ONOS_ROOT/tools/package/archetypes mvn clean install # Create ONOS app cd ~/ onos-create-app ``` ---- ## Fill-in app info ![create app](https://i.imgur.com/3Z3yECl.png) ---- ## Modify pom.xml ```shell= cd sdnds-app; vim pom.xml ``` ![vim pom.xml](https://i.imgur.com/vByQkqi.png) ---- ### Import your app project to IntelliJ Path: sdnds-app/pom.xml ![import path](https://i.imgur.com/SCdBc2K.png) ---- ## Next ![next](https://i.imgur.com/81tsaN5.png) ---- ## Next ![snapshot next](https://i.imgur.com/IdmEC6S.png) ---- ## select 1.8 ![jdk1.8](https://i.imgur.com/wAZUTne.png) ---- ## Finish ![finish](https://i.imgur.com/K1Imu9S.png) --- ### Write a simple app handling ping ---- ## A fresh app ![fresh app](https://i.imgur.com/sjYAX8y.png) ---- ## Going to do - active org.onosproject.proxyarp - make all hosts in mininet ping to others ---- ## Before getting into this :::info - CoreService - DeviceService - FlowRuleService - FlowObjectiveService ::: ---- ## CoreService *Provide registeration for app* - Functions - registerApplication - getAppId - ... ---- ## DeviceService *Discovering and tracking the devices* - Functions - addListener - removeListener - getAvailableDevices - ... - DeviceEvent - DEVICE_ADDED - DEVICE_UPDATED - DEVICE_REMOVED - ... ---- ## FlowRuleService *Managing ONOS flows* - Functions - removeFlowRulesById - ... - Flow states - PENDING_ADD - ADDED - PENDING_REMOVE - REMOVED - FAILED ---- ## FlowObjectiveService *Abstraction for data-plane flows* *Pipeline unaware for application* - Functions - forwardingObjective - DefaultForwardingObjective - ... ---- ## FlowObjective sample ```javascript= ForwardingObjective forwardingObjective = DefaultForwardingObjective.builder() .withSelector(selectorBuilder) .withTreatment(treatment) .withPriority(DEFAULT_PRIORITY) .withFlag(ForwardingObjective.Flag.VERSATILE) .fromApp(appId) .makePermanent() .add(); ``` ---- ## TrafficSelector What you expect ```javascript= TrafficSelector selectorBuilder = DefaultTrafficSelector.builder() .matchEthType(EthType.EtherType.IPV4.ethType().toShort()) .matchIPProtocol(IPv4.PROTOCOL_ICMP) .build(); ``` ---- ## TrafficTreatment What you want to do ```javascript= TrafficTreatment treatment = DefaultTrafficTreatment.builder() .setOutput(out_port) .build(); ``` ---- ### Build and install to a running ONOS ```shell= # Compile source code without test cd ~/sdnds-app mvn clean install -DskipTests # Install app to a running ONOS onos-app localhost install target/sdnds-app-1.9.0.oar # Only if reinstall needed onos-app localhost reinstall tw.sdnds.app target/sdnds-app-1.9.0.oar ``` --- ## Demo for ping app --- ## Time for you to write ONOS app all by yourself ---- ## Register an account at gitlab https://gitlab.sdn.nctu.edu.tw ---- ## Open a private project Project name: *workshop2017* ---- ## git push Try to push your app to gitlab by skills you learn from PeterDaveHello's slide: https://goo.gl/g8W7TV ---- ## Try to let host can full connect to each others https://url.fit/ZbJEK ---- ## Questions about writing app You can also write issue about the problem you face on your app --- ## Q&A --- ## Thank You!! ###### tags: `APP` `ONOS` `SDN`
{"metaMigratedAt":"2023-06-14T12:52:33.031Z","metaMigratedFrom":"Content","title":"ONOS","breaks":true,"contributors":"[]"}
    2390 views