Mininet network simulator review

The Mininet open-source network simulator is designed to support research and education in the field of Software Defined Networking systems. Mininet creates a simulated network that runs real software on the components of the network so it can be used to interactively test networking software.

Mininet open source network simulator

Software Defined Networking (SDN) is a relatively new technology, but it is already being deployed in some networks: most famously, in Google’s internal network. Many companies are developing products to deploy and support networks using SDN technologies. In the following test drive, we will use Mininet to simulate and test some SDN scenarios and evaluate Mininet as network simulator.

Mininet and Software Defined Networking

Mininet was created by a group of professors at Stanford University to be used as a tool to research and to teach network technologies.

Mininet is designed to easily create virtual software-defined networks consisting of an OpenFlow controller, a flat Ethernet network of multiple OpenFlow-enabled Ethernet switches, and multiple hosts connected to those switches. It has built-in functions that support using different types of controllers and switches. We can create also complex custom scenarios using the Mininet Python API.

Network Namespaces

Mininet uses Linux network namespaces to create virtual nodes in the simulated network. This is a lightweight and fast way to create virtual nodes but it does not provide fully separated virtual machines and it is not possible to save configurations on each of the virtual nodes after the simulation is shut down.

By default, Mininet creates a new network namespace for each host in the simulated network. Also by default, Mininet starts the switch and controller processes in the Mininet VM’s root namespace — essentially they are just processes running on the Mininet VM. It is also possible to set up the controllers and the switches each in their own network namespace so they operate as separate virtual machines networked to each other across virtual Ethernet interfaces. See the Mininet Walkthrough for more details.

In this example, we will just use the default configuration. This makes all virtual interfaces we set up in the simulation available to be monitored by programs like Wireshark so it simplifies the observation of events in the simulated network.

Set up a simple network

First, we will look at a very simple network scenario.

Mininet can be started with options that specify the network topology to be created. To see all available options run the Mininet command mn with the -h option to see the help menu.

$ sudo mn -h

Mininet must be run as root so we must use the sudo command to run Mininet.

The Mininet network topology can be specified using the –topo option. If started without any topology options, Mininet will create the minimal built-in topology, which consists of two virtual machines connected to an Openflow switch, which is managed by an Openflow controller. In our case, we will create a topology that consists of four virtual machines connected to an OpenFlow switch, which is connected to an OpenFlow controller.

To create a network topology with four virtual machines connected to a switch, enter the command:

$ sudo mn --topo=single,4

In this scenario, we did not specify the type of controller so we are using Mininet’s default controller, ovs-controller, which implements the functionality of a basic layer-2 MAC-learning switch. The controller learns the MAC addresses of the hosts connected to the network and programs the switch’s flow tables to set up connections between hosts that are sending packets to each other.

You will see the following output as Mininet creates the simulated network topology:

*** Creating network
*** Adding controller
*** Adding hosts:
h1 h2 h3 h4
*** Adding switches:
s1
*** Adding links:
(h1, s1) (h2, s1) (h3, s1) (h4, s1)
*** Configuring hosts
h1 h2 h3 h4
*** Running terms on localhost:10.0
*** Starting controller
*** Starting 1 switches
s1
*** Starting CLI:
mininet>

The mininet> prompt shows Mininet is started and we are using the Mininet command-line interface.

Start Wireshark

To monitor the communications between the controller and any switches in the simulated network, we start Wireshark and capture traffic on the Mininet VM’s loopback interface. Wireshark must be started with superuser privileges so on the Mininet VM terminal, enter the command:

$ sudo wireshark &

Because Mininet creates the controller and the switch as processes running in the root namespace, they exchange communications using the Mininet VM’s loopback interface. So, we set Wireshark to capture packets on the Mininet VM’s loopback interface, lo.

In the Wireshark program, click on the menu commands:

Capture --> Interfaces

Then select the lo (loopback) interface and press the Start button.

