Create an OpenFlow Network within a single PC
For more detail, visit
http://www.openflowswitch.org/wk/index.php/OpenFlowVMS
1. Overview
When developing applications using OpenFlow, a small network of OpenFlow switches is often needed for testing and debugging. Using a simulated network for such development would be ideal, allowing more people to develop efficiently at their own pace. The
OpenFlow Virtual Machine Simulation (
OpenFlowVMS) package is developed to create that virtual simulated network in your very own desktop/laptop.
OpenFlowVMS is a set of Python scripts that create that virtual simulated network automatically, letting developers concentrate on their real tasks and not fight the details of setting up a testbed.
2. Description of an Example Network
3. Hardware Requirement
You will need a Linux PC. If you have Windows or Mac, you can use a virtual machine to run Linux on top of it. People have successfully used VMWare and VirtualBox. In the following, we assume you have Debian Linux (Lenny).
4. Setup Network
Step1: Install the dependencies
In Debian, run the following command
sudo apt-get install vde2 graphviz gv qemu genisoimage psmisc \
debootstrap git git-core screen xterm python2.5 python-xml
Step2: Download Software and Disk Images
Get OpenFlowVMS using git with
git clone git://openflowswitch.org/openflow-vms.git openflowvms
You will see the following directory/file structure.
openflowvms
|- bin
|- vms-*.sh
|- vms-*.py
|- pylib
|-*.py
|- samples
|-*.xml
|- xsd
|-*.xsd
Make sure that
- openflowvms/pylib directory is in your PYTHONPATH
- openflowvms/bin directory is in your PATH
If you are sadly behind a firewall, try
gitweb. More instructions for Git is available at
the git page.
Then, download the following files:
| File Name | Description | For OpenFlow v0.8.9 | For OpenFlow v1.0 |
| hda.dsk | disk image used for the hosts running on qemu | Download Link |
| kernel.bin | kernel image used for the hosts running on qemu | Download Link |
| ofdatapath.ko | openflow switch (kernel module); not supported from v1.0 and later
| Download Link | Download Link |
| ofdatapath | openflow switch (userspace)
|
| ofprotocol | openflow protocol module (used to communicate to the controller) |
| dpctl | openflow datapath control command |
If you want to modify these files, you can create them by yourself. Please refer to
OpenFlowVMS page.
Next, create the working directory for yourself and place the downloaded files as follows (the blue colored names are the downloaded files.)
<working directory>
|- openflow.cd
|- ofprotcol
|- dpctl
|- ofdatapath.ko (not included in v1.0)
|- ofdatapath
|- kernel.bin
|- hda.dsk
Step3. Create Configuration File
Create network configuration file describing
this topology. Let's start with the example configuration file, openflowvms/examples/2hosts-1ofsw.vms.xml, to create our own file.
$ cp openflowvms/samples/2hosts-1ofsw.vms.xml <working directory>/2hosts-2ofsw.vms.xml
The original file should look like this:
<network name="Simple Network">
<of_mem>48</of_mem>
<openflowswitch name="of1">
</openflowswitch>
<host name="host1">
<ip><dynamic/></ip>
</host>
<host name="host2">
<ip><dynamic/></ip>
</host>
<link end1="of1" end2="host1" />
<link end1="of1" end2="host2" />
</network>
We modify it to the following (the modified part is highlighted by red)
<network name="Simple Network">
<of_mem>48</of_mem>
<openflowswitch name="of1">
<!--To let spawn an xterm-->
<xterm>true</xterm>
</openflowswitch>
<openflowswitch name="of2">
<xterm>true</xterm>
</openflowswitch>
<host name="host1">
<xterm>true</xterm>
<ip><static>192.168.100.1</static></ip>
</host>
<host name="host2">
<xterm>true</xterm>
<ip><static>192.168.100.2</static></ip>
</host>
<link end1="of1" end2="host1" />
<link end1="of1" end2="of2" />
<link end1="of2" end2="host2" />
</network>
Step4. Verify Configuration File
There are a few ways to check the validity of the configuration we have created above. It is a good practice to validate your network, before running it (you can skip this step if you're confident with the correctness of your configuration file).
To verify the xml file
We can check the validity of our configuration by verifying it against its schema definition.
$xmlstarlet val -e -s openflowvms/xsd/vms.xsd <working directory>/2hosts-2ofsw.vms.xml
Errors will be listed if any, else the file will be declared as valid.
To verify the network topology
Also, we can draw the network and see if it is what we have intended.
$ vms-draw.py 2hosts-2ofsw.vms.xml
5. Setup Controller
Please refer to the
Controller Setup Section for multiple PCs/NetFPGA setup. Please make sure you run your controller on port 6633. Also, you need to match OpenFlow protocol version with switches and the controller. If you use OpenFlow v0.8.9 switches, which talks wiring protocol 0x97, you need a controller compiled with OpenFlow v0.8.9. If you use OpenFlow v1.0 switches, which talk wiring protocol 0x01, you need a controller compiled with OpenFlow v1.0. The above link has an explanation how to compile each version.
6. Run/Stop
To run your network, you will now run the following commands:
For kernel space switch (for v0.8.9 only) :
vms-start.py 2hosts-2ofsw.vms.xml
For user space switch (for v1.0 and for v0.8.9 if you prefer user space switch) , "-u" option is needed:
vms-start.py -u 2hosts-2ofsw.vms.xml
Note that files and directories needed for the setup will be checked for in the script.
Note that the
vde directory generated contains the UNIX sockets through which you can control the VDE switches and wirefilters. Hosts and OpenFlow switches are run in qemu virtual machines, using screen.
Viola! Your very own OpenFlow network! All you have to do is to have your OpenFlow controller running at
localhost port 6633.
To stop simulated network, there are two ways. The recommended way is to run
./<your network name>-stop.sh
which is generated when you run
vms-start.py (<your network name> is "2hosts-2ofsw" in this case). The other "violent" method is to kill all the networks at one go using
vms-start.py -k
7. Basic Testing
On the controller PC, first check the switches are connected to the controller. You can check this by
$ netstat -n | grep 6633
To login to the host1, run the following command (both login name and password are "root").
$ screen -r host1
Similarly, to login to the of1 (openflow switch), run the following command:
$ screen -r of1
On the host1, run ping to check the the reachability to host2.
# ping 192.168.100.2
On each openflow switch, you can run the following command to see the flow table is actually installed.
# cd /cdrom
# ./dpctl dump-flows nl:0