Test Select Group in OpenFlow 1.3



     |      |



There are two paths from H1 to H2. One is via s1-s2-s4 and the other is via s1-s3-s4. In this test, I will show how to use the select group entry. The path 1 or 2 will be chosen.



from mininet.net import Mininet

from mininet.node import Controller, RemoteController, OVSKernelSwitch, UserSwitch, OVSSwitch

from mininet.cli import CLI

from mininet.log import setLogLevel

from mininet.link import Link, TCLink


def topology():

        net = Mininet( controller=RemoteController, link=TCLink, switch=OVSKernelSwitch)


        # Add hosts and switches

        h1= net.addHost( 'h1', mac="00:00:00:00:00:01" )

        h2 = net.addHost( 'h2', mac="00:00:00:00:00:02" )


        s1 = net.addSwitch( 's1', protocols=["OpenFlow10,OpenFlow13"], listenPort=6634 )

        s2 = net.addSwitch( 's2', protocols=["OpenFlow10,OpenFlow13"], listenPort=6635 )

        s3 = net.addSwitch( 's3', protocols=["OpenFlow10,OpenFlow13"], listenPort=6636 )

        s4 = net.addSwitch( 's4', protocols=["OpenFlow10,OpenFlow13"], listenPort=6637 )


        c0 = net.addController( 'c0', controller=RemoteController, ip='', port=6633 )


        net.addLink( h1, s1)

        net.addLink( h2, s4)

        net.addLink( s1, s2)

        net.addLink( s1, s3)

        net.addLink( s2, s4)

        net.addLink( s3, s4)



        s1.start( [c0] )

        s2.start( [c0] )

        s3.start( [c0] )

        s4.start( [c0] )


        print "*** Running CLI"

        CLI( net )


        print "*** Stopping network"



if __name__ == '__main__':

    setLogLevel( 'info' )



[script for setting up rules]

ovs-ofctl -O OpenFlow13 add-flow s2 in_port=1,actions=output:2

ovs-ofctl -O OpenFlow13 add-flow s2 in_port=2,actions=output:1

ovs-ofctl -O OpenFlow13 add-flow s3 in_port=1,actions=output:2

ovs-ofctl -O OpenFlow13 add-flow s3 in_port=2,actions=output:1

ovs-ofctl -O OpenFlow13 add-flow s4 in_port=2,actions=output:1

ovs-ofctl -O OpenFlow13 add-flow s4 in_port=3,actions=output:1

ovs-ofctl -O OpenFlow13 add-flow s4 in_port=1,actions=output:3

ovs-ofctl -O OpenFlow13 add-flow s1 in_port=2,actions=output:1

ovs-ofctl -O OpenFlow13 add-flow s1 in_port=3,actions=output:1

ovs-ofctl -O OpenFlow13 add-group s1 group_id=5,type=select,bucket=output:2,bucket=output:3

ovs-ofctl -O OpenFlow13 add-flow s1 in_port=1,actions=group:5





Open another terminal to run the script for setting rules for switches


Check the rules for s1


Check the port status for s1


Use iperf to test select group (TCP flow)


Check the port status for s1 (From the following feature, we can see that s1-eth3 is selected. Because we can see a change in tx_pkts for s1-eth3)


Run the iperf again (This time s1-eth2 is selected. So path s1-s3-s4 is chosen for transmission)


Run the iperf again (UDP)



Run the iperf for many times (UDP) We can see that only s1-eth2 is chosen. S1-eth3 will not be selected.


I have found the reasons at https://mail.openvswitch.org/pipermail/ovs-discuss/2016-August/042394.html.

Open vSwitch 2.4 and later by default hashes the source and

>     destination Ethernet address, VLAN ID, Ethernet type, IPv4/v6

>     source and destination address and protocol, and for TCP and SCTP

>     only, the source and destination ports.  The hash is "symmetric",

>     meaning that exchanging source and destination addresses does not

>     change the bucket selection.


>     Select groups in Open vSwitch 2.4 and later can be configured to

>     use a different hash function, using a Netronome extension to the

>     OpenFlow 1.5+ group_mod message.  For more information, see

>     Documentation/group-selection-method-property.txt in the Open

>     vSwitch source tree.  (OpenFlow 1.5 support in Open vSwitch is still

>     experimental.)


Dr. Chih-Heng Ke (smallko@gmail.com)

Department of Computer Science and Information Engineering,

National Quemoy University, Kinmen, Taiwan.