1 of 38

for ONOS 1.5.0 (Falcon)

ONOS Distributed Tutorial

#ONOSProject

2 of 38

ONOS Tutorial Sessions

  • Overview & Setup
    • ONOS overview, description of BYON app
    • run-time environment & development setup, initial app deployment
  • Controlling network via intents
    • enhance NetworkManager to use IntentService to control connectivity
    • implement a CLI command
  • Distributed store component
    • implement DistributedNetworkStore component
  • Events & Monitoring
    • enhance core components for event dispatching
    • implement NetworkMonitor component to intercept events

#ONOSProject

3 of 38

ONOS Architecture Tenets

  • High-availability, scalability and performance
    • required to sustain demands of service provider & enterprise networks
  • Strong abstractions and simplicity
    • required for development of apps and solutions
  • Protocol and device behaviour independence
    • avoid contouring and deformation due to protocol specifics
  • Separation of concerns and modularity
    • allow tailoring and customization without speciating the code-base

#ONOSProject

4 of 38

ONOS Distributed Architecture

NB Core API

Distributed Core

(state management, notifications, high-availability & scale-out)

SB Core API

Protocols

Providers

Protocols

Providers

Protocols

Providers

Protocols

Providers

Apps

Apps

#ONOSProject

5 of 38

ONOS Distributed Architecture

NB Core API

Distributed Core

(state management, notifications, high-availability & scale-out)

SB Core API

Protocols

Providers

Protocols

Providers

Protocols

Providers

Protocols

Providers

Apps

Apps

Distributed Core

(state management, notifications, high-availability & scale-out)

SB Core API

NB Core API

Providers

Providers

Providers

Providers

Protocols

Protocols

Protocols

Protocols

#ONOSProject

6 of 38

ONOS Core Subsystems

Device

Link

Host

Topology

Flow Rule

Path

Packet

Statistics

Intent

Application

Leadership

Messaging

Storage

Region

Mastership

Driver

Group

Security

Flow Objective

Event

OpenFlow

NetConf

OVSDB

Core

Cluster

. . .

Proxy ARP

Mobility

L2 Forwarding

REST API

GUI

CLI

Network Cfg.

SDN IP / BGP

Packet / Optical

Tunnel

. . .

OSGi / Apache Karaf

Network Virt.

Device Cfg.

Config

UI Extension

External Apps

Graph

Discovery

Tenant

. . .

#ONOSProject

7 of 38

ONOS Core Subsystem Structure

Manager

Component

Manager

Component

Provider

Component

Provider

Component

App

Component

Listener

notify

command

command

sync & persist

add & remove

query &

command

App

Component

Provider

Component

Manager

Component

Manager

Component

ProviderRegistry

Provider

ProviderService

Service

AdminService

Listener

notify

register & unregister

command

command

sensing

add & remove

query &

command

Protocols

Store Store

Provider

Component

ProviderRegistry

Provider

ProviderService

register & unregister

sensing

Protocols

Service

AdminService

Store Store

sync & persist

ProviderRegistry

ProviderRegistry

Provider

Provider

ProviderService

ProviderService

AdminService

AdminService

Service

Service

Listener

Listener

#ONOSProject

8 of 38

ONOS Applications & OSGi

multi-bundle app

simple app

multi-feature & multi-bundle app

bundle

bundle

bundle

bundle

bundle

feature.xml

features.xml

bundle

bundle

features.xml

features.xml

bundle

.oar

.oar

.oar

app.xml

app.xml

app.xml

#ONOSProject

9 of 38

ONOS Applications

  • Application as a mere Component
    • offers no API, self-contained, e.g. reactive forwarding, proxy ARP
    • generally interacts only with the network environment
  • Application with Service Interface
    • offers API; for other Apps, CLI, REST or GUI
    • interacts with network environment, but also other software entities (hence API)
  • Application ignited as “service component”
    • “singleton”, with activate/deactivate/modify methods
    • ignited by OSGi service component run-time (SCR)
    • dependencies on other services auto-wired by OSGi SCR
  • Applications may have their own state; use Store pattern
    • delegates responsibility for tracking state to a separate component

#ONOSProject

10 of 38

OSGi Bundles & Karaf Features

  • OSGi bundles are Java JAR files with an enhanced Manifest
    • bundles have name and version
    • bundles explicitly require/import other Java packages
    • bundles explicit provide/export Java packages for others
  • Karaf features are means to install or uninstall a set of bundles as a group
    • features are defined via an XML artifact - a feature repository
    • feature references, but does not deliver the bundle JAR artifacts
  • Karaf uses Maven repos as OSGi Bundle Repositories for retrieval of feature and bundle artifacts

#ONOSProject

11 of 38

