Search This Blog

Friday, May 17, 2013

How is a single OpenFlow flow defined on a switch

We have discussed previously what OpenFlow is and how it works (What is Openflow). But at the end of the day it is a technology that is embedded in layer 2 and layer 3 switches/routers. That means that an OpenFlow compatible access switch has to be able to handle traffic like:
  • network layer 2 broadcast
  • network layer 3 broadcast
  • ARP, GARP (OSI  layer 2 packet)
  • ICMP (layer 3 packets)
  • generic IP datagrams
  • IP unicast, broadcast and multicast  
  • TCP packets
  • other then IPv4 protocols carried inside Ethernet frames (for example ipv6)
  • Vlans
  • others
According to OpenFlow idea the traffic will be classified into flows and each flow will have certain rules how to handle it.

This raises a question: how is a flow defined? 

This is important because as we see a flow need to be flexible enough to deal with the complexities and technical details of layer 2 layer 3 network packets. The answer is in the OpenFlow Specification document that defines a flow in a following way:

The specification provide as well a C implementation of the flow structure that looks like:
/* A.2.3 Flow Match Structures
 * When describing a ow entry, the following structures are used:

/* The match type indicates the match structure (set of fields that compose the
* match) in use. The match type is placed in the type field at the beginning
* of all match structures. The "standard" type corresponds to ofp_match and
* must be supported by all OpenFlow switches. Extensions that define other
* match types may be published on the OpenFlow wiki. Support for extensions is
* optional.
enum ofp_match_type {
OFPMT_STANDARD,                  /* The match fields defined in the ofp_match
                        structure apply */
/* Fields to match against flows */
struct ofp_match {
uint16_t type;               /* One of OFPMT_* */
uint16_t length;             /* Length of ofp_match */
uint32_t in_port;            /* Input switch port. */
uint32_t wildcards;          /* Wildcard fields. */
uint8_t dl_src[OFP_ETH_ALEN]; /* Ethernet source address. */
uint8_t dl_src_mask[OFP_ETH_ALEN]; /* Ethernet source address mask. */
uint8_t dl_dst[OFP_ETH_ALEN]; /* Ethernet destination address. */
uint8_t dl_dst_mask[OFP_ETH_ALEN]; /* Ethernet destination address mask. */
uint16_t dl_vlan;            /* Input VLAN id. */
uint8_t dl_vlan_pcp;         /* Input VLAN priority. */
28OpenFlow Switch Specication Version 1.1.0 Implemented
uint8_t pad1[1];             /* Align to 32-bits */
uint16_t dl_type;            /* Ethernet frame type. */
uint8_t nw_tos;              /* IP ToS (actually DSCP field, 6 bits). */
uint8_t nw_proto;            /* IP protocol or lower 8 bits of
                              * ARP opcode. */
uint32_t nw_src;             /* IP source address. */
uint32_t nw_src_mask;        /* IP source address mask. */
uint32_t nw_dst;             /* IP destination address. */
uint32_t nw_dst_mask;        /* IP destination address mask. */
uint16_t tp_src;             /* TCP/UDP/SCTP source port. */
uint16_t tp_dst;             /* TCP/UDP/SCTP destination port. */
uint32_t mpls_label;         /* MPLS label. */
uint8_t mpls_tc;             /* MPLS TC. */
uint8_t pad2[3];             /* Align to 64-bits */
uint64_t metadata;           /* Metadata passed between tables. */
uint64_t metadata_mask;      /* Mask for metadata. */
OFP_ASSERT(sizeof(struct ofp_match) == OFPMT_STANDARD_LENGTH);

Based on the spec we can see that a flow definition if far beyond more complex than a simple MAC or IP addresses tuple. It looks like it can match any Ethernet frame or IP datagrams including TCP or UDP packets. What is not clearly specified is how it handles the IPv6 packets.

No comments:

Post a Comment