Introduction

In the previous post, Install Mininet and Ryu Controller, the software defined networking (SDN) controller is Ryu. It makes it easy for developers to create network management, control application, and prototyping. However, if you want to deploy SDN in a realistic network environment, it's better to use ONOS and OpenDayLight since they have better support for legacy network, a distributed model for the controller, very good modularity, and GUI. A complete comparison of SDN controllers can be found in Controller selection in software defined networks using best-worst multi-criteria decision-making. This post demonstrates how to build a ONOS controller and connects the it to Mininet.

Environments

I'm running a Ubuntu VM with base memory 65536 MB and virtual disk image (VDI) 100 GB in VitrualBox. Mininet is installed with the following command:
$ sudo apt-get install mininet
Their versions are:
  1. VirtualBox Version 6.0.18 r136238 (Qt5.6.2)
  2. Ubuntu 18.04.4 LTS
  3. Mininet 2.2.2

Building ONOS

First, get bridge-utils for LinuxBridge.
$ sudo apt-get install bridge-utils

Installing Bazel on Ubuntu

ONOS is built with Bazel. Follow the instructions here, add Bazel distribution URL as a package source.
$ sudo apt install curl gnupg
$ curl https://bazel.build/bazel-release.pub.gpg | sudo apt-key add -
$ echo "deb [arch=amd64] https://storage.googleapis.com/bazel-apt stable jdk1.8" | sudo tee /etc/apt/sources.list.d/bazel.list
Install and update Bazel. Noted that I have to specify the Bazel version as 3.0.0 otherwise there would be errors when building ONOS.
$ sudo apt-get update && sudo apt-get install bazel-3.0.0
Install a JDK.
$ sudo apt-get install openjdk-11-jdk

Build ONOS from source

  1. Clone the code from the ONOS repository. I've also forked a fixed version of the repository here.
    $ git clone https://gerrit.onosproject.org/onos
  2. Add the ONOS developer environment to the bash profile.
    $ cd onos
    $ cat << EOF >> ~/.bash_profile
    export ONOS_ROOT="`pwd`"
    source $ONOS_ROOT/tools/dev/bash_profile
    EOF
    $ . ~/.bash_profile
  3. Build ONOS.
    $ ./tools/build/onos-build build onos
    (omitting outputs ...)
    INFO: Elapsed time: 2699.299s, Critical Path: 111.21s
    INFO: 2490 processes: 2111 linux-sandbox, 2 local, 377 worker.
    INFO: Build completed successfully, 2654 total actions

Running ONOS with onos.py (Failed!)

Originally, I was following the steps in Mininet and onos.py workflow. However, as I came to Running ONOS with onos.py, it kept popping out error messages.
$ cd ~/onos/tools/dev/mininet
$ sudo mn --custom onos.py --controller onos,1 --topo tree,2,2
*** ONOS startup errors:
<<2020-07-20T15:35:47,573 | ERROR | SCR Component Actor | onos-core-primitives             | 195 - org.onosproject.onos-core-primitives - 2.5.0.SNAPSHOT | bundle org.onosproject.onos-core-primitives:2.5.0.SNAPSHOT (195)[org.onosproject.store.atomix.impl.AtomixManager(66)] : The activate method has thrown an exception
2020-07-20T15:35:47,652 | ERROR | FelixDispatchQueue | FrameworkEvent                   | 195 - 
(omitting outputs ...)
The full error message can be found here. After surveying on this error messages on these discussions:
  1. Getting Errors, running ONOS using onos.py and Mininet
  2. ONOS Developers › Forming a cluster using onos.py
  3. bug 7773 fixed
I still could not resolve the issues. As a result, I go for another option.