Service Component Runtime

  • Components are effectively stateful singletons whose life-cycle is controlled by the framework
    • components defined by OSGI-INF/*.xml files at run-time
    • ONOS uses maven-scr-plugin to convert Java annotations to OSGI-INF/*.xml files at compile-time
  • Components can provide @Services to others
  • Components can @Reference services from others
  • @Activate, @Modified and @Deactivate methods serve as component life-cycle hooks

#ONOSProject

12 of 38

Bundle & Feature Shell Commands

  • Bundle related commands

onos> bundle:*

  • Feature related commands

onos> feature:*

  • Service Component Runtime related commands

onos> scr:*

#ONOSProject

13 of 38

Developing ONOS apps

  • Maven archetypes
    • onos-api-archetype - basis for a app Java API bundle
    • onos-bundle-archetype - basis for an ONOS bundle or an app
    • onos-cli-archetype - overlay for apps with CLI extensions
    • onos-ui-archetype - overlay for apps with GUI extensions
    • onos-uitab-archetype - overlay for apps with GUI table views
    • onos-uitopo-archetype - overlay for apps with GUI topo overlays
  • Run mvn archetype:generate to create a working minimal project module
  • For simpler usage run onos-create-app shell tool

#ONOSProject

14 of 38

Bundles, Features & ONOS Apps

  • Apps are delivered via ONOS App aRchive (.oar) files
    • OAR is a JAR with app.xml, features.xml and bundle artifacts
    • onos-maven-plugin generates an *.oar file as part of Maven build
  • Apps are managed on the entire ONOS cluster
    • via REST API: GET|POST|DELETE /onos/v1/applications
    • via shell tool: onos-app {install|activate|deactivate|uninstall}
    • via CLI: onos:app {install|activate|deactivate|uninstall}
    • via GUI
  • Back-end installation and activation is done via normal feature & bundle services

#ONOSProject

15 of 38

BYON Application

  • BYON is a service which allows you to spawn virtual networks
    • All hosts in the virtual networks are interconnected through a full mesh
  • Each virtual network contains a full mesh of the hosts within it
  • BYON allows users to interact with it through CLI commands
    • In particular, list-networks is a CLI command that you will use in this part
    • Other available CLI commands are:
      • create-network - provided
      • add-host - provided
      • remove-host - to be implemented
      • remove-network - to be implemented

#ONOSProject

16 of 38

BYON Application Example

s1

s2

s3

h2

h1

h3

h4

Physical

h2

h1

h3

h4

h2

h1

h3

h4

Network #2

Network #1

#ONOSProject

17 of 38

BYON App Structure

Manager

Component

Manager

Component

NetworkMonitor

Component

Listener

notify

register app id

sync & persist

NetworkMonitor

Component

NetworkManager

Component

NetworkManager

Component

Provider

Service

Listener

notify

register app id

Store Store

Provider

Service

NetworkStore NetworkStore

sync & persist

CoreService

CoreService

NeworkService

NetworkService

NetworkListener

NetworkListener

submit & withdraw intents

Provider

submit & withdraw intents

Provider

IntentService

IntentService

#ONOSProject

18 of 38

Environment Overview

Container

(LXC)

onos1

10.0.3.101

Container

(LXC)

onos2

10.0.3.102

Container

(LXC)

onos3

10.0.3.103

Mininet Network

Amazon EC2 VM

VPN

Development on VM

(VirtualBox)

or

Native Development

(Mac or Linux)

Developer Laptop

192.168.42.1

#ONOSProject

19 of 38

Environment Setup (Laptop)

Development on VM (easiest)

  • Install VirtualBox
  • Import VM to VirtualBox
  • User: onos / Password: onos

Native Development (Mac or Linux)

  • Install IntelliJ (or Eclipse)
  • Install Oracle JDK 8
  • Install apache-maven
  • Install apache-karaf
  • Install curl
  • git clone https://gerrit.onosproject.org/onos
  • Set up the ONOS bash_profile
  • Build onos
  • git clone https://github.com/bocon13/onos-byon

#ONOSProject

20 of 38

Download Links

  • These slides: http://tinyurl.com/onos-tutorial
  • IntelliJ IDEA:

https://www.jetbrains.com/idea/download/

  • Eclipse:

https://eclipse.org/downloads/

https://karaf.apache.org/index/community/download.html

  • cURL (available via brew):

http://curl.haxx.se/download.html

#ONOSProject

21 of 38

Environment Setup (VPN to EC2)

Mac

  • Choose Apple menu (top left corner) > System Preferences, then click Network
  • Click Add (+) at the bottom of the network connection services list, then choose VPN from the Interface pop-up menu. Enter password in Authentication Settings...
  • Click Connect

Windows

  • Right-click the network icon in the system tray and select Open Network and Sharing Center
  • Click Set up a new connection or network
  • On the wizard, select Connect to a workplace, and click Next
  • Select Use my internet connection (VPN)
  • Enter user and password, then Connect

(Windows only) To disable default gateway: (Note: this must be done before connecting)

  • Open the Network Connections window
  • Right-click the VPN connection > Properties, then click the Networking tab, then TCP/IPv4
  • Click the "Advanced..." button, and uncheck Use default gateway on remote network
  • Click OK three times

Server Address: <provided on request> Test by ping 10.0.3.101

VPN Type: PPTP User: onos Password: onos Encryption: 128 bit

#ONOSProject

22 of 38

Tutorial Cell Setup

  • Import the cell

$ cell tutorial

#ONOSProject

23 of 38

Lab Sections

  • Lab #1: Basics
    • build skeletal app with a few provided files; build deploy app and test via CLI
  • Lab #2: Core manager component
    • implement NetworkService methods; build, deploy, test
  • Lab #3: Add intents
    • implement addHost to submit intents; build, deploy, test
  • Lab #4: Remove intents
    • implement removeHost to withdraw intents
    • implement remove-host CLI command; build, deploy, test
  • Lab #5: Distributed store component
    • implement NetworkStore using ConsistentMap primitive; build, deploy, test
  • Lab #6: Events & Monitor
    • enhance NetworkStore and NetworkManager to propagate NetworkEvents
    • implement NetworkMonitor component to log events

#ONOSProject

24 of 38

Lab #1: Import & Build BYON App

  • Follow Lab #1 of the Distributed Tutorial on the ONOS Wiki

https://goo.gl/5ezwoI

#ONOSProject

25 of 38

Lab #1: Recap

  • Imported the BYON project into IDE
  • Built app via mvn
  • Deployed app via onos-app command
  • Verified functionality via list-networks CLI command

#ONOSProject

26 of 38

Lab #2: Network Manager & Store

  • Follow Lab #2 of the Distributed Tutorial on the ONOS Wiki

https://goo.gl/0SQkPO

$ ssh onos@$OCN

$ ./start-net.sh

#ONOSProject

27 of 38

Lab #2: Recap

  • Referenced NetworkStore component via @Reference
  • Implemented NetworkManager methods to use NetworkStore functionality
  • Built & re-deployed the app
  • Verified that network data is correctly tracked

#ONOSProject

28 of 38

Lab #3: Adding Intents

  • Follow Lab #3 of the Distributed Tutorial on the ONOS Wiki

https://goo.gl/Xhe5SE

#ONOSProject

29 of 38

Lab #3: Recap

  • Referenced IntentService component via @Reference
  • Enhanced NetworkManager addHost method to create and submit required HostToHostIntents
  • Built & re-deployed the app
  • Verified that intent is properly installed
  • Verified that connectivity is established between hosts

#ONOSProject

30 of 38

LUNCH!

#ONOSProject

31 of 38

Lab #4: Removing Intents

  • Follow Lab #4 of the Distributed Tutorial on the ONOS Wiki

https://goo.gl/ZIjQlU

#ONOSProject

32 of 38

Lab #4: Recap

  • Enhanced NetworkManager removeHost method to withdraw all required HostToHostIntents
  • Enhanced NetworkManager removeNetwork method to withdraw all required HostToHostIntents
  • Implemented and registered CLI commands
  • Built & re-deployed the app
  • Verified that intent is properly withdrawn
  • Verified that connectivity is severed between hosts

#ONOSProject

33 of 38

Lab #5: Distributed Store

  • Follow Lab #5 of the Distributed Tutorial on the ONOS Wiki

https://goo.gl/wx10vS

#ONOSProject

34 of 38

Lab #5: Recap

  • Enhanced DistributedNetworkStore to use ONOS ConsistentMap distributed primitive
  • Built & re-deployed the app
  • Verified that intent is properly distributed to other ONOS instances in the cluster

#ONOSProject

35 of 38

Lab #6: Event Notifications

  • Follow Lab #6 of the Distributed Tutorial on the ONOS Wiki

https://goo.gl/omi8tz

#ONOSProject

36 of 38

Lab #6: Recap

  • Defined NetworkEvent and NetworkStoreDelegate
  • Enhanced DistributedNetworkStore to delegate events to NetworkManager component
  • Enhanced NetworkManager to notify event listeners
  • Created NetworkMonitor component as event listener
  • Built & re-deployed the app
  • Verified that listeners are notified about network events

#ONOSProject

37 of 38

ONOS Tutorial Recap

  • Imported project into IDE
  • Used mvn to build and onos-app to deploy app
  • Used @Reference to get reference to other components
  • Controlled connectivity between hosts via IntentService
  • Created a distributed store using ConsistentMap primitive
  • Implemented CLI commands
  • Created asynchronous event notification mechanism
  • Implemented a component as a NetworkEventListener

#ONOSProject

38 of 38

Wrap-Up

  • Browse ONOS Wiki

https://wiki.onosproject.org/

  • Watch ONOS how-to screencasts on YouTube

https://goo.gl/8Druv0

  • Browse ONOS Java API

http://api.onosproject.org/

  • Join ONOS onos-dev@onosproject.org mailing list

https://wiki.onosproject.org/display/ONOS/ONOS+Mailing+Lists

  • Engage with ONOS developers & community

#ONOSProject