The easiest way to get started using the Mininet network simulator is to use the Mininet virtual machine. It is based on the Ubuntu Linux Server operating system and comes with all the software and tools required to support Mininet already installed.
The Mininet web site provides detailed setup notes, describing how to download and use the Mininet virtual machine. While I was following the procedure described in these notes, I found a few points where some more information would have been helpful. For my own reference, and to help anyone else who will install Mininet, I list the procedure I followed in the post, below.
SSH and X Server software
I set up the Mininet virtual machine on my Apple iMac computer. The Mac OS X operating system comes with SSH software but does not come with an X server already installed. You must install the XQuartz X server from http://xquartz.macosforge.org. See the Apple Support web sit for more details at: http://support.apple.com/kb/HT5293.
On the Linux desktop distributions, the SSH and X-server software are already available.
Download the Mininet virtual machine
Download the Mininet virtual machine (VM) from http://mininet.org/download. I chose the latest version available, which was mininet-2.1.0-130919-ubuntu-13.04-server-amd64-ovf.zip. This file is a compressed ZIP archive containing two files so, after downloading it, decompress it and save the files to my hard drive.
To decompress the archive, double-click on the mininet-2.1.0-130919-ubuntu-13.04-server-amd64-ovf.zip file to automatically launch the archive application or use the following command in the terminal window:
$ tar -xvf mininet-2.1.0-130919-ubuntu-13.04-server-amd64-ovf.zip
This will create a folder named mininet-2.1.0-130919-ubuntu-13.04-server-amd64-ovf. The folder will contain the following files:
Import the virtual machine into VirtualBox
Next, create a version of the Mininet virtual machine that will run in VirtualBox by importing the Mininet virtual machine into the VirtualBox program
Start the VirtualBox manager application on your host system.
To import the Mininet virtual machine, use the VirtualBox menu command:
File → Import Appliance
In the next screen, click the “Open appliance” button.
Navigate to the folder containing the mininet-2.1.0-130919-ubuntu-13.04-server-amd64.ovf file and select it.
Then, click the “Continue” button to get to the Appliance Settings screen. Use the default settings, but you can change virtual machine’s name, if you want to. I changed the name from vm to Mininet. Click on the “Import” button.
After a few minutes, you will see the Mininet VM you imported in the VirtualBox window.
To use Mininet in the way recommended by the Mininet setup notes, you must create a “host only” network interface in VirtualBox. This creates a loopback interface on the host computer that can be used to connect the virtual machine to the host computer (or to other virtual machines). You will need this so that the host computer can run remote X11 sessions on the virtual machine in the later steps.
Open the VirtualBox preferences panel. Use the VirtualBox menu command:
VirtualBox → Preferences.
Click on the “Network” icon in the Preferences panel. Then. click on the small green “plus” sign on the right side of the window to add a new network adapter. An adapter called vboxnet0 will be created. The default settings should be acceptable.
Check the settings by clicking on the small “screwdriver” icon on the right side of the window to edit the adapter’s configuration. Make a note of the IP address.
In this case the default IP address used by VirtualBox for the first host-only adapter is 192.168.56.1/24.
The DHCP server is enabled on the interface and we see that the Lower Address Bound is 192.168.56.101/24. So, we know that the IP address of the virtual interface connected to the host-only network on the virtual machine will be assigned that IP address.
For future use, note the following information:
- Host-only network address: 192.168.56.0/24
- Host IP address on host-only network: 192.168.56.1/24
- Virtual Machine’s virtual interface IP address on host-only network: 192.168.56.101/24
In the VirtualBox Manager window, click on the Mininet virtual machine and then click on the “Settings” icon on the top of the window. Click on the “Network” icon in the settings panel that appears.
The virtual machine already has one interface defined. On the “Adapter 1” tab, we see an interface set up as a NAT.
This will allow the virtual machine to connect to the internet. But to use Mininet we still need a way for the virtual machine to connect directly to the host computer. So, we need to add another virtual adapter and connect it to the “host-only network” interface we created earlier.
Click on the “Adapter 2” tab and, in the “Attached to:” field, select “Host-only network”. This allows other programs running on your host computer to connect to the VM using SSH. Since only one host-only network is currently created, VirtualBox will automatically select the vboxnet0 host-only network.
Click the “OK” button.
Now the network settings are configured for the Mininet virtual machine. You may change some of the other settings if you want to but the default values for all other settings will work well.
Start the Mininet virtual machine
In the VirtualBox manager, select the Mininet virtual machine and then click the “Start” button to start the Mininet VM.
The VM will boot up and present you with a login prompt.
Log in with userid=mininet and password=mininet
Run the ifconfig command to see the interfaces available on the Mininet virtual machine. We see two interfaces: eth0 and lo. You previously set up the Mininet virtual machine so that the interface eth0 would be connected to the NAT interface on your host computer, so it has been assigned an IP address that will work on the LAN connected to the host computer. In this case, eth0 has the IP address, 10.0.2.15/24.
This allows the virtual machine to connect to the internet. We can verify a connection to the internet by pinging an external server such as google.com.
mininet@mininet-vm:~$ ping -c 1 google.com
But, we do not see an interface that is connected to the host-only interface. We need to configure eth1.
To see all available interfaces, even ones that are not up, execute the
ifconfig -a command.
mininet@mininet-vm:~$ ifconfig -a
Now, we see that we have three interfaces: lo, eth0, and eth1. But eth1 is not up and does not have an IP address assigned. We can fix this by starting the DHCP client on
eth1 so it will request an IP address from the DHCP server that is running on the host-only interface connected to eth1.
mininet@mininet-vm:~$ sudo dhclient eth1
ifconfig command again. You will see that the interface eth1 now has an IP address 192.168.56.101 assigned to it.
You can verify this interface is working now by pinging the host computer’s host-only interface address, 192.168.56.1 from the Mininet virtual machine.
mininet@mininet-vm:~$ ping -c 1 192.168.56.1
To permanently configure the new interface, edit the /etc/network/interfaces file and add an interface named eth1.
mininet@mininet-vm:~$ sudo vi /etc/network/interfaces
Just copy the same configuration for eth0 for eth1. In my case, I added the following lines to the file:
auto eth1 iface eth1 inet dhcp
Now, the next time you start the Mininet virtual machine, the system will automatically configure the eth1.
Using SSH to connect to the Mininet VM
We are done using the VirtualBox interface to the Mininet virtual machine. In the next steps, you will use the SSH client software on your computer to connect to the Mininet virtual machine. This accomplishes two things:
- From the host computer, we can connect to remote X applications running on the Mininet VM, such as xterm and wireshark.
- We can use an easier-to-use terminal window or xterm window to interact with the Mininet virtual machine. You will have noticed by now that working with the VirtualBox console window is difficult because:
- The VirtualBox console window captures your mouse whenever you use it and you have to use the appropriate “host key” to escape from the virtual machine and return control to your host computer.
- You cannot cut-and-paste text from the virtual machine console window to a program on your host computer.
We need to set up an SSH connection to the virtual machine with X11 forwarding enabled so that we can run X applications on the Mininet virtual machine but display the applications on the X Server running on our host computer. Then we can set up an Xterm and stop using the virtual machine console window.
On the Mininet VM, SSH forwarding is already enabled (in the /etc/ssh/sshd_config file). So you do not need to make any SSH configuration changes on the virtual machine.
Connect with SSH
Open the Terminal application on your computer (Windows users will use PuTTY).
In the Terminal window, use the SSH client on your computer to start an SSH session to the Mininet VM.
iMac:Desktop blinklet$ ssh -Y firstname.lastname@example.org
You will see a warning about the RSA key. Enter “yes” to continue. This will also add the RSA key to your SSH client so you will not see the warning again.
Now you are logged into the Mininet virtual machine via a secure SSH session. Now, you can run remote X11 clients on the Mininet virtual machine over this SSH session.
Launch a remote X11 client
In the Terminal window, which is now running an SSH session connected to the Mininet virtual machine, start an Xterm:
mininet@mininet-vm:~$ xterm -sb &
An Xterm window will open on the screen. You need the “-sb” option if you want to have a scrolling buffer in the Xterm window (so you can scroll back if you need to).
Now you know that applications running on the Mininet virtual machine can use X forwarding to display windows on the host computer. You will be able to use the Mininet virtual machine as described in the documentation on the Mininet web site.
As an extra activity, run Wireshark on the Mininet Xterm window:
mininet@mininet-vm:~$ sudo wireshark &
Wireshark should start up running on the Mininet virtual machine but is displayed in an X window on your host computer.
You have completed setting up the Mininet virtual machine.
We set up the Mininet virtual machine on our computer and we verified that we can communicate properly with it. We are ready to work with Mininet. The next step is to follow the documentation on the Mininet web site and try out the Mininet Walkthrough tutorial.