Hcprobe

Framework for testing OpenFlow controllers

View the Project on GitHub ARCCN/hcprobe

Introduction

Hcprobe is a framework for testing OpenFlow controllers. It includes a library in Haskell that provides means to work with OpenFlow protocol. Also it includes a reference implementation of an OpenFlow software switch and a domain-specific language (EDSL) for constructing new custom switches and writing programs for them.

Hcprobe provides a bunch of libraries, which can be used for creating various tests (peformance, fuctional, security). The core of Hcprobe is FakeSwitch - a model of an OpenFlow switch with custom parameters and configuration. It performs initial handshake with a controller, defines a default switch behavior on receiving some types of OpenFlow messages and provides a callback-based interface for using it in your test scenarios.

You can implement any testcase you need using Haskell, though the most convinient way of creating new tests is with EDSL. EDSL provides means for creating any number of switches with custom settings, defining their logic, e.g. the scenario of sending any type of OpenFlow messages to the controller, and collecting various statistics.

A typical EDSL test includes a definition of OpenFlow switches, a sending messages scenario and, optionally, setting handlers for incoming and outcoming messages, which collect statistics or redefine the default switch behavior. A simple example of EDSL test (running one switch, which sends one PacketIn with bad length):

fakeSw <- config $ do
                switch $ do
                    addMACs [1..450]
                    features $ do
                      addPort [] [] [OFPPF_1GB_FD, OFPPF_COPPER] def
                      addPort [] [] [OFPPF_1GB_FD, OFPPF_COPPER] def
                      
withSwitch fakeSw "127.0.0.1" 6633 $ forever $ do
    let payload = putDefaultEthernetFrame
        msg     = putOFMessage $ do
                      putOFHeader $ do
                          putHdrType OFPT_PACKET_IN
                          putPacketLength 42 -- Bad length!
                      putPacketIn $ do
                          putPacketInData pl
        send msg

Build

To build hcprobe you need cabal.

To build it in a sandbox use cabal-dev tool:

cabal insatall cabal-dev

Building hcprobe with cabal-dev:

cd src
cabal update
cabal-dev install-deps
cabal-dev configure
cabal-dev build

Executables can be found in dist/build/

Hcprobe Tests

Hcprobe contains a reference switch implementation test and a number of EDSL test examples.

Reference Switch

For the source code see hcprobe.hs. This test emulates several OpenFlow switches, sending fixed PacketIn messages (the idea is same to the traditional Cbench controllers benchmark).

To run the reference switch implementation:

./dist/build/hcprobe/hcprobe

By default it runs 16 OpenFlow switches, which try to connect to an OpenFlow controller at 127.0.0.1, port 6633. You can change IP and the TCP port, the number of emulated switches and switch ports, the number of unique MAC adresses (hosts), assosiated with one port, etc. For the list of options run with --help.

EDSL Examples

Source code for EDSL examples can be found in examples, executables - in dist/build/.

The following examples describe basic templates for defining OF switches and their logic:

Also we used the following Hcprobe EDSL tests in our controllers testing project:

For more information on writing tests with EDSL see Documentation.

When creating a new test note that you need to add it to the hcprobe.cabal file to build executables (see existing entries for an example), then rebuild Hcprobe (see Build).

Contacts

If you have any questions or wish to contribute, please contact us: dev@arccn.ru.