Skip to main content

OpenFlow App Framework

Project description

MIT licensed Build Status codecov.io

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)

  • SSL connections

  • Auxiliary OpenFlow connections over TCP and UDP

  • 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

Requirements

  • 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

Demos

To run the layer2 controller demo:

python -m zof.demo.layer2

Architecture

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
msg:
  command: ADD
  match:
    - field: IN_PORT
      value: 1
    - field: ETH_DST
      value: 00:00:00:00:00:01
  instructions:
    - instruction: APPLY_ACTIONS
      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')

@APP.message('packet_in')
def packet_in(event):
    APP.logger.info('packet_in message %r', event)

@APP.message(any)
def other(event):
    APP.logger.info('other message %r', event)

if __name__ == '__main__':
    zof.run()

Place the above text in a file named demo.py and run it with python demo.py. 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 demo.py program with the layer2 demo:

python demo.py --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.

Source Distribution

zof-0.3.0.tar.gz (54.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

zof-0.3.0-py3-none-any.whl (50.0 kB view details)

Uploaded Python 3

File details

Details for the file zof-0.3.0.tar.gz.

File metadata

  • Download URL: zof-0.3.0.tar.gz
  • Upload date:
  • Size: 54.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for zof-0.3.0.tar.gz
Algorithm Hash digest
SHA256 4b729f61345915b586c1b142357286aea525dafc0daaee62bb00adeda9eb3097
MD5 65038fef5a1fec9ed8753f4c5a1d527b
BLAKE2b-256 d7791005fd2603be8ada77147696a8f4e590ec22d5d59e27f8f7ea4ad4f355f7

See more details on using hashes here.

File details

Details for the file zof-0.3.0-py3-none-any.whl.

File metadata

  • Download URL: zof-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 50.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for zof-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 b77dc294503a0537a2504a5a74c871067be8f2dcfe853ef1971ef97ab2cec70f
MD5 7c162dc94f9871353daf8b7d78dcc13f
BLAKE2b-256 96608ecba9dad9639cfbd1cb227b10c87a54011beb3eb08ad2b70ea0b9725248

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page