cabeggar

Software Defined Network in Data Center II - Simple learning switch

A simple learning switch is a switch which can learn forward messages from packets received. It learn source MAC address and input port from new packets and store messages in its own table. For packets it don’t know where to forward it simply floods them. If we replace simple learning switch with a Openflow dumb switch, the main difference will be the logic will be implemented in the controller. The flow chart will be like this.

simple learning switch flow chart

From the flow chart, we can see that there are two tables, one in the switch and the other one in the controller. We can implement Openflow controller with Ryu and test it in a simple network simulated by Mininet. We run this experiment on Ubuntu 14.04.

To install Mininet, we can just run apt-get in terminal: sudo apt-get install mininet, since we don’t need much from Mininet source code. But for Ryu, we’d better clone the source code and install them since we need to take their source code as a reference.

1
2
3
4
5
$ sudo apt-get install python-pip python-dev build-essential
$ sudo pip install --upgrade pip
$ sudo pip install --upgrade six
$ git clone git://github.com/osrg/ryu.git
$ cd ryu; python ./setup.py install

There maybe something missing in these command lines. Just remember install and upgrade everything the output of console tells you.

linear 2 network topology

We can run command sudo mn --topo=linear,2 --controller=remote --mac to generate a topology with 2 linear switch-host pairs. Then in another terminal window we get into the Ryu directory and run PYTHONPATH=. ./bin/ryu-manager ryu/app/simple_switch.py to run the simple learning switch controller script. You can first do xterm s1 s2 to open switch console and sudo ovs-ofctl dump-flows s1(or s2) in xterm to see flow entries in both switches. Then we run h1 ping h2 in mininet CLI and observe the changes in both switches’ flow entries. To understand the operations better, you can read through source code of simple_switch.py.