Mininet on CentOS 7 KVM

Mininet is a Linux-based network emulator which enables the prototyping, development and sharing of OpenFlow and Software-Defined Networking (SDN) networks. Given the growing importance of these networking technologies, Mininet has potential as a teaching tool in the IT lab.  This post describes how to get Mininet running in KVM on CentOS 7, and introduces some basic commands and workflows.

The recommended way to install Mininet is to use the pre-built VM appliance available on the project website. This is based in the long-term support version of Ubuntu (Trusty Tahr 14.04). The download is a zipped package containing an OVF file and a VMDK image. For use in KVM (Virtual Machine Manager) on CentOS 7, disregard the OVF file and convert the VMDK image to QCOW2 format as follows:

qemu-img convert -O qcow2 MyAppliance.vmdk MyAppliance.qcow2

This image is now ready for used in a new KVM virtual machine. A quick look at the OVF file indicates that the VM expects only 1 CPU, 1024 MB of RAM and an E1000 network card.

When the Mininet VM boots up, log in as user mininet with password mininet. This can be done directly in KVM’s Virtual Machine Manager console, or (once you know the VM’s IP address) via SSH. If using SSH don’t forget to add the -X option to allow X11 forwarding if you want to use xterm terminals (see below):

ssh -X mininet@192.168.122.xxx

Once logged in, Mininet can be started immediately with a default minimal configuration by running this short command:

[sudo] mn

This network topology consists of one OpenFlow kernel switch connected to two hosts, plus the OpenFlow reference controller. The Mininet CLI prompt now awaits further input:

The help command provides an overview of where we can go from here:

The basic informational commands are as follows:

The output of these commands when used with the minimal topology is:

Terminals can be opened on nodes and normal system commands (eg. ip, tcpdump, tshark and arp) run in those terminals:

Tip: to start an Xterm for every node on startup, pass the -x option:

[sudo] mn -x

Note that Mininet is an example of network virtualisation using network namespaces. It virtualises only the network; otherwise, each host process in a topology sees the same set of processes and directories (those of the Mininet host VM).

The Mininet website has two good resources for getting started with Mininet:

There are also quite a few videos available on Mininet:

There are also some Mininet teaching resources available:

Hopefully this post¬† has been enough to demonstrate Mininet’s potential as a modern network design and testing tool, and to get you started.

For CentOS users not overly familiar with Ubuntu, an Ubuntu system can be shutdown like this:

[sudo] shutdown -P now