Openflowj-loxigen Introduction

Source: Internet
Author: User

Openflowj-loxigen Introduction
Floodlight v1.0 and above rely on the new Openflowj-loxigen library. The OpenFlow version supported by Openflowj-loxigen is from 1.0 to 1.4. All OpenFlow concepts and types can be obtained by Openflowj-loxigen. Openflowj-loxigen supports updates, more optimized ways to create OpenFlow messages, match Fields (Matches), Action sets (actions), Flow table changes (Flowmods), and more. This paper mainly analyzes some common classes and construction methods in Openflowj-loxigen library.

Offactory

Almost all OpenFlow concepts (ofobject, for example: Match, Ofaction, ofmessage, etc) can be constructed by constructors and all constructors are exposed through offactory. Because of the differences in different versions of the OpenFlow protocol, each OpenFlow protocol version corresponds to a specially-factory class:

OFFactoryVer10
OFFactoryVer11
OFFactoryVer12
OFFactoryVer13
OFFACTORYVER14 (not officially supported in floodlight)
These all implement the Offactory interface, so you can simply use the Offactory interface, ignoring the existence of different versions of the factory class.
There are many ways to get the Offactory instance you want. You can request a specific version of Offactory from Openflowj-loxigen by specifying an enumeration value for Ofversion.

OFFactory my13Factory = OFFactories.getOFFactory(OFVersion.OF_13);    //取得一个OpenFlow 1.3的工厂类

More practical, you can get the factory class from the Iofswitch.

IOFSwitch mySwitch = switchService.getSwitch(DatapathId.of("00:00:00:00:00:00:00:01"));OFFactory myFactory = mySwitch.getOFFactory();    //取得与请求交换机版本相符的工厂类版本

You can also get a specific offactory from an existing object generated by Offactory, and all the ofversion from Offactory constructed objects are the same as the offactory constructs.

OFVersion flowModVersion = myFlowMod.getVersion();    //假设myFlowMod已经被构造好OFFactory myFactory = OFFactories.getFactory(flowModVersion);

Match

Matching fields (match) are typically used in OpenFlow to represent and define the characteristics of the head field of a package. As mentioned above, most OpenFlow concepts can be constructed using factory classes. So creating a reference to a factory class is a preparation for constructing a matching domain.

Match Mymatch = myfactory. Buildmatch(). Setexact(Matchfield. Inch_port, Ofport. of(1)). Setexact(Matchfield. ETH_type, Ethtype. IPv4). setmasked(Matchfield. IPV4_SRC, Ipv4addresswithmask. of("192.168.0.1/24")). Setexact(Matchfield. IP_proto, Ipprotocol. TCP). Setexact(Matchfield. TCP_DST, Transportport. of( the)). Build();

As you can see, the instance of Offactory MyFactory contains a constructor (Match.builder), which can be returned using the Buildmatch method. You can specify exact match and mask matching by calling the Setexact and setmasked methods of the constructor.

Actions

Ofaction ' s, like a matching field, is constructed by Offactory. Note: There is a class called Ofaction and another class called Ofactions. In order to represent the plural form of ofaction, Ofaction ' s is used here. Although there are grammatical problems, it is not confused with ofactions.

OFActions allActions = myFactory.actions();

The actions call can return an implemented Ofactions interface. The implementation of this return depends entirely on the version of Offactoy. (This article only describes the actions of OpenFlow v1.3)
OpenFlow 1.2 introduced the OXM (OpenFlow extensible Match). With OXM, all actions that result in the modification of the existing head domain are described with a new Set-field action, and the Set-field action contains the OXM specifies the header field and the new value written to the header field. Note the difference between OXM ' s and oxms here, and the difference between ofaction ' s and Ofactions, OXMS is an interface that contains all the independent OXM ' s.

arraylist<ofaction> actionlist = new Arraylist<ofaction> (); ActionList used to store different actions.Ofactions actions = Myof13factory. Actions(); The actions are instantiated interfaces that contain all the independent ofactionOfoxms OXMS = myof13factory. Oxms(); OXMS is an instantiated interface that contains all the independent OXM/ * Use OXM to modify the address of the Data link layer * /Ofactionsetfield SETDLDST = Actions. Buildsetfield(). SetField(OXMS. BUILDETHDST(). SetValue(MacAddress. of("Ff:ff:ff:ff:ff:ff")). Build()    ). Build();ActionList. Add(SETDLDST);/ * Use OXM to modify the address of the network layer * /Ofactionsetfield SETNWDST = Actions. Buildsetfield(). SetField(OXMS. BUILDIPV4Dst (). SetValue(ipv4address. of("255.255.255.255")). Build()    ). Build();ActionList. Add(SETNWDST);/ * Go to VLAN spike not OXM but a ofaction * /Ofactionpopvlan Popvlan = Actions. Popvlan();ActionList. Add(Popvlan);/ * Send to a port not OXM but a ofaction * /Ofactionoutput output = Actions. Buildoutput(). Setmaxlen(0xFFffFFff). Setport(Ofport. of(1)). Build();ActionList. Add(output);

Flowmods

The Openflowj-loxigen Library provides a version-independent Offlowmod interface that allows you to write a specific type of offlowmod related to a specific offlowmodcommand by a number of sub-interfaces:

Offlowadd
Offlowmodify
Offlowmodifystrict
Offlowdelete
Offlowdeletestrict
About Offlowmods Note: OpenFlow 1.3 Removes the default Table-miss operation (packet-in to Controller), OpenFlow 1.3 Specifies that the controller must insert a specific Table-miss flow table with a priority of 0. Wildcard all matching fields, action list defined by Ofaction ' s

OFFlowAdd flowAdd = myFactory.buildFlowAdd()

Similar to other OpenFlow concepts, offactory can be used to produce a specific type of offlowmod.
Offactory can return the constructor of the Offlowmod type you specified. But in general, we will find it more practical to convert offlowmod from one offlowmodcommand to another. This feature is not currently supported by Openflowj-loxigen, but can be achieved by Net.floodlightcontroller.util.FlowModUtils.java

offlowadd flowadd = Myfactory . Buildflowadd  () .build  () ;  /* convert Flowadd to floodmodify. */ Offlowmodify flowmodify = Flowmodutils.toflowmodify  (FLOWADD)  Offlowmodifystrict flowmodifystrict = Flowmodutils.toflowmodifystrict  ( Flowadd)  Offlowdelete flowdelete = Flowmodutils.toflowdelete  (FLOWADD)  Offlowdeletestrict flowdelstrict = Flowmodutils.toflowdeletestrict  (flowAdd )  Offlowadd flowAdd2 = Flowmodutils.toflowadd  (flowmodify)   

The following discusses how to compose a offlowmod

offlowadd flowadd = My13factory.buildFlowAdd  () Span class= "Hljs-preprocessor" >.setbufferid (Ofbufferid.no  _BUFFER) .sethardtimeout  (3600 ) .setidletimeout  (10 ) .setpriority  (32768 ) .setmatch  (mymatch) .setactions  (actionlist) .setoutport  (Ofport) .settableid  (Tableid.of  (1 )) .build  ()  

Openflowj-loxigen Introduction

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.