Running ONOS and Mininet separately (Succeeded!)

  1. Run ONOS locally on the development machine inside onos folder:
    $ bazel run onos-local clean debug
    (omitting outputs ...)
    Updated node 127.0.0.1 state to READY
  2. In another terminal, open ONOS CLI window and activate OpenFlow provider suite and reactive forwarding app.
    $ ./tools/test/bin/onos localhost
    Welcome to Open Network Operating System (ONOS)!
         ____  _  ______  ____     
        / __ \/ |/ / __ \/ __/   
       / /_/ /    / /_/ /\ \     
       \____/_/|_/\____/___/     
                                   
    Documentation: wiki.onosproject.org      
    Tutorials:     tutorials.onosproject.org 
    Mailing lists: lists.onosproject.org     
    
    Come help out! Find out how at: contribute.onosproject.org 
    
    Hit '<tab>' for a list of available commands
    and '[cmd] --help' for help on a specific command.
    Hit '<ctrl-d>' or type 'logout' to exit ONOS session.
    
    ubuntu@root > app activate org.onosproject.openflow                     17:11:16
    Activated org.onosproject.openflow
    ubuntu@root > app activate org.onosproject.fwd                          17:11:52
    Activated org.onosproject.fwd
  3. In another terminal, start Mininet and pingall devices.
    $ sudo mn --controller remote,ip=127.0.0.1 --topo torus,3,3
    *** Creating network
    *** Adding controller
    Connecting to remote controller at 127.0.0.1:6653
    *** Adding hosts:
    h1x1 h1x2 h1x3 h2x1 h2x2 h2x3 h3x1 h3x2 h3x3 
    *** Adding switches:
    s1x1 s1x2 s1x3 s2x1 s2x2 s2x3 s3x1 s3x2 s3x3 
    *** Adding links:
    (h1x1, s1x1) (h1x2, s1x2) (h1x3, s1x3) (h2x1, s2x1) (h2x2, s2x2) (h2x3, s2x3) (h3x1, s3x1) (h3x2, s3x2) (h3x3, s3x3) (s1x1, s1x2) (s1x1, s2x1) (s1x2, s1x3) (s1x2, s2x2) (s1x3, s1x1) (s1x3, s2x3) (s2x1, s2x2) (s2x1, s3x1) (s2x2, s2x3) (s2x2, s3x2) (s2x3, s2x1) (s2x3, s3x3) (s3x1, s1x1) (s3x1, s3x2) (s3x2, s1x2) (s3x2, s3x3) (s3x3, s1x3) (s3x3, s3x1) 
    *** Configuring hosts
    h1x1 h1x2 h1x3 h2x1 h2x2 h2x3 h3x1 h3x2 h3x3 
    *** Starting controller
    c0 
    *** Starting 9 switches
    s1x1 s1x2 s1x3 s2x1 s2x2 s2x3 s3x1 s3x2 s3x3 ...
    *** Starting CLI:
    mininet> pingall
    *** Ping: testing ping reachability
    h1x1 -> h1x2 h1x3 h2x1 h2x2 h2x3 h3x1 h3x2 h3x3 
    h1x2 -> h1x1 h1x3 h2x1 h2x2 h2x3 h3x1 h3x2 h3x3 
    h1x3 -> h1x1 h1x2 h2x1 h2x2 h2x3 h3x1 h3x2 h3x3 
    h2x1 -> h1x1 h1x2 h1x3 h2x2 h2x3 h3x1 h3x2 h3x3 
    h2x2 -> h1x1 h1x2 h1x3 h2x1 h2x3 h3x1 h3x2 h3x3 
    h2x3 -> h1x1 h1x2 h1x3 h2x1 h2x2 h3x1 h3x2 h3x3 
    h3x1 -> h1x1 h1x2 h1x3 h2x1 h2x2 h2x3 h3x2 h3x3 
    h3x2 -> h1x1 h1x2 h1x3 h2x1 h2x2 h2x3 h3x1 h3x3 
    h3x3 -> h1x1 h1x2 h1x3 h2x1 h2x2 h2x3 h3x1 h3x2 
    *** Results: 0% dropped (72/72 received)
    mininet> 

Now, access ONOS GUI use http://localhost:8181/onos/ui.

Login ONOS GUI

The default username and password are karaf.

ONOS topology viewer

Conclusion

After setting up ONOS controller with Mininet, we can start to develop network mangement and control application on top of this environment. As the next step, I'm planning to integrate Snort as an intrusion detection system (IDS) to conduct packet checking on network devices inside Mininet.

History

Reference

  1. Mininet
  2. ONOS