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.
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.
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.
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.
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:
Now we see the Wireshark window open and monitoring for OpenFlow messages between the controller and the switch.
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.
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.
To quit Mininet and stop all processes and virtual nodes created by Mininet, enter the exit command at the Mininet prompt:
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.
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.
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).