Select Page

I often find myself working on many different projects that have different scopes and the need for different development environments. It can be quite a pain to have all the development software installed on your workstation only to find out that you have a software conflict or you need to install new software that doesn’t function on your preferred operating system. Compounded by possibly needing to have your development workspace on both your workstation and your laptop, it can get quite hairy. Developing using OpenFlow is no different and considering that most of the software used in OF development require Linux and don’t work properly on Windows, it might be a good idea to virtualize your workspace.

For me personally, I use Ubuntu as my primary OS and, thankfully, don’t need to use Windows-only applications on a daily basis. But this is not true for many developers out there who need to use Windows either for corporate policy or they just simply prefer it. Others prefer the simplicity of Macs, but still need a real Linux environment for development.

In this article, I’ll provide instructions on setting up your Virtual Workspace for OpenFlow development with Ryu and Mininet. By the end, you should have a portable VM that you can expand as you further learn and develop your controller applications. Further articles will also assume that you have a workspace based on Ubuntu 16.04 LTS and software installed in the same way as illustrated here, though you won’t technically have to have it in a VM if you already use this on your host directly.

If you already have an Ubuntu 16.04 environment or want to skip the steps for creating the virtual machine, either collapse the sections below or skip ahead to Installing Mininet and Open vSwitch.

Hypervisor (Physical Workstation) Requirements

In order to make sure enough resources are allocated to both your VM and the Host that the VM runs on, it is import to make sure your workstation has an ample amount of resources. Here are the requirements for this track:

Minimal Requirements
  • VirtualBox 4.3 or equivalent
  • 64-bit, 4 CPU cores or 8 HTs with hardware virtualization support
  • 8GB RAM
  • 100GB free disk space
  • VirtualBox 5.1 or equivalent
  • 64-bit, 8 CPU cores or 16 HTs with hardware virtualization support
  • 16GB RAM
  • 200GB free disk space

For reference, I use a modest home-built workstation with an AMD FX-8320 8-core CPU with 32GB RAM and a 1TB HDD running Ubuntu 14.04 LTS. Any modern workstation should more than match these requirements. If you are looking for a lower cost solution than a computer built as a workstation, I recommend getting a decent gaming rig without the high-end graphics card. For normal development, these PCs are more than adequate, are generally very stable when not overclocked, and are designed with maximum cooling in mind. Just make sure the RAM requirements are met. There is no need to invest more than $700-$800 on a base development workstation. As a plus side, the motherboards used in gaming rigs often contain an extra PCIe x16 slot that can be used for a multi-port network card down the road if you choose to emulate or test hardware switches.

The second thing to note is that the total RAM used by your running VMs should always be at least 4GB less than your host’s RAM. This ensures that the hypervisor OS (Linux or Windows) has at least 4GB to work with. Otherwise, excessive page swapping may occur.

Creating the Virtual Machine

If you don’t already have a preferred virtualization application, go ahead and install VirtualBox. If you followed the previous article on available tutorials from Mininet and Ryu, you probably already have this set up. If you already use something else like Parallels or VMware, feel free to use that and adjust the steps accordingly. VMware Workstation, for example, can automatically install Ubuntu 16.04 without having to go through most of these steps.


You will need to download the install ISO for Ubuntu Desktop 16.04, 64-bit edition. See the download page for Ubuntu Desktop.

Configuring the VM

  1. In VirtualBox, click the New button in the toolbar. Fill out the basic information for your new VM. Make sure to select the Type as Linux and Version as Ubuntu (64-bit). Click Next. vwp-1
  2. On the next screen, select the memory size. We’ll be running a full desktop environment, so I recommend at least 4GB. If you plan on installing and running ONOS or using a large IDE like Eclipse, 6GB would be a good minimum. Of course, your host operating system needs memory to run as well. Selecting anywhere in the green area on the slider should be ok. Click Next. vwp-2
  3. Next, select “Create a virtual hard disk now” and click “Create”.
  4. A new window will appear guiding the creation of a new virtual hard disk. The default of “VDI” is fine here. If you need interoperability with other hypervisors, “VMDK” might be your best choice to prevent having to convert the disk image later when exporting it as a virtual appliance (OVF/OVA). Click Next. vwp-3
  5. Depending on what type you chose, it will ask you if you want a dynamically allocated hard disk file or a fixed size file. I recommend fixed size if you are working with spinning media as it can help prevent excessive fragmentation. There is not much benefit of using fixed size if using an SSD, however, and having the smaller initial size is a plus. Select which one you want and click Next.
  6. Now we are asked for the size of the virtual hard disk. Again, the size is dependent on what you plan on using in the future. For just Ryu and Mininet, the default of 8GB should be fine. If you plan on installing more complex IDEs or developing for ONOS as well, it might be best to select 40GB or more. Remember that if you selected a dynamically allocated image, the file will start small and grow only as disk space is used (but not recovered). Select the size you want and click Create. vwp-4
  7. The new VM details should now be showing. There is one change that needs to be made before installing Ubuntu. vwp-5
  8. Ubuntu may fail to load the graphical environment during installation due to low memory assigned to the virtual video card. Click the “Settings” button on the toolbar and select “Display” on the list to the left. Change the Video Memory to 64 MB then click OK. vwp-5.1
  9. Go ahead and click Start or double-click on the VM in the list on the left side of the window. Since this is the first time running the VM, you should get a window asking you to select a start-up disk. Click the folder icon at the bottom right of the window. vwp-6
  10. A file selector will appear where you can select the installation ISO. Browse to where you downloaded Ubuntu 16.04 64-bit, select it, and click Open. vwp-7