Configure Wireshark to capture packets on the Mininet VM's loopback interface
Configure Wireshark to capture packets on the Mininet VM’s loopback interface

Since many processes are passing information through the loopback interface, filter on the OpenFlow messages by entering the following expression into the Wireshark filter box and click Apply:

of

Now we see the Wireshark window open and monitoring for OpenFlow messages between the controller and the switch.

Filtering for OpenFlow packets using the of filter
Filtering for OpenFlow packets using the of filter

Testing the simulation

Now the network is set up. We expect that each virtual machine will be able to communicate with any other virtual machine on the same switch. Mininet provides a built-in command to check the communication between all hosts in the network. Use the Mininet pingall command, which will run the ping command on each host and ping every other host, then report the results in the Mininet command line interface:

mininet> pingall
*** Ping: testing ping reachability
h1 -> h2 h3 h4
h2 -> h1 h3 h4
h3 -> h1 h2 h4
h4 -> h1 h2 h3
*** Results: 0% dropped (12/12 received)

We also see openFlow messages appear in the Wireshark window, showing how the controller and the switch communicate to determine how to pass the ICMP (ping) packets through the switch to their destinations.

OpenFlow packets captured by Wireshark
OpenFlow packets captured by Wireshark

Mininet commands

Mininet provides commands that allow you to inspect and control each network element from the command line. The pingall command used above was on example of a Mininet command. Some other useful commands are:

  • help: lists the mininet commands
  • dump: lists information about the nodes, switches, and controllers in the simulated network.
  • nodes: lists the names of the network elements in the simulated network
  • net: shows how network elements are connected to each other in the simulated network.

For example, we execute the dump command to see the IP addresses of each node in the simulated network.

mininet> dump
<Host h1: h1-eth0:10.0.0.1 pid=1411> 
<Host h2: h2-eth0:10.0.0.2 pid=1412> 
<Host h3: h3-eth0:10.0.0.3 pid=1413> 
<Host h4: h4-eth0:10.0.0.4 pid=1414> 
<OVSSwitch s1: lo:127.0.0.1,s1-eth1:None,s1-eth2:None,s1-eth3:None,s1-eth4:None pid=1417> 
<OVSController c0: 127.0.0.1:6633 pid=1403> 
mininet>

Run commands on hosts

Mininet will pass commands to the nodes in the network from the Mininet command line when the user starts the command with the name of a node. The output of the command will be displayed on the Mininet terminal. For example, to list the working director on host h1 and then list the contents of that directory, execute the Mininet commands:

mininet> h1 pwd
/home/mininet
mininet> h1 ls
install-mininet-vm.sh
mininet
of-dissector
oflops
oftest
openflow
pox
mininet> 

This is useful in simple cases.

Interacting with hosts

To perform more interactive tasks on the virtual host computer, such as editing configuration files or working with programs that have their own command-line interfaces, like quagga, it is best to open an xterm window to the network element. For example: if you enter the Mininet command:

mininet> xterm h1

Mininet will open an xterm window on host h1.

You can also start multiple xterm windows from the same command, if you want:

mininet> xterm h2 h3 h4

After executing the two commands above, we see four xterm windows opened on our desktop. Each xterm is connected to a virtual machine. Each xterm window is identified by the name of the device on which it is running, such as host:h1.

Other X sessions can be started on the virtual hosts in the simulated network by entering a command from the Mininet command line or by entering the command on the xterm window running on the virtual host. For example, to start wireshark on host h1, we can execute the command in Mininet or in the xterm window running on host h1.

On Mininet, we enter the command:

mininet> h1 wireshark &

Or, on the xterm window running on host h1, we enter the command:

# wireshark &

Commands running on each host only have visibility of network resources and configuration files related to that host’s network namespace. So, in this example, Wireshark can only capture packets on interface h1-eth0 on host h1 (and/or on the loopback interface lo on host h1).

Emulating network behavior

