-
Notifications
You must be signed in to change notification settings - Fork 6
2. Warp OpenFlow Driver Dynamic API Step By Step
(work in progress)
- [Overview] (Warp-OpenFlow-Driver-API-Step-By-Step#overview)
- [OpenFlow message provider] (Warp-OpenFlow-Driver-API-Step-By-Step#openflow-message-provider)
- Hello Messages and Connection Establishing
- Handshake
- [Packet-In Messages] (Warp-OpenFlow-Driver-API-Step-By-Step#packet-in-messages)
Warp OpenFlow Driver provides a dynamic Java API for build, serialize into binary stream and de-serialize OpenFlow messages. This document provides you a step-by-step instruction how to operate with OpenFlow messages using Warp Dynamic API.
Message builder is the root element of the API. To create a Builder instance, you should pass to it either byte array containing incoming message or *.avpr file with protocol definition:
import org.flowforwarding.warp.protocol.common.OFMessageRef.OFMessageBuilder;
public OFMessageBuilder (String containerType, String src);
public OFMessageBuilder (String containerType, byte[] src);
Builder builds a Message Reference; this class encapsulates all OpenFlow Message data. Using Builder you can build either empty OpenFlow message or use any incoming TCP payload to build it:
public OFMessageBulder type(String msgType);
public OFMessageBulder value(byte[] in);
public OFMessageRef build();
Let's see a quick example. I assume that TCP level is covered, and concentrate only on OpenFlow level. So your controller gets an incoming message from Switch. In this case you can establish an OpenFlow connection and make Handshake:
byte[] in = /*...*/; // It contains incoming message
OFMessageBulder builder = new OFMessageBuilder("avro", in.toArray()); // Now you have Builder initialized
OFMessageRef inMsg = builder.value(in).build(); // Now you have incoming message parsed
byte[] helloMsg = builder.type("ofp_hello").build().encode()));
byte[] featReq = builder.type("ofp_switch_features_request").build().encode()));