• POX Wiki

Versions Compared

Key

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

...

Code Block
themeConfluence
languagepython
import pox.openflow.libopenflow_01 as of # POX convention
import pox.lib.packet as pkt # POX convention
my_match = of.ofp_match(dl_type = pkt.ethernet.IP_TYPE, nw_proto = pkt.ipv4.TCP_PROTOCOL, tp_dst = 80)

To read When reading a match structure (e.g. as returned in a flow_removed message or a flow_stats reply) , you'll need to see which fields are wildcarded by checking the wildcards attribute. Fields that are not wildcarded will have relevant values that are matched against packets. Most of the fields are identified by the following flags:

  •   OFPFW_IN_PORT
  •   OFPFW_DL_VLAN
  •   OFPFW_DL_SRC
  •   OFPFW_DL_DST
  •   OFPFW_DL_TYPE
  •   OFPFW_NW_PROTO
  •   OFPFW_TP_SRC
  •   OFPFW_TP_DST
  •   OFPFW_DL_VLAN_PCP
  •   OFPFW_NW_TOS     

The IP source and destination address wildcards are defined by 6 bit integers embedded in the bitfield. You can extract them like this:

src_ip_wild_bits = (match.wildcards >> 8) & 0x3F

dst_ip_wild_bits = (match.wildcards >> 14) & 0x3F

These integers define how many LSBits are wildcarded and thus are the opposite (32-X) of the usage of traditional CIDR notation. So the my_match.nw_src = all wildcarded fields are set to None. To learn which bits of the IP source and destination addresses are being matched, retrieve them with match.get_nw_src() and match.get_nw_dst() which will return a tuple such as (IPAddr("192.168.42.0/24" example above will have the src wildcard field set to 8"), 24) which includes the subnet mask.

Define a match from an existing packet

...