OFNet SDN network emulator

OFNet is a new software-defined network (SDN) emulator that offers functionality similar to the Mininet network emulator and adds some useful tools for generating traffic and monitoring OpenFlow messages and evaluating SDN controller performance.

ofnet-splash

OFNet is an open-source project that is distributed as a virtual machine (VM) image. The OFNet source code is available in the OFNet VM’s filesystem. In this post, we will use the OFNet VM provided by the OFNet developer to run SDN emulation scenarios in OFNet.

Updated April 25, 2019: The OFNet SDN network emulator is now a dead project. The ownership of the OFNet project’s domain, *http://sdninsights.org*, has lapsed and it has been taken over by spammers. It appears there is no trace of the original project on the web. RIP OFNet.

The OFNet Virtual Machine

The OFNet VM image is packaged as an OVA file which can be imported into most virtual machine managers. In this case, we are using VirtualBox. You may download the OFNet VM from the OFNET web site.

The OFNet VM contains a Linux system running Ubuntu 12.04 and has the VirtualBox extensions installed.

Create a new virtual machine using the OFNet VM image, start up the VM and log in. After logging in, review the available OFNet documentation and install Wireshark.

Install the OFNet VM in VirtualBox

Import the OFNet.ova file into VirtualBox. Use the File → Import Appliance VirtualBx menu command or press <Ctrl-I>. Navigate to the location where you saved the OFNet.ova file and select it. Click Next and then click Import.

Start the VM. It will start in graphical desktop mode and ask for a login password. Login using userid: ofnet and password: ofnet.

The password is ofnet
The password is ofnet

Do not upgrade the VM

After logging into the VM, do not upgrade the VM. The Ubuntu Software Updater will ask you to upgrade. Ignore it.

The OFNet VM is based on Ubuntu 12.04. You do not need the latest version of every Ubuntu 12.04 package to perform experiments with OFNet and upgrading may cause problems on this VM. In my case, I upgraded to the latest 12.04 patches and after that the VM kept sending me error messages stating “System problem detected”. So I deleted the VM and created a new OFNet VM by importing the OFNet.ova file again.

Review the OFNet documentation

Review the OFNet documentation. The OFNet SDN network emulator is not yet fully documented but you may review the tutorial on the OFNet web site, work through the OFNet demo script provided with the OFNet VM, and read text files in the VM filesystem to learn how to set up and run OFNet SDN emulations. Below is a list of useful documents that explain how to use OFNet:

  • A brief OFNet tutorial is available at the OFNet web site.
  • The README file is available in the OFNet VM at ~/ofnet/README.
  • The tmp_doc file at ~/ofnet/documentation/tmp_doc documents how to build an OFNet topology file.
  • Look at the contents of files in the ~/ofner/demo directory to see examples of network topology files.
  • The dir_structure file at ~/ofnet/documentation/dir_structure shows the location of configuration and runtime files.
  • Launch the OFNet_Demo script in the Desktop folder of the OFNet VM. Follow the instructions in the script to walk through the main features of OFNet.

All OFNet files are in the ~/ofnet folder.

Install Wireshark

The Wireshark packet analyzer is not installed in the OFNet VM. We must install a recent version of Wireshark because we need the OpenFlow display filters. Install the newest stable version of Wireshark from the PPA as follows:

$ sudo add-apt-repository ppa:wireshark-dev/stable
$ sudo apt-get update
$ sudo apt-get install wireshark

Build and run and OFNet network emulation scenario

To run a network emulation in OFNet, users first use a text editor to create a topology file. Then they compile the topology file into a network file. Next, they start up and configure the SDN controller that will run the network scenario. Finally, OFNet uses the network file to start the network.

Create an OFNet topology file

To create an OFNet SDN emulation scenario, you must start with an OFNet topology file. The format of the file can be very simple but the topology description syntax also supports complex customized scenarios.

To learn more about the OFNet topology file syntax and the rules for creating a topology file, read the file ~/ofnet/documentation/tmp_doc in the OFNet VM. Also, you can look at the demonstration topology files in the ~/ofnet/ofnet/demo folder.

For example, a regular tree topology can be created with just a few lines of text. In this case, I used a text editor to create the file shown below:

