Skip to main content

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)

  • 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

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

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

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

Metadata

Release files for zof 0.19.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for zof 0.19.0
File Size Uploaded
zof-0.19.0.tar.gz 74.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for zof 0.19.0
File Interpreter ABI Platform
zof-0.19.0-py3-none-any.whl Python 3 none any Details

Total release size: 142.3 kB

Release files / zof-0.19.0.tar.gz

Download URL zof-0.19.0.tar.gz
Size 74.8 kB
Tags Source
SHA-256 checksum
How to use checksums
0be48b6f9070485a80331546ba55e7e48fdd53e41781603e6cdf2f32ffb0a9f7
BLAKE2b-256 checksum
How to use checksums
3fe201f42efbc02666a80fb581aa8ea410b82cc3514a4ebe1e158dbf9f9be4fe
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.8.1 pkginfo/1.3.2 requests/2.11.1 setuptools/28.8.0 requests-toolbelt/0.7.0 clint/0.5.1 CPython/3.6.3 Darwin/17.7.0

Release files / zof-0.19.0-py3-none-any.whl

Download URL zof-0.19.0-py3-none-any.whl
Size 67.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
2403445ae8a18f3711ec436219827edff49a168e3d28a91ae2b2aecda8371889
BLAKE2b-256 checksum
How to use checksums
a92ff08d0ab1eaa1c853a323f46607f4648e13f235df1a0ab5f9777b12692f11
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.8.1 pkginfo/1.3.2 requests/2.11.1 setuptools/28.8.0 requests-toolbelt/0.7.0 clint/0.5.1 CPython/3.6.3 Darwin/17.7.0

Release history Release notifications | RSS feed

This release

0.19.0 This release

2 release files

0.18.0

2 release files

0.15.0

2 release files

0.14.0

2 release files

0.13.0

2 release files

0.12.0

2 release files

0.11.0

2 release files

0.9.0

2 release files

0.8.0

2 release files

0.7.0

2 release files

0.6.0

2 release files

0.5.0

2 release files

0.4.1

2 release files

0.4.0

2 release files

0.3.1

2 release files

0.3.0

2 release files

0.2.0

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page