Saturday, December 7, 2013


The ovs-ofctl command line tool that ships with Open vSwitch provides a very convenient way to interact with OpenFlow forwarding rules, not just with Open vSwitch, but with any switch that can be configured to accept passive connections from an OpenFlow controller.

This article looks takes the example in Integrated hybrid OpenFlow and repeats it without an OpenFlow controller, using ovs-ofctl instead.

First start Mininet without a controller and configure the switch to listen for OpenFlow commands:
sudo mn --topo single,3 --controller none --listenport 6633
Next use enable normal forwarding in the switch:
ovs-ofctl add-flow tcp: priority=10,action=normal
The following command blocks traffic from host 1 (
ovs-ofctl add-flow tcp: priority=11,dl_type=0x0800,nw_src=,action=drop
The following command removes the block:
ovs-ofctl --strict del-flows tcp: priority=11,dl_type=0x0800,nw_src=
Finally, modify the controller script with the following block() and allow() functions:
function addFlow(spec) {

function removeFlow(spec) {

function block(address) {
  if(!controls[address]) {
     addFlow(['priority=11','dl_type=0x0800','nw_src=' + address,'action=drop']);
     controls[address] = { action:'block', time: (new Date()).getTime() };

function allow(address) {
  if(controls[address]) {
     removeFlow(['priority=11','dl_type=0x0800','nw_src=' + address]);
     delete controls[address];
Moving from Mininet to a production setting is simply a matter of modifying the script to connect to the remote switch, configuring the switch to listen for OpenFlow commands, and configuring the switch to send sFlow data to sFlow-RT.

DDoS mitigation is only one use case for large flow control, others described on this blog include: ECMP / LAG load balancing, traffic marking and packet capture. This script can be modified to address these different use cases. The Mininet test bed provides a useful way to test hybrid OpenFlow control schemes before moving them into production using physical switches that support integrated hybrid OpenFlow and sFlow.


  1. I am getting one error
    ovs-ofctl : connectiong to tcp: (connection refused). I am using openvswitch.

    1. I think you shoud use: ovs-ofctl add-flow card_bridge (example: xenbr0)