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)

  2. I am trying to add flows for torus topology with pox in order to ping all the hosts in mininet. Here is my add flow command.

    sudo mn --custom=sflow-rt/extras/ --link tc,bw=10 --topo torus,3,3 --controller remote --switch ovsk,stp=1 --mac

    sudo ovs-ofctl add-flow s1x1 priority=65535,arp,in_port=1,vlan_tci=0x0000,dl_src=00:00:00:00:00:01,dl_dst=00:00:00:00:00:02,arp_spa=,arp_tpa=,arp_op=2 actions=output:1

    sudo ovs-ofctl add-flow s1x2 priority=65535,arp,in_port=1,vlan_tci=0x0000,dl_src=00:00:00:00:00:02,dl_dst=00:00:00:00:00:01,arp_spa=,arp_tpa=,arp_op=2,actions=output:1

    sudo ovs-ofctl add-flow s1x1 priority=65535,icmp,in_port=1,vlan_tci=0x0000,dl_src=00:00:00:00:00:01,dl_dst=00:00:00:00:00:02,nw_src=,nw_dst=,nw_tos=0,icmp_type=8,icmp_code=0,actions=output:1

    sudo ovs-ofctl add-flow s1x2 priority=65535,icmp,in_port=1,vlan_tci=0x0000,dl_src=00:00:00:00:00:02,dl_dst=00:00:00:00:00:01,nw_src=,nw_dst=,nw_tos=0,icmp_type=8,icmp_code=0,actions=output:1

    Even after adding, I am still unable to ping the hosts. Can you please help me?