Installing Ubuntu

  1. Once the ISO is selected, click the Start button at the bottom of the “Select start-up disk” window. Ubuntu will start up and eventually show a window where you can select “Try Ubuntu” or “Install Ubuntu”. Depending on the resolution of your monitor, you may need to move the window in the VM. Click on “Install Ubuntu”. vwp-8
  2. Keep the defaults, click “Continue” and then “Install Now”. A confirmation window will pop up making sure you approve the changes to the disk. Since this is a new VM, there is nothing on the disk anyways, so click “Continue” again.
  3. While installing, it will ask several questions such as timezone, keyboard layout, initial user and so on and are self explanatory. Once the questions are answered, only the installation progress will show with general information about Ubuntu. Allow the installation to finish. vwp-9
  4. Once finished, it will ask you to restart. Go ahead and click on the “Restart Now” button. vwp-10
  5. If your VM stalls while shutting down for the restart, click the “File” menu and select “Close…”. A dialog box will show asking which action to take. Select “Power off the machine” then start the VM back up. vwp-11

Installing Guest Additions

  1. Once the VM restarts and you’ve logged in, click the “Devices” menu in the VirtualBox menu and select “Insert Guest Additions CD image…” vwp-12
  2. A dialog box will pop up asking if you want to run the software on the guest additions ISO. Click the “Run” button. vwp-13
  3. Authentication will be requested to run the software as the super user. Insert the password you set up for the initial account when you installed Ubuntu, then click Authenticate. vwp-14
  4. The guest additions installer will now install the required modules for better integration with VirtualBox as a guest. At the end you should see this the following. Press enter to close the window. vwp-15
  5. Restart Ubuntu by clicking the system icon on the right of the top bar, then select “Shut Down…” You may need to scroll the display to the right to see it. Select “Restart”. vwp-16
  6. Now you should see that the resolution of the VM matches the VirtualBox window and the scrollbars are removed. The resolution will dynamically change as you resize the window, so you can maximise it without having to go full screen. vwp-17

Final Steps

Now that you have a working Ubuntu Virtual Machine as your shiny new development workspace, a few final steps need to be performed. Specifically, ensure that you have the latest updates installed by clicking the System menu on the top right of the screen and select “About This Computer”. A window will show giving details of the VM with a button on the bottom right that should say “Install Updates”.


This will start the Software Updater. You may have already been presented with this window. In either case, if updates are available, click “Install Now”. You may be asked again for your password to update the software. Enter your password and click “Authenticate”. It will then start installing updates. This may take a few minutes first time this is done after installation.


See the Official Ubuntu Documentation for further information on taking care of your OS.

Quick Tweaks and Tips

To prevent the VM from locking the session while idle, Open up the system settings (gear on the launcher), or select “All Settings” if you still have the Details window open. Select “Brightness & Lock” then deselect “Lock”. It is also useful to disable turning the screen off when inactive.

The terminal window manager I use in the Ubuntu screenshots below and in my other tutorials is Byobu and can be installed by running sudo apt-get install byobu in a console. Once installed, start it from the launcher and press Shift+F1 for help.


Setting up a graphical Linux VM is actually optional. You could, for example, just set up an Ubuntu Server VM and run Ryu, Mininet and other applications through SSH with X-Server forwarding, similar to the instructions on the I’ve Got a Ton of Tutorials. Now What? article. This takes a bit more setup, but is probably the best choice for long-term projects. Coupled with tools like Vagrant, it can reduce the effort required for setting up and provisioning development environments with larger teams. I may write an article on this subject in the future.