Each host created by Mininet can run real Linux commands. So, we can use startdard Linux traffic control commands to modify performance parameters on each link (or we can start Mininet with the –link option and specify performand paramenters that will be applied to every link at startup). We can also bring a link down using Linux commands of using the mininet link command.

The Mininet Python API provides methods to modify the performance attributes of links in the network while the simulation is running.

Quit Mininet

To quit Mininet and stop all processes and virtual nodes created by Mininet, enter the exit command at the Mininet prompt:

mininet> exit

Simulating a large network

Mininet supports a number of built-in network topologies that can be set up using the –topo option when starting Mininet. Let’s see how Mininet supports a larger network simulation. In this case, we will create a tree topology, where we can specify the depth of the tree and the fanout of the tree, where fanout is the number of “downstream” links on each virtual switch. After the last row of switches in the tree is created, Mininet creates a host on each “downstream” link on the last row of switches.

Using the tree topology, it is possible to specify a large network. For example, a tree topology with a depth of 3 and a fanout of 4 would create 21 switches and 64 hosts (and one controller).

I ran the following command:

$ sudo mn --topo tree,depth=3,fanout=4

The Mininet network simulator started all the virtual switches and virtual hosts quickly. I was able to run commands on the virtual hosts and I noticed no issues with responsiveness.

Mininet and routing

To create a network where hosts are in different networks (which would typically be connected by routers), we must use a controller that will provide the functionality of a routed network.

The default functionality provided by Mininet does not support this type of functionality. But, we could add this functionality and run a network that uses IP routing protocols like OSPF to build the forwarding tree in the network, which would then be implemented as flows in the virtual Ethernet network by an Openflow controller. A good example of this functionality is provided by the RouteFlow project.

Mininet tutorials

The Mininet web site offers some very good tutorials to help new users understand how to use Mininet. For more details about using Mininet and about OpenFlow controllers, please see the Mininet walkthrough tutorial and the Openflow tutorial.

Conclusion

Mininet is a unique open-source network simulator that is developed to support reseatch and education in Software Defined Networking. I found the Mininet command-line interface to be very easy to use. Because Mininet uses network namespaces as its virtualization technology, it can support a large number of virtual nodes without slowing down the simulation.

Mininet also has excellent documentation and a very active community of users on the Mininet mailing list.

As a simulator for Software Defined Networking, Mininet seems to work well. However, Mininet — as it is provided by the Mininet project without modification — will not simulate a “traditional” IP network composed of hosts, switches, and routers.

Mininet seems to be most suitable to researchers who will implement new controller software and test it using Mininet. I think that a user of Mininet would find it most useful if they were experienced with the Python scripting language and so were able to utilize Mininet’s Python API and also inspect the Mininet source code (which is written in Python).

