Skip to content

trema/learning_switch

Repository files navigation

Learning Switch

Build Status Coverage Status Code Climate Dependency Status Inline docs

An OpenFlow controller that emulates layer 2 switches.

Prerequisites

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

Install

$ git clone https://github.com/trema/learning_switch.git
$ cd learning_switch
$ bundle install

Play

The lib/learning_switch.rb is an OpenFlow controller implementation that emulates a layer 2 switch. Run this like so:

$ ./bin/trema run ./lib/learning_switch.rb -c trema.conf

Then send some packets from host1 to host2, and show received packet stats of host2:

$ ./bin/trema send_packets --source host1 --dest host2 --npackets 10
$ ./bin/trema show_stats host2
Packets received:
 192.168.0.1 -> 192.168.0.2 = 10 packets

The lib/multi_learning_switch.rb is an extension to lib/learning_switch.rb. It can emulate multiple OpenFlow switches.

$ ./bin/trema run ./lib/multi_learning_switch.rb -c trema.multi.conf

Enjoy!