What is Mininet?
Mininet is a software that emulates virtual network environment with OpenFlow support. It is great for learning, prototyping and testing SDN features and applications.
How to install Mininet?
There are several ways you can install Mininet. The easiest and recommended one is to go to https://github.com/mininet/mininet/wiki/Mininet-VM-Images and download the image for your virtualization platform.
Another option is to install Mininet from source. I have installed it from source, because I already had a VM (Ubuntu 16.04 with GUI). This is how you can do it too:
Run the following command (make sure you have git installed):
git clone git://github.com/mininet/mininet
Go to mininet directory and check out the latest version (in my case it is 2.2.2):
git tag # list available versions
git checkout -b 2.2.2
Run install shell script. Option -s /home/orkhans/mn instructs installer where it should install Mininet files:
./util/install.sh -s /home/orkhans/mn -a
You can run the following command to make sure you have installed everything successfully:
sudo mn --test pingall
We will be using CLI to manage our virtual network. The default topology includes two hosts (h1,h2), OpenFlow Switch(s1) and OpenFlow controller(c0).
Run sudo mn to enter CLI mode. Commands net and nodes give us information about our nodes and their interconnections:
available nodes are:
c0 h1 h2 s1
s1 lo: s1-eth1:h1-eth0 s1-eth2:h2-eth0
We can find IP address of either host by running h1 ifconfig -a or h2 ifconfig -a
We can test connectivity between them using ping command:
mininet> h1 ping h2
PING 10.0.0.2 (10.0.0.2) 56(84) bytes of data.
64 bytes from 10.0.0.2: icmp_seq=1 ttl=64 time=2.34 ms
64 bytes from 10.0.0.2: icmp_seq=2 ttl=64 time=0.393 ms
64 bytes from 10.0.0.2: icmp_seq=3 ttl=64 time=0.078 ms
--- 10.0.0.2 ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2031ms
rtt min/avg/max/mdev = 0.078/0.938/2.345/1.003 ms
Another useful CLI command is dump which displays summary information about all devices:
<Host h1: h1-eth0:10.0.0.1 pid=3300>
<Host h2: h2-eth0:10.0.0.2 pid=3302>
<OVSSwitch s1: lo:127.0.0.1,s1-eth1:None,s1-eth2:None pid=3307>
<Controller c0: 127.0.0.1:6653 pid=3293>
We have just seen that default topology contains 1 controller, 1 switch and 2 hosts. The good news is that we can easily instruct emulator to build a different topology by specifying options in sudo mn command.
For example, this is how we can create single switch network with 4 hosts:
orkhans@ubuntu4:~$ sudo mn --topo=single,4
[sudo] password for orkhans:
*** Creating network
*** Adding controller
*** Adding hosts:
h1 h2 h3 h4
*** Adding switches:
*** Adding links:
(h1, s1) (h2, s1) (h3, s1) (h4, s1)
*** Configuring hosts
h1 h2 h3 h4
*** Starting controller
*** Starting 1 switches
*** Starting CLI:
The following command will create a topology as shown in the picture sudo mn –topo=tree,depth=2,fanout=2:
In this tutorial you learned how to install and perform basic tasks in Mininet emulator.