The Mininet network simulator includes MiniEdit, a simple GUI editor for Mininet. MiniEdit is an experimental tool created to demonstrate how Mininet can be extended.
To show how to use MiniEdit to create and run network simulations, we will work through a tutorial that demonstrates how to use MiniEdit to build a network, configure network elements, save the topology, and run the simulation.
Set up Mininet
You should already be familiar with Mininet before trying to use MiniEdit. If you need some basic information about Mininet, please read my Mininet overview.
Before starting this tutorial, you should have already started the Mininet VM and connected to it via SSH with X forwarding enabled. If you need to learn how to do this, please read my post describing how to set up Mininet.
The MiniEdit script is located in Mininet’s examples folder. To run MiniEdit, execute the command:
$ sudo ~/mininet/examples/miniedit.py
Mininet needs to run with root privileges so we started MiniEdit using the sudo command.
MiniEdit user interface
MiniEdit has a simple user interface that presents a canvas with a row of tool icons on the left side of the window, and a menu bar along the top of the window.
The icons represent the following tools:
The Select tool is used to move nodes around on the canvas. Click and drag any existing node. Interestingly the Select tool is not needed to select a node or link on the canvas. To select an existing node or link, just hover the mouse pointer over it — this works regardless of the tool that is currently active — and then either right-click to reveal a configuration menu for the selected element or press the Delete key to remove the selected element.
The Host tool creates nodes on the canvas that will perform the function of host computers. Click on the tool, then click anywhere on the canvas you wish to place a node. As long as the tool remains selected, you can keep adding hosts by clicking anywhere on the canvas. The user may configure each host by right-clicking on it and choosing Properties from the menu.
The Switch tool creates OpenFlow-enabled switches on the canvas. These switches are expected to be connected to a controller. The tool operates the same way as the Hosts tool above. The user may configure each switch by right-clicking on it an choosing Properties from the menu.
The Legacy Switch tool creates a learning Ethernet switch with default settings. The switch will operate independently, without a controller. The legacy switch cannot be configured and is set up with Spanning Tree disabled, so do not connect legacy switches in a loop.
The Legacy Router tool creates a basic router that will operate independently, without a controller. It is basically just a host with IP Forwarding enabled. The legacy router cannot be configured from the MiniEdit GUI.
The NetLink tool creates links between nodes on the canvas. Create links by selecting the NetLink tool, then clicking on one node and dragging the link to the target node. The user may configure the properties of each link by right-clicking on it an choosing Properties from the menu.
The Controller tool creates a controller. Multiple controllers can be added. By default, the MiniEdit creates a mininet openFlow referencecontroller, which implements the behavior of a learning switch. Other controller types can be configured. The user may configure the properties of each controller by right-clicking on it an choosing Properties from the menu.
The Run starts Mininet simulation scenario currently displayed in the MiniEdit canvas. The Stop button stops it. When MininEdit simulation is in the “Run” state, right-clicking on network elements reveals operational functiosn such as opening a terminal window, viewing switch configuration, or setting the status of a link to “up” or “down”.
Create a custom network topology using MiniEdit
First we will add some hosts to network scenario. Click on the Host icon, then move the pointer to the location on the MiniEdit canvas where you want the host to appear, then click again. A host icon will appear on the canvas.
As long as the Host tool is active, you can add more hosts. Keep clicking at each spot on the canvas where you want a host to appear. In this example, we will add ten hosts.
Add eight switches and three controllers using the same method: Click on the Switch tool and add switches, then click on the Controller tool and add controllers.
Next, add links between the nodes on the canvas. Click on the NetLink tool, then click on a node and drag the link over to another node. For example: connect a host to a switch, or a switch to another switch. Connect every host to at least one switch. Connect the switches together to create a network. Then, connect each switch to one of the controllers.
Your completed network should be similar to the network show in the screenshot below:
We were able to create this complex custom network topology in a few minutes using MiniEdit. Manually writing a Mininet custom topology script to create this scenario would have taken a lot longer.
Configure the controllers
We have three controllers. In this basic example, we will use the default OpenFlow Reference controller that comes built in to Mininet. However, we need to configure each controller so it uses a different port.
Right-click on each controller and select Properties from the menu that appears. The default port number for each controller is 6633. Change this so the port numbers used by controllers c0, c1, and c2 are 6633, 6634, and 6635, respectively.
Set MiniEdit Preferences
To set MiniEdit preferences, use the MiniEdit menu command, Edit → Preferences. In the dialogue box that appears, make the changes you need.
Set the Start CLI option
By default, the MiniEdit console window does not give the user access to the Mininet command line interface. If you want to be able to use the Mininet CLI when a simulation is running, check the Start CLI box. You may also set the version of OpenFlow you will use.
In our scenario, we will use the CLI and will leave all other settings at default values.
The MiniEdit Preferences are saved in the MiniEdit topology file for each scenario so you may have different preferences for each saved scenario.
Save the configuration
Now we have a software-defined network scenario that should allow each host to communicate with any other host in the network.
We will save the MiniEdit topology file so we can load this scenario into MiniEdit in the future. We will also export a Mininet Python script that we can run in a terminal window to execute the scenario.
Save topology file
To save the Mininet Topology (*.mn) file, click on File in the top menu bar and select Save from the drop-down menu. Type in a file name and save the file.
Save custom Mininet script
To save the Mininet Custom Topology (*.py) file, click on File in the top menu bar and select Save Level 2 Script from the drop-down menu. Type in the file name and save the file.
Run the MiniEdit network scenario
To start the simulation scenario, click the Run button on the MiniEdit GUI. In the terminal window from which you started MiniEdit, you will see some messages showing the progress of the simulation startup and then the Miniedit CLI prompt (because we checked Start CLI box in the MiniEdit preferences window).
Pay attention to the warning message. Before stopping the simulation with the Stop button, ensure you quit from the CLI by typing
exit at the Mininet prompt in the MiniEdit console window.
Experiment with the network
After starting the simulation scenario, we will view the status of different elements in the network, open terminal windows, run network traffic, run programs on simulated hosts, and simulate network failures. These activities will demonstrate how to use some of the features of MiniEdit.
View Open vSwitch configurations
First, check the switch configurations in the network simulation to verify that everything is set up correctly. You can run the MiniEdit menu command, Run → Show OVS Summary to see an listing of switch configurations. In this case, we can verify that each switch is listening to the correct controller on the correct port.
Check switch flow tables
Next, view the flow tables of some of the switches using the
ovs-ofctl dump-flows command. You need to run this command on the host computer (or the virtual machine) that is running Mininet. So, you need to use a terminal window connected to the computer (not to one of the nodes in the network simulation). You can use MiniEdit to open an xterm connected to the host computer by using the MiniEdit menu command, Run → Root Terminal
In the root terminal window, first change the userid from root to mininet, so you can view the switches running in the mininet account. Remember that we logged into the Mininet VM as user mininet so all mininet processes are running in the mininet account.
# su mininet
Then, check the flow table on switch s1 using the commands below. It should be empty.
$ sudo ovs-ofctl dump-flows s1
Run programs to generate and monitor traffic
Open a xterm window on hosts h1 and h8. Right-click on each host in the MiniEdit GUI and select Terminal from the menu that appears.
In the h1 xterm window, start a Wireshark with the command,
wireshark &. In the h8 xterm window, start a packet trace with the command
tcpdump. We do this just to demonstrate two different methods of monitoring traffic on the virtual Ethernet ports of each host.
Then, run a ping command to send traffic between host h1 and h8. On the MiniEdit console window, enter the following command:
mininet> h1 ping h8
In the MiniEdit console, you see the results of the ping command. In the Wireshark window and in the host h8 xterm window — which is running tcpdump — you will see ICMP packets successfully sent and responses received.
Simulate a broken link
To simulate a broken link in the network, move the mouse pointer over one of the blue links in the network and right-click. Choose Link Down from the menu that appears. The link will turm into a dashed blue line, indicating it is down.
You should observe that no more traffic is received at host h8 and that the ping command shows packets sent from host h1 are not being responded to.
Now, restore the link operation by right-clicking on the dashed line and choosing Link Up from the menu. The link will again appear as a solid blue line, traffic will again be received at host h8, and the ping command running on h1 will show it is receiving responses from h8.
Check flow tables again
Check the flow table on switch s1 again. You should see flows installed for ICMP packets and ARP packets. On the root terminal window, enter the command:
$ sudo ovs-ofctl dump-flows s1
Stop the simulation
Quit Wireshark and tcpdump on hosts h1 and h8.
Quit the ping command in the MiniEdit console window by pressing Ctrl-C on the keyboard.
Then, quit the Mininet CLI by typing
exit at the
Now, press the Stop button on the MiniEdit GUI.
Run a saved Mininet custom topology script
An alternative to running a simulation directly in MiniEdit is to run a Mininet custom topology script created by MiniEdit. This is the file with the .py extension previously created when we used the menu command: File → Save Level 2 Script.
The advantage of running a Mininet custom topology script is that you can edit the script originally created by MiniEdit to create more complex scenarios and to use Mininet features not supported by MiniEdit.
To run the custom topology you created in MiniEdit, execute the Mininet custom topology script. First, change the file permissions so it is an executable file, then execute the file. In the example below, the file is named test-001.py.
$ cd ~/mininet/examples/test $ sudo chmod 777 test-01.py $ sudo ./test-01.py
The script sets up the network topology and the
mininet> command line prompt appears. Now you can test the scenario by using the ping command to test connectivity between hosts in the network. For example:
mininet> h1 ping -c3 h2 mininet> h1 ping -c3 h8
We used MiniEdit to create and run a simulation of a custom network topology. We showed how to use many of MiniEdit’s features.
MiniEdit seems to be a useful tool for creating custom software-defined network simulation scenarios.