When a researcher uses the Mininet network simulator to create a network of hosts and switches connected to an SDN controller, he or she may wish to be able to see what the simulated network topology looks like.
The POX SDN controller includes a component that will send network topology data to the Gephi data visualization platform, which can the show a graph of nodes and links representing the network topology. In this post, I will show how to set up POX and Gephi so we can see the network topologies created using the topology options in the Mininet command.
While we work through this tutorial we will also see how the POX SDN controller, which does not offer a native Northbound API, can use POX components to provide northbound interfaces.
Prerequisite skills and activities
This tutorial assumes you already have the following. I include links to relevant posts if you need to review any of these requirements.
- You have a basic understanding of Ethernet, IP, and software defined networking.
- You have set up the Mininet 2.2.1 virtual machine on your computer
- You have a basic understanding of how Mininet commands work
- You are familiar with the POX SDN controller
- You installed Gephi on the Mininet VM.
This is a long post. Here is an overview of the main steps we will follow in the tutorial, with links to each section:
- How to log into the Mininet VM
- Important: you must upgrade the POX controller to the dart branch
- A detailed description of the stock POX components used in this tutorial
- How to set up Gephi by installing the Graph Streaming plugin and adding a streaming client
- Run Mininet and set up a standard network topology
- Modify Gephi settings so you can view the network graph.
- Observing real-time network topology changes in Gephi
- Examples of more network topologies
Log into the Mininet VM
The Mininet VM should be running on your computer (see the links in section above if it is not) and should be accessible at the IP address assigned by the VirtualBox host-only interface. In our example, this is IP address 192.168.56.101. Check the interface on the Mininet VM to see which IP address is assigned in your case.
From a terminal window on your host computer, access the Mininet VM with the command:
t400:~$ ssh -X email@example.com
Enter the password, which is mininet. The prompt will show you are now logged into the Mininet VM:
Open three terminal sessions
I recommend you open three terminal windows and log into the Mininet VM from each one. Each terminal window will be your console for each of the following programs:
Upgrade the POX controller
The version of POX running on the Mininet 2.2.1 VM is the carp branch. This version has a bug in it that prevents it from connecting the the Gephi graph streaming plugin. See the comments below the POX-Gephi graph streaming announcement for more information.
The bug is fixed in the dart branch. To upgrade, execute the following commands on the Mininet VM:
$ cd ~/pox $ git checkout dart
In the first terminal window (or tab), we will run the POX SDN controller.
When we start POX, we will select standard POX components, one of which is the misc.gephi_topo component, to create an SDN application. The misc.gephi_topo component is the component that provides a data stream to the Gephi graph visualization platform.
The command we use to start POX is:
$ sudo ~/pox/pox.py forwarding.l2_learning \ openflow.discovery misc.gephi_topo \ openflow.spanning_tree --no-flood --hold-down \ host_tracker info.packet_dump \ samples.pretty_log log.level --DEBUG
Monitor the POX console
Now we see that POX is running. On the terminal session we used to start POX, we see the POX log messages showing actions detected or performed by each POX component that is running.
The stock POX components
You may skip this section if you are not interested in the functions provided by each of the POX components we chose to run.
The command we used to start the POX controller also specified the POX components that will run along with the controller. The sections below describe the function of each component we use in this example:
The L2 Learning component makes OpenFlow switches act like Ethernet learning switches. It learns Ethernet MAC addresses, and matches all fields in the packet header so it may install multiple flows in the network for each pair of MAC addresses. For example, different TCP connections will result in different flows being installed.
This L2 Learning component creates flows with idle timeout values so switches will automatically delete flows that have not services packets during the timeout period (which is ten seconds). This helps keep flow tables manageable.
The OpenFlow Discovery component uses LLDP messages sent to and received from OpenFlow switches to discover the network topology. It also detects when network links go up or down. This information may be used by other components.
The Gephi Topo component streams updates from POX to the Gephi graph visualization platform when POX detects changes to the network topology.
The Gephi Topo component effectively creates a northbound interface to the Gephi graph visualization platform. It streams real-time data to an IP address and port to which Gephi will be listening, in a format Gephi can interpret.
openflow.spanning_tree ‐‐no-flood ‐‐hold-down
The Spanning Tree component is required in cases where the topology of the network contains loops. It works with the OpenFlow Discovery component to build a view of the network topology and constructs a spanning tree by disabling flooding on switch ports that aren’t on the tree. The options no-flood and hold-down are used to ensure no packets are flooded in the network before the component creates the spanning tree.
The Spanning Tree component will respond to changes in the network topology. If a link is broken, and if an alternate link exists, it can maintain connectivity in a network by creating a new tree that enables flooding on the ports connected to the alternate link.
When using the Spanning Tree component, also use a forwarding component that creates flows that have a timeout value set. In this example, we used the L2 Learning component.
The Host Tracker component attempts to keep track of hosts in the network. Host Tracker examines messages received by POX and learns MAC and IP of hosts in the network. Host Tracker will work in our example but it relies on packets coming to the controller. Packet forwarding in the network must be done reactively so we need to use a forwarding component like forwarding.l2_learning.
The Packet Dump component will display on the log console information about data packets received by POX from switches. This will help us see how the switches interact with the POX controller without running tcpdump.
The Log Level component allows the POX user to specify the amount of detail they will see in the log information produced by POX. The most detailed level is DEGUG, so we will use that in our example. By default, logs appear on the POX console so you will see them on the same terminal session used to start POX.
The Pretty Log component formats log messages into a custom log format to provide attractive and readable log output on the POX console.
To use the Gephi graph visualization platform as a network visualization tool, we need to install the Graph Streaming plugin so Gephi can receive information streamed from the POX SDN controller’s Gephi Topo component and we need to set up the graph display so that the graph is deployed in an readable manner.
In this tutorial, we will run Gephi on the Mininet virtual machine. If you have not already installed it, please see my post about installing Gephi on the Mininet VM.
Install the Gephi Graph Streaming plugin
Gephi provides a plugin for streaming graph data back and forth between it and another process, such as the POX SDN controller. We need to install the plugin and add a streaming client.
First, start Gephi (use a new terminal window).
$ cd ~/gephi/bin $ sudo ./gephi
To install the Graph Streaming Plugin, do the following:
In the Gephi user interface, go to Tools –> Plugins
Click on the Available Plugins tab on the plugins window and search for the Graph Streaming plugin. Select it and then click the Install button on the lower left of the window.
Gephi will ask to restart. Allow it to restart.
Add a streaming client
First, click on the Overview button at the top of the Gephi user interface. This will show you the Graph window and this is where the streaming window will appear after the Graph Streaming plugin is installed.
Configure the streaming server settings. The Gephi.Topo component uses TCP port 8282. Click the Settings button and set Port to 8282 and clear the SSL check box.
In the Gephi user interface, go to the Streaming tab and click the green “ADD” sign. A Connect to Stream configuration window will appear. Enter the URL to which Gephi will connect. In our case, both Gephi and the POC=X controller are running on the same machine so the IP address of the URL is the loopback address, which can be entered as either 127.0.0.1 or as localhost. The port number, as used by the Gephi_Topo component, is 8282. So enter the URL:
We see that a client and server is created in the Streaming tab. In the POX console, we should see a log message from the Gephi Topo component indicating it is connected to a client.
We are using the Mininet network emulator to create the network of switches and hosts. In this case, we are using the Mininet virtual machine, which is available from the Mininet web site.
In a new terminal session, run the command:
$ sudo mn --topo torus,3,3 --controller remote
This will set up a network topology in a torus configuration, which is a complex topology that contains loops. The network also connects to a remote controller using the default IP address and TCP port.
Mininet network is now running
At this point, you have the Mininet network running and you see the Mininet command prompt in the terminal session from which you started either MiniEdit or Mininet.
We can look at the POX SDN controller console and see the openflow events being handled by the POX controller, which are displayed in the POX log messages because we set the log level to DEBUG. We see the POX SDN controller connecting to switches and setting up the spanning tree.
Viewing network topologies
In the Gephi graph window, we will immediately see some nodes and links appear.
At this point in the tutorial, we have shown how to send data from the POX SDN controller to an external application, such as Gephi, using POX components.
However, the nodes and links in the graph appear at random locations and are so small we can barely see them. We need to modify some settings so we can get a better view of the nodes and links being displayed in Gephi.
First we will use one of Gephi’s Layout algorithms to automatically arrange the nodes and links for us. Open the Layout window with the menu command: Window –> Layout.
The layout panel will appear. In Layout panel, choose the Force Atlas layout. The Force Atlas layout arranges nodes and links around a “center of gravity”. It uses parameters specified by the user to determine how far apart nodes will be from each other and how much each node is attracted to the center of the graph.
The default settings will space the nodes too far apart so we change them to the values shown in the screen capture below, then click Run.
We see that the nodes move much closer to the centyer. In fact they may appear to completely disappear because they now occupy such a small section of the graph window.
Now we zoom in to view the nodes and links. Press middle mouse button and move the mouse up, or use the scroll wheel on mouse. Use the right mouse button to move the canvas around (after clicking on the drag tool, the hand icon on the left of the graph window). If you get lost, click the looking glass icon to center the view and return to default magnification, and try agaon.
We see only the switches in this view. The POX SDN controller has not yet detected any hosts because the Host Tracker component looks for ARP requests and responses sent by hosts and, since no traffic is running in our network yet, it has not seen any.
So we need to generate some traffic so that the POX SDN controller can detect the hosts and send the data describing them to gephi. A convenient way to generate traffic to every host is to use the
pingall command in Mininet. In the Mininet console, type:
We see Gephi placing the new hosts on the graph. Initially, they are placed at random locations on the graph but the Force Atlas laypit algorithim is running and pulls them into view. Note that the algorith will change the positions of all nodes in the network so the switches move, too. In the end, the graph changes to look like below:
You may need to change some of the layout Force Atlas parameters to get all the switches and hosts to appear in the graph window. In my case, I increased the Gravity and Attraction Strength parameters.
Now, stop the Force Atlas layout algorithm. The nodes stay where they are. But with the algorithm no longer constantly updating node locations on the graph, nodes will stay where we move them to instead of snapping back into place. Also, if we remove links, the nodes will not all move around into a new alignment, which can be distracting.
We do not know which switch is which. We need to add some labels to the nodes in the graph. Click the Show Labels button below the graph window.
By default, the labels will be too large and will obscure the graph. We can fix the label size by choosing a smaller font and using the label size slider.
Experiment until you find a label size that is easy to read.
Now, we can see the MAC address of each node. This is the MAC address of the interface on each node that is connected to the POX SDN controller.
Observing real-time network topology changes
Gephi is receiving a constantly-updated stream of data from the POX SDN controller. Gephi will display changes to the SDN network topology as they occur in real time. Let’s test this.
First, let’s view which nodes are connect to each other. In this particular case, and in more complex networks, it may not be obvious just by looking at the graph. You can see which nodes are connected to any node on the graph by hovering the mouse pointer over the node. This highlights connected links and nodes.
In this case, we see that the node with the MAC address 00:00:00:00:03:03 is connected to nodes with Mac addresses 00:00:00:00:03:01, 00:00:00:00:02:03, and 00:00:00:00:03:02.
On the mininet console, run the Mininet
net command to view the links in the Mininet simulation.
We know that the MAC addresses are set up by Mininet to easily identify each switch. Switch s3x3, for example, has the label 00:00:00:00:03:03.
So we can disconnect three of the links going to switch s3x3 with the following Mininet commands:
mininet> link s3x3 s3x1 down mininet> link s3x3 s2x3 down mininet> link s3x3 s3x2 down
We see that the links disappear in the Gephi graph window each time we take down a link.
More Mininet topologies
We can view what other mininet topologies look like in Gephi.
First, exit the current simulation in Mininet.
mininet> exit $ sudo mn -c
Then, create a new network using the Mininet command. Run
pingall each time to include the hosts in the graph.
The following Mininet command create a tree topology that is three levels deep than fans out with two links at each level.
$ sudo mn --topo tree,3,2 --controller remote mininet> pingall
Follow the same steps as shown in the sections above to create a readable topology. Then, drag the nodes around to align them into a layered tree model.
The following commands stop the running simulation and create a new linear topology made up of three switches with two hosts connected at each switch.
mininet> exit $ sudo mn -c $ sudo mn --topo linear,3,2 --controller remote mininet> pingall
We’ve seen how to set up a scenario that integrates the POX SDN controller with the Gephi graph visualization platform a via “northbound” interface provided by the Gephi Topo POX component.
We could explore further the functions provided by Gephi to make the graph more usable and to output the graph in an attractive format similar to the image at the top of this post. We will cover how to manipulate