Installing Mininet and Open vSwitch

Installing Mininet is fairly simple and I’ve based these instructions on Option 2 of the Mininet Download page. However, there is a bug that doesn’t allow the latest release version (2.2.1 as of this article) to be installed in 16.04 64-bit. Instead, Mininet needs to be installed from master. Let’s get started.

First, create a workspace directory that you will install Mininet and Ryu in:

Git will be used to download Mininet, but is not installed by default. Go ahead and install it:

Checkout the Mininet repository:

At this point, your console should look somewhat like this:


At this point, there are several installation options to choose from. Since this is our workspace VM dedicated to OpenFlow development, we can just have it install everything.

This will take a while as it has to download the prerequisite libraries and compile several applications, including Open vSwitch, Wireshark, Stanford reference controller, and several others. Might want to grab a cup. If all goes well, the last line printed should say “Enjoy Mininet!”


Finally, let’s test Mininet to make sure it’s working.

At the end, you should see this:


Congratulations! Mininet is installed and ready to go. It is important to note that there are a few more directories besides mininet in the workspace directory created earlier. You should now see mininet, oflops, oftest, openflow, and pox depending on what you selected in the install script.

Installing Ryu

Ryu is a Python-based controller framework, so we need to make sure that some python dependencies are installed. First, let’s make sure we have access to pip, which is the Python package installer much like npm for Node or cpan for Perl. Installing this installer is simple enough:

Python Virtual Environments

If you wanted to keep the dependencies from being installed globally and instead having them in your workspace directory, you could use virtualenv. This is especially recommended if you are experimenting with multiple versions of Ryu or work on different Python projects on the same VM (or host if installing directly on the host rather than a VM). To quickly set this up:

Now any pip or python commands will be run from the virtual environment. Packages installed with pip will have their CLI interfaces in the PATH. Also, the shell prompt will have (venv) to remind you that you are in the virtual environment. To exit:

Note that you must run the cd and source commands above in any new terminal session to activate the environment. Closing the terminal session automatically deactivates it.

For more information, visit the Virtual Environments page in the Python Guide.

Install Ryu’s required dependencies.

Now install a few optional dependencies that are needed for certain parts of Ryu. This is technically optional, but recommended if you want to try out features like OF-Config, NETCONF or OVSDB support.

Finally, let’s clone and install Ryu.

Make sure everything is installed properly:

If you get the version printed and no errors, then Ryu should be installed properly. It should look something like this:


Testing Ryu and Mininet

Now that Ryu and Mininet are installed successfully, let’s run the provided simple switch example application. This closely mirrors Ryu’s own OpenFlow example, though now we are using the latest version of Ryu installed directly on our system. Open two terminal sessions. In the first one, run:

Mininet will start up a single switch with three hosts. Let’s see if the hosts can ping each other. In the mininet> prompt, type pingall and press enter. You should see 100% dropped.


Of course, this is expected since we haven’t started the controller yet, but this does confirm that the switch is not preconfigured to pass packets. In the second terminal, run:

Immediately, the switch connects to the newly started controller. The --verbose flag shows additional data about the switch, such as the features provided.


Let’s try the pingall command again:


All the hosts can ping each other and Ryu displays events that the OpenFlow switch sent to the controller. This confirms that Mininet and Ryu are communicating properly and is now ready for use in development.

Snapshots Are Your Friend

I’d like to close this article on a tip that I found very useful, especially while writing this piece. Things go wrong. Well, another phrase is more commonly used, but you get the idea. With experimental software and rapid development, you can expect builds to fail or even simple mistakes on the command line to completely ruin your day. When using Virtual Machines for development, take advantage of the Snapshot feature provided by your hypervisor. I’ve had to revert my test VM more than half a dozen times to test the commands I’ve written to make sure they work properly. When I missed a dependency, I could just quickly roll back to the previous snapshot. Think of it as a very simple (though potentially very large) version control system. It doesn’t have to be limited to development, either. I used snapshots for my demo Windows 10 VM while installing Ubuntu as a nested VM inside it (though I had to use VMware as the root hypervisor to support nested virtualization).

On the subject of version control systems, always start your code inside a repository. A simple git init is all it takes to start, and committing your changes often can save you a lot of time if you accidently break something. On the subject of breaking things, I found that is the best way to learn.

Now, go have fun, break a few things, and learn more about OpenFlow. Happy Coding! =)

Share This