212 | | === 3c. Run a traffic duplication controller === |
| 212 | === 3c. Debugging your Controller === |
| 213 | While you are developing your controller, some useful debugging tools are: |
| 214 | |
| 215 | ==== i. Print messages ==== |
| 216 | Run your controller in verbose mode (add --verbose) and add print messages around to see what your controller is seeing. |
| 217 | |
| 218 | ==== ii. Check the status in the switch ==== |
| 219 | If you are using an OVS switch dump you can dump information about your switch, like dumping the flows: |
| 220 | {{{ |
| 221 | sudo ovs-ofctl dump-flows br0 |
| 222 | }}} |
| 223 | Two other useful commands show you the status of your switch: |
| 224 | {{{ |
| 225 | sudo ovs-vsctl show br0 |
| 226 | sudo ovs-ofctl show |
| 227 | }}} |
| 228 | |
| 229 | ==== iii. Use Wireshark to see the OpenFlow messages ==== |
| 230 | Many times it is useful to see the OpenFlow messages being exchanged between your controller and the switch. This will tell you whether the messages that are created by your controller are correct and will allow you to see the details of any errors you might be seeing from the switch. If you are using OVS then you can use wireshark on both ends of the connection, in hardware switches you have to rely only on the controller view. |
| 231 | |
| 232 | The controller host and OVS has wireshark installed, including the openflow dissector. For more information on wireshark you can take a look at the [http://wiki.wireshark.org/ wireshark wiki]. |
| 233 | |
| 234 | Here we have a simple case of how to use the OpenFlow dissector for wireshark. |
| 235 | |
| 236 | If you are on a Linux friendly machine (this includes MACs) open a terminal and ssh to your controller machine using the -Y command line argument, i.e. |
| 237 | {{{ |
| 238 | ssh -Y <username>@<controller> |
| 239 | }}} |
| 240 | |
| 241 | We will need to capture a packet trace to feed into wireshark to analyze it. So once you are logged in run: |
| 242 | {{{ |
| 243 | sudo tcpdump -s 0 -w out.pcap tcp port 6633 |
| 244 | }}} |
| 245 | |
| 246 | The above command will run tcpdump capturing the full packets (`-s 0`), saving the capture to and out.pcap file (`-w out.pcap`) and only capturing packets with src/dst tcp port 6633 that is where our controller is running (`tcp port 6633`). |
| 247 | |
| 248 | Run wireshark by typing: |
| 249 | {{{ |
| 250 | wireshark & |
| 251 | }}} |
| 252 | Use the file menu to load the pcap file. Right-click on one of the files and choose "Decode as ...." and choose the OFP protocol. Once you do that you will see the OpenFlow message types in wireshark. If you have more than openflow packets in your pcap you can type `of` in the filter box on the top and only show OpenFlow messages. |
| 253 | |
| 254 | === 3d. Run a traffic duplication controller === |