Skip to main content
Join the official 2020 Python Developers SurveyStart the survey!

OpenFlow App Framework

Project description

MIT licensed Build Status

zof is a Python framework for creating asyncio-based applications that control the network using the OpenFlow protocol.

Supported Features

  • OpenFlow versions 1.0 - 1.4 (with partial support for 1.5)
  • TLS connections
  • Limited packet parsing and generation: ARP, LLDP, IPv4, IPv6, UDP, TCP, ICMPv4, ICMPv6
  • App’s can simulate switches; Supports both sides of the OpenFlow protocol


  • Python 3.5.1 or later
  • oftr command line tool

Install - Linux

# Install /usr/bin/oftr dependency.
sudo add-apt-repository ppa:byllyfish/oftr
sudo apt-get update
sudo apt-get install oftr

# Create virtual environment and install latest zof.
python3.5 -m venv myenv
source myenv/bin/activate
pip install zof

The oftr command line tool can also be installed on a Raspberry PI or using HomeBrew.


To run the layer2 controller demo:

python -m zof.demo.layer2


zof uses a separate oftr process to terminate OpenFlow connections and translate OpenFlow messages to JSON.

Architecture diagram

Architecture: The oftr process translates OpenFlow to JSON.

You construct OpenFlow messages via YAML strings or Python dictionaries. Incoming OpenFlow messages are generic Python objects. Special OpenFlow constants such as ‘NO_BUFFER’ appear as strings.

type: FLOW_MOD
  command: ADD
    - field: IN_PORT
      value: 1
    - field: ETH_DST
      value: 00:00:00:00:00:01
    - instruction: APPLY_ACTIONS
        - action: OUTPUT
          port_no: 2

The basic building block of zof is an app. An app is associated with various message and event handlers. You create an app object using the zof.Application class. Then, you associate handlers using the app’s message decorator.

import zof

APP = zof.Application('app_name_here')

def packet_in(event):'packet_in message %r', event)

def other(event):'other message %r', event)

if __name__ == '__main__':

Place the above text in a file named and run it with python This app handles OpenFlow ‘PACKET_IN’ messages using the packet_in function. All other messages are dispatched to the other function. The app does not do anything; it just logs events.

To compose the program with the layer2 demo:

python --x-modules=zof.demo.layer2

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for zof, version 0.19.0
Filename, size File type Python version Upload date Hashes
Filename, size zof-0.19.0-py3-none-any.whl (67.4 kB) File type Wheel Python version py3 Upload date Hashes View
Filename, size zof-0.19.0.tar.gz (74.8 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page