Library to parse and generate OpenFlow messages
Project description
python-openflow is a low level library to parse and create OpenFlow messages. If you want to read an OpenFlow packet from an open socket or send a message to an OpenFlow switch, this is your best friend. The main features are: high performance, short learning curve and free software license.
This library is part of Kytos project, but feel free to use this simple and intuitive library in other projects.
A quick start follows for you to check whether this project fits your needs. For a more detailed documentation, please check the python-openflow API Reference Manual.
Quick Start
Installing
We use python3.6. So in order to use this software please install python3.6 into your environment beforehand.
We are doing a huge effort to make Kytos and its components available on all common distros. So, we recommend you to download it from your distro repository.
But if you are trying to test, develop or just want a more recent version of our software no problem: Download now, the latest release (it still a beta software), from our repository:
First you need to clone python-openflow repository:
$ git clone https://github.com/kytos/python-openflow.git
After cloning, the installation process is done by standard setuptools install procedure:
$ cd python-openflow
$ sudo python3.6 setup.py install
Alternatively, if you are a developer and want to install in develop mode:
$ cd python-openflow
$ pip3.6 install -r requirements/dev.txt
Basic Usage Example
See how it is easy to create a feature request message with this library. You can use ipython3 to get the advantages of autocompletion:
>>> from pyof.v0x01.controller2switch.features_request import FeaturesRequest
>>> request = FeaturesRequest()
>>> print(request.header.message_type)
Type.OFPT_FEATURES_REQUEST
If you need to send this message via socket, call the pack() method to get its binary representation to be sent through the network:
>>> binary_msg = request.pack()
>>> print(binary_msg)
b"\x01\x05\x00\x08\x14\xad'\x8d"
>>> # Use a controller (e.g. Kytos SDN controller) to send "binary_msg"
To parse a message, use the unpack() function:
>>> from pyof.utils import unpack
>>> binary_msg = b"\x01\x05\x00\x08\x14\xad'\x8d"
>>> msg = unpack(binary_msg)
>>> print(msg.header.version)
UBInt8(1) # OpenFlow 1.0
>>> print(msg.header.message_type)
Type.OFPT_FEATURES_REQUEST
Please, note that this library do not send or receive messages via socket. You have to create your own server to receive messages from switches. This library only helps you to handle OpenFlow messages in a more pythonic way.
Contributing
If you want to contribute to this project, please read Kytos Documentation website.
License
This software is under MIT-License. For more information please read LICENSE file.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for python_openflow-2020.2b2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c8abc6ac137801c2747da75190895abff0da61e03fe96cfedf9860186d938cc2 |
|
MD5 | 1d728cfde55a4b2ed47b64e0945aefff |
|
BLAKE2b-256 | d231cfdc49ce40754371217bcc349e47cab5293a279a4f69e20edc9e82e0b371 |