nettle-netkit-0.2.0: DSL for describing OpenFlow networks, and a compiler generating NetKit labs.

Nettle.Netkit.LabUtil

Contents

Description

This module provides facilities for easily creating Netkit (http://wiki.netkit.org/index.php/Main_Page) labs to experiment with OpenFlow switches and controllers. This module provides a notation for describing simple OpenFlow-based network topologies, and provides a command that generates a NetKit lab that can be used to simulate the network.

To use this module, describe the configuration of your test network, including hosts, switches and their interconnectivity using the functions in this module (see the example below), and then run one of the makeLab commands to generate the Netkit files needed to run the lab. You can then move into the directory containing the Netkit lab and start the lab using Netkit commands (e.g. lstart). The generated lab will include hosts and switches, but not a controller. The lab will setup a TAP interface with subnet 10.0.0.0/8 from the switch virtual machines to the host on which you started the lab, and the switches will attempt to contact a controller with IP address 10.0.0.1 over that TAP interface, at the server port mentioned in the lab. You can then control the switches by starting a controller on the host at the specified port. See the example below for more details.

The generated lab is designed to work with a customized netkit file system that has OpenFlow software in a particular location. Instructions for obtaining this file system are here http://haskell.cs.yale.edu/?page_id=383; see the last instruction in the section on Installing on Your Own Machine. The generator (i.e. makeLab) must know the location of this file in order to generate the Netkit lab files. The default options assume the files are in the user's ~/.nettle directory, but they can be placed in other locations as well. If they are in another location, then the Lab options must be set appropriately.

Synopsis

Lab descriptions

data LabConfig Source

Constructors

LabConfig 

Fields

switches :: [Switch]

Switches for this lab

controllerServerPort :: ControllerTCPPort

The TCP port number at which the controller will listen for switch connections

hosts :: [((Host, Interface), SwitchPort)]

A description of where the host interfaces are attached to switches in the network

links :: [(SwitchPort, SwitchPort)]

A description of how switches are connected

data Options Source

A datatype for specifying lab options, including the paths to the kernel and filesystem used by netkit machines, as well as the OpenFlow version of the reference switch software.

Instances

data OpenFlowVersion Source

An enumerated data type representing OpenFlow versions supported by this module.

Constructors

Ver0_9_0 
Ver1_0_0 

newtype Switch Source

Constructors

Switch SwitchID 

Instances

data Host Source

Constructors

Host 

Fields

hostID :: Int
 

Instances

newtype Port Source

Constructors

Port PortID 

Instances

(#) :: Switch -> Port -> SwitchPortSource

Denotes a SwitchPort, i.e. a port on a switch.

(<-->) :: SwitchPort -> SwitchPort -> (SwitchPort, SwitchPort)Source

Denotes a link (switch-to-switch) connection.

(@@) :: (Host, Interface) -> SwitchPort -> ((Host, Interface), SwitchPort)Source

Denotes where a host is attached to the network of switches.

Generating labs

makeLab :: FilePath -> Options -> LabConfig -> IO ()Source

makeLabWithDefaults path options lab is a command that writes the files and directories needed to run a Netkit lab that implements the description provided by lab. It writes the files to directory path, and the options are specified by options.

makeLabWithDefaults :: FilePath -> OpenFlowVersion -> LabConfig -> IO ()Source

makeLabWithDefaults path version lab is a command that writes the files and directories needed to run a Netkit lab that implements the description provided by lab. It writes the files to directory path, and the switches will run the OpenFlow reference switch software for OpenFlow version version.

Example

Below is an example lab config, describing a network with 3 switches, each connected to the other two and 3 hosts (one per switch). The switches will attempt have one interface associated with a TAP interface on the host system. This TAP interface has subnet 10.0.0.0/8 and the controller is assumed to be running at 10.0.0.1. In this example, the controller should be running at TCP port 2525, so that the switches will find it.

 lab :: LabConfig
 lab = LabConfig { controllerServerPort = 2525, 
                   switches             = [sw1, sw2, sw3], 
                   hosts                = [ (host 1, Interface 0 (ipAddress 11 1 1 5)) @@ (sw1 # port 1), 
                                            (host 2, Interface 0 (ipAddress 11 1 2 5)) @@ (sw2 # port 1), 
                                            (host 3, Interface 0 (ipAddress 11 1 3 5)) @@ (sw3 # port 1) ], 
                   links                = [sw1 # port 2 <--> sw2 # port 2, 
                                           sw1 # port 3 <--> sw3 # port 2,
                                           sw2 # port 3 <--> sw3 # port 3 ] 
                               }
    where sw1 = switch 1
          sw2 = switch 2
          sw3 = switch 3 

The lab can be generated and written to directory /foo/bar by running the following command (the target directory may need to be created before running this command):

 makeLabWithDefaults "/foo/bar" Ver1_0_0 lab

The switches will have two files (both in the root directory), startProtocol.sh, startSwitch.sh which run the ofprotocol and ofdatapath programs, respectively, with the correct parameters for the switch and controller. The switches will run these scripts at start up time. These scripts are run with screen, and you can reattach to them using screen. To see the screen session names, run screen -list from one of the switch terminals.

Limitations

The library currently has several limitations: * Each host interface is on a /24 subnet containing its IP address. This should be configurable. * The controller is assumed to be at 10.0.0.1. This should be configurable.