The most succinct demonstration of OpenFlow on OpenVSwitch is the Openflow version 1.3 tutorial on SDN Hub.
They make use of a pre-packaged VM for their demo. Which is easy enough to do with basic packages:
$ apt-get update $ apt-get install openvswitch-switch python-openvswitch ryu-bin python-ryu mininet tshark
The openvswitch installation will install and start up the openvswitch service. OpenVSwitch does regular switching and can also act as an OpenFlow agent. For the purposes of the demonstration, openvswitch should be set for OpenFlow version 1.3.
$ ovs-vsctl set bridge s1 protocols=OpenFlow13
An OpenFlow agent needs to be controlled by an OpenFlow controller. A large number of them are available. OpenSource. ClosedSource. or in between.
I use SaltStack for provisioning, automation and orchestration. It is a Python based tool. To stay with the theme of Python, I have selected RYU as a controller, which is developed in Python. The RYU install comes with a number of example scripts. A simple switch controller can be started with:
$ ryu-manager --verbose /usr/lib/python2.7/dist-packages/ryu/app/simple_switch_13.py
It listens on port 6653 and 6633:
t# netstat -ln Active Internet connections (only servers) Proto Recv-Q Send-Q Local Address Foreign Address State tcp 0 0 0.0.0.0:6653 0.0.0.0:* LISTEN tcp 0 0 0.0.0.0:6633 0.0.0.0:* LISTEN tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN tcp6 0 0 :::22 :::* LISTEN udp 0 0 0.0.0.0:68 0.0.0.0:*
Mininet is a nice little utility which makes use of Linux' namespace and cgroups to setup emulated hosts and uses openvswitch to handle switching. This example makes use of a simple switch with three hosts. When starting up, it initializes the topology, and then provides a prompt for running commands.
$ mn --topo single,3 --mac --controller remote --switch ovsk,protocols=OpenFlow13 *** Creating network *** Adding controller *** Adding hosts: h1 h2 h3 *** Adding switches: s1 *** Adding links: (h1, s1) (h2, s1) (h3, s1) *** Configuring hosts h1 h2 h3 *** Starting controller c0 *** Starting 1 switches s1 ... *** Starting CLI: mininet> h1 ping h2 PING 10.0.0.2 (10.0.0.2) 56(84) bytes of data. 64 bytes from 10.0.0.2: icmp_seq=1 ttl=64 time=19.2 ms 64 bytes from 10.0.0.2: icmp_seq=2 ttl=64 time=0.312 ms 64 bytes from 10.0.0.2: icmp_seq=3 ttl=64 time=0.082 ms ^C --- 10.0.0.2 ping statistics --- 3 packets transmitted, 3 received, 0% packet loss, time 2028ms rtt min/avg/max/mdev = 0.082/6.534/19.209/8.963 ms mininet>
Additional ports for communicating:
$ netstat -ln Active Internet connections (only servers) Proto Recv-Q Send-Q Local Address Foreign Address State tcp 0 0 0.0.0.0:6653 0.0.0.0:* LISTEN tcp 0 0 0.0.0.0:6633 0.0.0.0:* LISTEN tcp 0 0 0.0.0.0:6634 0.0.0.0:* LISTEN tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN tcp6 0 0 :::22 :::* LISTEN udp 0 0 0.0.0.0:68 0.0.0.0:*
Dumping flows of the resulting actions:
Continue reading "OpenFlow on Debian Stretch with OpenVSwitch,..." »# ovs-ofctl dump-flows s1 -O OpenFlow13 OFPST_FLOW reply (OF1.3) (xid=0x2): cookie=0x0, duration=185.861s, table=0, n_packets=24, n_bytes=1856, priority=0 actions=CONTROLLER:65535 cookie=0x0, duration=180.186s, table=0, n_packets=5, n_bytes=378, priority=1,in_port=2,dl_dst=00:00:00:00:00:01 actions=output:1 cookie=0x0, duration=180.181s, table=0, n_packets=4, n_bytes=336, priority=1,in_port=1,dl_dst=00:00:00:00:00:02 actions=output:2