Skip to content
vieangry edited this page Dec 27, 2018 · 17 revisions

Overview

OpenFlowJ-Loxi is the Java artifact of Loxigen. It exposes the OpenFlow protocol through a version-agnostic, fluent Java API.

Architecture

  • Introductory presentation https://raw.github.com/wiki/floodlight/loxigen/docs/openflowj-loxi-introduction.pdf

  • OpenFlow Messages and other concepts (Matches, Actions, Instructions etc.) are exposed as version-agnostic Interfaces (the API exposes the union of the functionality available in OF1.0-OF1.3).

    • version specific implementations are hidden from the user, and exposed/created through OFFactory.
  • Value Types (static concepts) like IP address, Mac Address, Ports etc. are exposed as instance-controlled immutable objects (pattern: OFPort.of(123) ).

  • Both messages and Value types are immutable - Builders are available to gradually build those objects.

Message Interfaces and Value Type Classes
Message Interfaces and Implementations

API Example

        OFFlowAdd.Builder builder = factory.buildFlowAdd();
        builder.setXid(0x12345678)
                .setCookie(U64.parseHex("FEDCBA9876543210"))
                .setCookieMask(U64.parseHex("FF00FF00FF00FF00"))
                .setTableId(TableId.of(3))
                .setIdleTimeout(5)
                .setHardTimeout(10)
                .setPriority(6000)
                .setBufferId(OFBufferId.of(50))
                .setOutPort(OFPort.of(6))
                .setOutGroup(8)
                .setFlags(ImmutableSet.<OFFlowModFlags> of())
                .setMatch(
                        factory.buildMatch()
                                .setMasked(MatchField.IN_PORT, OFPort.of(4), OFPort.of(5))
                                .setExact(MatchField.ETH_TYPE, EthType.IPv6)
                                .setExact(MatchField.IP_PROTO, IpProtocol.TCP)
                                .setMasked(MatchField.IPV6_SRC, IPv6WithMask.of("2001:1e76:23::/32")
                                .build())
                .setInstructions(
                        ImmutableList.<OFInstruction> of(
                                factory.instructions().gotoTable(TableId.of(4))
                             )
                        );
        OFFlowAdd flowAdd = builder.build();

Using OpenFlowJ-Loxi in a Project

OpenFlowJ-Loxi is published as a maven artifact (currently only as a snapshot, a release version coming soon).

Step 1: Add module as a maven dependency

To add it to a maven project as a dependency do the following:

<project>
   [...]
   <dependencies>
        <dependency>
            <groupId>org.projectfloodlight</groupId>
            <artifactId>openflowj</artifactId>
            <version>0.3-SNAPSHOT</version>
        </dependency>
   </dependencies>
</project>

Step 2a: Add the Sonatype snapshot repository

Because openflowj-loxi is currently in snapshot state (i.e., active development is happening), it is not yet available from Maven Central. You can get the snapshot from the public The ProjectFloodlight Sonatype OSS repository or your can build and install the artifact locally.

<project>
  [...]
  <repositories>
    [...]
    <repository>
      <id>sonatype-oss-snapshot</id>
      <name>Sonatype OSS snapshot repository</name>
      <url>https://oss.sonatype.org/content/repositories/snapshots</url>
    </repository>
  </repositories>
</project>

Step 2b: Install artifact locally

git clone git@github.com:floodlight/loxigen.git
cd loxigen
make install-java

Developing OpenFlowJ-Loxi

Setting up an Eclipse development environment for OpenFlowJ-Loxi

# go to the loxi main repo at https://github.com/floodlight/loxigen/, fork repo to your user
git clone git@github.com:${myuser}/loxigen.git
cd loxigen
make java-eclipse
# Eclipse: Import loxigen/openflowj with "Import Existing project into workspace"
  • Do not use mvn eclipse:eclipse directly. The eclipse workspace is patched by make java-eclipse
  • Do not use "Import Maven Project into Workspace" – the loxigen project is set up in a particular way that doesn't roll well with the eclipse maven plugin
  • Obviously, do not edit the files under gen-src directly – they will be overriden. Instead, edit the logic under java_gen/ and java_gen/templates