Skip to content

Instantly share code, notes, and snippets.

@kazuyas
kazuyas / gist:9448970
Last active August 29, 2015 13:57 — forked from yasuhito/gist:9085031
Trema チュートリアル & コードレビュー (2014/3/21 沖縄オープンラボ)

Trema チュートリアル&コードレビュー

チュートリアル&コードレビューで使う VM とセットアップ方法を説明します。

当日までに VM にログインできることを確認 しておいてください。

必要なハードウェア

class FilteripTap < Controller
def start
load 'filtering-tap.conf'
end
def switch_ready dpid
$condition.each do | each |
each[ :in_port ] = $port_a
send_flow_mod_add( dpid,
:match => Match.new( each ),
class PortNameMapper < Controller
periodic_timer_event :show_ports, 3
def start
@pdb = {}
end
def switch_ready dpid
@pdb[ dpid ] = {}
send_message dpid, FeaturesRequest.new
config 'ofswitch'
option 'dp' 'dp0'
option 'dpid' '000000000001'
option 'ofports' 'eth0.1 eth0.2 eth0.3 eth0.4'
option 'ofctl' 'tcp:192.168.1.249:6633'
option 'mode' 'outofband'
@kazuyas
kazuyas / build.sh
Created April 4, 2012 05:26
build.sh
#!/bin/sh
TREMA_HOME=/home/kazuya/proj/trema/
gcc `$TREMA_HOME/trema-config --cflag` -c $1
gcc ${1%.c}.o `$TREMA_HOME/trema-config --libs` -o ${1%.c}
@kazuyas
kazuyas / matchtest.c
Created March 31, 2012 14:55
MatchTest_c
#include <stdio.h>
#include "trema.h"
static void
handle_switch_ready( uint64_t datapath_id, void *user_data )
{
UNUSED( user_data );
struct ofp_match match;
memset( &match, 0, sizeof( match ) );
@kazuyas
kazuyas / matchtest.rb
Created March 31, 2012 13:42
MatchTest3
class MatchTest < Controller
def switch_ready datapath_id
match = Match.new(
:dl_type => 0x0800,
:nw_dst => "192.168.1.0/24"
)
send_flow_mod_add(
datapath_id,
:match => match
@kazuyas
kazuyas / matchtest.rb
Created March 31, 2012 12:52
MatchTest2
class MatchTest < Controller
def switch_ready datapath_id
match = Match.new(
:nw_dst => "192.168.1.0/24"
)
send_flow_mod_add(
datapath_id,
:match => match
)
@kazuyas
kazuyas / network.conf
Created March 31, 2012 12:35
Simple network
vswitch {
datapath_id 0x1
}
vhost ( "host1" )
vhost ( "host2" )
link "0x1", "host1"
link "0x1", "host2"