wiki:Internal/OpenFlow/VendorTutorial

Version 1 (modified by akoshibe, 12 years ago) ( diff )

How-To: Extending OpenFlow with Vendor messages

OpenFlow provides a vendor message type as a way to offer third parties a way to customize the protocol without going out of spec. This tutorial attempts to describe how to create custom vendor messages using openflowj (the Java OpenFlow implementation) and to use them in Floodlight.

Overview

The vendor type message has its own header and a fully customizable payload.

A vendor message must specify a vendor ID and a data type in its header. The vendor ID is a unique ID, typically the OUI, of the vendor implementing the custom message. The data type is used to indicate any subtypes that this message may have. For example, Nicira's vendor messages use Nicira's OUI (002320) as the vendor ID and come in two types, a Request and Reply, indicated by the data types of "10" and "11".

The rest of the message is the vendor message payload, and can be freely defined. To sum it up, the full OpenFlow vendor message takes on the following format:

<-------OpenFlow header-------><---Vendor message header--><----vendor message payload----->
[OF ver(1)|OFType(1)|length(2)][Vendor ID(2-8)|dataType(4)][user-defined structures(varied)]

Where the numbers in the parenthesis denote the field size in Bytes. Vendor messages are identified by OpenFlow message type (OFType) value of 4.

In openflowj

OFVendorData is the interface for the generic vendor message payload. All vendor type message payloads must implement OFVendorData. The vendor ID is also typically defined in the implementing class, as we see here in OFNiciraVendorData, the base class for all Nicira vendor messages:

public class OFNiciraVendorData implements OFVendorData {

    public static final int NX_VENDOR_ID = 0x00002320;
...

This base class can then be subclassed to implement the various types of this message.

The Vendor ID and VendorData must be registered before it can properly be parsed by your controller. Floodlight's core controller class, Controller, registers each vendor message and its subtypes during startup by calling initVendorMessages():

    private void initVendorMessages() {
        // Configure openflowj to be able to parse the role request/reply
        // vendor messages.
        OFBasicVendorId niciraVendorId = new OFBasicVendorId(             (1)
                OFNiciraVendorData.NX_VENDOR_ID, 4);
        OFVendorId.registerVendorId(niciraVendorId);
        OFBasicVendorDataType roleRequestVendorData =                     (
                new OFBasicVendorDataType(
                        OFRoleRequestVendorData.NXT_ROLE_REQUEST,
                        OFRoleRequestVendorData.getInstantiable());
        niciraVendorId.registerVendorDataType(roleRequestVendorData);
        OFBasicVendorDataType roleReplyVendorData =
                new OFBasicVendorDataType(
                        OFRoleReplyVendorData.NXT_ROLE_REPLY,
                        OFRoleReplyVendorData.getInstantiable());
         niciraVendorId.registerVendorDataType(roleReplyVendorData);
    }
   // register vendor ID
    OFBasicVendorId ofvid = new OFBasicVendorId(CPL_VENDOR_ID, 4);
    OFVendorId.registerVendorId(ofvid);

    // and then the message types
    OFBasicVendorDataType ofvdt = new OFBasicVendorDataType(20,
            OFExportsReply.getInstantiable());
    ofvid.registerVendorDataType(ofvdt);

A non-registered Vendor message data payload is interpreted simply as a byte array (OFByteArrayVendorData to be precise), and is not easily processed e.g. the methods in your VendorData classes would not be applicable as you would not be able to cast the byte array to your message (sub)class(es).

Note: See TracWiki for help on using the wiki.