Add custom flows with dpctl

Note: Google Drive links may not work or might be expired. You can find the scripts here

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

1

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

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

dpctl add-flow tcp:127.0.0.1:6634 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. 127.0.0.1 is localhost IP since switch is inside mininet , it will be changed practically by switch IP address)

2

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

>s1 dpctl dump-flows tcp:127.0.0.1:6634

3

4) To check results we can use ping utility.

>pingall

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

4

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:127.0.0.1:6634 2 down    # down port no. 2

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

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