OpenFlowJ Loxi

Andreas Wundsam edited this page Nov 26, 2013 · 15 revisions
Clone this wiki locally


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


  • Introductory presentation

  • 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();
                .setFlags(ImmutableSet.<OFFlowModFlags> of())
                                .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")
                        ImmutableList.<OFInstruction> of(
        OFFlowAdd flowAdd =;

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:


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.

      <name>Sonatype OSS snapshot repository</name>

Step 2b: Install artifact locally

git clone
cd loxigen
make install-java

Developing OpenFlowJ-Loxi

Setting up an Eclipse development environment for OpenFlowJ-Loxi

# go to the loxi main repo at, fork repo to your user
git clone${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