Code Monkey home page Code Monkey logo

tres's Introduction

Tres - an Elixir OpenFlow development platform

Build Status codecov Supported OTP version LICENSE Hex Version

Overview

Tres is a framework and set of helper libraries to develop OpenFlow controllers in Elixir.

How to build your own controller application

Installation

def deps do
  [
    {:tres, "~> 0.1.2"}
  ]
end

callbacks

config :tres,
  callback_module: Tres.ExampleHandler,
  callback_args:   []

To use Tres.Controller with your code, set the handler callback_module to your callback module. This module must implement the Module.start_link/1 that returns on_start.

Set the callback_args to the terms you want pass to the start_link/2 callback function.

% cat lib/sample.ex
defmodule Sample do
  use GenServer
  use Tres.Controller

  def start_link([datapath_id, _start_args]) do
    GenServer.start_link(__MODULE__, [datapath_id])
  end
  
  def init([datapath_id]) do
    # As an example create a flow to receive all packet_ins from port 1
    redirect_action = Output.new(:controller)
    apply_ins = ApplyActions.new(redirect_action)
    match = Match.new(in_port: 1)
    :ok = send_flow_mod_add(datapath_id, 
                            priority: 1,
                            match: match,
                            instructions: [apply_ins])
    {:ok, datapath_id}
  end
  
  def handle_info(%PacketIn{} = packet_in, datapath_id) do
    # print the packet_in message struct
    IO.inspect(packet_in)
    {:noreply, datapath_id}
  end
end

To run the controller

$ iex -S mix

Examples

  • learning-switch: Simple Layer2 switch
  • leader-example: Simple election based multiple controller using Ulf Wiger's Locks Leader
  • patch_panel: inteligent patch_panel example
  • simple_router: An OpenFlow controller that emulates layer 3 switch (router).
  • nx_learning_switch: Example for very simple-minded L2 switch using NXAST_LEARN action.

License

Tres is released under the SUSHI-WARE LICENSE.

私に寿司をおごってください

tres's People

Contributors

shun159 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

Forkers

mahmoud-shuker

tres's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.