TOPOLOGY TREE {

   3,3,3;

   CONTROLLER SECTION :

   contr0(127.0.0.1);

   ALL -- contr0;

}

This file will create a topology consisting of a tree topology three levels deep, with three leaves per node, and with three hosts as leaves at the last level

The topology file also defines the network address of the SDN controller. In this example, the SDN controller is installed on the same machine as OFNet so we use the system loopback address. If the SDN controller is running on another machine, you may enter the IP address of the other machine.

I saved the topology file in the folder ~/ofnet/demo, alongside other demonstration topology files. You can use any filename but the OFNet developer’s convention seems to be to use the filename extension “.topo”. In this case, I chose to use the filename test.topo.

Using the Topology Create command, topo_create

As an alternative to building a topology file, you may create simple standard network topologies using the topo_create command. Use the -help parameter to see all the command options.

$ topo_create -help

Help :
   topo_create -f topo_file_name -t type p1 p2 .. [-c controller_ip]

   Syntax :

   tree    :   topo_create -t tree levels children leaves [-c controller_ip]
   ring    :   topo_create -t ring nodes hosts [-c controller_ip]
   overlay :   topo_create -t overlay vswitches vms [-c controller_ip]
   matrix  :   topo_create -t matrix rows columns hosts [-c controller_ip]

For example, to create the same tree topology as shown above, type the following command:

$ topo_create -f test.topo -t tree 3 3 3

This will create a file test.topo that contains text similar to the file we previously created.

The topo_create command automatically compiles the topology file so it also creates a network file, which in this case is named test.topo.net. When using the topo_create command, you may skip the compile step described below.

Compile the OFNet topology file

To run the OFnet scenario we must compile the topology file we created above. Remember, I saved the file as: ~/ofnet/demo/test.topo.

The topology compile command, topoc, builds a network file that can be used to build the OFNet network emulation. The command parameters are the topology file name, test.topo, and the output file name. You may use any name for the output file but the OFNet developer’s convention is to use a filename with the extension, .net.

$ cd ~/ofnet/demo
$ topoc test.topo test.net

The compile process creates the network file ~/ofnet/demo/test.net* and also outputs an image of the network topology. In our case, the network appears as shown below:

OFnet topology
OFnet topology

By default, OFNet switches are named gs0, gs1, …gsx and hosts are named gh1, gh2,…ghy.

OFNet assigns Ethernet MAC addresses and IP addresses sequentially by default. The IP addresses of host gh1 is 10.0.0.1 and its MAC address is 00:00:00:00:00:01. Similarly, the IP addresses of host gh27 is 10.0.0.27 and its MAC address is 00:00:00:00:00:1B (which is 27 in hexadecimal).

Start the Floodlight SDN controller

The OFNet VM has two SDN controllers installed — Floodlight and Beacon.

In this example, I will use the Floodlight SDN controller. Start the controller using the start_floodlight_controller.sh script.

$ start_floodlight_controller.sh

You will see the controller start and it will begin posting log messages to the terminal screen. Leave this terminal window alone until you need to quit Floodlight.

OpenDaylight controller

I prefer to use the OpenDaylight SDN controller so I will cover installing and using OpenDaylight at the end of this post. I use Floodlight for now because I found that some OFNet features did not work well with OpenDaylight.

Start the OFNet network

To start the OFNet network, open a new terminal window and run the ctopo command.

$ ctopo netup test.net

The command will output the following text and the results of a ping test.

CREATING YOUR NETWORK TOPOLOGY. PLEASE WAIT.. THIS MIGHT TAKE SOME TIME

Total Switches : 13, Total Hosts : 27  

Test : hsh gh1 ping -c 3 10.0.0.10

PING 10.0.0.10 (10.0.0.10) 56(84) bytes of data.
64 bytes from 10.0.0.10: icmp_req=1 ttl=64 time=1103 ms
64 bytes from 10.0.0.10: icmp_req=2 ttl=64 time=100 ms
64 bytes from 10.0.0.10: icmp_req=3 ttl=64 time=0.138 ms

--- 10.0.0.10 ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2030ms
rtt min/avg/max/mdev = 0.138/401.342/1103.551/498.219 ms, pipe 2
$ 

