Code Monkey home page Code Monkey logo

trema-edge's Introduction

Welcome to Trema

Build Status Code Climate Coverage Status Dependency Status

Trema is an OpenFlow controller programming framework that provides everything needed to create OpenFlow controllers in Ruby. It provides a high-level OpenFlow library and also a network emulator that can create OpenFlow-based networks for testing on your PC. This self-contained environment helps streamlines the entire process of development and testing.

Prerequisites

  • Ruby 2.0.0 or higher (RVM).
  • Open vSwitch (apt-get install openvswitch-switch).

Documentation

See https://relishapp.com/trema/trema/docs for links to documentation for all APIs.

Sample Code

Study sample code for implementation examples of Trema features. Each sample code project is executable source example of how to write a OpenFlow controller using Trema Ruby API.

Contributors

Special thanks to all contributors for submitting patches. A full list of contributors including their patches can be found at:

https://github.com/trema/trema/contributors

License

Trema is released under the GNU General Public License version 2.0 or MIT License:

trema-edge's People

Contributors

charlesmcchan avatar hideyukishimonishi avatar ihiroakikawai avatar jemiam avatar kaishuu0123 avatar masanohashi avatar nhst-zz avatar nickkaranatsios avatar rakshasa avatar sugyo avatar userlocalhost avatar yasuhito avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

trema-edge's Issues

trema version コマンドの出力

trema version コマンドでは以下のように出力されるが、無印 Trema の出力と見分けがつかない。

kazuya@callisto:~/proj/trema-edge/bin$ ./trema version
trema version 0.1.0

無印 Trema との見分けをできるようにした方がよいのでは?

FLOW_MODに使用するバイトオーダ

現在、trema-edgeによるコントローラ作成を行っていますが、
フローの削除が行えない事象が発生しました。
原因を調べたところ、以下の箇所で使用しているバイトオーダが異なる事により
正常に処理出来なかったように見えるため確認をお願い致します。

FLOW_MODを扱う側はcommandをネットワークバイトオーダから

ホストバイトオーダに変換して利用しています。(★1、★2の箇所)

