| 218 | |
| 219 | === picking at OFP (8/4) === |
| 220 | !OpenFlow data structure is defined under /include/openflow/openflow.h . |
| 221 | |
| 222 | Whether it is NOX or the !Openflow Regression Suite it is all in lots of C. Trying to make Ruby work with C seemed a bit too messy for our own good, so we sent an email to the NOX developer's mailing list in hopes of some elucidation of how to create a Ruby interface to !OpenFlow, instead of Python (which is what NOX does, as described [http://noxrepo.org/wp/?page_id=2 here]) |
| 223 | |
| 224 | ==== some experimentation with Ruby sockets ==== |
| 225 | |
| 226 | The switch will keep trying to contact a controller, regardless of whether the controller is active. This happens once every 15 seconds or so, and can be seen with a very simple script that listens on TCP 6633 (the default !OpenFlow port) on the console's !OpenFlow VLAN interface, which has the IP address 172.16.100.1: |
| 227 | |
| 228 | {{{ |
| 229 | #!/usr/bin/ruby -w |
| 230 | require 'socket' |
| 231 | |
| 232 | # allow the switch to try to establish a connection |
| 233 | ofpsock = TCPserver.new("172.16.100.1", 6633) |
| 234 | |
| 235 | #listen to see what port the switch is using |
| 236 | while (session = ofpsock.accept) |
| 237 | t = Time.now # to see interval of messages |
| 238 | peer = session.peeraddr |
| 239 | puts "#{peer[1]} #{peer[2]} #{t.to_s.split[3]}" |
| 240 | session.close |
| 241 | end |
| 242 | |
| 243 | |
| 244 | }}} |
| 245 | |
| 246 | You get: |
| 247 | {{{ |
| 248 | 55354 172.16.100.10 20:53:22 |
| 249 | 55353 172.16.100.10 20:53:37 |
| 250 | 55352 172.16.100.10 20:53:52 |
| 251 | 55351 172.16.100.10 20:54:07 |
| 252 | ... |
| 253 | }}} |
| 254 | |
| 255 | The first column shows the switch's port. 172.16.100.10 is the vlan interface IP address for the Openflow VLAN on the switch, so you know it is the !OpenFlow switch trying to establish a connection with the controller. To be honest it's not clear if the timestamps would reflect the speed of the code or the activity of the switch. |
| 256 | |
| 257 | |