32 thoughts on “Mininet network simulator review”

  1. hi
    Please provide some information for how to create namespace and and how to connect the name spaces……

  2. Pingback: How to use MiniEdit, Mininet’s graphical user interface | Open-Source Routing and Network Simulation

  3. Hey,
    A nice compilation you have here, all at one place.
    With your experience with Mininet, do you know if it’s feasible to implement asymmetric links in Mininet? By asymmetric, I mean, different download and upload speeds on a link? If yes, how?

    1. Hi Chaitanya,
      Thanks for your question. I have not tried to make links asymmetrical in Mininet. The Mininet documentation does not show how to do this when setting up a link. You may be able to do this after the link is set up by using the Python API to execute Linux commands on the hosts connected to these links and restrict bandwidth differently in each direction.
      /Brian

      1. Alright, that looks like a nice workaround, thanks! Any headstart as to what commands specifically? Just off the top of your head, if any?

  4. Pingback: How to map OpenFlow switch TCP ports in Mininet SDN simulations | Open-Source Routing and Network Simulation

    1. I agree. As of today, every tool I mention on this site is, in fact, an emulator. But, I’ve found that most people refer to both emulators and simulators using the term, “simulator” (unless they use both types of tools in their work or research). I have not written very much

      So, I made an editorial decision to use the term “simulator” most of the time when I talk about either network emulators or network simulators.

      Do you think that’s fair, or do you think I should use therm “emulator” more?

  5. Hi,

    Please can some1 help me in pinging h1 and h2,in single topology. i.e
    >>sudo mn –topo=single,2 –mac –controller=remote –switch=ovsk,protocols=OpenFlow13
    ** network topology is created

    >>h1 ping h2
    host unreachable
    host unreachable

    when i dump flows,i couldn’t see any of the flows, but ping is working for linear and tree topology

    pls some1 help me plssss!!!

  6. Pingback: Mininet Graphical Topology Creation – Mohit Ritolia

  7. Create a simple scenario of a network; one source, one destination and they communicate via a network (of wireless access points etc.)

    Sir kindly help in implementing this task please. I would be grateful to you.

      1. Thanx a lot sir for writing to my question. Sir actually i want to create wireless network consisting of two hosted connected via Wireless access point. Sir i would be greatfull if you please assist me in this regard.
        Waiting impatiently for your reply sir,
        With Regards,

        1. Hi Arsalan,
          I searched for some information on Google and I found a project called “Mininet-WiFi” that might help you. See the following links:
          Mininet-WiFi
          https://github.com/intrig-unicamp/mininet-wifi
          http://www.ramonfontes.com/index.php/mininet-wifi
          http://www.ramonfontes.com/mininetwifi/EADCA%20Presentation%20-%20English.pdf
          http://switchon.ampath.net/wp-content/uploads/2015/08/Christian-Rothenberg-Mininet-Wifi-Towards-an-Emulator-for-Software-Defined-Wireless-Networks.pdf
          http://www.dca.fee.unicamp.br/~shbbrito/public/cnsm15-mininet-wifi.pdf
          Regards,
          Brian

  8. HI brian brother….
    i ran the sudo mn –topo=single,4 and then ran wireshark but when i enter “of” in filter box then its said that ” of is not a valid display filter:of is neither a field nor a protocol name.”
    the protocol shows only is TCP..
    please help..

    1. Hi Adnan,
      If you installed mininet yourself, then you will have a different WireShark OpenFlow dissector than is supplied with the Mininet VM. Try filtering on “openflow” instead of “of”. If that does not work, ensure you have the latest stable version of Wireshark, then try to filter on “openflow” again.
      Thanks,
      Brian

      1. No sir,,,every thing is good but i think openflow plugin dissector required for that but i dont know how to install openflow dissector…
        please tell me how to install i tried too much but not working

        1. # hg clone https://bitbucket.org/barnstorm/of-dissector
          # cd of-dissector/src
          # sudo apt-get install scons
          # export WIRESHARK=/usr/include/wireshark/
          # sudo scons install

          i tried this also but the following error occurs…….

          ### ERROR: You need to set the WIRESHARK environment variable to the location of your wireshark include directory.
          ### ERROR: (such that epan/packet.h is a valid include path)

          please tell me what should i do now????

          1. Hi Adnan,
            The openflow dissector will already be installed in the Mininet VM. Filter on “of” in Wireshark. If that does not work, then I do not know what the problem could be…
            Brian

  9. Hi all,
    I am new in Opendaylight development. I am trying to test SNMP plugin(implemented in ODL) that how it communicate with network devices i.e virtual switches…..But I did not found any command of mininet which create virtual network for SNMP. Although I tested openflow well using this command:
    $ sudo mn –topo linear,3 –mac –controller=remote,ip=192.168.56.101,port=6633 –switch ovs,protocols=OpenFlow13
    kindly help me how can I test SNMP using mininet
    Thanks

  10. hi Brian

    i’m using ‘Floodlight-v1.1+Mininet’ which i downloaded from this link:

    http://www.projectfloodlight.org/download/

    now i want to use miniedit to create different topology and use mininet examples.
    but in this file i can’t find mininet path! would you please tell me that how can i find i use miniedit?

    thanx for your attention

Comments are closed.

Scroll to Top