logo
Free, unlimited AI code reviews that run on commit
git-lrc git-lrc GitHub Install Now We'd appreciate a star git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt

python-openflowlibrary - python-openflow library Documentation

Author

       Kytos Project

Authors

       For a complete list of authors, please open AUTHORS.rst file.

Contributing

       If you want to contribute to this project, please read KytosDocumentation website.

License

       This software is under MIT-License. For more information please read LICENSE file.

       Here you will find examples on how to use python-openflow for both unpack raw  binary  openflow  messages
       and create new openflow messages and pack them as binary data to be sent throughtout your network.

Name

       python-openflowlibrary - python-openflow library Documentation

       [image: Experimental] [image]
        OpenflowTagReleaseLicenseBuildstatusCodecoverageCode-qualityscorepython-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 Kytosproject, but feel free to use this simple and intuitive library in other
       projects.

       ATTENTION:python-openflow does not perform I/O operations. To communicate with a switch, you must write your own
          controller using this library or use our KytosSDNPlatform.

       A quick start follows for you to check whether this  project  fits  your  needs.   For  a  more  detailed
       documentation, please check the python-openflowAPIReferenceManual.

Packing Examples

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

   BasicUsageExample
       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 unpack_message():

          >>> from pyof.v0x01.common.utils import unpack_message
          >>> binary_msg = b"\x01\x05\x00\x08\x14\xad'\x8d"
          >>> msg = unpack_message(binary_msg)
          >>> 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.

Todo

       Write unpacking examples, showing how the library behaves on simple and complex messages.

       • Beraldo Leal <beraldo AT ncc DOT unesp DOT br>

       • Artur Baruchi <abaruchi AT ncc DOT unesp DOT br>

       • Carlos Eduardo Moreira dos Santos <cadu AT ncc DOT unesp DOT br>

       • Diego Rabatone Oliveira <diraol AT ncc DOT unesp DOT br>

       • Macártur de Sousa Carvalho <macartur.sc AT gmail DOT com>

       • Raphael Cóbe <rmcobe AT ncc DOT unesp DOT br>

       • André Tadeu <andretadeu AT ncc DOT unesp DOT br>

       The MIT License (MIT)

       Copyright (c) 2016 Kytos Team

       Permission  is  hereby  granted,  free  of  charge,  to  any person obtaining a copy of this software and
       associated documentation files (the "Software"), to deal in the Software without  restriction,  including
       without  limitation  the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
       copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to  the
       following conditions:

       The  above  copyright  notice  and  this permission notice shall be included in all copies or substantial
       portions of the Software.

       THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR  IMPLIED,  INCLUDING  BUT  NOT
       LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO
       EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
       IN  AN  ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
       THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Unpacking Examples

See Also