• POX Wiki

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
themeConfluence
languagepython
# Traffic to 192.168.101.101:80 should be sent out switch port 4

# One thing at a time...
msg = of.ofp_flow_mod()
msg.priority = 42
msg.match.dl_type = 0x800
msg.match.nw_dst = IPAddr("192.168.101.101")
msg.match.tp_dst = 80
msg.actions.append(of.ofp_action_output(port = 4))
self.connection.send(msg)

# Same exact thing, but in a single line...
self.connection.send( of.ofp_flow_mod( action=of.ofp_action_output( port=4 ),
                                       priority=42,
                                       match=of.ofp_match( dl_type=0x800,
                                                           nw_dst="192.168.101.101",
                                                           tp_dst=80 )))
Code Block
themeConfluence
languagepython
# Example to delete all flows from all switches connected to this controller.

# create ofp_flow_mod message to delete all flows
msg = of.ofp_flow_mod(match=of.ofp_match(),command=of.OFPFC_DELETE)

# iterate all switches attached to the controller to delete all their flows
for connection in core.openflow._connections.values():
  connection.send(msg)
  log.debug("Clearing all flows from %s." % dpidToStr(connection.dpid))

ofp_stats_request - Requesting statistics from switches

...