Note that the startup ping test is hard-coded to ping from host gh1 to host gh10. So, if you build a topology with less than 10 hosts, do not worry if the startup ping test fails.

Now the network is running and you may use OFNet commands to interact with hosts.

More options

The ctopo command can also be used while the network is running to take down or bring up links, add links, delete links, and more. Use the -help option to see the command options:

$ ctopo -help
Help : ctopo
ctopo
ctopo [-c | -nd | -help] addlink/deletelink/linkup/linkdown node1 node2
ctopo netdown
ctopo [-of[1.0|1.2|1.3|all] [-pport] [-iinterface] netup image_file

The Floodlight controller GUI

To view the Floodlight controller’s graphical user interface, open a browser window and enter in the URL: `http://127.0.0.1:8080/ui/index.html`. This will open a page that shows the Floodlight Dashboard.

Floodlight GUI
Floodlight GUI

The dashboard shows the switches and hosts in the network. Users can get more details about each switch or host by clicking on the switch’s DPID or the host’s MAC address in the dashboard. For example, the details for switch gs0 are shown below:

Floodlight shows flows on switch
Floodlight shows flows on switch

Clicking on the Topology shows the Floodlight controller’s view of the network.

Floodlight topology view
Floodlight topology view

So we can see that OFNet allows users to experiment with different functions of SDN controllers like Floodlight.

OFNet commands

The OFNet SDN network emulator provides many built-in commands that allow users to perform functions such as: run commands on hosts, generate random pings, ping all nodes, animate openflow events, etc.

Host Shell command, hsh

The host shell command, hsh allows the user to execute commands on any host in the emulated network. For example, to make the host gh1 ping host gh24, execute the following OFNet command:

$ hsh gh1 ping -c 1 10.0.0.24

Or, to list the contents of the current directory in the gh1 host’s filesystem, enter the command:

$ hsh gh1 ls

Using hsh, the OFNet user may run commands like ip, ifconfig, ping, netperf, etc… to make configuration changes in the hosts and to generate network events.

Forwarding State command, fstate

The OFNet fstate command will output graphical information related to the last command executed in the network. For example, if we launch a ping command from host gh4 to host gh15, we execute the command:

$ hsh gh4 ping -c 1 10.0.0.15; fstate

The command opens a web browser to display and HTML file containing the forwarding state information collected by the fstate command:

Output of fstate command
Output of fstate command

The fstate command seems to be useful for demonstrating the OpenFlow forwarding state to people learning about SDN. I think this is one feature of OFNet that would be useful to educators.

OpenFlow Event command, ofevent

The OpenFlow Event command ofevent provides more information about the OpenFlow messages exchanged between the SDN controller and the network switches when a network event occurs, and also provides flow state information.

For example, if we want to see the OpenFlow events generated by a ping command from host gh18 to host gh24, we run the command:

$ ofevent hsh gh18 ping -c 1 10.0.0.24

The ofevent command creates a report consisting of flow diagrams and event diagrams to show how the controller and the network nodes communicate together to create the OpenFlow forwarding tables.

The first diagram illustrates the OpenFlow messages and flows created in the network.

OpenFlow event diagram
OpenFlow event diagram

The Control Plane Transactions chart shows OpenFlow messages between the switches and the SDN controller:

Control Plane Transactions
Control Plane Transactions

The Forwarding Diagram show the forwarding state after the flows have been set up, similar to the output of the fstate command above.

Forwarding state diagram
Forwarding state diagram

Users may hover the mouse pointer over the arrowheads in the diagrams to see what events are represented by each arrow. These diagrams and reports are useful when you are building your own OpenFlow applications and wish to see how flows are created on the network.

The ofevent command appears to be another command that would be useful to educators. However, the output of the command quickly becomes overwhelming if you try to track more than one or two events. For example, try running the command ofevent pingall and see what happens.

Traffic Generator

OFNet includes a traffic generator command, tctrl, which will source and sink different types of data between hosts in the OFNet emulated network.

Run the tctrl help command to see all the command options:

$ tctrl help
     tctrl history last_n#
     tctrl failure_history last_n#
     tctrl fail_list
     tctrl start
     tctrl restart
     tctrl stop
     tctrl exit
     tctrl (all|web|dns|nfs|lsend|ftp|telnet|ping|multicast)(on|off)
     tctrl log off|on
     tctrl set_fps fps#
     tctrl get_fps 
     tctrl multicast_server gh#
     tctrl dns_server gh#
     tctrl nfs_server gh#

The OFNet VM comes with a scripts named trafficup and trafficdown, which execute a series of tctrl commands to start traffic in the network and also starts the traffic monitoring function. In the example below we start generating and monitoring traffic.

$ trafficup
Starting traffic generator..
Erase Previous Failed Events ? (y/n)   
y
Traffic Generators Spawned

Traffic configuration file /tmp/traffic.conf does not exist.
Using defaults
Current Traffic Rate (Desired) : 100 Flows/Second
Current Traffic Rate (Actual) : 0 Flows/Second
Current Failure Rate : 0 Flows/Second
Total Flows Generated : 0 
Total Failures : 0 

Individual Interarrival Times (per host)
    DNS : 480 msecs
    Web : 1200 msecs
    Ping : 1600 msecs
    NFS : 4800 msecs
    Multi-cast : 4800 msecs
    Large-send : 12000 msecs
    FTP : 12000 msecs
    Telnet : 24000 msecs

EVENT_CLOCK_TICK_MS : 300 msecs Total hosts : 24

DNS Server (simulated) : gh2
NFS Server (simulated) : gh22
Multicast Server : gh12

Traffic generator started
All web traffic turned off
You may exit by running `trafficdown` from another window

After a while, the traffic monitoring dashboard will show the results of the traffic generated and the SDN controller behavior as shown below:

Traffic monitoring dashboard
Traffic monitoring dashboard

Each point on the X-axis of each chart above represents ten seconds. So the example above shows 60 seconds of data.

See the scripts in the ~/ofnet/bin/sh folder for more examples of using tctrl command.

To stop traffic, run the trafficdown script from another terminal window.

$ trafficdown

Viewing traffic generation logs

To view the commands that OFNet is running the hosts to generate traffic, use the tctrl history command. This is helpful if you are debugging unexpected results.

For example, the following command will output the last 4 commands that generated traffic in the emulated network:

$ tctrl history 4

279. On Host : gh2 Command : hsh gh2 netperf -H 10.0.0.2 -t UDP_RR -l -1 -- -r 128,128 > /dev/null 2>> error_traffic.log Return Status : 0

278. On Host : gh4 Command : hsh gh4 netperf -H 10.0.0.2 -t UDP_RR -l -1 -- -r 128,128 > /dev/null 2>> error_traffic.log Return Status : 0

277. On Host : gh3 Command : hsh gh3 ping -c 1 10.0.0.10 > /dev/null 2>> error_traffic.log Return Status : 0

276. On Host : gh3 Command : hsh gh3 netperf -H 10.0.0.2 -t UDP_RR -l -1 -- -r 128,128 > /dev/null 2>> error_traffic.log Return Status : 0

In the history file, we see each command “silences” its output by directing STDOUT to /dev/null but each command still logs errors by directing STDERR to the error_traffic.log file. See this explanation of the command syntax.

Other OFNet commands

Run the ofnet_cmds command to see a list of most of the OFNet commands.

$ ofnet_cmds 

-----------------------------
OFNet Quick command reference
-----------------------------

You have enter each of the command with -help option to view the detailed help.

topo_create -> Creates standard topologies - tree, ring, overlay

topoc -> Compiles a custom topology in to a n/w image

ctopo -> Start/stop network, add/delete links, bring down/up links, view current topology

hsh -> Run a command on a host

pingall -> Every host pings every other host

npings -> Generate n random pings

fstate -> Show current forwarding state

ofevent -> Run a command as an event and show what happened

event_animate -> Show the previously ofevent as an animation

trafficup -> Start traffic generator

trafficdown -> Stop traffic generator

tctrl -> View/control traffic generation

save_ofevent -> Saves a the output of last ofevent command as a zip file

view_ofevent -> To view saved ofevent as a zip file

ofclean -> Clean directories in case of errors

ofstat -> Display various statistics

Another useful command is the get_host_ip command, which will output the IP address if given the hostname as an input. For example:

$ get_host_ip gh1

Using WireShark with OFNet

Wireshark can be used to capture and display OpenFlow messages passing between the controller and the switches in the OFNet emulation. Wireshark can also capture and display network traffic passing on links between nodes in the emulated network.

To start Wireshark, run the command:

$ sudo wireshark &

To capture and display OpenFlow messages, select the loopback interface in Wireshark and start capturing.

ofnet-wireshark-002

Other system traffic is also running on the loopback interface so we need to filter the displayed packets so we see only the OpenFlow messages we want to see. Enter openflow_v1 in the display filter field as shown below. Now we see the OpenFlow messages. This is useful for analyzing controller or network application behaviors.

Captured OpenFlow traffic
Captured OpenFlow traffic

Network traffic between hosts and switches may be viewed in Wireshark if we capture traffic from an interface created by OFNet. In this example, we will capture packets on the link gs0_to_gs1 since most traffic will pass through the “backbone” of the network.

Stop the capture and then select the interface gs0_to_gs1. Then, start the capture again.

Capture on interface *gs0_to_gs1*
Capture on interface *gs0_to_gs1*

Next, run an OFNet command to generate some traffic. In the example below, we ran the following command in a terminal window:

$ hsh gh1 ping -c 1 10.0.0.24

Now we see the data passing between host gh1 and host gh24 across the link between switches gs0 and gs1 in the emulated network.

Captured network traffic on link *gs0_to_gs1*
Captured network traffic on link *gs0_to_gs1*

Quit the demo

To stop the network emulation and free up resources, use the ctopo netdown command with the same network file that you previously used to start the network as an input parameter.

$ ctopo netdown test.net

Then, quit the Floodlight SDN controller by entering the <Ctrl-C> key combination in the terminal window that was running Floodlight.

OpenDaylight SDN Controller

Now we’ve demonstrated most of OFNet’s major features. In the next sections, I discuss using OFNet to compare different SDN controllers. OpenDaylight is a popular SDN controller so I will install OpenDaylight in the OFNet VM and then show how it works in OFNet.

As I worked through the steps below, I found that OpenDaylight is not stable when interoperating with OFNet. You may find at times that it does not work as expected. I found that restarting the VM sometimes solved problems with OpenDaylight and OFNet.

Install Java 8

To install the latest version of the OpenDaylight SDN controller, we must first install Java version 8.

Install Java 8 since Boron requires it and Ubuntu 12.04 comes with java 6

$ sudo add-apt-repository ppa:openjdk-r/ppa
$ sudo apt-get update 
$ sudo apt-get install openjdk-8-jdk
$ echo "export JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64" >> ~/.bashrc
$ source ~/.bashrc

Run command to verify correct version of Java will be used:

$ sudo update-alternatives --config java

The output should look like:

  Selection    Path                                            Priority   Status
------------------------------------------------------------
* 0            /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java   1069      auto mode
  1            /usr/lib/jvm/java-6-openjdk-amd64/jre/bin/java   1061      manual mode
  2            /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java   1069      manual mode

The asterix indicates that java-8 is the default version of Java. Press <Enter> to continue.

Install OpenDaylight

Install OpenDaylight on the OFNet VM by running the commands shown below. I describe these commands in more detail in my post about Using OpenDaylight with Mininet.

First choose a directory where you will download OpenDaylight (I chose my home directory), download the OpenDaylight container and extract it from the compressed archive.

$ cd ~
$ wget https://nexus.opendaylight.org/content/groups/public/org/opendaylight/integration/distribution-karaf/0.5.0-Boron/distribution-karaf-0.5.0-Boron.tar.gz
$ tar -xvf distribution-karaf-0.5.0-Boron.tar.gz

Take a VirtualBox snapshot of the OFNet VM before you run OpenDaylight and install features in OpenDaylight. In the future, if you want to start from a clean install of OpenDaylight you will use this snapshot.

Run OpenDaylight and install useful feature bundles:

$ cd distribution-karaf-0.5.0-Boron
$ ./bin/karaf
OpenDaylight console
OpenDaylight console

Next, install the bundles that enable functionality similar to switched Ethernet network, enable the DLUX OpenDaylight GUI, and enable host tracking:

opendaylight-user@root> feature:install odl-restconf odl-l2switch-switch-ui odl-mdsal-apidocs odl-dlux-all

Once installed, these bundles will start whenever OpenDaylight is started. They do not need to be re-installed after shutting down OpenDaylight. In fact, installed bundles cannot be easily removed. If you need to go back to the OpenDaylight base configuration, restart the OFnet VM from the VirtualBox snapshot you created above.

Remember: When you want to stop the controller, enter the key <ctrl-d> combination or type system:shutdown or logout at the opendaylight-user@root> prompt.

Use OpenDaylight with OFNet

After installing OpenDaylight in the previous section, it should be controlling the switches in the OFNet emulated network.

While testing OpenDaylight in the same way I tested Floodlight above, I noticed that OFNet does not track OpenFlow messages generated by OpenDaylight in the same way it tracks OpenFlow messages generated by Floodlight.

ofevent and fstate commands with OpenDaylight

The ofevent and fstate commands do not work when using OpenDaylight to control the network. They do not show any flows or forwarding status changes. I think that OFNet needs to be updated to correctly parse OpenFlow messages generated by OpenDaylight.

Using the OpenDaylight GUI

In addition to seeing that traffic can be sent from one host to another, we can use the OpenDaylight GUI to see how OpenDaylight is discovering nodes in the emualated network.

Open a browser window and type in the OpenDaylight GUI URL, which is `http://127.0.0.1:8181/index.html`. The OpenDaylight DLUX GUI will appear. We should see the topology of switches.

OpenDaylight network view at startup
OpenDaylight network view at startup

OpenDaylight does not automatically discover hosts. But when it received a packet from a host it can discover the host. Here for example is the change to the OpenDaylight’s view of the topology after running the command:

$ hsh gh1 ping -c 1 10.0.0.24
OpenDaylight network view after one ping
OpenDaylight network view after one ping

When we ping to and from every host using the pingall command, OpenDaylight learns about all hosts in the network:

OpenDaylight network view after pingall
OpenDaylight network view after pingall

This shows that OpenDaylight is working with OFNet.

Comparing controllers

OFnet’s traffic generation and monitoring features make it possible to characterize the performance of different network controllers or network applications. As an example, let us compare the monitored behavior of OpenFlow messaging generated by two different network controllers: Floodlight and OpenDaylight.

Here we use OFNet’s traffic monitoring function to look at the differences in behavior of the two controllers. This first dashboard shows the Floodlight controller’s performance measured over a period of five hundred seconds.

OpenDaylight network view after pingall
OpenDaylight network view after pingall

This next dashboard shows the OpenDaylight controller’s performance measured over a period of five hundred seconds.

OpenDaylight network view after pingall
OpenDaylight network view after pingall

Comparing these two results shows us that the two controllers seem to be operating very differently. For example: OpenDaylight seems to be able to offer network connectivity to all hosts while generating significantly fewer OpenFlow messages and a much smaller number of flow table entries.

I cannot confirm that the monitoring is accurate. For example: the OFNet ofevent and fstate commands could not interpret OpenFlow messages sent by OpenDaylight so maybe the OFNet traffic monitoring feature is also misinterpreting OpenFlow traffic for OpenDaylight. More analysis is needed to make a real conclusion.

The above example shows the potential to use OFNet to characterize controller behavior and performance.

Conclusion

OFNet is a new project designed to emulate SDN networks. It provides visual presentations of control plane transactions. OFNet offers a virtual machine image you can try. OFNet is an open source project and the source code is included on the OFNet VM, in the ~/ofnet/src directory.

Unfortunately, as of April 2019 the OFNet SDN network emulator is a dead project. The ownership of the OFNet project’s domain has lapsed and it has been taken over by spammers. There is no trace that I can find of the original project on the web.

RIP OFNet.

3 thoughts on “OFNet SDN network emulator”

    1. After creating custom topology ,when i open floodlight controller interface it gives default number switches((7 switches)…not my updated one..i mean my topology file can not connect to controller although start the controller. Please give me solution…

Comments are closed.

Scroll to Top