Mininet is a lightweight container orchestration system for network emulation. With Mininet and onos.py
, you can easily start up an ONOS cluster, and a modeled data network for any topology you might like, in a single VM or server. This is usually the most convenient way to create an ONOS development environment on your laptop, and you can be up and running in a matter of minutes (or seconds if you have already built ONOS and have already installed Mininet!)
onos.py
and Mininet?If you are already running Mininet in a VM or on a physical server, it is easy to use onos.py
to start up a complete emulated ONOS network in a single VM - including a ONOS cluster, modeled control network, and data network.
This simplifies development on a laptop, because you can run a single development VM (or no VM at all if you are running on a Linux machine!) Moreover, it is more efficient than a multi-VM setup because the entire emulated network lives in a single VM and shares a single Linux kernel.
Additionally, onos.py
models the control network as well as the data network; you can easily change the number of nodes in your ONOS cluster, as well as things like the delay or bandwidth between nodes in the control network. It's even possible to change the control network topology as well as the data network topology. (We hope to make this more convenient and powerful in the future.)
onos.py
provides a single, unified CLI prompt where you can enter both Mininet and ONOS commands - this can be very convenient! (We call this "One CLI to Rule Them All.")
onos.py
also automatically handles port forwarding, so you can easily connect to the GUI (or to karaf, or to the controllers' OpenFlow ports) by connecting to ports on the VM.
Chances are you're already using Mininet, so it's nice to be able to start an ONOS cluster using Mininet itself without installing or configuring additional software.
onos.py
parametrizes both the control network (ONOS cluster) and the data network; so it's easy to iterate over multiple cluster sizes and network topologies.
We also hope that using onos.py
will make ONOS development easier and more fun.
Getting Mininet
In order to use onos.py
, you need Mininet. It's easy to install Mininet from source in an Ubuntu VM or server:
git clone http://github.com/mininet/mininet
mininet/util/install.sh -nv
You can also download a pre-built Mininet VM.
If you are running Ubuntu 16.04, you can easily install Mininet 2.2 using apt-get
:
apt-get install mininet
onos.py
and MininetONOS |
First, make sure that you have built ONOS in your Mininet VM or server using buck
:
cd ~/onos
buck build onos
Next, use Mininet and onos.py
to start up a virtual ONOS cluster and data network:
cd ~/onos/tools/dev/mininet
sudo mn --custom onos.py --controller onos,3 --topo torus,4,4
You should see a bunch of output showing the startup of the control network and the data network.
After ONOS starts up and the switches connect, you should see the customized mininet CLI prompt:
mininet-onos>
At this point, you can enter mininet commands like pingall
(all-to-all ping test) and help
(find out about Mininet CLI commands.)
You can also enter ONOS commands like onos:apps
or onos:balance-masters
and they should be invoked via karaf's client
command on onos1
.
You can also invoke the ONOS client using the onos
command - press control-D
to exit.
To exit Mininet, use the exit
command or press control-D
.
If things don't start up correctly, look carefully at any error messages or exceptions which may have been generated - usually they give you important information which will enable you to figure out what is going wrong and to fix the issue. Also check out the troubleshooting section below. |
mn
command line options do?--custom onos.py
: uses onos.py
to extend Mininet with new controller and switch types as well as a customized CLI
--controller onos,3
: tells Mininet to start up an ONOS controller cluster with 3 ONOS nodes
--topo torus,4,4
: tells Mininet to use a 4x4 torus topology for the data network
By default, it uses Open vSwitch. onos.py replaces the default
switch with a new switch class called ONOSOVSSwitch
or --switch onosovs
. This switch class knows how to connect to an ONOS cluster with multiple IP addresses.
In order to select the user switch (either Stanford reference switch or CPqD switch, depending on which one you have installed), you can use --switch onosuser
.
mn
command, writing Mininet scripts, etc.?There are lots of things you can do with Mininet, including customizing your data network topology, setting link parameters, etc..
For more information on Mininet, please check out http://docs.mininet.org
For now, try using ONOS_APPS
or connecting to the karaf
console and using ONOS CLI commands. As root:
ONOS_APPS=drivers,openflow,fwd,proxyarp,mobility mn --custom onos.py --controller onos,3 --topo tree,3,3
or (with sudo
):
sudo env ONOS_APPS=drivers,openflow,fwd,proxyarp,mobility mn --custom onos.py --controller onos,3 --topo tree,3,3
or
ONOS_APPS=drivers,openflow,fwd,proxyarp,mobility sudo -E mn --custom onos.py --controller onos,3 --topo tree,3,3
Note that sudo
clears environment variables by default, but the ONOS_APPS
environment variable must be set in order for mn
to read it.
In the future, there should be an option to --controller onos
and/or ONOSCluster()
.
--controller onos
and ONOSCluster()
take an ipBase
option; the default is 192.168.123.0/24
You can change it by passing in a new option to mn
or to ONOSCluster()
:
sudo mn --custom onos.py --controller onos,3,ipBase=172.1.2.0/24 --topo tree,3,3
mininet-onos>
prompt?mininet-onos> onos
press control-D
to return to the mininet-onos>
prompt.
There are several ways of doing it - you can use the one which works best for you. Here are four equivalent ways of invoking the onos:apps
command:
mininet-onos> onos:apps
mininet-onos> onos :apps
mininet-onos> onos onos:apps
mininet-onos> onos1 client onos:apps
The first two methods can be used for executing any commands that begin with "onos:
".
The last two methods can be used to execute any karaf command.
The final method can be used to run client on a specific ONOS instance (and connect to that instance.)
Make sure karaf's bin/
directory is in your path, then:
client -h 192.168.123.1 # or the address of the ONOS node you wish to connect to
ssh
?ssh -p 8101 karaf@192.168.123.1
In this example, 8101
is the karaf port, and 192.168.123.1
is the IP address of onos1
.
Note that this is using ssh
inside the Mininet VM itself - from another machine, you should use the VM's IP address and the appropriate forwarded port as described below.
By default, onos.py
automatically forwards connections to the Mininet VM/server to the appropriate ONOS instance.
Service | VM port to connect to |
---|---|
GUI/REST | 8181 (onos1 ), 8182 (onos2 ) ... |
Karaf via ssh | 8101 (onos1 ), 8102 (onos2 ) ... |
OpenFlow | 6653 (onos1 ), 6654 (onos2 ) ... |
So if you are using a VM whose IP address is 192.168.x.y
, to connect to the GUI on ONOS1, you would use the URL http://192.168.x.y:8181/onos/ui/
You need to use the real, correct IP address for your VM - the address |
onos.py
to control an external hardware (or virtual) network?Yes you can! Simply use --topo none
; for example,
mn --custom onos.py --controller onos,3 --topo none
onos.py
will forward the ports (e.g. 6653, 6654, 6655) appropriately as described above.