Add custom flows with dpctl

Tutorial no 10

                   DataPathController(DPCTL) is command line tool which sends OpenFlow messages to switch. Using this tool we get switch port and flow statistic also flow entries. We can also add flow rules in OpenFlowswitch using DPCTL. It’s very great tool to communicate switch directly without OpenFlowController.

In this tutorial, we use DPCTL to get flow status from switch and also we will learn how to add flow rule in switch using DPCTL.

1) Lets create a simple topology with one switch and 6 hosts.

>sudo mn – -topo single,6  – -mac – -switch ovsk – -controller remote


2) Now we will add flow rule for host1 and host2

dpctl add-flow tcp: in_port=1, actions:output=2 

dpctl add-flow tcp: in_port=2, actions:output=1

So data can be forwarded between port 1 & port 2 (i.e. Between host1 and host2)(Note:- You can choose switch instead s1 according to your topology. is localhost IP since switch is inside mininet , it will be changed practically by switch IP address)


3) you can verify the flows installed in switch or not.

>s1 dpctl dump-flows tcp:


4) To check results we can use ping utility.


Here we have connectivity between hosts 1 & 2 only, since we have added rule for port1 and port2 (i.e. host1 and host2)


5) Similarly you can add various flow rules using DPCTL without need of controller. Here I have listed some DPCTL commands

i) Manually shut up, shut down, flood, nonflood packets

>s1 dpctl mod-port tcp: 2 down    # down port no. 2

>s1 dpctl mod-port tcp: up       # up port no. 13

>s1 dpctl dump-ports tcp: gives physical port information, RX-TX  counters, error counters