■trema-edge/src/switch_manager/ofpmsg_send.cから引用
static int
update_flowmod_cookie( buffer *buf, char *service_name ) {
struct ofp_flow_mod *flow_mod = buf->data;
uint16_t command = ntohs( flow_mod->command ); ★1
uint16_t flags = ntohs( flow_mod->flags );
uint64_t cookie = ntohll( flow_mod->cookie );

switch ( command ) { ★2
case OFPFC_ADD:
{
uint64_t *new_cookie = insert_cookie_entry( &cookie, service_name, flags );
if ( new_cookie == NULL ) {
return -1;
}
flow_mod->cookie = htonll( *new_cookie );
flow_mod->flags = htons( flags | OFPFF_SEND_FLOW_REM );
}
break;

(以降省略)

対してFLOW_MODを作成する側はcommandをホストバイトオーダのまま

格納しています。(★3箇所)

■trema-edge/src/lib/openflow_message.cから引用
buffer *
create_flow_mod( const uint32_t transaction_id, const uint64_t cookie, const uint64_t cookie_mask,
const uint8_t table_id, const uint8_t command, const uint16_t idle_timeout,
const uint16_t hard_timeout, const uint16_t priority,
const uint32_t buffer_id, const uint32_t out_port, const uint32_t out_group,
const uint16_t flags, const oxm_matches *match,
const openflow_instructions *instructions ) {
(途中省略)
flow_mod = ( struct ofp_flow_mod * ) buffer->data;
flow_mod->cookie = htonll( cookie );
flow_mod->cookie_mask = htonll( cookie_mask );
flow_mod->table_id = table_id;
flow_mod->command = command; ★3
flow_mod->idle_timeout = htons( idle_timeout );
flow_mod->hard_timeout = htons( hard_timeout );
flow_mod->priority = htons( priority );
flow_mod->buffer_id = htonl( buffer_id );
flow_mod->out_port = htonl( out_port );
flow_mod->out_group = htonl( out_group );
flow_mod->flags = htons( flags );
memset( &flow_mod->pad, 0, sizeof( flow_mod->pad ) );
construct_ofp_match( &flow_mod->match, match );

(以降省略)

FLOW_MODを作成する際に★3の箇所を以下のように変更が必要かと

思いますので、ご確認をお願い致します。

flow_mod->command = command;

flow_mod->command = htons( command );

FlowMultipartRequestがエラーになる。 (Ipv4SrcAddr)

#79 のフロー取得がエラーになる件、素早い対応ありがとうございました。

EthSrc.new, EthDst.new で問題なくフローが取得できることを確認しました。

フロー取得を試みていたところ、Ipv4SrcAddr.new, Ipv4DstAddr.new でも同様のエラーが発生してしまいました。

class Sample < Controller
    def switch_ready datapath_id
        match = Match.new( eth_type: 0x0800 )
        action = SetField.new( action_set: [ Ipv4DstAddr.new( ip_addr: IPAddr.new("10.0.0.1"))])
        ins = ApplyAction.new( actions: [ action ] )

        send_flow_mod_add( datapath_id, match: match, instructions: [ ins ] )
        send_flow_multipart_request( datapath_id, cookie: 0 )
    end

    def flow_multipart_reply datapath_id, message
        p message
    end
end

以下のエラーが出力されます。

/home/common/trema-edge/ruby/trema/accessor.rb:161:in `block in initialize': Required option ip_addr is missing for Trema::Actions::Ipv4DstAddr (ArgumentError)

ご確認お願いできますでしょうか。

FlowMultipartRequestがエラーになる

スイッチからフローを取得する以下のコードがエラーとなります。

class Sample < Controller
    def switch_ready( datapath_id )
        action = SetField.new( action_set:
                               [EthSrc.new(mac_address: Trema::Mac.new("00:00:00:00:00:01"))])
        ins = ApplyAction.new( actions: [action] )
        send_flow_mod_add( datapath_id, instructions: [ins])

        send_message( datapath_id, FlowMultipartRequest.new(cookie: 0))
    end

    def flow_multipart_reply( datapath_id, message )
        p message
    end
end

以下のエラーが出力されます。

/home/fukui/trema-edge/ruby/trema/accessor.rb:161:in `block in initialize': Required option mac_address is missing for Trema::Actions::EthSrc (ArgumentError)

アクションに EthSrc.new を指定しなければ問題なく動作します。


【補足】
エラーの種類としては、EthSrc.new に mac_address: オプションを指定しなかった場合と同じ内容のエラーのようです。

class Sample < Controller
    def start
        # 正しくは EthSrc.new( mac_address: Trema::Mac.new("00:00:00:00:00:01") )
        EthSrc.new( Trema::Mac.new("00:00:00:00:00:01") )
    end
end

出力されるエラー。

/home/fukui/trema-edge/ruby/trema/accessor.rb:171:in `initialize': Required option mac_address missing for Trema::Actions::EthSrc (ArgumentError)

ご確認よろしくお願いします。

Dumper.rb の port_status メソッド が正しく動作しない

実行すると以下のとおり。

$ trema run dumper.rb -c dumper.conf
src/examples/dumper/dumper.rb:126:in 'port_status': undefined method 'phy_port' for #
<Trema::Messages::PortStatus:0x00000001972650> (NoMethodError)

phy_port がないと言われるので、Openflow v1.3 の 仕様書 [A.4.3 Port Status Message (P78)] をみると、
使用上定義されていないことがわかる。
そこで、dumper.rb の 126 行目を

dump_phy_port message

に変更して実行すると、今度は dump_phy_port でエラー

$ trema run dumper.rb -c dumper.conf
src/examples/dumper/dumper.rb:165:in `dump_phy_port': undefined method `number' for # 
<Trema::Messages::PortStatus:0x00000001d1b7e8> (NoMethodError)

ruby/trema/messages/port.rb を見ると、確かに number はない。
Tremaでは変数名 "number" だったが、Trema-edgeDeha "port_no" に変更されていることが理由なので、

def numder
  port_no
end

を追記することで、正しく動作することを確認。

Trema では PortStatus#number だったので、Trema-edge 変数名が異なっている。
Trema-edge でも Port#number に変更したほうが良いのでは…?

make失敗およびlearning-switchの実行失敗

現在、Trema-Edgeのインストールと動作確認を行なっております。
その中でlearning-switchのコンパイルおよび実行におきまして、
以下の様な問題を発見したのでご報告させて頂きます。

環境

Description:    Ubuntu 12.10
Release:        12.10
Ruby:           2.0.0p0 (2013-02-24 revision 39474)

問題事象

①src配下でmakeを実行すると失敗する。
②learning_switch.sh実行でエラーになる

手順
(1)GitからTrema-Edgeを落としインストール実施
(2)/trema-edge/srcでmakeコマンド実行

$ make
make[1]: Entering directory `/home/ikeuchi/trema-edge/src/lib'
make[1]: *** No rule to make target `all'.  Stop.
make[1]: Leaving directory `/home/ikeuchi/trema-edge/src/lib'
make[1]: Entering directory `/home/ikeuchi/trema-edge/src/packetin_filter'
make[1]: *** No rule to make target `all'.  Stop.
make[1]: Leaving directory `/home/ikeuchi/trema-edge/src/packetin_filter'
make[1]: Entering directory `/home/ikeuchi/trema-edge/src/switch_manager'
make[1]: *** No rule to make target `all'.  Stop.
make[1]: Leaving directory `/home/ikeuchi/trema-edge/src/switch_manager'
/bin/sh: 1: cd: can't cd to switchd
make[1]: Entering directory `/home/ikeuchi/trema-edge/src'
make[2]: Entering directory `/home/ikeuchi/trema-edge/src/lib'
make[2]: *** No rule to make target `all'.  Stop.
make[2]: Leaving directory `/home/ikeuchi/trema-edge/src/lib'
make[2]: Entering directory `/home/ikeuchi/trema-edge/src/packetin_filter'
make[2]: *** No rule to make target `all'.  Stop.
make[2]: Leaving directory `/home/ikeuchi/trema-edge/src/packetin_filter'
make[2]: Entering directory `/home/ikeuchi/trema-edge/src/switch_manager'
make[2]: *** No rule to make target `all'.  Stop.
make[2]: Leaving directory `/home/ikeuchi/trema-edge/src/switch_manager'
/bin/sh: 1: cd: can't cd to switchd
make[2]: Entering directory `/home/ikeuchi/trema-edge/src'
(以下、無限ループ)

上記の通り無限ループしてしまい、makeが終了しません。(問題①)
★以下の3ファイルを修正し問題を回避できた事を報告いたします。

■/trema-edge/src/MakeFile
(修正前)

# Copyright (C) 2013 NEC Corporation
#

SUBDIRS = lib packetin_filter switch_manager switchd examples

.PHONY: all clean $(SUBDIRS)

all: $(SUBDIRS)
        @for DIR in $(SUBDIRS); do ( cd $$DIR; make all ); done

clean: $(SUBDIRS)
        @for DIR in $(SUBDIRS); do ( cd $$DIR; make clean ); done

(修正後)

#
# Copyright (C) 2013 NEC Corporation
#

SUBDIRS = lib packetin_filter switch_manager switch examples

.PHONY: all clean $(SUBDIRS)

all: $(SUBDIRS)
        @for DIR in $(SUBDIRS); do ( cd $$DIR; make all ); done

clean: $(SUBDIRS)
        @for DIR in $(SUBDIRS); do ( cd $$DIR; make clean ); done

 SUBDIRSに記載された"switchd""switch"に修正。
 
■/trema-edge/src/examples/MakeFile
(修正前)

#
# Copyright (C) 2013 NEC Corporation
#

SUBDIRS = dumper dumper_debug learning_switch

.PHONY: all clean $(SUBDIRS)

all: $(SUBDIRS)
        @for DIR in $(SUBDIRS); do ( cd $$DIR; make all ); done

clean: $(SUBDIRS)
        @for DIR in $(SUBDIRS); do ( cd $$DIR; make clean ); done

(修正後)

#
# Copyright (C) 2013 NEC Corporation
#

SUBDIRS = dumper learning_switch

.PHONY: all clean $(SUBDIRS)

all: $(SUBDIRS)
        @for DIR in $(SUBDIRS); do ( cd $$DIR; make all ); done

clean: $(SUBDIRS)
        @for DIR in $(SUBDIRS); do ( cd $$DIR; make clean ); done

SUBDIRSから"dumper_debug"を削除。

■/trema-edge/src/examples/learning_switch/MakeFile
(修正前)

#
# Copyright (C) 2013 NEC Corporation
#

CC = gcc
AR = ar
RANLIB = ranlib

CFLAGS = -I../../lib/ -g -std=gnu99 -D_GNU_SOURCE -fno-strict-aliasing -Wall -Werror -Wextra -Wformat=2 -Wcast-qual -Wcast-align -Wwrite-strings -Wconversion -Wfloat-equal -Wpointer-arith
LDFLAGS = -ltrema -lpthread -lsqlite3 -ldl -lrt

LIBDIR = ../../lib
(以下略)

(修正後)

#
# Copyright (C) 2013 NEC Corporation
#

CC = gcc
AR = ar
RANLIB = ranlib

CFLAGS = -I../../lib/ -g -std=gnu99 -D_GNU_SOURCE -fno-strict-aliasing -Wall -Werror -Wextra -Wformat=2 -Wcast-qual -Wcast-align -Wwrite-strings -Wconversion -Wfloat-equal -Wpointer-arith
LDFLAGS = -ltrema -lpthread -lsqlite3 -ldl -lrt

LIBDIR = ../../../objects/lib/
(以下略)

LIBDIRのパスを"../../lib"から"../../../objects/lib/"に変更

(3)make再実行

$ make
make[1]: Entering directory `/home/ikeuchi/trema-edge/src/lib'
make[1]: *** No rule to make target `all'.  Stop.
make[1]: Leaving directory `/home/ikeuchi/trema-edge/src/lib'
make[1]: Entering directory `/home/ikeuchi/trema-edge/src/packetin_filter'
make[1]: *** No rule to make target `all'.  Stop.
make[1]: Leaving directory `/home/ikeuchi/trema-edge/src/packetin_filter'
make[1]: Entering directory `/home/ikeuchi/trema-edge/src/switch_manager'
make[1]: *** No rule to make target `all'.  Stop.
make[1]: Leaving directory `/home/ikeuchi/trema-edge/src/switch_manager'
make[1]: Entering directory `/home/ikeuchi/trema-edge/src/switch'
make[1]: *** No rule to make target `all'.  Stop.
make[1]: Leaving directory `/home/ikeuchi/trema-edge/src/switch'
make[1]: Entering directory `/home/ikeuchi/trema-edge/src/examples'
make[2]: Entering directory `/home/ikeuchi/trema-edge/src/examples/dumper'
gcc -MM -I./ -I../../lib -g -std=gnu99 -D_GNU_SOURCE -fno-strict-aliasing -Werror -Wall -Wextra -Wformat=2 -Wcast-qual -Wcast-align -Wwrite-strings -Wconversion -Wfloat-equal -Wpointer-arith dumper.c > .depends
make[2]: Leaving directory `/home/ikeuchi/trema-edge/src/examples/dumper'
make[2]: Entering directory `/home/ikeuchi/trema-edge/src/examples/learning_switch'
gcc -MM -I../../lib/ -g -std=gnu99 -D_GNU_SOURCE -fno-strict-aliasing -Wall -Werror -Wextra -Wformat=2 -Wcast-qual -Wcast-align -Wwrite-strings -Wconversion -Wfloat-equal -Wpointer-arith learning_switch.c > .depends
make[2]: Leaving directory `/home/ikeuchi/trema-edge/src/examples/learning_switch'
make[1]: Leaving directory `/home/ikeuchi/trema-edge/src/examples'

makeが成功

(4)/trema-edge/learning_switch.shの実行

$ ./learning_switch.sh start
./learning_switch.sh: 53: ./learning_switch.sh: ./objects/examples/learning_switch/learning_switch: not found

上記の通り起動に失敗する。(問題②)
★以下のファイルを修正し問題を回避できた事を報告いたします。

■/trema-edge/learning_switch.sh
(修正前)

(省略)
TREMA_SRC=.
OBJECTS="${TREMA_SRC}/objects"

APP_NAME="learning_switch"
APP="${OBJECTS}/examples/learning_switch/learning_switch"
(省略)

(修正後)

(省略)
TREMA_SRC=.
OBJECTS="${TREMA_SRC}/objects"

APP_NAME="learning_switch"
APP="${TREMA_SRC}/src/examples/learning_switch/learning_switch"
(省略)

APPのソースを"${OBJECTS}/examples/learning_switch/learning_switch"から
"${TREMA_SRC}/src/examples/learning_switch/learning_switch"に変更

(5)~/trema-edge/learning_switch.shの再実行

$ ./learning_switch.sh start
$
$ ps x
  PID TTY      STAT   TIME COMMAND
 1297 tty1     S+     0:00 -bash
13543 ?        Ss     0:00 ./objects/switch_manager/switch_manager -l debug --daemonize --switch=./objects/s
13550 ?        Ss     0:00 ./src/examples/learning_switch/learning_switch -l debug --name learning_switch --
13551 pts/0    R+     0:00 ps x
30479 ?        S      0:03 sshd: ikeuchi@pts/0
30480 pts/0    Ss     0:00 -bash
$
$ ./learning_switch.sh stop
$
$ ps x
  PID TTY      STAT   TIME COMMAND
 1297 tty1     S+     0:00 -bash
13555 pts/0    R+     0:00 ps x
30479 ?        S      0:03 sshd: ikeuchi@pts/0
30480 pts/0    Ss     0:00 -bash

問題なく実行、停止が出来た事を確認。

★上記の通り、以下のファイルの内容に誤りがある認識です。
 ご確認と修正をお願い致します。

  • /trema-edge/src/MakeFile
  • /trema-edge/src/examples/MakeFile
  • /trema-edge/src/examples/learning_switch/MakeFile
  • /trema-edge/learning_switch.sh

Create OpenFlow 1.3 Instructions

The following instructions should be created:

  • goto_table
  • write_metadata
  • write_actions
  • apply_actions
  • clear_actions
  • meter
  • experimenter

action buckets に複数の action を定義できない

action buckets に複数の action を定義できないように見えます。

トポロジ

# Trema switch definition
trema_switch( "sw1" ) {
  datapath_id "0x111"
}

# Host definition
vhost ( "host1" ) {
  ip "192.168.0.1"
  netmask "255.255.255.0"
}
vhost ( "host2" ) {
  ip "192.168.0.2"
  netmask "255.255.255.0"
}
vhost ( "host3" ) {
  ip "192.168.0.3"
  netmask "255.255.255.0"
}
vhost ( "host4" ) {
  ip "192.168.0.4"
  netmask "255.255.255.0"
}

# Link definition
link "sw1", "host1"
link "sw1", "host2"
link "sw1", "host3"
link "sw1", "host4"

スイッチ

src/examples/openflow_message/group-mod.rb をベースに以下のように定義

  def switch_ready datapath_id
    bucket1 = Bucket.new(
      weight: 1,
      watch_port: 2,
      actions: [
        SetField.new( action_set: [
          EthDst.new( mac_address: Mac.new( "00:00:5E:00:42:01" ) ),
          EthSrc.new( mac_address: Mac.new( "00:00:5E:00:42:02" ) )
        ] ),
        SendOutPort.new(
          port_number: 2,
          max_len: OFPCML_NO_BUFFER
      )]
    )
    bucket2 = Bucket.new(
      weight: 1,
      watch_port: 3,
      actions: [
#        SetField.new( action_set: [
#          EthDst.new( mac_address: Mac.new( "00:00:5E:00:42:03" ) ),
#          EthSrc.new( mac_address: Mac.new( "00:00:5E:00:42:04" ) )
#        ] ),
        SendOutPort.new(
          port_number: 3,
          max_len: OFPCML_NO_BUFFER
      )]
    )
    bucket3 = Bucket.new(
      weight: 1,
      watch_port: 4,
      actions: [
        SetField.new( action_set: [
          EthDst.new( mac_address: Mac.new( "00:00:5E:00:42:05" ) ),
          EthSrc.new( mac_address: Mac.new( "00:00:5E:00:42:06" ) )
        ] ) ]
#        SendOutPort.new(
#          port_number: 4,
#          max_len: OFPCML_NO_BUFFER
#      )]
    )

    send_group_mod_add(
      datapath_id,
      type: OFPGT_SELECT,
      group_id: 100,
      buckets: [ bucket1, bucket2, bucket3 ]
    )

    send_group_desc_multipart_request datapath_id

    action = GroupAction.new( group_id: 100 )
    ins = Instructions::ApplyAction.new( actions: [ action ] )
    send_flow_mod_add(
      datapath_id,
      match: Match.new( :in_port => 1 ),
      instructions: [ ins ]
    )
  end

実行結果

datapath_id: 0x111
transaction_id: 0x4f3c0005
type: 1
flags: 0
group_id: 100
  type: 1
  bucket:
    weight: 1
    watch_port: 2
    watch_group: 0
    action: Trema::Actions::SetField
  bucket:
    weight: 1
    watch_port: 3
    watch_group: 0
    SendOutPort:
      port_number: 3
      max_len: 65535
  bucket:
    weight: 1
    watch_port: 4
    watch_group: 0
    action: Trema::Actions::SetField

Create new DSL syntax for trema_switch

To be able to execute the new trema switch using the trema run command a new DSL needs to be created. The executable resides at objects/switch/switch and called switch. At least the following options should be passed as command line arguments to switch:

  • datapath_id=datapath_id
  • switch-ports=<interface/logical port >

TremaEdgeでPioが動作しない

TremaEdgeで基底クラス(Objectクラス)に、arrayとかstringという
クラスメソッドが追加されているせいで、Pioが使えません。
↓以下みたいにして確認したら、ObjectクラスでarrayもstringもTrueでした。


class Fuga
end
p Fuga.superclass # => Object class
p Fuga.superclass.respond_to?("array") # => true
p Fuga.superclass.respond_to?("string") # => true


ここで、Objectクラスが編集されているせいで、Tremaに関係しないクラスでも
普通にarrayやらstringを常に保持しており、
Pio内部でやってるBinDataを使った宣言の箇所でエラーになりました。

以下のように、TremaEdgeが持っていない名前で宣言するように指定すれば、
正常に動作しました。


・ string
=> BinData::Stringを継承した自作Typeに変更
class PioString < BinData::String
end
※ stringからpio_string に宣言時に名前を変更
・ array
=> BinData::Arrayを継承した自作Typeに変更
class PioArray < BinData::Array
end
※ arrayからpio_array に宣言時に名前を変更


宣言名が紛らわしくなるため、出来ましたら修正をお願いします。

Messages' transaction_id is not accessible until it is sent?

I tried the following spec for the Hello message expecting that it returns its transaction_id (set by get_transaction_id()), but it returned nil:

module Trema
  describe Hello, ".new" do
    its( :transaction_id ) { should_not be_nil }  # FAIL
  end
end

I guess the reason is that all attributes is set when the message is sent by controllers, by pack_xxx method. My question is that is it possible to set the basic message attributes like the transaction_id on creation time, not on being sent? IMHO these attributes can be determined on the creation time, so it's more natural to me to be accessible right after it is created.

生成したフレームをpacket_outのdata:として指定した際にエラーが出力される

#サンプルコードは以下の通りです。

def handle_arp_request( datapath_id, message )
    @arp_table.learn message.arp_spa.to_s, message.arp_sha.to_s, message.in_port.to_i
    daddr = message.arp_tpa
    interface = @interface.find_by_ipaddr( daddr )
    if interface.class.name != "SQLite3::Statement" and @interface.has?( message.eth_dst )
        puts "send a arp reply to #{ message.arp_spa.to_s }"
        packet_out datapath_id, create_arp_reply_from( message, interface["hwaddr"] ), Actions::SendOutPort.new( port_number: interface["port"] )
    end
end

def packet_out datapath_id, message, action
    send_packet_out(
        p message
        datapath_id,
        data: message,
        actions: action
    )
end

#messageの内容は以下の通りです。
p message => "d1PT\x01\x14\0\x90\xFB-\xDCi\b\x06\0\x01\b\0\x06\x04\0\x02\0\x90\xFB-\xDCi\xC0\xA8\0\xFEd1PT\x01\x14\xC0\xA8\0\x01\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"

#出力されるエラーは以下の通りです。
An Ethernet frame must be provided if buffer_id is equal to 0xffffffff

'trema' does not work

$ ./trema run src/examples/learning_switch/learning-switch.rb -c src/examples/learning_switch/learning_switch.conf
/home/whoami/.rvm/rubies/ruby-2.0.0-rc2/lib/ruby/site_ruby/2.0.0/rubygems/custom_require.rb:36:in `require': cannot load such file -- gli (LoadError)
        from /home/whoami/.rvm/rubies/ruby-2.0.0-rc2/lib/ruby/site_ruby/2.0.0/rubygems/custom_require.rb:36:in `require'
        from ././bin/trema:25:in `<main>'
$ gem install gli
Fetching: gli-2.5.6.gem (100%)
Successfully installed gli-2.5.6
1 gem installed
Installing ri documentation for gli-2.5.6...
Building YARD (yri) index for gli-2.5.6...
Installing RDoc documentation for gli-2.5.6...
$ ./trema run src/examples/learning_switch/learning-switch.rb -c src/examples/learning_switch/learning_switch.conf
ERROR: Trema is not compiled yet!

Please try the following command:
% ./build.rb
error: exit

send_flow_mod_delete

TremaEdgeのソースにsend_flow_mod_deleteが無かったため、以下を追記して使用しています。
このメソッド(flow削除のメソッド)は非常に良く使うため、TremaEdgeにもあるとありがたいです。

def send_flow_mod_delete datapath_id, options
options[ :command ] = OFPFC_DELETE
options[ :table_id ] = OFPTT_ALL if options[ :table_id ].nil?
options[ :match ] = Match.new if options[ :match ].nil?
options[ :cookie ] = 0 if options[ :cookie ].nil?
options[ :cookie_mask ] = 0 if options[ :cookie_mask ].nil?
options[ :out_port ] = OFPP_ANY if options[ :out_port ].nil?
options[ :out_group ] = OFPG_ANY if options[ :out_group ].nil?
send_flow_mod datapath_id, options
end

Write-Action instruction does not allow to modify multiple header fields

writeインストラクションのactionリストに複数のフィールドに対するset_fieldを
指定した場合、list中の最後に現れるset_fieldしか実行されない。

OF1.3.3の仕様上、writeインストラクションで書き換えを行うaction setには
各アクションは一つずつしか存在できないが、set_fieldアクションに関しては
書き換え対象のフィールドが異なれば、action set上に複数存在できる
(OF1.3.3 pp.24)。

例) flow modの内容が下記の場合、eth_srcは01:23:45:67:89:00にならず、
eth_dstのみeth_dst:01:23:44:55:66:77になる。
flow_mod cmd=add
table_id=0 prio=100
write: set_field=eth_src:01:23:45:67:89:00
set_field=eth_dst:01:23:44:55:66:77
output=1

Ruby implementation of timers

As a way of relieving the workload of the C event loop if possible timers could be created in Ruby and run as such. At the moment this is not possible since the trema event loops locks the application waiting for an event to happen.

Multiple table usage error

Hi there,

I have tried to use multiple tables with trema-edge base controller with trema-edge switch.
When I specify goto table instruction in table 0 which specifies table 1 as the destination table.
However, I got error message as below.

Goto table from 0 to 0 is not allowed.
Failed to apply instructions ( ret = 1 ).

Actually, I have specified table1 in table0, so the message seems strange.

Thanks for your help.

./trema-run.sh

Hi Tream guys,

Simple problem,
I can not find trema-run.sh which is mentioned in README.md.

Thanks for your fix. ;-)

...hiroshi miyata

OpenFLow 1.3.3

OpenFlow1.3.3

FieldBitsBytesMaskPre-requisiteDescription
OXM_OF_PBB_ISID243YesETH_TYPE=0x88E7The I-SID in the first PBB service instance tag.

Table 12: Match fields details.

create OFP1.3 match fields.

A packet can be matched against the following fields:

  • InPort - input port
  • InPhyPort - input physical port
  • Metadata - any 64-bit data
  • EthDst - ethernet destination address
  • EthSrc - ethernet source address
  • EthType - ethernet type
  • VlanVid - VLAN VID
  • VlanPriority - VLAN priority
  • IpDscp - Diffserv code point
  • IpEcn - refers to IP ECN value
  • IPProto - IP proto field
  • IPv4SrcAddr - IPv4 source address
  • IPv4DstAddr - IPv4 destination address
  • TcpSrcPort - Source port for TCP and ICMP
  • TcpDstPort - Destination port for TCP and ICMP
  • UdpSrcPort - UDP source port
  • UdpDstPort - UDP destination port
  • SctpSrcPort - SCTP source port
  • SctpDstPort - SCTP destination port
  • Icmpv4Type - ICMPv4 type
  • Icmpv4Code - ICMPv4 code
  • ArpOp - ARP opcode
  • ArpSpa - ARP source protocol address
  • ArpTpa - ARP target protocol address
  • ArpSha - ARP source hardware (MAC) address
  • ArpTha - ARP target hardware (MAC) address
  • Ipv6Src - IPv6 source address
  • Ipv6Dst - IPv6 destination address
  • IPv6FlowLabel - IPv6 flow label
  • ICMPv6Type - ICMPv6 type
  • ICMPv6Code - ICMPv6 code
  • IPv6NdTarget - IPv6 neighbor target address
  • IPv6NdSll - IPv6 neighbor source link layer address
  • IPv6NdTll - IPv6 neighbor target link layer address
  • MplsLabel - Mpls Label
  • MplsBos - MPLS Bottom of Stack( 1 bit )
  • TunnelId - Tunnel-id
  • IPv6ExtHdr - IPv6 extension header

Define a class for each action set using ruby and can append those actions to openflow_actions by calling append_action_set_field_xxx. Where xxx would be the instance variable of each action, For example append_action_set_field_in_port. This results into a long else if statement to check for the type of action set to set.

LoggerモジュールがSinatraと衝突して動かない

RESTAPIを搭載したく、Sinatraと動かそうとしました。
その結果、trema-edgeとsinatraを使ってみようとしたところ、webアクセスをしようとすると以下のエラーが出ました。
Logger is not a class
※ ブラウザ上は、504 internal error になっていました

恐らく、trema-edgeではまだLogger用のモジュールがDefaultLoggerではなく、Loggerであるため、ぶつかったんだと思われます。
(sinatraのloggerがRac::CommonLogger のLoggerクラスであるため、これがtremaのLoggerモジュールとぶつかった)
trema のmodule名をTremaLoggerにしたところ、問題なくsinatraでWebアクセスできました。
(とりあえず、dpidのArrayを画面表示させるところまで出来ることを確認)
※ logger.cの内容とlogger.rb、controller.rbの内容を変更しています。(*.cも変えてますので、最後にrakeしてます。)

logger.c
mLogger = rb_define_module_under( mTrema, "Logger" ); //変更前
mLogger = rb_define_module_under( mTrema, "TremaLogger" ); //変更後

logger.rb
module Logger # 変更前
module TremaLogger # 変更後

Controller.rb
include Logger # 変更前
include TremaLogger # 変更後

※ ちなみにDefaultLoggerじゃなく、TremaLoggerにしたのは、絶対ぶつからないようにしたかったからです。

Create OPF1.3 ruby action classes

OPF1.3 has many actions and most actions have some attributes therefore a common way to declare and validate attributes of such actions is needed. At the moment I am inclining to use the pattern used with activerecord validations. An example is always best.

class Action
  include ActionHelper
end

class PushMpls < Action
  def initialize ether_type
    create_validate : :ether_type, :presence => true, :within => "ether_type_range", :validate_with => "unsigned_16bit_number", :value => ether_type
  end

The above create_validate method would create the attribute ether_type and raise an exception if no value is given and for example call the validation functions ether_type_range and unsigned_16bit_number.

IPv6 address resolution

Hi trema-team,
I tried ping6 on learning_switch with ofsoftswitch13, but it did not work well.
I could see NS in packet_in message, but cannot see packet_out message corresponding to it. Can trema-edge handle NS/NA?

Thanks,

Missing learning_switch directory

I cloned and build trema-edge Mar. 25. When I run learning_switch.sh an error occured, since the directory of objects/examples/learning_switch did not exists.

Thanks,

Trema-switch to offer configuration/command management control

Either use an extended version of trema command or even a browser to specify configuration commands that switch would act upon to facilitate ease of testing. One way to implement such function would be to use Redis but a simple control socket might be adequate enough.

ExactMatch.from is not fully implemented yet

In current implementation, ExactMatch.from just returns a match structure included in a Packet-In message. It it not desired behavior. ExactMatch.from should parse a packet and build a new match structure.

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.