Monday, September 16, 2013

Add and delete flow paths from POX controller

POX>from pox.core import core
POX>import pox.openflow.libopenflow_01 as of
POX>from pox.lib.addresses import IPAddr

Add flows

POX>for connection in core.openflow.connections:
                connection.send(of.ofp_flow_mod(action=of.ofp_action_output(port=2),priority=32,
 match=of.ofp_match(dl_type=0x800,nw_src="10.0.0.1",nw_dst="10.0.0.2")))

Delete flows

POX>for connection in core.openflow.connections:    
                connection.send(of.ofp_flow_mod(command=of.OFPFC_DELETE_STRICT,
 action=of.ofp_action_output(port=3),priority=32,
 match=of.ofp_match(dl_type=0x800,nw_src="10.0.0.1",nw_dst="10.0.0.3")))

Dont forget to add
net.staticArp() after net.build() in mininet code

*make sure in for loops, intendent is there
     For connection....
              connection.send......

4 comments:

  1. Your example code in this blog is cut off on the right side so I cannot see all of the parameters to your connection.send call for adding a flow. Can you somehow make all the parameters visible or email your examples to me at uvugdbrown@gmail.com? Thanks!

    ReplyDelete
  2. Hello,
    i was going through your blog, call me dumb, but i couldnt understand where to add these flows.

    connection.send(of.ofp_flow_mod(action=of.ofp_action_output(port=2),priority=32,
    match=of.ofp_match(dl_type=0x800,nw_src="10.0.0.1",nw_dst="10.0.0.2")))

    i mean are we supposed to add this code in a file in controller or some where else?
    if in file then in which one, please?

    ReplyDelete
  3. i am using custom topology as shown in below how we add a flows in pox controller
    net.addLink(Host1, Switch1, **linkopts )
    net.addLink(Switch1, Switch2, **linkopts )
    net.addLink(Switch1, Switch3, **linkopts )
    net.addLink(Switch3, Switch4, **linkopts )
    net.addLink(Switch2, Switch5, **linkopts )
    net.addLink(Switch4, Switch5, **linkopts )
    net.addLink(Switch4, Host2, **linkopts )

    ReplyDelete