209 | | In the above example we ran a very simple controller. The power of OpenFlow comes from the fact that you can decide to forward the packet anyway you want based on the supported OpenFlow actions. |
| 209 | Now let's do a slightly more complicated controller. OpenFlow gives you the power to overwrite fields of your packets at the switch, for example the TCP source or destination port and do port forwarding. You can have clients trying to contact a server at port 5000, and the OpenFlow switch can redirect your traffic to a service listening on port 6000. |
| 210 | |
| 211 | Under the `ext` directory there are two files PortForwarding.py and myPortForwarding.py that are similar like the previous exercise. Both of these controller are configured by a configuration file at `ext/port_forward.config`. |
| 212 | |
| 213 | To run the controller do (while at /local/pox directory) |
| 214 | {{{ |
| 215 | ./pox.py --verbose myPortForwarding.py |
| 216 | }}} |
| 217 | |
| 218 | To test your controller we are going to use netcat. Go to the two terminals of host2. In one terminal run: |
| 219 | {{{ |
| 220 | nc -l 5000 |
| 221 | }}} |
| 222 | |
| 223 | and in the other terminal run |
| 224 | {{{ |
| 225 | nc -l 6000 |
| 226 | }}} |
| 227 | |
| 228 | Now first start the simple layer 2 forwarding controller: |
| 229 | {{{ |
| 230 | ovs:/local/pox% ./pox.py --verbose forwarding.l2_learning |
| 231 | }}} |
| 232 | |
| 233 | Go to the terminal of host1 and connect to host2 at port 5000: |
| 234 | {{{ |
| 235 | nc 10.10.1.2 5000 |
| 236 | }}} |
| 237 | |
| 238 | Type something and you should see it at the the terminal of host2 at port 5000. |
| 239 | |
| 240 | Start your controller and do the same, now your text should appear on the other terminal of host2. |