https://github.com/shun159/tres
OpenFlow Controller In Elixir
https://github.com/shun159/tres
elixir erlang networking openflow openflow-controller sdn
Last synced: about 2 months ago
JSON representation
OpenFlow Controller In Elixir
- Host: GitHub
- URL: https://github.com/shun159/tres
- Owner: shun159
- License: other
- Created: 2018-02-08T13:32:37.000Z (over 7 years ago)
- Default Branch: develop
- Last Pushed: 2019-09-24T09:00:37.000Z (over 5 years ago)
- Last Synced: 2025-04-14T13:10:48.379Z (2 months ago)
- Topics: elixir, erlang, networking, openflow, openflow-controller, sdn
- Language: Elixir
- Homepage:
- Size: 5.9 MB
- Stars: 5
- Watchers: 3
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# Tres - an Elixir OpenFlow development platform
[](https://travis-ci.org/shun159/tres)
[](https://codecov.io/gh/shun159/tres)
[](http://erlang.org/)
[](https://github.com/MakeNowJust/sushi-ware)
[](https://hex.pm/packages/tres)## Overview
Tres is a framework and set of helper libraries to develop OpenFlow controllers in Elixir.
## How to build your own controller application
### Installation
```elixir
def deps do
[
{:tres, "~> 0.1.2"}
]
end
```### callbacks
```elixir
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.Controllerdef 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
```bash
$ 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__.__私に寿司をおごってください__