OpenFlow v1.5 Messages and Structures

OpenFlow v1.5 Messages and Structures

Controller-to-Switch Messages

Handshake

class os_ken.ofproto.ofproto_v1_5_parser.OFPFeaturesRequest(datapath)

Features request message

The controller sends a feature request to the switch upon session establishment.

This message is handled by the OSKen framework, so the OSKen application do not need to process this typically.

Example:

def send_features_request(self, datapath):
    ofp_parser = datapath.ofproto_parser

    req = ofp_parser.OFPFeaturesRequest(datapath)
    datapath.send_msg(req)

JSON Example:

{
   "OFPFeaturesRequest": {}
}
class os_ken.ofproto.ofproto_v1_5_parser.OFPSwitchFeatures(datapath, datapath_id=None, n_buffers=None, n_tables=None, auxiliary_id=None, capabilities=None)

Features reply message

The switch responds with a features reply message to a features request.

This message is handled by the OSKen framework, so the OSKen application do not need to process this typically.

Example:

@set_ev_cls(ofp_event.EventOFPSwitchFeatures, CONFIG_DISPATCHER)
def switch_features_handler(self, ev):
    msg = ev.msg

    self.logger.debug('OFPSwitchFeatures received: '
                      'datapath_id=0x%016x n_buffers=%d '
                      'n_tables=%d auxiliary_id=%d '
                      'capabilities=0x%08x',
                      msg.datapath_id, msg.n_buffers, msg.n_tables,
                      msg.auxiliary_id, msg.capabilities)

JSON Example:

{
   "OFPSwitchFeatures": {
      "auxiliary_id": 0, 
      "capabilities": 79, 
      "datapath_id": 1, 
      "n_buffers": 255, 
      "n_tables": 255
   }
}

Switch Configuration

class os_ken.ofproto.ofproto_v1_5_parser.OFPSetConfig(datapath, flags=0, miss_send_len=0)

Set config request message

The controller sends a set config request message to set configuraion parameters.

Attribute Description
flags

Bitmap of the following flags.

OFPC_FRAG_NORMAL
OFPC_FRAG_DROP
OFPC_FRAG_REASM
miss_send_len Max bytes of new flow that datapath should send to the controller

Example:

def send_set_config(self, datapath):
    ofp = datapath.ofproto
    ofp_parser = datapath.ofproto_parser

    req = ofp_parser.OFPSetConfig(datapath, ofp.OFPC_FRAG_NORMAL, 256)
    datapath.send_msg(req)

JSON Example:

{
   "OFPSetConfig": {
      "flags": 0, 
      "miss_send_len": 128
   }
}
class os_ken.ofproto.ofproto_v1_5_parser.OFPGetConfigRequest(datapath)

Get config request message

The controller sends a get config request to query configuration parameters in the switch.

Example:

def send_get_config_request(self, datapath):
    ofp_parser = datapath.ofproto_parser

    req = ofp_parser.OFPGetConfigRequest(datapath)
    datapath.send_msg(req)

JSON Example:

{
   "OFPGetConfigRequest": {}
}
class os_ken.ofproto.ofproto_v1_5_parser.OFPGetConfigReply(datapath, flags=None, miss_send_len=None)

Get config reply message

The switch responds to a configuration request with a get config reply message.

Attribute Description
flags

Bitmap of the following flags.

OFPC_FRAG_NORMAL
OFPC_FRAG_DROP
OFPC_FRAG_REASM
miss_send_len Max bytes of new flow that datapath should send to the controller

Example:

@set_ev_cls(ofp_event.EventOFPGetConfigReply, MAIN_DISPATCHER)
def get_config_reply_handler(self, ev):
    msg = ev.msg
    dp = msg.datapath
    ofp = dp.ofproto
    flags = []

    if msg.flags & ofp.OFPC_FRAG_NORMAL:
        flags.append('NORMAL')
    if msg.flags & ofp.OFPC_FRAG_DROP:
        flags.append('DROP')
    if msg.flags & ofp.OFPC_FRAG_REASM:
        flags.append('REASM')
    self.logger.debug('OFPGetConfigReply received: '
                      'flags=%s miss_send_len=%d',
                      ','.join(flags), msg.miss_send_len)

JSON Example:

{
   "OFPGetConfigReply": {
      "flags": 0, 
      "miss_send_len": 128
   }
}

Modify State Messages

class os_ken.ofproto.ofproto_v1_5_parser.OFPTableMod(datapath, table_id, config, properties)

Flow table configuration message

The controller sends this message to configure table state.

Attribute Description
table_id ID of the table (OFPTT_ALL indicates all tables)
config

Bitmap of configuration flags.

OFPTC_EVICTION
OFPTC_VACANCY_EVENTS
properties List of OFPTableModProp subclass instance

Example:

def send_table_mod(self, datapath):
    ofp = datapath.ofproto
    ofp_parser = datapath.ofproto_parser

    req = ofp_parser.OFPTableMod(datapath, 1, 3)
    flags = ofp.OFPTC_VACANCY_EVENTS
    properties = [ofp_parser.OFPTableModPropEviction(flags)]
    req = ofp_parser.OFPTableMod(datapath, 1, 3, properties)
    datapath.send_msg(req)

JSON Example:

{
   "OFPTableMod": {
      "config": 4, 
      "properties": [
         {
            "OFPTableModPropEviction": {
               "flags": 2, 
               "length": 8, 
               "type": 2
            }
         }
      ], 
      "table_id": 255
   }
}
class os_ken.ofproto.ofproto_v1_5_parser.OFPFlowMod(datapath, cookie=0, cookie_mask=0, table_id=0, command=0, idle_timeout=0, hard_timeout=0, priority=32768, buffer_id=4294967295, out_port=0, out_group=0, flags=0, importance=0, match=None, instructions=None)

Modify Flow entry message

The controller sends this message to modify the flow table.

Attribute Description
cookie Opaque controller-issued identifier
cookie_mask Mask used to restrict the cookie bits that must match when the command is OPFFC_MODIFY* or OFPFC_DELETE*
table_id ID of the table to put the flow in
command

One of the following values.

OFPFC_ADD
OFPFC_MODIFY
OFPFC_MODIFY_STRICT
OFPFC_DELETE
OFPFC_DELETE_STRICT
idle_timeout Idle time before discarding (seconds)
hard_timeout Max time before discarding (seconds)
priority Priority level of flow entry
buffer_id Buffered packet to apply to (or OFP_NO_BUFFER)
out_port For OFPFC_DELETE* commands, require matching entries to include this as an output port
out_group For OFPFC_DELETE* commands, require matching entries to include this as an output group
flags

Bitmap of the following flags.

OFPFF_SEND_FLOW_REM
OFPFF_CHECK_OVERLAP
OFPFF_RESET_COUNTS
OFPFF_NO_PKT_COUNTS
OFPFF_NO_BYT_COUNTS
importance Eviction precedence
match Instance of OFPMatch
instructions list of OFPInstruction* instance

Example:

def send_flow_mod(self, datapath):
    ofp = datapath.ofproto
    ofp_parser = datapath.ofproto_parser

    cookie = cookie_mask = 0
    table_id = 0
    idle_timeout = hard_timeout = 0
    priority = 32768
    buffer_id = ofp.OFP_NO_BUFFER
    importance = 0
    match = ofp_parser.OFPMatch(in_port=1, eth_dst='ff:ff:ff:ff:ff:ff')
    actions = [ofp_parser.OFPActionOutput(ofp.OFPP_NORMAL, 0)]
    inst = [ofp_parser.OFPInstructionActions(ofp.OFPIT_APPLY_ACTIONS,
                                             actions)]
    req = ofp_parser.OFPFlowMod(datapath, cookie, cookie_mask,
                                table_id, ofp.OFPFC_ADD,
                                idle_timeout, hard_timeout,
                                priority, buffer_id,
                                ofp.OFPP_ANY, ofp.OFPG_ANY,
                                ofp.OFPFF_SEND_FLOW_REM,
                                importance,
                                match, inst)
    datapath.send_msg(req)

JSON Example:

{
   "OFPFlowMod": {
      "buffer_id": 0, 
      "command": 0, 
      "cookie": 1311768467463790320, 
      "cookie_mask": 18446744073709551615, 
      "flags": 0, 
      "hard_timeout": 0, 
      "idle_timeout": 0, 
      "importance": 39032, 
      "instructions": [
         {
            "OFPInstructionActions": {
               "actions": [
                  {
                     "OFPActionPopVlan": {
                        "len": 8, 
                        "type": 18
                     }
                  }, 
                  {
                     "OFPActionSetField": {
                        "field": {
                           "OXMTlv": {
                              "field": "ipv4_dst", 
                              "mask": null, 
                              "value": "192.168.2.9"
                           }
                        },
                        "len": 16,
                        "type": 25
                     }
                  }, 
                  {
                     "NXActionLearn": {
                        "cookie": 0, 
                        "experimenter": 8992, 
                        "fin_hard_timeout": 0, 
                        "fin_idle_timeout": 0, 
                        "flags": 0, 
                        "hard_timeout": 300, 
                        "idle_timeout": 0, 
                        "len": 96, 
                        "priority": 1, 
                        "specs": [
                           {
                              "NXFlowSpecMatch": {
                                 "dst": [
                                    "vlan_vid", 
                                    0
                                 ], 
                                 "n_bits": 12, 
                                 "src": [
                                    "vlan_vid", 
                                    0
                                 ]
                              }
                           }, 
                           {
                              "NXFlowSpecMatch": {
                                 "dst": [
                                    "eth_dst_nxm", 
                                    0
                                 ], 
                                 "n_bits": 48, 
                                 "src": [
                                    "eth_src_nxm", 
                                    0
                                 ]
                              }
                           }, 
                           {
                              "NXFlowSpecLoad": {
                                 "dst": [
                                    "vlan_vid", 
                                    0
                                 ], 
                                 "n_bits": 12, 
                                 "src": 0
                              }
                           }, 
                           {
                              "NXFlowSpecLoad": {
                                 "dst": [
                                    "tunnel_id_nxm", 
                                    0
                                 ], 
                                 "n_bits": 64, 
                                 "src": [
                                    "tunnel_id_nxm", 
                                    0
                                 ]
                              }
                           }, 
                           {
                              "NXFlowSpecOutput": {
                                 "dst": "", 
                                 "n_bits": 32, 
                                 "src": [
                                    "in_port", 
                                    0
                                 ]
                              }
                           }
                        ], 
                        "subtype": 16, 
                        "table_id": 99, 
                        "type": 65535
                     }
                  }
               ], 
               "len": 128, 
               "type": 4
            }
         }, 
         {
            "OFPInstructionGotoTable": {
               "len": 8, 
               "table_id": 100, 
               "type": 1
            }
         }
      ], 
      "match": {
         "OFPMatch": {
            "length": 70, 
            "oxm_fields": [
               {
                  "OXMTlv": {
                     "field": "in_port", 
                     "mask": null, 
                     "value": 43981
                  }
               }, 
               {
                  "OXMTlv": {
                     "field": "eth_dst", 
                     "mask": null, 
                     "value": "aa:bb:cc:99:88:77"
                  }
               }, 
               {
                  "OXMTlv": {
                     "field": "eth_type", 
                     "mask": null, 
                     "value": 2048
                  }
               }, 
               {
                  "OXMTlv": {
                     "field": "vlan_vid", 
                     "mask": null, 
                     "value": 5095
                  }
               }, 
               {
                  "OXMTlv": {
                     "field": "ipv4_dst", 
                     "mask": null, 
                     "value": "192.168.2.1"
                  }
               }, 
               {
                  "OXMTlv": {
                     "field": "tunnel_id", 
                     "mask": null, 
                     "value": 50000
                  }
               }, 
               {
                  "OXMTlv": {
                     "field": "tun_ipv4_src", 
                     "mask": null, 
                     "value": "192.168.2.3"
                  }
               }, 
               {
                  "OXMTlv": {
                     "field": "tun_ipv4_dst", 
                     "mask": null, 
                     "value": "192.168.2.4"
                  }
               }
            ], 
            "type": 1
         }
      }, 
      "out_group": 0, 
      "out_port": 0, 
      "priority": 0, 
      "table_id": 2
   }
}
{
   "OFPFlowMod": {
      "buffer_id": 0, 
      "command": 0, 
      "cookie": 1311768467463790320, 
      "cookie_mask": 18446744073709551615, 
      "flags": 0, 
      "hard_timeout": 0, 
      "idle_timeout": 0, 
      "importance": 39032, 
      "instructions": [
         {
            "OFPInstructionActions": {
               "actions": [
                  {
                     "NXActionConjunction": {
                        "clause": 1, 
                        "experimenter": 8992, 
                        "id": 11259375, 
                        "len": 16, 
                        "n_clauses": 2, 
                        "subtype": 34, 
                        "type": 65535
                     }
                  }
               ], 
               "len": 24, 
               "type": 4
            }
         }
      ], 
      "match": {
         "OFPMatch": {
            "length": 70, 
            "oxm_fields": [
               {
                  "OXMTlv": {
                     "field": "in_port", 
                     "mask": null, 
                     "value": 43981
                  }
               }, 
               {
                  "OXMTlv": {
                     "field": "eth_dst", 
                     "mask": null, 
                     "value": "aa:bb:cc:99:88:77"
                  }
               }, 
               {
                  "OXMTlv": {
                     "field": "eth_type", 
                     "mask": null, 
                     "value": 2048
                  }
               }, 
               {
                  "OXMTlv": {
                     "field": "vlan_vid", 
                     "mask": null, 
                     "value": 5095
                  }
               }, 
               {
                  "OXMTlv": {
                     "field": "ipv4_dst", 
                     "mask": null, 
                     "value": "192.168.2.1"
                  }
               }, 
               {
                  "OXMTlv": {
                     "field": "tunnel_id", 
                     "mask": null, 
                     "value": 50000
                  }
               }, 
               {
                  "OXMTlv": {
                     "field": "tun_ipv4_src", 
                     "mask": null, 
                     "value": "192.168.2.3"
                  }
               }, 
               {
                  "OXMTlv": {
                     "field": "tun_ipv4_dst", 
                     "mask": null, 
                     "value": "192.168.2.4"
                  }
               }
            ], 
            "type": 1
         }
      }, 
      "out_group": 0, 
      "out_port": 0, 
      "priority": 0, 
      "table_id": 4
   }
}
{
   "OFPFlowMod": {
      "buffer_id": 0, 
      "command": 0, 
      "cookie": 1311768467463790320, 
      "cookie_mask": 18446744073709551615, 
      "flags": 0, 
      "hard_timeout": 0, 
      "idle_timeout": 0, 
      "importance": 39032, 
      "instructions": [
         {
            "OFPInstructionActions": {
               "actions": [
                  {
                     "OFPActionPopVlan": {
                        "len": 8, 
                        "type": 18
                     }
                  }, 
                  {
                     "OFPActionSetField": {
                        "field": {
                           "OXMTlv": {
                              "field": "ipv4_dst", 
                              "mask": null, 
                              "value": "192.168.2.9"
                           }
                        },
                        "len": 16,
                        "type": 25
                     }
                  }
               ], 
               "len": 32, 
               "type": 4
            }
         }, 
         {
            "OFPInstructionGotoTable": {
               "len": 8, 
               "table_id": 100, 
               "type": 1
            }
         }
      ], 
      "match": {
         "OFPMatch": {
            "length": 12, 
            "oxm_fields": [
               {
                  "OXMTlv": {
                     "field": "conj_id", 
                     "mask": null, 
                     "value": 11259375
                  }
               }
            ], 
            "type": 1
         }
      }, 
      "out_group": 0, 
      "out_port": 0, 
      "priority": 0, 
      "table_id": 3
   }
}
class os_ken.ofproto.ofproto_v1_5_parser.OFPGroupMod(datapath, command=0, type_=0, group_id=0, command_bucket_id=4294967295, buckets=None, properties=None, bucket_array_len=None)

Modify group entry message

The controller sends this message to modify the group table.

Attribute Description
command

One of the following values.

OFPGC_ADD
OFPGC_MODIFY
OFPGC_DELETE
OFPGC_INSERT_BUCKET
OFPGC_REMOVE_BUCKET
type

One of the following values.

OFPGT_ALL
OFPGT_SELECT
OFPGT_INDIRECT
OFPGT_FF
group_id Group identifier.
command_bucket_id Bucket Id used as part of OFPGC_INSERT_BUCKET and OFPGC_REMOVE_BUCKET commands execution.
buckets List of OFPBucket instance
properties List of OFPGroupProp instance

type attribute corresponds to type_ parameter of __init__.

Example:

def send_group_mod(self, datapath):
    ofp = datapath.ofproto
    ofp_parser = datapath.ofproto_parser

    port = 1
    max_len = 2000
    actions = [ofp_parser.OFPActionOutput(port, max_len)]

    weight = 100
    watch_port = 0
    watch_group = 0
    buckets = [ofp_parser.OFPBucket(weight, watch_port, watch_group,
                                    actions)]

    group_id = 1
    command_bucket_id=1
    req = ofp_parser.OFPGroupMod(datapath, ofp.OFPGC_ADD,
                                 ofp.OFPGT_SELECT, group_id,
                                 command_bucket_id, buckets)
    datapath.send_msg(req)

JSON Example:

{
    "OFPGroupMod": {
        "bucket_array_len": 56,
        "buckets": [
            {
                "OFPBucket": {
                    "action_array_len": 24,
                    "actions": [
                        {
                            "OFPActionPopVlan": {
                                "len": 8,
                                "type": 18
                            }
                        },
                        {
                            "OFPActionSetField": {
                                "field": {
                                    "OXMTlv": {
                                        "field": "ipv4_dst",
                                        "mask": null,
                                        "value": "192.168.2.9"
                                    }
                                },
                                "len": 16,
                                "type": 25
                            }
                        }
                    ],
                    "bucket_id": 305419896,
                    "len": 56,
                    "properties": [
                        {
                            "OFPGroupBucketPropWeight": {
                                "length": 8,
                                "type": 0,
                                "weight": 52428
                            }
                        },
                        {
                            "OFPGroupBucketPropWatch": {
                                "length": 8,
                                "type": 1,
                                "watch": 56797
                            }
                        },
                        {
                            "OFPGroupBucketPropWatch": {
                                "length": 8,
                                "type": 2,
                                "watch": 4008636142
                            }
                        }
                    ]
                }
            }
        ],
        "command": 3,
        "command_bucket_id": 3149642683,
        "group_id": 2863311530,
        "properties": [],
        "type": 1
    }
}
class os_ken.ofproto.ofproto_v1_5_parser.OFPPortMod(datapath, port_no=0, hw_addr='00:00:00:00:00:00', config=0, mask=0, properties=None)

Port modification message

The controller sneds this message to modify the behavior of the port.

Attribute Description
port_no Port number to modify
hw_addr The hardware address that must be the same as hw_addr of OFPPort of OFPSwitchFeatures
config

Bitmap of configuration flags.

OFPPC_PORT_DOWN
OFPPC_NO_RECV
OFPPC_NO_FWD
OFPPC_NO_PACKET_IN
mask Bitmap of configuration flags above to be changed
properties List of OFPPortModProp subclass instance

Example:

def send_port_mod(self, datapath):
    ofp = datapath.ofproto
    ofp_parser = datapath.ofproto_parser

    port_no = 3
    hw_addr = 'fa:c8:e8:76:1d:7e'
    config = 0
    mask = (ofp.OFPPC_PORT_DOWN | ofp.OFPPC_NO_RECV |
            ofp.OFPPC_NO_FWD | ofp.OFPPC_NO_PACKET_IN)
    advertise = (ofp.OFPPF_10MB_HD | ofp.OFPPF_100MB_FD |
                 ofp.OFPPF_1GB_FD | ofp.OFPPF_COPPER |
                 ofp.OFPPF_AUTONEG | ofp.OFPPF_PAUSE |
                 ofp.OFPPF_PAUSE_ASYM)
    properties = [ofp_parser.OFPPortModPropEthernet(advertise)]
    req = ofp_parser.OFPPortMod(datapath, port_no, hw_addr, config,
                                mask, properties)
    datapath.send_msg(req)

JSON Example:

{
   "OFPPortMod": {
      "config": 0, 
      "hw_addr": "00:11:00:00:11:11", 
      "mask": 0, 
      "port_no": 1, 
      "properties": [
         {
            "OFPPortModPropEthernet": {
               "advertise": 4096, 
               "length": 8, 
               "type": 0
            }
         }, 
         {
            "OFPPortModPropOptical": {
               "configure": 3, 
               "fl_offset": 2000, 
               "freq_lmda": 1500, 
               "grid_span": 3000, 
               "length": 24, 
               "tx_pwr": 300, 
               "type": 1
            }
         }, 
         {
            "OFPPortModPropExperimenter": {
               "data": [], 
               "exp_type": 0, 
               "experimenter": 101, 
               "length": 12, 
               "type": 65535
            }
         }, 
         {
            "OFPPortModPropExperimenter": {
               "data": [
                  1
               ], 
               "exp_type": 1, 
               "experimenter": 101, 
               "length": 16, 
               "type": 65535
            }
         }, 
         {
            "OFPPortModPropExperimenter": {
               "data": [
                  1, 
                  2
               ], 
               "exp_type": 2, 
               "experimenter": 101, 
               "length": 20, 
               "type": 65535
            }
         }
      ]
   }
}
class os_ken.ofproto.ofproto_v1_5_parser.OFPMeterMod(datapath, command=0, flags=1, meter_id=1, bands=None)

Meter modification message

The controller sends this message to modify the meter.

Attribute Description
command

One of the following values.

OFPMC_ADD
OFPMC_MODIFY
OFPMC_DELETE
flags

Bitmap of the following flags.

OFPMF_KBPS
OFPMF_PKTPS
OFPMF_BURST
OFPMF_STATS
meter_id Meter instance
bands

list of the following class instance.

OFPMeterBandDrop
OFPMeterBandDscpRemark
OFPMeterBandExperimenter

JSON Example:

{
   "OFPMeterMod": {
      "bands": [
         {
            "OFPMeterBandDrop": {
               "burst_size": 10, 
               "len": 16, 
               "rate": 1000, 
               "type": 1
            }
         }, 
         {
            "OFPMeterBandDscpRemark": {
               "burst_size": 10, 
               "len": 16, 
               "prec_level": 1, 
               "rate": 1000, 
               "type": 2
            }
         }
      ], 
      "command": 0, 
      "flags": 14, 
      "meter_id": 100
   }
}

Multipart Messages

class os_ken.ofproto.ofproto_v1_5_parser.OFPDescStatsRequest(datapath, flags=0, type_=None)

Description statistics request message

The controller uses this message to query description of the switch.

Attribute Description
flags Zero or OFPMPF_REQ_MORE

Example:

def send_desc_stats_request(self, datapath):
    ofp_parser = datapath.ofproto_parser

    req = ofp_parser.OFPDescStatsRequest(datapath, 0)
    datapath.send_msg(req)

JSON Example:

{
   "OFPDescStatsRequest": {
      "flags": 0, 
      "type": 0
   }
}
class os_ken.ofproto.ofproto_v1_5_parser.OFPDescStatsReply(datapath, type_=None, **kwargs)

Description statistics reply message

The switch responds with this message to a description statistics request.

Attribute Description
body Instance of OFPDescStats

Example:

@set_ev_cls(ofp_event.EventOFPDescStatsReply, MAIN_DISPATCHER)
def desc_stats_reply_handler(self, ev):
    body = ev.msg.body

    self.logger.debug('DescStats: mfr_desc=%s hw_desc=%s sw_desc=%s '
                      'serial_num=%s dp_desc=%s',
                      body.mfr_desc, body.hw_desc, body.sw_desc,
                      body.serial_num, body.dp_desc)

JSON Example:

{
   "OFPDescStatsReply": {
      "body": {
         "OFPDescStats": {
            "dp_desc": "dp", 
            "hw_desc": "hw", 
            "mfr_desc": "mfr", 
            "serial_num": "serial", 
            "sw_desc": "sw"
         }
      }, 
      "flags": 0, 
      "type": 0
   }
}
class os_ken.ofproto.ofproto_v1_5_parser.OFPFlowDescStatsRequest(datapath, flags=0, table_id=255, out_port=4294967295, out_group=4294967295, cookie=0, cookie_mask=0, match=None, type_=None)

Individual flow descriptions request message

The controller uses this message to query individual flow descriptions.

Attribute Description
flags Zero or OFPMPF_REQ_MORE
table_id ID of table to read
out_port Require matching entries to include this as an output port
out_group Require matching entries to include this as an output group
cookie Require matching entries to contain this cookie value
cookie_mask Mask used to restrict the cookie bits that must match
match Instance of OFPMatch

Example:

def send_flow_desc_request(self, datapath):
    ofp = datapath.ofproto
    ofp_parser = datapath.ofproto_parser

    cookie = cookie_mask = 0
    match = ofp_parser.OFPMatch(in_port=1)
    req = ofp_parser.OFPFlowDescStatsRequest(datapath, 0,
                                             ofp.OFPTT_ALL,
                                             ofp.OFPP_ANY,
                                             ofp.OFPG_ANY,
                                             cookie, cookie_mask,
                                             match)
    datapath.send_msg(req)

JSON Example:

{
    "OFPFlowDescStatsRequest": {
        "cookie": 1234605616436508552,
        "cookie_mask": 18446744073709551615,
        "flags": 0,
        "match": {
            "OFPMatch": {
                "length": 12,
                "oxm_fields": [
                    {
                        "OXMTlv": {
                            "field": "in_port",
                            "mask": null,
                            "value": 1
                        }
                    }
                ],
                "type": 1
            }
        },
        "out_group": 4294967295,
        "out_port": 4294967295,
        "table_id": 1,
        "type": 1
    }
}
class os_ken.ofproto.ofproto_v1_5_parser.OFPFlowDescStatsReply(datapath, type_=None, **kwargs)

Individual flow descriptions reply message

The switch responds with this message to an individual flow descriptions request.

Attribute Description
body List of OFPFlowDesc instance

Example:

@set_ev_cls(ofp_event.EventOFPFlowDescStatsReply, MAIN_DISPATCHER)
def flow_desc_reply_handler(self, ev):
    flows = []
    for stat in ev.msg.body:
        flows.append('table_id=%s priority=%d '
                     'idle_timeout=%d hard_timeout=%d flags=0x%04x '
                     'importance=%d cookie=%d match=%s '
                     'stats=%s instructions=%s' %
                     (stat.table_id, stat.priority,
                      stat.idle_timeout, stat.hard_timeout,
                      stat.flags, stat.importance,
                      stat.cookie, stat.match,
                      stat.stats, stat.instructions))
    self.logger.debug('FlowDesc: %s', flows)

JSON Example:

{
    "OFPFlowDescStatsReply": {
        "body": [
            {
                "OFPFlowDesc": {
                    "cookie": 1234605616436508552,
                    "flags": 1,
                    "hard_timeout": 255,
                    "idle_timeout": 255,
                    "importance": 43690,
                    "instructions": [
                        {
                            "OFPInstructionGotoTable": {
                                "len": 8,
                                "table_id": 2,
                                "type": 1
                            }
                        }
                    ],
                    "length": 64,
                    "match": {
                        "OFPMatch": {
                            "length": 12,
                            "oxm_fields": [
                                {
                                    "OXMTlv": {
                                        "field": "in_port",
                                        "mask": null,
                                        "value": 1
                                    }
                                }
                            ],
                            "type": 1
                        }
                    },
                    "priority": 5,
                    "stats": {
                        "OFPStats": {
                            "length": 12,
                            "oxs_fields": [
                                {
                                    "OXSTlv": {
                                        "field": "flow_count",
                                        "value": 1
                                    }
                                }
                            ]
                        }
                    },
                    "table_id": 1
                }
            }
        ],
        "flags": 0,
        "type": 1
    }
}
class os_ken.ofproto.ofproto_v1_5_parser.OFPFlowStatsRequest(datapath, flags=0, table_id=255, out_port=4294967295, out_group=4294967295, cookie=0, cookie_mask=0, match=None, type_=None)

Individual flow statistics request message

The controller uses this message to query individual flow statistics.

Attribute Description
flags Zero or OFPMPF_REQ_MORE
table_id ID of table to read
out_port Require matching entries to include this as an output port
out_group Require matching entries to include this as an output group
cookie Require matching entries to contain this cookie value
cookie_mask Mask used to restrict the cookie bits that must match
match Instance of OFPMatch

Example:

def send_flow_stats_request(self, datapath):
    ofp = datapath.ofproto
    ofp_parser = datapath.ofproto_parser

    cookie = cookie_mask = 0
    match = ofp_parser.OFPMatch(in_port=1)
    req = ofp_parser.OFPFlowStatsRequest(datapath, 0,
                                         ofp.OFPTT_ALL,
                                         ofp.OFPP_ANY, ofp.OFPG_ANY,
                                         cookie, cookie_mask,
                                         match)
    datapath.send_msg(req)

JSON Example:

{
   "OFPFlowStatsRequest": {
      "cookie": 0, 
      "cookie_mask": 0, 
      "flags": 0, 
      "match": {
         "OFPMatch": {
            "length": 4, 
            "oxm_fields": [], 
            "type": 1
         }
      }, 
      "out_group": 4294967295, 
      "out_port": 4294967295, 
      "table_id": 0, 
      "type": 17
   }
}
class os_ken.ofproto.ofproto_v1_5_parser.OFPFlowStatsReply(datapath, type_=None, **kwargs)

Individual flow statistics reply message

The switch responds with this message to an individual flow statistics request.

Attribute Description
body List of OFPFlowStats instance

Example:

@set_ev_cls(ofp_event.EventOFPFlowStatsReply, MAIN_DISPATCHER)
def flow_stats_reply_handler(self, ev):
    flows = []
    for stat in ev.msg.body:
        flows.append('table_id=%s reason=%d priority=%d '
                     'match=%s stats=%s' %
                     (stat.table_id, stat.reason, stat.priority,
                      stat.match, stat.stats))
    self.logger.debug('FlowStats: %s', flows)

JSON Example:

{
    "OFPFlowStatsReply": {
        "body": [
            {
                "OFPFlowStats": {
                    "length": 40,
                    "match": {
                        "OFPMatch": {
                            "length": 12,
                            "oxm_fields": [
                                {
                                    "OXMTlv": {
                                        "field": "in_port",
                                        "mask": null,
                                        "value": 1
                                    }
                                }
                            ],
                            "type": 1
                        }
                    },
                    "priority": 1,
                    "reason": 0,
                    "stats": {
                        "OFPStats": {
                            "length": 12,
                            "oxs_fields": [
                                {
                                    "OXSTlv": {
                                        "field": "flow_count",
                                        "value": 1
                                    }
                                }
                            ]
                        }
                    },
                    "table_id": 1
                }
            }
        ],
        "flags": 0,
        "type": 17
    }
}
class os_ken.ofproto.ofproto_v1_5_parser.OFPAggregateStatsRequest(datapath, flags, table_id, out_port, out_group, cookie, cookie_mask, match, type_=None)

Aggregate flow statistics request message

The controller uses this message to query aggregate flow statictics.

Attribute Description
flags Zero or OFPMPF_REQ_MORE
table_id ID of table to read
out_port Require matching entries to include this as an output port
out_group Require matching entries to include this as an output group
cookie Require matching entries to contain this cookie value
cookie_mask Mask used to restrict the cookie bits that must match
match Instance of OFPMatch

Example:

def send_aggregate_stats_request(self, datapath):
    ofp = datapath.ofproto
    ofp_parser = datapath.ofproto_parser

    cookie = cookie_mask = 0
    match = ofp_parser.OFPMatch(in_port=1)
    req = ofp_parser.OFPAggregateStatsRequest(datapath, 0,
                                              ofp.OFPTT_ALL,
                                              ofp.OFPP_ANY,
                                              ofp.OFPG_ANY,
                                              cookie, cookie_mask,
                                              match)
    datapath.send_msg(req)

JSON Example:

{
   "OFPAggregateStatsRequest": {
      "cookie": 0, 
      "cookie_mask": 0, 
      "flags": 0, 
      "match": {
         "OFPMatch": {
            "length": 4, 
            "oxm_fields": [], 
            "type": 1
         }
      }, 
      "out_group": 4294967295, 
      "out_port": 4294967295, 
      "table_id": 255, 
      "type": 2
   }
}
class os_ken.ofproto.ofproto_v1_5_parser.OFPAggregateStatsReply(datapath, type_=None, **kwargs)

Aggregate flow statistics reply message

The switch responds with this message to an aggregate flow statistics request.

Attribute Description
body Instance of OFPAggregateStats

Example:

@set_ev_cls(ofp_event.EventOFPAggregateStatsReply, MAIN_DISPATCHER)
def aggregate_stats_reply_handler(self, ev):
    body = ev.msg.body

    self.logger.debug('AggregateStats: stats=%s', body.stats)

JSON Example:

{
    "OFPAggregateStatsReply": {
        "body": {
            "OFPAggregateStats": {
                "length": 16,
                "stats": {
                    "OFPStats": {
                        "length": 12,
                        "oxs_fields": [
                            {
                                "OXSTlv": {
                                    "field": "flow_count",
                                    "value": 1
                                }
                            }
                        ]
                    }
                }
            }
        },
        "flags": 0,
        "type": 2
    }
}
class os_ken.ofproto.ofproto_v1_5_parser.OFPPortStatsRequest(datapath, flags, port_no, type_=None)

Port statistics request message

The controller uses this message to query information about ports statistics.

Attribute Description
flags Zero or OFPMPF_REQ_MORE
port_no Port number to read (OFPP_ANY to all ports)

Example:

def send_port_stats_request(self, datapath):
    ofp = datapath.ofproto
    ofp_parser = datapath.ofproto_parser

    req = ofp_parser.OFPPortStatsRequest(datapath, 0, ofp.OFPP_ANY)
    datapath.send_msg(req)

JSON Example:

{
   "OFPPortStatsRequest": {
      "flags": 0, 
      "port_no": 4294967295, 
      "type": 4
   }
}
class os_ken.ofproto.ofproto_v1_5_parser.OFPPortStatsReply(datapath, type_=None, **kwargs)

Port statistics reply message

The switch responds with this message to a port statistics request.

Attribute Description
body List of OFPPortStats instance

Example:

@set_ev_cls(ofp_event.EventOFPPortStatsReply, MAIN_DISPATCHER)
def port_stats_reply_handler(self, ev):
    ports = []
    for stat in ev.msg.body:
        ports.append(stat.length, stat.port_no,
                     stat.duration_sec, stat.duration_nsec,
                     stat.rx_packets, stat.tx_packets,
                     stat.rx_bytes, stat.tx_bytes,
                     stat.rx_dropped, stat.tx_dropped,
                     stat.rx_errors, stat.tx_errors,
                     repr(stat.properties))
    self.logger.debug('PortStats: %s', ports)

JSON Example:

{
   "OFPPortStatsReply": {
      "body": [
         {
            "OFPPortStats": {
               "duration_nsec": 0, 
               "duration_sec": 0, 
               "length": 224, 
               "port_no": 7, 
               "properties": [
                  {
                     "OFPPortStatsPropEthernet": {
                        "collisions": 0, 
                        "length": 40, 
                        "rx_crc_err": 0, 
                        "rx_frame_err": 0, 
                        "rx_over_err": 0, 
                        "type": 0
                     }
                  }, 
                  {
                     "OFPPortStatsPropOptical": {
                        "bias_current": 300, 
                        "flags": 3, 
                        "length": 44, 
                        "rx_freq_lmda": 1500, 
                        "rx_grid_span": 500, 
                        "rx_offset": 700, 
                        "rx_pwr": 2000, 
                        "temperature": 273, 
                        "tx_freq_lmda": 1500, 
                        "tx_grid_span": 500, 
                        "tx_offset": 700, 
                        "tx_pwr": 2000, 
                        "type": 1
                     }
                  }, 
                  {
                     "OFPPortStatsPropExperimenter": {
                        "data": [], 
                        "exp_type": 0, 
                        "experimenter": 101, 
                        "length": 12, 
                        "type": 65535
                     }
                  }, 
                  {
                     "OFPPortStatsPropExperimenter": {
                        "data": [
                           1
                        ], 
                        "exp_type": 1, 
                        "experimenter": 101, 
                        "length": 16, 
                        "type": 65535
                     }
                  }, 
                  {
                     "OFPPortStatsPropExperimenter": {
                        "data": [
                           1, 
                           2
                        ], 
                        "exp_type": 2, 
                        "experimenter": 101, 
                        "length": 20, 
                        "type": 65535
                     }
                  }
               ], 
               "rx_bytes": 0, 
               "rx_dropped": 0, 
               "rx_errors": 0, 
               "rx_packets": 0, 
               "tx_bytes": 336, 
               "tx_dropped": 0, 
               "tx_errors": 0, 
               "tx_packets": 4
            }
         }, 
         {
            "OFPPortStats": {
               "duration_nsec": 0, 
               "duration_sec": 0, 
               "length": 120, 
               "port_no": 6, 
               "properties": [
                  {
                     "OFPPortStatsPropEthernet": {
                        "collisions": 0, 
                        "length": 40, 
                        "rx_crc_err": 0, 
                        "rx_frame_err": 0, 
                        "rx_over_err": 0, 
                        "type": 0
                     }
                  }
               ], 
               "rx_bytes": 336, 
               "rx_dropped": 0, 
               "rx_errors": 0, 
               "rx_packets": 4, 
               "tx_bytes": 336, 
               "tx_dropped": 0, 
               "tx_errors": 0, 
               "tx_packets": 4
            }
         }
      ], 
      "flags": 0, 
      "type": 4
   }
}
class os_ken.ofproto.ofproto_v1_5_parser.OFPPortDescStatsRequest(datapath, flags=0, port_no=4294967295, type_=None)

Port description request message

The controller uses this message to query description of one or all the ports.

Attribute Description
flags Zero or OFPMPF_REQ_MORE
port_no Port number to read (OFPP_ANY to all ports)

Example:

def send_port_desc_stats_request(self, datapath):
    ofp = datapath.ofproto
    ofp_parser = datapath.ofproto_parser

    req = ofp_parser.OFPPortDescStatsRequest(datapath, 0, ofp.OFPP_ANY)
    datapath.send_msg(req)

JSON Example:

{
    "OFPPortDescStatsRequest": {
        "flags": 0,
        "port_no": 48346,
        "type": 13
    }
}
class os_ken.ofproto.ofproto_v1_5_parser.OFPPortDescStatsReply(datapath, type_=None, **kwargs)

Port description reply message

The switch responds with this message to a port description request.

Attribute Description
body List of OFPPort instance

Example:

@set_ev_cls(ofp_event.EventOFPPortDescStatsReply, MAIN_DISPATCHER)
def port_desc_stats_reply_handler(self, ev):
    ports = []
    for p in ev.msg.body:
        ports.append('port_no=%d hw_addr=%s name=%s config=0x%08x '
                     'state=0x%08x properties=%s' %
                     (p.port_no, p.hw_addr,
                      p.name, p.config, p.state, repr(p.properties)))
    self.logger.debug('OFPPortDescStatsReply received: %s', ports)

JSON Example:

{
   "OFPPortDescStatsReply": {
      "body": [
         {
            "OFPPort": {
               "config": 0, 
               "hw_addr": "f2:0b:a4:d0:3f:70", 
               "length": 168, 
               "name": "Port7", 
               "port_no": 7, 
               "properties": [
                  {
                     "OFPPortDescPropEthernet": {
                        "advertised": 10240, 
                        "curr": 10248, 
                        "curr_speed": 5000, 
                        "length": 32, 
                        "max_speed": 5000, 
                        "peer": 10248, 
                        "supported": 10248, 
                        "type": 0
                     }
                  }, 
                  {
                     "OFPPortDescPropOptical": {
                        "length": 40, 
                        "rx_grid_freq_lmda": 1500, 
                        "rx_max_freq_lmda": 2000, 
                        "rx_min_freq_lmda": 1000, 
                        "supported": 1, 
                        "tx_grid_freq_lmda": 1500, 
                        "tx_max_freq_lmda": 2000, 
                        "tx_min_freq_lmda": 1000, 
                        "tx_pwr_max": 2000, 
                        "tx_pwr_min": 1000, 
                        "type": 1
                     }
                  }, 
                  {
                     "OFPPortDescPropExperimenter": {
                        "data": [], 
                        "exp_type": 0, 
                        "experimenter": 101, 
                        "length": 12, 
                        "type": 65535
                     }
                  }, 
                  {
                     "OFPPortDescPropExperimenter": {
                        "data": [
                           1
                        ], 
                        "exp_type": 1, 
                        "experimenter": 101, 
                        "length": 16, 
                        "type": 65535
                     }
                  }, 
                  {
                     "OFPPortDescPropExperimenter": {
                        "data": [
                           1, 
                           2
                        ], 
                        "exp_type": 2, 
                        "experimenter": 101, 
                        "length": 20, 
                        "type": 65535
                     }
                  }
               ], 
               "state": 4
            }
         }, 
         {
            "OFPPort": {
               "config": 0, 
               "hw_addr": "f2:0b:a4:7d:f8:ea", 
               "length": 72, 
               "name": "Port6", 
               "port_no": 6, 
               "properties": [
                  {
                     "OFPPortDescPropEthernet": {
                        "advertised": 10240, 
                        "curr": 10248, 
                        "curr_speed": 5000, 
                        "length": 32, 
                        "max_speed": 5000, 
                        "peer": 10248, 
                        "supported": 10248, 
                        "type": 0
                     }
                  }
               ], 
               "state": 4
            }
         }
      ], 
      "flags": 0, 
      "type": 13
   }
}
class os_ken.ofproto.ofproto_v1_5_parser.OFPQueueStatsRequest(datapath, flags=0, port_no=4294967295, queue_id=4294967295, type_=None)

Queue statistics request message

The controller uses this message to query queue statictics.

Attribute Description
flags Zero or OFPMPF_REQ_MORE
port_no Port number to read
queue_id ID of queue to read

Example:

def send_queue_stats_request(self, datapath):
    ofp = datapath.ofproto
    ofp_parser = datapath.ofproto_parser

    req = ofp_parser.OFPQueueStatsRequest(datapath, 0, ofp.OFPP_ANY,
                                          ofp.OFPQ_ALL)
    datapath.send_msg(req)

JSON Example:

{
   "OFPQueueStatsRequest": {
      "flags": 0,
      "port_no": 43981,
      "queue_id": 4294967295,
      "type": 5
   }
}
class os_ken.ofproto.ofproto_v1_5_parser.OFPQueueStatsReply(datapath, type_=None, **kwargs)

Queue statistics reply message

The switch responds with this message to an aggregate flow statistics request.

Attribute Description
body List of OFPQueueStats instance

Example:

@set_ev_cls(ofp_event.EventOFPQueueStatsReply, MAIN_DISPATCHER)
def queue_stats_reply_handler(self, ev):
    queues = []
    for stat in ev.msg.body:
        queues.append('port_no=%d queue_id=%d '
                      'tx_bytes=%d tx_packets=%d tx_errors=%d '
                      'duration_sec=%d duration_nsec=%d'
                      'properties=%s' %
                      (stat.port_no, stat.queue_id,
                       stat.tx_bytes, stat.tx_packets, stat.tx_errors,
                       stat.duration_sec, stat.duration_nsec,
                       repr(stat.properties)))
    self.logger.debug('QueueStats: %s', queues)

JSON Example:

{
   "OFPQueueStatsReply": {
      "body": [
         {
            "OFPQueueStats": {
               "duration_nsec": 0, 
               "duration_sec": 0, 
               "length": 104, 
               "port_no": 7, 
               "properties": [
                  {
                     "OFPQueueStatsPropExperimenter": {
                        "data": [], 
                        "exp_type": 0, 
                        "experimenter": 101, 
                        "length": 12, 
                        "type": 65535
                     }
                  }, 
                  {
                     "OFPQueueStatsPropExperimenter": {
                        "data": [
                           1
                        ], 
                        "exp_type": 1, 
                        "experimenter": 101, 
                        "length": 16, 
                        "type": 65535
                     }
                  }, 
                  {
                     "OFPQueueStatsPropExperimenter": {
                        "data": [
                           1, 
                           2
                        ], 
                        "exp_type": 2, 
                        "experimenter": 101, 
                        "length": 20, 
                        "type": 65535
                     }
                  }
               ], 
               "queue_id": 1, 
               "tx_bytes": 0, 
               "tx_errors": 0, 
               "tx_packets": 0
            }
         }, 
         {
            "OFPQueueStats": {
               "duration_nsec": 0, 
               "duration_sec": 0, 
               "length": 48, 
               "port_no": 6, 
               "properties": [], 
               "queue_id": 1, 
               "tx_bytes": 0, 
               "tx_errors": 0, 
               "tx_packets": 0
            }
         }, 
         {
            "OFPQueueStats": {
               "duration_nsec": 0, 
               "duration_sec": 0, 
               "length": 48, 
               "port_no": 7, 
               "properties": [], 
               "queue_id": 2, 
               "tx_bytes": 0, 
               "tx_errors": 0, 
               "tx_packets": 0
            }
         }
      ], 
      "flags": 0, 
      "type": 5
   }
}
class os_ken.ofproto.ofproto_v1_5_parser.OFPQueueDescStatsRequest(datapath, flags=0, port_no=4294967295, queue_id=4294967295, type_=None)

Queue description request message

The controller uses this message to query description of all the queues.

Attribute Description
flags Zero or OFPMPF_REQ_MORE
port_no Port number to read (OFPP_ANY for all ports)
queue_id ID of queue to read (OFPQ_ALL for all queues)

Example:

def send_queue_desc_stats_request(self, datapath):
    ofp = datapath.ofproto
    ofp_parser = datapath.ofproto_parser

    req = ofp_parser.OFPQueueDescStatsRequest(datapath, 0,
                                              ofp.OFPP_ANY,
                                              ofp.OFPQ_ALL)
    datapath.send_msg(req)

JSON Example:

{
    "OFPQueueDescStatsRequest": {
        "flags": 0,
        "port_no": 52651,
        "queue_id": 57020,
        "type": 15
    }
}
class os_ken.ofproto.ofproto_v1_5_parser.OFPQueueDescStatsReply(datapath, type_=None, **kwargs)

Queue description reply message

The switch responds with this message to a queue description request.

Attribute Description
body List of OFPQueueDesc instance

Example:

@set_ev_cls(ofp_event.EventOFPQueueDescStatsReply, MAIN_DISPATCHER)
def queue_desc_stats_reply_handler(self, ev):
    queues = []
    for q in ev.msg.body:
        queues.append('port_no=%d queue_id=0x%08x properties=%s' %
                     (q.port_no, q.queue_id, repr(q.properties)))
    self.logger.debug('OFPQueueDescStatsReply received: %s', queues)

JSON Example:

{
   "OFPQueueDescStatsReply": {
      "body": [
         {
            "OFPQueueDesc": {
               "len": 32, 
               "port_no": 7, 
               "properties": [
                  {
                     "OFPQueueDescPropExperimenter": {
                        "data": [], 
                        "exp_type": 0, 
                        "experimenter": 101, 
                        "length": 12, 
                        "type": 65535
                     }
                  }
               ], 
               "queue_id": 0
            }
         }, 
         {
            "OFPQueueDesc": {
               "len": 88, 
               "port_no": 8, 
               "properties": [
                  {
                     "OFPQueueDescPropMinRate": {
                        "length": 8, 
                        "rate": 300, 
                        "type": 1
                     }
                  }, 
                  {
                     "OFPQueueDescPropMaxRate": {
                        "length": 8, 
                        "rate": 900, 
                        "type": 2
                     }
                  }, 
                  {
                     "OFPQueueDescPropExperimenter": {
                        "data": [], 
                        "exp_type": 0, 
                        "experimenter": 101, 
                        "length": 12, 
                        "type": 65535
                     }
                  }, 
                  {
                     "OFPQueueDescPropExperimenter": {
                        "data": [
                           1
                        ], 
                        "exp_type": 1, 
                        "experimenter": 101, 
                        "length": 16, 
                        "type": 65535
                     }
                  }, 
                  {
                     "OFPQueueDescPropExperimenter": {
                        "data": [
                           1, 
                           2
                        ], 
                        "exp_type": 2, 
                        "experimenter": 101, 
                        "length": 20, 
                        "type": 65535
                     }
                  }
               ], 
               "queue_id": 1
            }
         }
      ], 
      "flags": 0, 
      "type": 15
   }
}
class os_ken.ofproto.ofproto_v1_5_parser.OFPGroupStatsRequest(datapath, flags=0, group_id=4294967292, type_=None)

Group statistics request message

The controller uses this message to query statistics of one or more groups.

Attribute Description
flags Zero or OFPMPF_REQ_MORE
group_id ID of group to read (OFPG_ALL to all groups)

Example:

def send_group_stats_request(self, datapath):
    ofp = datapath.ofproto
    ofp_parser = datapath.ofproto_parser

    req = ofp_parser.OFPGroupStatsRequest(datapath, 0, ofp.OFPG_ALL)
    datapath.send_msg(req)

JSON Example:

{
   "OFPGroupStatsRequest": {
      "flags": 0, 
      "group_id": 4294967292, 
      "type": 6
   }
}
class os_ken.ofproto.ofproto_v1_5_parser.OFPGroupStatsReply(datapath, type_=None, **kwargs)

Group statistics reply message

The switch responds with this message to a group statistics request.

Attribute Description
body List of OFPGroupStats instance

Example:

@set_ev_cls(ofp_event.EventOFPGroupStatsReply, MAIN_DISPATCHER)
def group_stats_reply_handler(self, ev):
    groups = []
    for stat in ev.msg.body:
        groups.append('length=%d group_id=%d '
                      'ref_count=%d packet_count=%d byte_count=%d '
                      'duration_sec=%d duration_nsec=%d' %
                      (stat.length, stat.group_id,
                       stat.ref_count, stat.packet_count,
                       stat.byte_count, stat.duration_sec,
                       stat.duration_nsec))
    self.logger.debug('GroupStats: %s', groups)

JSON Example:

{
   "OFPGroupStatsReply": {
      "body": [
         {
            "OFPGroupStats": {
               "bucket_stats": [
                  {
                     "OFPBucketCounter": {
                        "byte_count": 2345, 
                        "packet_count": 234
                     }
                  }
               ], 
               "byte_count": 12345, 
               "duration_nsec": 609036000, 
               "duration_sec": 9, 
               "group_id": 1, 
               "length": 56, 
               "packet_count": 123, 
               "ref_count": 2
            }
         }
      ], 
      "flags": 0, 
      "type": 6
   }
}
class os_ken.ofproto.ofproto_v1_5_parser.OFPGroupDescStatsRequest(datapath, flags=0, group_id=4294967292, type_=None)

Group description request message

The controller uses this message to list the set of groups on a switch.

Attribute Description
flags Zero or OFPMPF_REQ_MORE
group_id ID of group to read (OFPG_ALL to all groups)

Example:

def send_group_desc_stats_request(self, datapath):
    ofp = datapath.ofproto
    ofp_parser = datapath.ofproto_parser

    req = ofp_parser.OFPGroupDescStatsRequest(datapath, 0, ofp.OFPG_ALL)
    datapath.send_msg(req)

JSON Example:

{
    "OFPGroupDescStatsRequest": {
        "flags": 0,
        "group_id": 52651,
        "type": 7
    }
}
class os_ken.ofproto.ofproto_v1_5_parser.OFPGroupDescStatsReply(datapath, type_=None, **kwargs)

Group description reply message

The switch responds with this message to a group description request.

Attribute Description
body List of OFPGroupDescStats instance

Example:

@set_ev_cls(ofp_event.EventOFPGroupDescStatsReply, MAIN_DISPATCHER)
def group_desc_stats_reply_handler(self, ev):
    descs = []
    for stat in ev.msg.body:
        descs.append('length=%d type=%d group_id=%d '
                     'buckets=%s properties=%s' %
                     (stat.length, stat.type, stat.group_id,
                      stat.bucket, repr(stat.properties)))
    self.logger.debug('GroupDescStats: %s', descs)

JSON Example:

{
    "OFPGroupDescStatsReply": {
        "body": [
            {
                "OFPGroupDescStats": {
                    "bucket_array_len": 32,
                    "buckets": [
                        {
                            "OFPBucket": {
                                "action_array_len": 16,
                                "actions": [
                                    {
                                        "OFPActionOutput": {
                                            "len": 16,
                                            "max_len": 65509,
                                            "port": 1,
                                            "type": 0
                                        }
                                    }
                                ],
                                "bucket_id": 65535,
                                "len": 32,
                                "properties": [
                                    {
                                        "OFPGroupBucketPropWeight": {
                                            "length": 8,
                                            "type": 0,
                                            "weight": 65535
                                        }
                                    }
                                ]
                            }
                        }
                    ],
                    "group_id": 1,
                    "length": 48,
                    "properties": [],
                    "type": 1
                }
            }
        ],
        "flags": 0,
        "type": 7
    }
}
class os_ken.ofproto.ofproto_v1_5_parser.OFPGroupFeaturesStatsRequest(datapath, flags=0, type_=None)

Group features request message

The controller uses this message to list the capabilities of groups on a switch.

Attribute Description
flags Zero or OFPMPF_REQ_MORE

Example:

def send_group_features_stats_request(self, datapath):
    ofp_parser = datapath.ofproto_parser

    req = ofp_parser.OFPGroupFeaturesStatsRequest(datapath, 0)
    datapath.send_msg(req)

JSON Example:

{
   "OFPGroupFeaturesStatsRequest": {
      "flags": 0, 
      "type": 8
   }
}
class os_ken.ofproto.ofproto_v1_5_parser.OFPGroupFeaturesStatsReply(datapath, type_=None, **kwargs)

Group features reply message

The switch responds with this message to a group features request.

Attribute Description
body Instance of OFPGroupFeaturesStats

Example:

@set_ev_cls(ofp_event.EventOFPGroupFeaturesStatsReply, MAIN_DISPATCHER)
def group_features_stats_reply_handler(self, ev):
    body = ev.msg.body

    self.logger.debug('GroupFeaturesStats: types=%d '
                      'capabilities=0x%08x max_groups=%s '
                      'actions=%s',
                      body.types, body.capabilities,
                      body.max_groups, body.actions)

JSON Example:

{
   "OFPGroupFeaturesStatsReply": {
      "body": {
         "OFPGroupFeaturesStats": {
            "actions": [
               67082241, 
               67082241, 
               67082241, 
               67082241
            ], 
            "capabilities": 5, 
            "max_groups": [
               16777216, 
               16777216, 
               16777216, 
               16777216
            ], 
            "types": 15
         }
      }, 
      "flags": 0, 
      "type": 8
   }
}
class os_ken.ofproto.ofproto_v1_5_parser.OFPMeterStatsRequest(datapath, flags=0, meter_id=4294967295, type_=None)

Meter statistics request message

The controller uses this message to query statistics for one or more meters.

Attribute Description
flags Zero or OFPMPF_REQ_MORE
meter_id ID of meter to read (OFPM_ALL to all meters)

Example:

def send_meter_stats_request(self, datapath):
    ofp = datapath.ofproto
    ofp_parser = datapath.ofproto_parser

    req = ofp_parser.OFPMeterStatsRequest(datapath, 0, ofp.OFPM_ALL)
    datapath.send_msg(req)

JSON Example:

{
   "OFPMeterStatsRequest": {
      "flags": 0, 
      "meter_id": 4294967295, 
      "type": 9
   }
}
class os_ken.ofproto.ofproto_v1_5_parser.OFPMeterStatsReply(datapath, type_=None, **kwargs)

Meter statistics reply message

The switch responds with this message to a meter statistics request.

Attribute Description
body List of OFPMeterStats instance

Example:

@set_ev_cls(ofp_event.EventOFPMeterStatsReply, MAIN_DISPATCHER)
def meter_stats_reply_handler(self, ev):
    meters = []
    for stat in ev.msg.body:
        meters.append('meter_id=0x%08x len=%d ref_count=%d '
                      'packet_in_count=%d byte_in_count=%d '
                      'duration_sec=%d duration_nsec=%d '
                      'band_stats=%s' %
                      (stat.meter_id, stat.len, stat.ref_count,
                       stat.packet_in_count, stat.byte_in_count,
                       stat.duration_sec, stat.duration_nsec,
                       stat.band_stats))
    self.logger.debug('MeterStats: %s', meters)

JSON Example:

{
   "OFPMeterStatsReply": {
      "body": [
         {
            "OFPMeterStats": {
               "band_stats": [
                  {
                     "OFPMeterBandStats": {
                        "byte_band_count": 0,
                        "packet_band_count": 0
                     }
                  }
               ],
               "byte_in_count": 0,
               "duration_nsec": 480000,
               "duration_sec": 0,
               "ref_count": 0,
               "len": 56,
               "meter_id": 100,
               "packet_in_count": 0
            }
         }
      ],
      "flags": 0,
      "type": 9
   }
}
class os_ken.ofproto.ofproto_v1_5_parser.OFPMeterDescStatsRequest(datapath, flags=0, meter_id=4294967295, type_=None)

Meter description statistics request message

The controller uses this message to query configuration for one or more meters.

Attribute Description
flags Zero or OFPMPF_REQ_MORE
meter_id ID of meter to read (OFPM_ALL to all meters)

Example:

def send_meter_desc_stats_request(self, datapath):
    ofp = datapath.ofproto
    ofp_parser = datapath.ofproto_parser

    req = ofp_parser.OFPMeterDescStatsRequest(datapath, 0,
                                                ofp.OFPM_ALL)
    datapath.send_msg(req)

JSON Example:

{
   "OFPMeterDescStatsRequest": {
      "flags": 0,
      "meter_id": 4294967295,
      "type": 10
   }
}
class os_ken.ofproto.ofproto_v1_5_parser.OFPMeterDescStatsReply(datapath, type_=None, **kwargs)

Meter description statistics reply message

The switch responds with this message to a meter description statistics request.

Attribute Description
body List of OFPMeterDescStats instance

Example:

@set_ev_cls(ofp_event.EventOFPMeterDescStatsReply, MAIN_DISPATCHER)
def meter_desc_stats_reply_handler(self, ev):
    configs = []
    for stat in ev.msg.body:
        configs.append('length=%d flags=0x%04x meter_id=0x%08x '
                       'bands=%s' %
                       (stat.length, stat.flags, stat.meter_id,
                        stat.bands))
    self.logger.debug('MeterDescStats: %s', configs)

JSON Example:

{
   "OFPMeterDescStatsReply": {
      "body": [
         {
            "OFPMeterDescStats": {
               "bands": [
                  {
                     "OFPMeterBandDrop": {
                        "burst_size": 10,
                        "len": 16,
                        "rate": 1000,
                        "type": 1
                     }
                  }
               ],
               "flags": 14,
               "length": 24,
               "meter_id": 100
            }
         }
      ],
      "flags": 0,
      "type": 10
   }
}
class os_ken.ofproto.ofproto_v1_5_parser.OFPMeterFeaturesStatsRequest(datapath, flags=0, type_=None)

Meter features statistics request message

The controller uses this message to query the set of features of the metering subsystem.

Attribute Description
flags Zero or OFPMPF_REQ_MORE

Example:

def send_meter_features_stats_request(self, datapath):
    ofp_parser = datapath.ofproto_parser

    req = ofp_parser.OFPMeterFeaturesStatsRequest(datapath, 0)
    datapath.send_msg(req)

JSON Example:

{
   "OFPMeterFeaturesStatsRequest": {
      "flags": 0, 
      "type": 11
   }
}
class os_ken.ofproto.ofproto_v1_5_parser.OFPMeterFeaturesStatsReply(datapath, type_=None, **kwargs)

Meter features statistics reply message

The switch responds with this message to a meter features statistics request.

Attribute Description
body List of OFPMeterFeaturesStats instance

Example:

@set_ev_cls(ofp_event.EventOFPMeterFeaturesStatsReply, MAIN_DISPATCHER)
def meter_features_stats_reply_handler(self, ev):
    features = []
    for stat in ev.msg.body:
        features.append('max_meter=%d band_types=0x%08x '
                        'capabilities=0x%08x max_bands=%d '
                        'max_color=%d' %
                        (stat.max_meter, stat.band_types,
                         stat.capabilities, stat.max_bands,
                         stat.max_color))
    self.logger.debug('MeterFeaturesStats: %s', features)

JSON Example:

{
   "OFPMeterFeaturesStatsReply": {
      "body": [
         {
            "OFPMeterFeaturesStats": {
               "band_types": 2147483654, 
               "capabilities": 15, 
               "features": 3, 
               "max_bands": 255, 
               "max_color": 0, 
               "max_meter": 16777216
            }
         }
      ], 
      "flags": 0, 
      "type": 11
   }
}
class os_ken.ofproto.ofproto_v1_5_parser.OFPControllerStatusStatsRequest(datapath, flags=0, type_=None)

Controller status multipart request message

The controller uses this message to request the status, the roles and the control channels of other controllers configured on the switch.

Attribute Description
flags Zero or OFPMPF_REQ_MORE

Example:

def send_controller_status_multipart_request(self, datapath):
    ofp_parser = datapath.ofproto_parser

    req = ofp_parser.OFPPortDescStatsRequest(datapath, 0)
    datapath.send_msg(req)

JSON Example:

{
    "OFPControllerStatusStatsRequest": {
        "flags": 0,
        "type": 18
    }
}
class os_ken.ofproto.ofproto_v1_5_parser.OFPControllerStatusStatsReply(datapath, type_=None, **kwargs)
Controller status multipart reply message

The switch responds with this message to a controller status multipart request.

Attribute Description
body List of OFPControllerStatus instance

Example:

@set_ev_cls(ofp_event.EventOFPControllerStatusStatsReply,
            MAIN_DISPATCHER)
def controller_status_multipart_reply_handler(self, ev):
    status = []
    for s in ev.msg.body:
        status.append('short_id=%d role=%d reason=%d '
                      'channel_status=%d properties=%s' %
                      (s.short_id, s.role, s.reason,
                       s.channel_status, repr(s.properties)))
    self.logger.debug('OFPControllerStatusStatsReply received: %s',
                      status)

JSON Example:

{
    "OFPControllerStatusStatsReply": {
        "body": [
            {
                "OFPControllerStatusStats": {
                    "channel_status": 1,
                    "length": 48,
                    "properties": [
                        {
                            "OFPControllerStatusPropUri": {
                                "length": 26,
                                "type": 0,
                                "uri": "tls:192.168.34.23:6653"
                            }
                        }
                    ],
                    "reason": 1,
                    "role": 1,
                    "short_id": 65535
                }
            }
        ],
        "flags": 0,
        "type": 18
    }
}
class os_ken.ofproto.ofproto_v1_5_parser.OFPTableStatsRequest(datapath, flags, type_=None)

Table statistics request message

The controller uses this message to query flow table statictics.

Attribute Description
flags Zero or OFPMPF_REQ_MORE

Example:

def send_table_stats_request(self, datapath):
    ofp_parser = datapath.ofproto_parser

    req = ofp_parser.OFPTableStatsRequest(datapath, 0)
    datapath.send_msg(req)

JSON Example:

{
   "OFPTableStatsRequest": {
      "flags": 0, 
      "type": 3
   }
}
class os_ken.ofproto.ofproto_v1_5_parser.OFPTableStatsReply(datapath, type_=None, **kwargs)

Table statistics reply message

The switch responds with this message to a table statistics request.

Attribute Description
body List of OFPTableStats instance

Example:

@set_ev_cls(ofp_event.EventOFPTableStatsReply, MAIN_DISPATCHER)
def table_stats_reply_handler(self, ev):
    tables = []
    for stat in ev.msg.body:
        tables.append('table_id=%d active_count=%d lookup_count=%d '
                      ' matched_count=%d' %
                      (stat.table_id, stat.active_count,
                       stat.lookup_count, stat.matched_count))
    self.logger.debug('TableStats: %s', tables)

JSON Example:

{
   "OFPTableStatsReply": {
      "body": [
         {
            "OFPTableStats": {
               "active_count": 4, 
               "lookup_count": 4, 
               "matched_count": 4, 
               "table_id": 0
            }
         }, 
         {
            "OFPTableStats": {
               "active_count": 4, 
               "lookup_count": 4, 
               "matched_count": 4, 
               "table_id": 1
            }
         }
      ], 
      "flags": 0, 
      "type": 3
   }
}
class os_ken.ofproto.ofproto_v1_5_parser.OFPTableDescStatsRequest(datapath, flags=0, type_=None)

Table description request message

The controller uses this message to query description of all the tables.

Attribute Description
flags Zero or OFPMPF_REQ_MORE

Example:

def send_table_desc_stats_request(self, datapath):
    ofp_parser = datapath.ofproto_parser

    req = ofp_parser.OFPTableDescStatsRequest(datapath, 0)
    datapath.send_msg(req)

JSON Example:

{
   "OFPTableDescStatsRequest": {
      "flags": 0, 
      "type": 14
   }
}
class os_ken.ofproto.ofproto_v1_5_parser.OFPTableDescStatsReply(datapath, type_=None, **kwargs)

Table description reply message

The switch responds with this message to a table description request.

Attribute Description
body List of OFPTableDesc instance

Example:

@set_ev_cls(ofp_event.EventOFPTableDescStatsReply, MAIN_DISPATCHER)
def table_desc_stats_reply_handler(self, ev):
    tables = []
    for p in ev.msg.body:
        tables.append('table_id=%d config=0x%08x properties=%s' %
                     (p.table_id, p.config, repr(p.properties)))
    self.logger.debug('OFPTableDescStatsReply received: %s', tables)

JSON Example:

{
   "OFPTableDescStatsReply": {
      "body": [
         {
            "OFPTableDesc": {
               "config": 0, 
               "length": 24, 
               "properties": [
                  {
                     "OFPTableModPropExperimenter": {
                        "data": [], 
                        "exp_type": 0, 
                        "experimenter": 101, 
                        "length": 12, 
                        "type": 65535
                     }
                  }
               ], 
               "table_id": 7
            }
         }, 
         {
            "OFPTableDesc": {
               "config": 0, 
               "length": 80, 
               "properties": [
                  {
                     "OFPTableModPropEviction": {
                        "flags": 0, 
                        "length": 8, 
                        "type": 2
                     }
                  }, 
                  {
                     "OFPTableModPropVacancy": {
                        "length": 8, 
                        "type": 3, 
                        "vacancy": 0, 
                        "vacancy_down": 0, 
                        "vacancy_up": 0
                     }
                  }, 
                  {
                     "OFPTableModPropExperimenter": {
                        "data": [], 
                        "exp_type": 0, 
                        "experimenter": 101, 
                        "length": 12, 
                        "type": 65535
                     }
                  }, 
                  {
                     "OFPTableModPropExperimenter": {
                        "data": [
                           1
                        ], 
                        "exp_type": 1, 
                        "experimenter": 101, 
                        "length": 16, 
                        "type": 65535
                     }
                  }, 
                  {
                     "OFPTableModPropExperimenter": {
                        "data": [
                           1, 
                           2
                        ], 
                        "exp_type": 2, 
                        "experimenter": 101, 
                        "length": 20, 
                        "type": 65535
                     }
                  }
               ], 
               "table_id": 8
            }
         }
      ], 
      "flags": 0, 
      "type": 14
   }
}
class os_ken.ofproto.ofproto_v1_5_parser.OFPTableFeaturesStatsRequest(datapath, flags=0, body=None, type_=None)

Table features statistics request message

The controller uses this message to query table features.

Attribute Description
body List of OFPTableFeaturesStats instances. The default is [].

JSON Example:

{
    "OFPTableFeaturesStatsRequest": {
        "body": [
            {
                "OFPTableFeaturesStats": {
                    "capabilities": 4,
                    "command": 1,
                    "features": 1,
                    "length": 80,
                    "max_entries": 255,
                    "metadata_match": 18446744073709551615,
                    "metadata_write": 18446744073709551615,
                    "name": "table1",
                    "properties": [
                        {
                            "OFPTableFeaturePropOxmValues": {
                                "length": 14,
                                "oxm_values": [
                                    {
                                        "OXMTlv": {
                                            "field": "eth_src",
                                            "mask": null,
                                            "value": "aa:bb:cc:dd:ee:ff"
                                        }
                                    }
                                ],
                                "type": 22
                            }
                        }
                    ],
                    "table_id": 1
                }
            }
        ],
        "flags": 0,
        "type": 12
    }
}
class os_ken.ofproto.ofproto_v1_5_parser.OFPTableFeaturesStatsReply(datapath, type_=None, **kwargs)

Table features statistics reply message

The switch responds with this message to a table features statistics request.

Attribute Description
body List of OFPTableFeaturesStats instance

JSON Example:

{
   "OFPTableFeaturesStatsReply": {
      "body": [
         {
            "OFPTableFeaturesStats": {
               "capabilities": 4,
               "command": 1,
               "features": 1,
               "length": 80,
               "max_entries": 255,
               "metadata_match": 18446744073709551615,
               "metadata_write": 18446744073709551615,
               "name": "table1",
               "properties": [
                  {
                     "OFPTableFeaturePropOxmValues": {
                        "length": 14,
                        "oxm_values": [
                           {
                              "OXMTlv": {
                                 "field": "eth_src",
                                 "mask": null,
                                 "value": "aa:bb:cc:dd:ee:ff"
                              }
                           }
                        ],
                        "type": 22
                     }
                  }
               ],
               "table_id": 1
            }
         }
      ],
      "flags": 0,
      "type": 12
   }
}
class os_ken.ofproto.ofproto_v1_5_parser.OFPFlowMonitorRequest(datapath, flags=0, monitor_id=0, out_port=4294967295, out_group=4294967295, monitor_flags=0, table_id=255, command=0, match=None, type_=None)

Flow monitor request message

The controller uses this message to query flow monitors.

Attribute Description
flags Zero or OFPMPF_REQ_MORE
monitor_id Controller-assigned ID for this monitor
out_port Require matching entries to include this as an output port
out_group Require matching entries to include this as an output group
monitor_flags

Bitmap of the following flags.

OFPFMF_INITIAL
OFPFMF_ADD
OFPFMF_REMOVED
OFPFMF_MODIFY
OFPFMF_INSTRUCTIONS
OFPFMF_NO_ABBREV
OFPFMF_ONLY_OWN
table_id ID of table to monitor
command

One of the following values.

OFPFMC_ADD
OFPFMC_MODIFY
OFPFMC_DELETE
match Instance of OFPMatch

Example:

def send_flow_monitor_request(self, datapath):
    ofp = datapath.ofproto
    ofp_parser = datapath.ofproto_parser

    monitor_flags = [ofp.OFPFMF_INITIAL, ofp.OFPFMF_ONLY_OWN]
    match = ofp_parser.OFPMatch(in_port=1)
    req = ofp_parser.OFPFlowMonitorRequest(datapath, 0, 10000,
                                           ofp.OFPP_ANY, ofp.OFPG_ANY,
                                           monitor_flags,
                                           ofp.OFPTT_ALL,
                                           ofp.OFPFMC_ADD, match)
    datapath.send_msg(req)

JSON Example:

{
   "OFPFlowMonitorRequest": {
      "command": 0, 
      "flags": 0, 
      "match": {
         "OFPMatch": {
            "length": 14, 
            "oxm_fields": [
               {
                  "OXMTlv": {
                     "field": "eth_dst", 
                     "mask": null, 
                     "value": "f2:0b:a4:7d:f8:ea"
                  }
               }
            ], 
            "type": 1
         }
      }, 
      "monitor_flags": 15, 
      "monitor_id": 100000000, 
      "out_group": 4294967295, 
      "out_port": 22, 
      "table_id": 33, 
      "type": 16
   }
}
class os_ken.ofproto.ofproto_v1_5_parser.OFPFlowMonitorReply(datapath, type_=None, **kwargs)

Flow monitor reply message

The switch responds with this message to a flow monitor request.

Attribute Description
body

List of list of the following class instance.

OFPFlowMonitorFull
OFPFlowMonitorAbbrev
OFPFlowMonitorPaused

Example:

@set_ev_cls(ofp_event.EventOFPFlowMonitorReply, MAIN_DISPATCHER)
def flow_monitor_reply_handler(self, ev):
    msg = ev.msg
    dp = msg.datapath
    ofp = dp.ofproto
    flow_updates = []

    for update in msg.body:
        update_str = 'length=%d event=%d' %
                     (update.length, update.event)
        if (update.event == ofp.OFPFME_INITIAL or
            update.event == ofp.OFPFME_ADDED or
            update.event == ofp.OFPFME_REMOVED or
            update.event == ofp.OFPFME_MODIFIED):
            update_str += 'table_id=%d reason=%d idle_timeout=%d '
                          'hard_timeout=%d priority=%d cookie=%d '
                          'match=%d instructions=%s' %
                          (update.table_id, update.reason,
                           update.idle_timeout, update.hard_timeout,
                           update.priority, update.cookie,
                           update.match, update.instructions)
        elif update.event == ofp.OFPFME_ABBREV:
            update_str += 'xid=%d' % (update.xid)
        flow_updates.append(update_str)
    self.logger.debug('FlowUpdates: %s', flow_updates)

JSON Example:

{
   "OFPFlowMonitorReply": {
      "body": [
         {
            "OFPFlowUpdateFull": {
               "cookie": 0, 
               "event": 0, 
               "hard_timeout": 700, 
               "idle_timeout": 600, 
               "instructions": [
                  {
                     "OFPInstructionActions": {
                        "actions": [
                           {
                              "OFPActionOutput": {
                                 "len": 16, 
                                 "max_len": 0, 
                                 "port": 4294967290, 
                                 "type": 0
                              }
                           }
                        ], 
                        "len": 24, 
                        "type": 4
                     }
                  }
               ], 
               "length": 64, 
               "match": {
                  "OFPMatch": {
                     "length": 10, 
                     "oxm_fields": [
                        {
                           "OXMTlv": {
                              "field": "eth_type", 
                              "mask": null, 
                              "value": 2054
                           }
                        }
                     ], 
                     "type": 1
                  }
               }, 
               "priority": 3, 
               "reason": 0, 
               "table_id": 0
            }
         }, 
         {
            "OFPFlowUpdateAbbrev": {
               "event": 4, 
               "length": 8, 
               "xid": 1234
            }
         }, 
         {
            "OFPFlowUpdatePaused": {
               "event": 5, 
               "length": 8
            }
         }
      ], 
      "flags": 0, 
      "type": 16
   }
}
class os_ken.ofproto.ofproto_v1_5_parser.OFPBundleFeaturesStatsRequest(datapath, flags=0, feature_request_flags=0, properties=None, type_=None)

Bundle features request message

The controller uses this message to query a switch about its bundle capabilities, including whether it supports atomic bundles, ordered bundles, and scheduled bundles.

Attribute Description
flags Zero or OFPMPF_REQ_MORE
feature_request_flags

Bitmap of the following flags.

OFPBF_TIMESTAMP
OFPBF_TIME_SET_SCHED
properties List of OFPBundleFeaturesProp subclass instance

Example:

def send_bundle_features_stats_request(self, datapath):
    ofp = datapath.ofproto
    ofp_parser = datapath.ofproto_parser

    req = ofp_parser.OFPBundleFeaturesStatsRequest(datapath, 0)
    datapath.send_msg(req)

JSON Example:

{
    "OFPBundleFeaturesStatsRequest": {
        "feature_request_flags": 3,
        "flags": 0,
        "properties": [
            {
                "OFPBundleFeaturesPropTime": {
                    "length": 72,
                    "sched_accuracy": {
                        "OFPTime": {
                            "nanoseconds": 1717986918,
                            "seconds": 6148914691236517205
                        }
                    },
                    "sched_max_future": {
                        "OFPTime": {
                            "nanoseconds": 2290649224,
                            "seconds": 8608480567731124087
                        }
                    },
                    "sched_max_past": {
                        "OFPTime": {
                            "nanoseconds": 2863311530,
                            "seconds": 11068046444225730969
                        }
                    },
                    "timestamp": {
                        "OFPTime": {
                            "nanoseconds": 3435973836,
                            "seconds": 13527612320720337851
                        }
                    },
                    "type": 1
                }
            }
        ],
        "type": 19
    }
}
class os_ken.ofproto.ofproto_v1_5_parser.OFPBundleFeaturesStatsReply(datapath, type_=None, **kwargs)

Bundle features reply message

The switch responds with this message to a bundle features request.

Attribute Description
body Instance of OFPBundleFeaturesStats

Example:

@set_ev_cls(ofp_event.EventOFPBundleFeaturesStatsReply, MAIN_DISPATCHER)
def bundle_features_stats_reply_handler(self, ev):
    body = ev.msg.body

    self.logger.debug('OFPBundleFeaturesStats: capabilities=%0x%08x '
                      'properties=%s',
                      body.capabilities, repr(body.properties))

JSON Example:

{
    "OFPBundleFeaturesStatsReply": {
        "body": {
            "OFPBundleFeaturesStats": {
                "capabilities": 7,
                "properties": [
                    {
                        "OFPBundleFeaturesPropTime": {
                            "length": 72,
                            "sched_accuracy": {
                                "OFPTime": {
                                    "nanoseconds": 1717986918,
                                    "seconds": 6148914691236517205
                                }
                            },
                            "sched_max_future": {
                                "OFPTime": {
                                    "nanoseconds": 2290649224,
                                    "seconds": 8608480567731124087
                                }
                            },
                            "sched_max_past": {
                                "OFPTime": {
                                    "nanoseconds": 2863311530,
                                    "seconds": 11068046444225730969
                                }
                            },
                            "timestamp": {
                                "OFPTime": {
                                    "nanoseconds": 3435973836,
                                    "seconds": 13527612320720337851
                                }
                            },
                            "type": 1
                        }
                    }
                ]
            }
        },
        "flags": 0,
        "type": 19
    }
}
class os_ken.ofproto.ofproto_v1_5_parser.OFPExperimenterStatsRequest(datapath, flags, experimenter, exp_type, data, type_=None)

Experimenter multipart request message

Attribute Description
flags Zero or OFPMPF_REQ_MORE
experimenter Experimenter ID
exp_type Experimenter defined
data Experimenter defined additional data

JSON Example:

{
   "OFPExperimenterStatsRequest": {
      "data": "aG9nZWhvZ2U=", 
      "exp_type": 3405678728, 
      "experimenter": 3735928495, 
      "flags": 0, 
      "type": 65535
   }
}
class os_ken.ofproto.ofproto_v1_5_parser.OFPExperimenterStatsReply(datapath, type_=None, **kwargs)

Experimenter multipart reply message

Attribute Description
body An OFPExperimenterMultipart instance

JSON Example:

{
   "OFPExperimenterStatsReply": {
      "body": {
         "OFPExperimenterMultipart": {
            "data": "dGVzdGRhdGE5OTk5OTk5OQ==", 
            "exp_type": 3405674359, 
            "experimenter": 3735928495
         }
      }, 
      "flags": 0, 
      "type": 65535
   }
}

Packet-Out Message

class os_ken.ofproto.ofproto_v1_5_parser.OFPPacketOut(datapath, buffer_id=None, match=None, actions=None, data=None, actions_len=None)

Packet-Out message

The controller uses this message to send a packet out throught the switch.

Attribute Description
buffer_id ID assigned by datapath (OFP_NO_BUFFER if none)
match Instance of OFPMatch (in_port is mandatory in the match field)
actions list of OpenFlow action class
data Packet data of a binary type value or an instances of packet.Packet.

Example:

def send_packet_out(self, datapath, buffer_id, in_port):
    ofp = datapath.ofproto
    ofp_parser = datapath.ofproto_parser

    match = OFPMatch(in_port=in_port)
    actions = [ofp_parser.OFPActionOutput(ofp.OFPP_FLOOD, 0)]
    req = ofp_parser.OFPPacketOut(datapath, buffer_id,
                                  match, actions)
    datapath.send_msg(req)

JSON Example:

{
    "OFPPacketOut": {
        "actions": [
            {
                "OFPActionOutput": {
                    "len": 16,
                    "max_len": 65535,
                    "port": 4294967291,
                    "type": 0
                }
            }
        ],
        "actions_len": 16,
        "buffer_id": 4294967295,
        "data": "dGVzdA==",
        "match": {
            "OFPMatch": {
                "length": 12,
                "oxm_fields": [
                    {
                        "OXMTlv": {
                            "field": "in_port",
                            "mask": null,
                            "value": 4294967040
                        }
                    }
                ],
                "type": 1
            }
        }
    }
}

Barrier Message

class os_ken.ofproto.ofproto_v1_5_parser.OFPBarrierRequest(datapath)

Barrier request message

The controller sends this message to ensure message dependencies have been met or receive notifications for completed operations.

Example:

def send_barrier_request(self, datapath):
    ofp_parser = datapath.ofproto_parser

    req = ofp_parser.OFPBarrierRequest(datapath)
    datapath.send_msg(req)

JSON Example:

{
   "OFPBarrierRequest": {}
}
class os_ken.ofproto.ofproto_v1_5_parser.OFPBarrierReply(datapath)

Barrier reply message

The switch responds with this message to a barrier request.

Example:

@set_ev_cls(ofp_event.EventOFPBarrierReply, MAIN_DISPATCHER)
def barrier_reply_handler(self, ev):
    self.logger.debug('OFPBarrierReply received')

JSON Example:

{
   "OFPBarrierReply": {}
}

Role Request Message

class os_ken.ofproto.ofproto_v1_5_parser.OFPRoleRequest(datapath, role=None, short_id=None, generation_id=None)

Role request message

The controller uses this message to change its role.

Attribute Description
role

One of the following values.

OFPCR_ROLE_NOCHANGE
OFPCR_ROLE_EQUAL
OFPCR_ROLE_MASTER
OFPCR_ROLE_SLAVE
short_id ID number for the controller. The default is OFPCID_UNDEFINED.
generation_id Master Election Generation ID

Example:

def send_role_request(self, datapath):
    ofp = datapath.ofproto
    ofp_parser = datapath.ofproto_parser

    req = ofp_parser.OFPRoleRequest(datapath, ofp.OFPCR_ROLE_EQUAL,
                                    ofp.OFPCID_UNDEFINED, 0)
    datapath.send_msg(req)

JSON Example:

{
   "OFPRoleRequest": {
      "generation_id": 1234605616436508552,
      "role": 1,
      "short_id": 43690
   }
}
class os_ken.ofproto.ofproto_v1_5_parser.OFPRoleReply(datapath, role=None, short_id=None, generation_id=None)

Role reply message

The switch responds with this message to a role request.

Attribute Description
role

One of the following values.

OFPCR_ROLE_NOCHANGE
OFPCR_ROLE_EQUAL
OFPCR_ROLE_MASTER
OFPCR_ROLE_SLAVE
short_id ID number for the controller. The default is OFPCID_UNDEFINED.
generation_id Master Election Generation ID

Example:

@set_ev_cls(ofp_event.EventOFPRoleReply, MAIN_DISPATCHER)
def role_reply_handler(self, ev):
    msg = ev.msg
    dp = msg.datapath
    ofp = dp.ofproto

    if msg.role == ofp.OFPCR_ROLE_NOCHANGE:
        role = 'NOCHANGE'
    elif msg.role == ofp.OFPCR_ROLE_EQUAL:
        role = 'EQUAL'
    elif msg.role == ofp.OFPCR_ROLE_MASTER:
        role = 'MASTER'
    elif msg.role == ofp.OFPCR_ROLE_SLAVE:
        role = 'SLAVE'
    else:
        role = 'unknown'

    self.logger.debug('OFPRoleReply received: '
                      'role=%s short_id=%d, generation_id=%d',
                      role, msg.short_id, msg.generation_id)

JSON Example:

{
   "OFPRoleReply": {
      "generation_id": 1234605616436508552,
      "role": 1,
      "short_id": 43690
   }
}

Bundle Messages

class os_ken.ofproto.ofproto_v1_5_parser.OFPBundleCtrlMsg(datapath, bundle_id=None, type_=None, flags=None, properties=None)

Bundle control message

The controller uses this message to create, destroy and commit bundles

Attribute Description
bundle_id Id of the bundle
type

One of the following values.

OFPBCT_OPEN_REQUEST
OFPBCT_OPEN_REPLY
OFPBCT_CLOSE_REQUEST
OFPBCT_CLOSE_REPLY
OFPBCT_COMMIT_REQUEST
OFPBCT_COMMIT_REPLY
OFPBCT_DISCARD_REQUEST
OFPBCT_DISCARD_REPLY
flags

Bitmap of the following flags.

OFPBF_ATOMIC
OFPBF_ORDERED
properties List of OFPBundleProp subclass instance

Example:

def send_bundle_control(self, datapath):
    ofp = datapath.ofproto
    ofp_parser = datapath.ofproto_parser

    req = ofp_parser.OFPBundleCtrlMsg(datapath, 7,
                                      ofp.OFPBCT_OPEN_REQUEST,
                                      ofp.OFPBF_ATOMIC, [])
    datapath.send_msg(req)

JSON Example:

{
   "OFPBundleCtrlMsg": {
      "bundle_id": 99999999, 
      "flags": 1, 
      "properties": [], 
      "type": 1
   }
}
class os_ken.ofproto.ofproto_v1_5_parser.OFPBundleAddMsg(datapath, bundle_id, flags, message, properties)

Bundle add message

The controller uses this message to add a message to a bundle

Attribute Description
bundle_id Id of the bundle
flags

Bitmap of the following flags.

OFPBF_ATOMIC
OFPBF_ORDERED
message MsgBase subclass instance
properties List of OFPBundleProp subclass instance

Example:

def send_bundle_add_message(self, datapath):
    ofp = datapath.ofproto
    ofp_parser = datapath.ofproto_parser

    msg = ofp_parser.OFPRoleRequest(datapath, ofp.OFPCR_ROLE_EQUAL, 0)

    req = ofp_parser.OFPBundleAddMsg(datapath, 7, ofp.OFPBF_ATOMIC,
                                     msg, [])
    datapath.send_msg(req)

JSON Example:

{
   "OFPBundleAddMsg": {
      "bundle_id": 99999999, 
      "flags": 1, 
      "message": {
         "OFPFlowMod": {
            "buffer_id": 0, 
            "command": 0, 
            "cookie": 1311768467463790320, 
            "cookie_mask": 18446744073709551615, 
            "flags": 0, 
            "hard_timeout": 0, 
            "idle_timeout": 0, 
            "importance": 39032, 
            "instructions": [
               {
                  "OFPInstructionActions": {
                     "actions": [
                        {
                           "OFPActionPopVlan": {
                              "len": 8, 
                              "type": 18
                           }
                        }, 
                        {
                           "OFPActionSetField": {
                              "field": {
                                 "OXMTlv": {
                                    "field": "ipv4_dst", 
                                    "mask": null, 
                                    "value": "192.168.2.9"
                                 }
                              },
                              "len": 16,
                              "type": 25
                           }
                        }, 
                        {
                           "NXActionLearn": {
                              "cookie": 0, 
                              "experimenter": 8992, 
                              "fin_hard_timeout": 0, 
                              "fin_idle_timeout": 0, 
                              "flags": 0, 
                              "hard_timeout": 300, 
                              "idle_timeout": 0, 
                              "len": 96, 
                              "priority": 1, 
                              "specs": [
                                 {
                                    "NXFlowSpecMatch": {
                                       "dst": [
                                          "vlan_vid", 
                                          0
                                       ], 
                                       "n_bits": 12, 
                                       "src": [
                                          "vlan_vid", 
                                          0
                                       ]
                                    }
                                 }, 
                                 {
                                    "NXFlowSpecMatch": {
                                       "dst": [
                                          "eth_dst_nxm", 
                                          0
                                       ], 
                                       "n_bits": 48, 
                                       "src": [
                                          "eth_src_nxm", 
                                          0
                                       ]
                                    }
                                 }, 
                                 {
                                    "NXFlowSpecLoad": {
                                       "dst": [
                                          "vlan_vid", 
                                          0
                                       ], 
                                       "n_bits": 12, 
                                       "src": 0
                                    }
                                 }, 
                                 {
                                    "NXFlowSpecLoad": {
                                       "dst": [
                                          "tunnel_id_nxm", 
                                          0
                                       ], 
                                       "n_bits": 64, 
                                       "src": [
                                          "tunnel_id_nxm", 
                                          0
                                       ]
                                    }
                                 }, 
                                 {
                                    "NXFlowSpecOutput": {
                                       "dst": "", 
                                       "n_bits": 32, 
                                       "src": [
                                          "in_port", 
                                          0
                                       ]
                                    }
                                 }
                              ], 
                              "subtype": 16, 
                              "table_id": 99, 
                              "type": 65535
                           }
                        }
                     ], 
                     "len": 128, 
                     "type": 4
                  }
               }, 
               {
                  "OFPInstructionGotoTable": {
                     "len": 8, 
                     "table_id": 100, 
                     "type": 1
                  }
               }
            ], 
            "match": {
               "OFPMatch": {
                  "length": 70, 
                  "oxm_fields": [
                     {
                        "OXMTlv": {
                           "field": "in_port", 
                           "mask": null, 
                           "value": 43981
                        }
                     }, 
                     {
                        "OXMTlv": {
                           "field": "eth_dst", 
                           "mask": null, 
                           "value": "aa:bb:cc:99:88:77"
                        }
                     }, 
                     {
                        "OXMTlv": {
                           "field": "eth_type", 
                           "mask": null, 
                           "value": 2048
                        }
                     }, 
                     {
                        "OXMTlv": {
                           "field": "vlan_vid", 
                           "mask": null, 
                           "value": 5095
                        }
                     }, 
                     {
                        "OXMTlv": {
                           "field": "ipv4_dst", 
                           "mask": null, 
                           "value": "192.168.2.1"
                        }
                     }, 
                     {
                        "OXMTlv": {
                           "field": "tunnel_id", 
                           "mask": null, 
                           "value": 50000
                        }
                     }, 
                     {
                        "OXMTlv": {
                           "field": "tun_ipv4_src", 
                           "mask": null, 
                           "value": "192.168.2.3"
                        }
                     }, 
                     {
                        "OXMTlv": {
                           "field": "tun_ipv4_dst", 
                           "mask": null, 
                           "value": "192.168.2.4"
                        }
                     }
                  ], 
                  "type": 1
               }
            }, 
            "out_group": 0, 
            "out_port": 0, 
            "priority": 0, 
            "table_id": 2
         }
      }, 
      "properties": []
   }
}

Set Asynchronous Configuration Message

class os_ken.ofproto.ofproto_v1_5_parser.OFPSetAsync(datapath, properties=None)

Set asynchronous configuration message

The controller sends this message to set the asynchronous messages that it wants to receive on a given OpneFlow channel.

Attribute Description
properties List of OFPAsyncConfigProp subclass instances

Example:

def send_set_async(self, datapath):
    ofp = datapath.ofproto
    ofp_parser = datapath.ofproto_parser

    properties = [
        ofp_parser.OFPAsyncConfigPropReasons(
            ofp.OFPACPT_PACKET_IN_SLAVE, 8,
            (1 << ofp.OFPR_APPLY_ACTION
             | 1 << ofp.OFPR_INVALID_TTL))]
    req = ofp_parser.OFPSetAsync(datapath, properties)
    datapath.send_msg(req)

JSON Example:

{
   "OFPSetAsync": {
      "properties": [
         {
            "OFPAsyncConfigPropReasons": {
               "length": 8, 
               "mask": 3, 
               "type": 0
            }
         }, 
         {
            "OFPAsyncConfigPropReasons": {
               "length": 8, 
               "mask": 3, 
               "type": 1
            }
         }, 
         {
            "OFPAsyncConfigPropReasons": {
               "length": 8, 
               "mask": 3, 
               "type": 2
            }
         }, 
         {
            "OFPAsyncConfigPropReasons": {
               "length": 8, 
               "mask": 3, 
               "type": 3
            }
         }, 
         {
            "OFPAsyncConfigPropReasons": {
               "length": 8, 
               "mask": 3, 
               "type": 4
            }
         }, 
         {
            "OFPAsyncConfigPropReasons": {
               "length": 8, 
               "mask": 3, 
               "type": 5
            }
         }, 
         {
            "OFPAsyncConfigPropReasons": {
               "length": 8, 
               "mask": 3, 
               "type": 6
            }
         }, 
         {
            "OFPAsyncConfigPropReasons": {
               "length": 8, 
               "mask": 3, 
               "type": 7
            }
         }, 
         {
            "OFPAsyncConfigPropReasons": {
               "length": 8, 
               "mask": 24, 
               "type": 8
            }
         }, 
         {
            "OFPAsyncConfigPropReasons": {
               "length": 8, 
               "mask": 24, 
               "type": 9
            }
         }, 
         {
            "OFPAsyncConfigPropReasons": {
               "length": 8, 
               "mask": 3, 
               "type": 10
            }
         }, 
         {
            "OFPAsyncConfigPropReasons": {
               "length": 8, 
               "mask": 3, 
               "type": 11
            }
         }, 
         {
            "OFPAsyncConfigPropExperimenter": {
               "data": [], 
               "exp_type": 0, 
               "experimenter": 101, 
               "length": 12, 
               "type": 65534
            }
         }, 
         {
            "OFPAsyncConfigPropExperimenter": {
               "data": [
                  1
               ], 
               "exp_type": 1, 
               "experimenter": 101, 
               "length": 16, 
               "type": 65535
            }
         }, 
         {
            "OFPAsyncConfigPropExperimenter": {
               "data": [
                  1, 
                  2
               ], 
               "exp_type": 2, 
               "experimenter": 101, 
               "length": 20, 
               "type": 65535
            }
         }
      ]
   }
}
class os_ken.ofproto.ofproto_v1_5_parser.OFPGetAsyncRequest(datapath)

Get asynchronous configuration request message

The controller uses this message to query the asynchronous message.

Example:

def send_get_async_request(self, datapath):
    ofp_parser = datapath.ofproto_parser

    req = ofp_parser.OFPGetAsyncRequest(datapath)
    datapath.send_msg(req)

JSON Example:

{
   "OFPGetAsyncRequest": {}
}
class os_ken.ofproto.ofproto_v1_5_parser.OFPGetAsyncReply(datapath, properties=None)

Get asynchronous configuration reply message

The switch responds with this message to a get asynchronous configuration request.

Attribute Description
properties List of OFPAsyncConfigProp subclass instances

Example:

@set_ev_cls(ofp_event.EventOFPGetAsyncReply, MAIN_DISPATCHER)
def get_async_reply_handler(self, ev):
    msg = ev.msg

    self.logger.debug('OFPGetAsyncReply received: '
                      'properties=%s', repr(msg.properties))

JSON Example:

{
   "OFPGetAsyncReply": {
      "properties": [
         {
            "OFPAsyncConfigPropReasons": {
               "length": 8, 
               "mask": 3, 
               "type": 0
            }
         }, 
         {
            "OFPAsyncConfigPropReasons": {
               "length": 8, 
               "mask": 3, 
               "type": 1
            }
         }, 
         {
            "OFPAsyncConfigPropReasons": {
               "length": 8, 
               "mask": 3, 
               "type": 2
            }
         }, 
         {
            "OFPAsyncConfigPropReasons": {
               "length": 8, 
               "mask": 3, 
               "type": 3
            }
         }, 
         {
            "OFPAsyncConfigPropReasons": {
               "length": 8, 
               "mask": 3, 
               "type": 4
            }
         }, 
         {
            "OFPAsyncConfigPropReasons": {
               "length": 8, 
               "mask": 3, 
               "type": 5
            }
         }, 
         {
            "OFPAsyncConfigPropReasons": {
               "length": 8, 
               "mask": 3, 
               "type": 6
            }
         }, 
         {
            "OFPAsyncConfigPropReasons": {
               "length": 8, 
               "mask": 3, 
               "type": 7
            }
         }, 
         {
            "OFPAsyncConfigPropReasons": {
               "length": 8, 
               "mask": 24, 
               "type": 8
            }
         }, 
         {
            "OFPAsyncConfigPropReasons": {
               "length": 8, 
               "mask": 24, 
               "type": 9
            }
         }, 
         {
            "OFPAsyncConfigPropReasons": {
               "length": 8, 
               "mask": 3, 
               "type": 10
            }
         }, 
         {
            "OFPAsyncConfigPropReasons": {
               "length": 8, 
               "mask": 3, 
               "type": 11
            }
         }, 
         {
            "OFPAsyncConfigPropExperimenter": {
               "data": [], 
               "exp_type": 0, 
               "experimenter": 101, 
               "length": 12, 
               "type": 65534
            }
         }, 
         {
            "OFPAsyncConfigPropExperimenter": {
               "data": [
                  1
               ], 
               "exp_type": 1, 
               "experimenter": 101, 
               "length": 16, 
               "type": 65535
            }
         }, 
         {
            "OFPAsyncConfigPropExperimenter": {
               "data": [
                  1, 
                  2
               ], 
               "exp_type": 2, 
               "experimenter": 101, 
               "length": 20, 
               "type": 65535
            }
         }
      ]
   }
}

Asynchronous Messages

Packet-In Message

class os_ken.ofproto.ofproto_v1_5_parser.OFPPacketIn(datapath, buffer_id=None, total_len=None, reason=None, table_id=None, cookie=None, match=None, data=None)

Packet-In message

The switch sends the packet that received to the controller by this message.

Attribute Description
buffer_id ID assigned by datapath
total_len Full length of frame
reason

Reason packet is being sent.

OFPR_TABLE_MISS
OFPR_APPLY_ACTION
OFPR_INVALID_TTL
OFPR_ACTION_SET
OFPR_GROUP
OFPR_PACKET_OUT
table_id ID of the table that was looked up
cookie Cookie of the flow entry that was looked up
match Instance of OFPMatch
data Ethernet frame

Example:

@set_ev_cls(ofp_event.EventOFPPacketIn, MAIN_DISPATCHER)
def packet_in_handler(self, ev):
    msg = ev.msg
    dp = msg.datapath
    ofp = dp.ofproto

    if msg.reason == ofp.TABLE_MISS:
        reason = 'TABLE MISS'
    elif msg.reason == ofp.OFPR_APPLY_ACTION:
        reason = 'APPLY ACTION'
    elif msg.reason == ofp.OFPR_INVALID_TTL:
        reason = 'INVALID TTL'
    elif msg.reason == ofp.OFPR_ACTION_SET:
        reason = 'ACTION SET'
    elif msg.reason == ofp.OFPR_GROUP:
        reason = 'GROUP'
    elif msg.reason == ofp.OFPR_PACKET_OUT:
        reason = 'PACKET OUT'
    else:
        reason = 'unknown'

    self.logger.debug('OFPPacketIn received: '
                      'buffer_id=%x total_len=%d reason=%s '
                      'table_id=%d cookie=%d match=%s data=%s',
                      msg.buffer_id, msg.total_len, reason,
                      msg.table_id, msg.cookie, msg.match,
                      utils.hex_array(msg.data))

JSON Example:

{
   "OFPPacketIn": {
      "buffer_id": 200, 
      "cookie": 0, 
      "data": "aG9nZQ==", 
      "match": {
         "OFPMatch": {
            "length": 40, 
            "oxm_fields": [
               {
                  "OXMTlv": {
                     "field": "in_port", 
                     "mask": null, 
                     "value": 43981
                  }
               }, 
               {
                  "OXMTlv": {
                     "field": "tunnel_id", 
                     "mask": null, 
                     "value": 50000
                  }
               }, 
               {
                  "OXMTlv": {
                     "field": "tun_ipv4_src", 
                     "mask": null, 
                     "value": "192.168.2.3"
                  }
               }, 
               {
                  "OXMTlv": {
                     "field": "tun_ipv4_dst", 
                     "mask": null, 
                     "value": "192.168.2.4"
                  }
               }
            ], 
            "type": 1
         }
      }, 
      "reason": 0, 
      "table_id": 100, 
      "total_len": 1000
   }
}

Flow Removed Message

class os_ken.ofproto.ofproto_v1_5_parser.OFPFlowRemoved(datapath, table_id=None, reason=None, priority=None, idle_timeout=None, hard_timeout=None, cookie=None, match=None, stats=None)

Flow removed message

When flow entries time out or are deleted, the switch notifies controller with this message.

Attribute Description
table_id ID of the table
reason

One of the following values.

OFPRR_IDLE_TIMEOUT
OFPRR_HARD_TIMEOUT
OFPRR_DELETE
OFPRR_GROUP_DELETE
OFPRR_METER_DELETE
OFPRR_EVICTION
priority Priority level of flow entry
idle_timeout Idle timeout from original flow mod
hard_timeout Hard timeout from original flow mod
cookie Opaque controller-issued identifier
match Instance of OFPMatch
stats Instance of OFPStats

Example:

@set_ev_cls(ofp_event.EventOFPFlowRemoved, MAIN_DISPATCHER)
def flow_removed_handler(self, ev):
    msg = ev.msg
    dp = msg.datapath
    ofp = dp.ofproto

    if msg.reason == ofp.OFPRR_IDLE_TIMEOUT:
        reason = 'IDLE TIMEOUT'
    elif msg.reason == ofp.OFPRR_HARD_TIMEOUT:
        reason = 'HARD TIMEOUT'
    elif msg.reason == ofp.OFPRR_DELETE:
        reason = 'DELETE'
    elif msg.reason == ofp.OFPRR_GROUP_DELETE:
        reason = 'GROUP DELETE'
    elif msg.reason == ofp.OFPRR_METER_DELETE:
        reason = 'METER DELETE'
    elif msg.reason == ofp.OFPRR_EVICTION:
        reason = 'EVICTION'
    else:
        reason = 'unknown'

    self.logger.debug('OFPFlowRemoved received: '
                      'table_id=%d reason=%s priority=%d '
                      'idle_timeout=%d hard_timeout=%d cookie=%d '
                      'match=%s stats=%s',
                      msg.table_id, reason, msg.priority,
                      msg.idle_timeout, msg.hard_timeout, msg.cookie,
                      msg.match, msg.stats)

JSON Example:

{
    "OFPFlowRemoved": {
        "cookie": 1234605616436508552,
        "hard_timeout": 255,
        "idle_timeout": 255,
        "match": {
            "OFPMatch": {
                "length": 12,
                "oxm_fields": [
                    {
                        "OXMTlv": {
                            "field": "in_port",
                            "mask": null,
                            "value": 1
                        }
                    }
                ],
                "type": 1
            }
        },
        "priority": 1,
        "reason": 0,
        "stats": {
            "OFPStats": {
                "length": 12,
                "oxs_fields": [
                    {
                        "OXSTlv": {
                            "field": "flow_count",
                            "value": 1
                        }
                    }
                ]
            }
        },
        "table_id": 1
    }
}

Port Status Message

class os_ken.ofproto.ofproto_v1_5_parser.OFPPortStatus(datapath, reason=None, desc=None)

Port status message

The switch notifies controller of change of ports.

Attribute Description
reason

One of the following values.

OFPPR_ADD
OFPPR_DELETE
OFPPR_MODIFY
desc instance of OFPPort

Example:

@set_ev_cls(ofp_event.EventOFPPortStatus, MAIN_DISPATCHER)
def port_status_handler(self, ev):
    msg = ev.msg
    dp = msg.datapath
    ofp = dp.ofproto

    if msg.reason == ofp.OFPPR_ADD:
        reason = 'ADD'
    elif msg.reason == ofp.OFPPR_DELETE:
        reason = 'DELETE'
    elif msg.reason == ofp.OFPPR_MODIFY:
        reason = 'MODIFY'
    else:
        reason = 'unknown'

    self.logger.debug('OFPPortStatus received: reason=%s desc=%s',
                      reason, msg.desc)

JSON Example:

{
   "OFPPortStatus": {
      "desc": {
         "OFPPort": {
            "config": 0, 
            "hw_addr": "f2:0b:a4:d0:3f:70", 
            "length": 168, 
            "name": "\u79c1\u306e\u30dd\u30fc\u30c8", 
            "port_no": 7, 
            "properties": [
               {
                  "OFPPortDescPropEthernet": {
                     "advertised": 10240, 
                     "curr": 10248, 
                     "curr_speed": 5000, 
                     "length": 32, 
                     "max_speed": 5000, 
                     "peer": 10248, 
                     "supported": 10248, 
                     "type": 0
                  }
               }, 
               {
                  "OFPPortDescPropOptical": {
                     "length": 40, 
                     "rx_grid_freq_lmda": 1500, 
                     "rx_max_freq_lmda": 2000, 
                     "rx_min_freq_lmda": 1000, 
                     "supported": 1, 
                     "tx_grid_freq_lmda": 1500, 
                     "tx_max_freq_lmda": 2000, 
                     "tx_min_freq_lmda": 1000, 
                     "tx_pwr_max": 2000, 
                     "tx_pwr_min": 1000, 
                     "type": 1
                  }
               }, 
               {
                  "OFPPortDescPropExperimenter": {
                     "data": [], 
                     "exp_type": 0, 
                     "experimenter": 101, 
                     "length": 12, 
                     "type": 65535
                  }
               }, 
               {
                  "OFPPortDescPropExperimenter": {
                     "data": [
                        1
                     ], 
                     "exp_type": 1, 
                     "experimenter": 101, 
                     "length": 16, 
                     "type": 65535
                  }
               }, 
               {
                  "OFPPortDescPropExperimenter": {
                     "data": [
                        1, 
                        2
                     ], 
                     "exp_type": 2, 
                     "experimenter": 101, 
                     "length": 20, 
                     "type": 65535
                  }
               }
            ], 
            "state": 4
         }
      }, 
      "reason": 0
   }
}

Controller Role Status Message

class os_ken.ofproto.ofproto_v1_5_parser.OFPRoleStatus(datapath, role=None, reason=None, generation_id=None, properties=None)

Role status message

The switch notifies controller of change of role.

Attribute Description
role

One of the following values.

OFPCR_ROLE_NOCHANGE
OFPCR_ROLE_EQUAL
OFPCR_ROLE_MASTER
reason

One of the following values.

OFPCRR_MASTER_REQUEST
OFPCRR_CONFIG
OFPCRR_EXPERIMENTER
generation_id Master Election Generation ID
properties List of OFPRoleProp subclass instance

Example:

@set_ev_cls(ofp_event.EventOFPRoleStatus, MAIN_DISPATCHER)
def role_status_handler(self, ev):
    msg = ev.msg
    dp = msg.datapath
    ofp = dp.ofproto

    if msg.role == ofp.OFPCR_ROLE_NOCHANGE:
        role = 'ROLE NOCHANGE'
    elif msg.role == ofp.OFPCR_ROLE_EQUAL:
        role = 'ROLE EQUAL'
    elif msg.role == ofp.OFPCR_ROLE_MASTER:
        role = 'ROLE MASTER'
    else:
        role = 'unknown'

    if msg.reason == ofp.OFPCRR_MASTER_REQUEST:
        reason = 'MASTER REQUEST'
    elif msg.reason == ofp.OFPCRR_CONFIG:
        reason = 'CONFIG'
    elif msg.reason == ofp.OFPCRR_EXPERIMENTER:
        reason = 'EXPERIMENTER'
    else:
        reason = 'unknown'

    self.logger.debug('OFPRoleStatus received: role=%s reason=%s '
                      'generation_id=%d properties=%s', role, reason,
                      msg.generation_id, repr(msg.properties))

JSON Example:

{
   "OFPRoleStatus": {
      "generation_id": 17356517385562371090, 
      "properties": [], 
      "reason": 0, 
      "role": 3
   }
}

Table Status Message

class os_ken.ofproto.ofproto_v1_5_parser.OFPTableStatus(datapath, reason=None, table=None)

Table status message

The switch notifies controller of change of table status.

Attribute Description
reason

One of the following values.

OFPTR_VACANCY_DOWN
OFPTR_VACANCY_UP
table OFPTableDesc instance

Example:

@set_ev_cls(ofp_event.EventOFPTableStatus, MAIN_DISPATCHER)
def table(self, ev):
    msg = ev.msg
    dp = msg.datapath
    ofp = dp.ofproto

    if msg.reason == ofp.OFPTR_VACANCY_DOWN:
        reason = 'VACANCY_DOWN'
    elif msg.reason == ofp.OFPTR_VACANCY_UP:
        reason = 'VACANCY_UP'
    else:
        reason = 'unknown'

    self.logger.debug('OFPTableStatus received: reason=%s '
                      'table_id=%d config=0x%08x properties=%s',
                      reason, msg.table.table_id, msg.table.config,
                      repr(msg.table.properties))

JSON Example:

{
   "OFPTableStatus": {
      "reason": 3, 
      "table": {
         "OFPTableDesc": {
            "config": 0, 
            "length": 80, 
            "properties": [
               {
                  "OFPTableModPropEviction": {
                     "flags": 0, 
                     "length": 8, 
                     "type": 2
                  }
               }, 
               {
                  "OFPTableModPropVacancy": {
                     "length": 8, 
                     "type": 3, 
                     "vacancy": 0, 
                     "vacancy_down": 0, 
                     "vacancy_up": 0
                  }
               }, 
               {
                  "OFPTableModPropExperimenter": {
                     "data": [], 
                     "exp_type": 0, 
                     "experimenter": 101, 
                     "length": 12, 
                     "type": 65535
                  }
               }, 
               {
                  "OFPTableModPropExperimenter": {
                     "data": [
                        1
                     ], 
                     "exp_type": 1, 
                     "experimenter": 101, 
                     "length": 16, 
                     "type": 65535
                  }
               }, 
               {
                  "OFPTableModPropExperimenter": {
                     "data": [
                        1, 
                        2
                     ], 
                     "exp_type": 2, 
                     "experimenter": 101, 
                     "length": 20, 
                     "type": 65535
                  }
               }
            ], 
            "table_id": 8
         }
      }
   }
}

Request Forward Message

class os_ken.ofproto.ofproto_v1_5_parser.OFPRequestForward(datapath, request=None)

Forwarded request message

The swtich forwards request messages from one controller to other controllers.

Attribute Description
request OFPGroupMod or OFPMeterMod instance

Example:

@set_ev_cls(ofp_event.EventOFPRequestForward, MAIN_DISPATCHER)
def request_forward_handler(self, ev):
    msg = ev.msg
    dp = msg.datapath
    ofp = dp.ofproto

    if msg.request.msg_type == ofp.OFPT_GROUP_MOD:
        self.logger.debug(
            'OFPRequestForward received: request=OFPGroupMod('
            'command=%d, type=%d, group_id=%d, command_bucket_id=%d, '
            'buckets=%s, properties=%s)',
            msg.request.command, msg.request.type,
            msg.request.group_id, msg.request.command_bucket_id,
            msg.request.buckets, repr(msg.request.properties))
    elif msg.request.msg_type == ofp.OFPT_METER_MOD:
        self.logger.debug(
            'OFPRequestForward received: request=OFPMeterMod('
            'command=%d, flags=%d, meter_id=%d, bands=%s)',
            msg.request.command, msg.request.flags,
            msg.request.meter_id, msg.request.bands)
    else:
        self.logger.debug(
            'OFPRequestForward received: request=Unknown')

JSON Example:

{
   "OFPRequestForward": {
      "request": {
         "OFPGroupMod": {
            "bucket_array_len": 56, 
            "buckets": [
               {
                  "OFPBucket": {
                     "action_array_len": 24, 
                     "actions": [
                        {
                           "OFPActionPopVlan": {
                              "len": 8, 
                              "type": 18
                           }
                        }, 
                        {
                           "OFPActionSetField": {
                              "field": {
                                 "OXMTlv": {
                                    "field": "ipv4_dst", 
                                    "mask": null, 
                                    "value": "192.168.2.9"
                                 }
                              },
                              "len": 16,
                              "type": 25
                           }
                        }
                     ], 
                     "bucket_id": 305419896, 
                     "len": 56, 
                     "properties": [
                        {
                           "OFPGroupBucketPropWeight": {
                              "length": 8, 
                              "type": 0, 
                              "weight": 52428
                           }
                        }, 
                        {
                           "OFPGroupBucketPropWatch": {
                              "length": 8, 
                              "type": 1, 
                              "watch": 56797
                           }
                        }, 
                        {
                           "OFPGroupBucketPropWatch": {
                              "length": 8, 
                              "type": 2, 
                              "watch": 4008636142
                           }
                        }
                     ]
                  }
               }
            ], 
            "command": 3, 
            "command_bucket_id": 3149642683, 
            "group_id": 2863311530, 
            "properties": [], 
            "type": 1
         }
      }
   }
}

Controller Status Message

class os_ken.ofproto.ofproto_v1_5_parser.OFPControllerStatus(datapath, status=None)

Controller status message

The switch informs the controller about the status of the control channel it maintains with each controller.

Attribute Description
status OFPControllerStatusStats instance

Example:

@set_ev_cls(ofp_event.EventOFPControllerStatus, MAIN_DISPATCHER)
def table(self, ev):
    msg = ev.msg
    dp = msg.datapath
    ofp = dp.ofproto
    status = msg.status

    if status.role == ofp.OFPCR_ROLE_NOCHANGE:
        role = 'NOCHANGE'
    elif status.role == ofp.OFPCR_ROLE_EQUAL:
        role = 'EQUAL'
    elif status.role == ofp.OFPCR_ROLE_MASTER:
        role = 'MASTER'
    elif status.role == ofp.OFPCR_ROLE_SLAVE:
        role = 'SLAVE'
    else:
        role = 'unknown'

    if status.reason == ofp.OFPCSR_REQUEST:
        reason = 'REQUEST'
    elif status.reason == ofp.OFPCSR_CHANNEL_STATUS:
        reason = 'CHANNEL_STATUS'
    elif status.reason == ofp.OFPCSR_ROLE:
        reason = 'ROLE'
    elif status.reason == ofp.OFPCSR_CONTROLLER_ADDED:
        reason = 'CONTROLLER_ADDED'
    elif status.reason == ofp.OFPCSR_CONTROLLER_REMOVED:
        reason = 'CONTROLLER_REMOVED'
    elif status.reason == ofp.OFPCSR_SHORT_ID:
        reason = 'SHORT_ID'
    elif status.reason == ofp.OFPCSR_EXPERIMENTER:
        reason = 'EXPERIMENTER'
    else:
        reason = 'unknown'

    if status.channel_status == OFPCT_STATUS_UP:
        channel_status = 'UP'
    if status.channel_status == OFPCT_STATUS_DOWN:
        channel_status = 'DOWN'
    else:
        channel_status = 'unknown'

    self.logger.debug('OFPControllerStatus received: short_id=%d'
                      'role=%s reason=%s channel_status=%s '
                      'properties=%s',
                      status.short_id, role, reason, channel_status,
                      repr(status.properties))

JSON Example:

{
    "OFPControllerStatus": {
        "status": {
            "OFPControllerStatusStats": {
                "channel_status": 1,
                "length": 48,
                "properties": [
                    {
                        "OFPControllerStatusPropUri": {
                            "length": 26,
                            "type": 0,
                            "uri": "tls:192.168.34.23:6653"
                        }
                    }
                ],
                "reason": 1,
                "role": 1,
                "short_id": 65535
            }
        }
    }
}

Symmetric Messages

Hello

class os_ken.ofproto.ofproto_v1_5_parser.OFPHello(datapath, elements=None)

Hello message

When connection is started, the hello message is exchanged between a switch and a controller.

This message is handled by the OSKen framework, so the OSKen application do not need to process this typically.

Attribute Description
elements list of OFPHelloElemVersionBitmap instance

JSON Example:

{
   "OFPHello": {
      "elements": [
         {
            "OFPHelloElemVersionBitmap": {
               "length": 8, 
               "type": 1, 
               "versions": [
                  6
               ]
            }
         }
      ]
   }
}
class os_ken.ofproto.ofproto_v1_5_parser.OFPHelloElemVersionBitmap(versions, type_=None, length=None)

Version bitmap Hello Element

Attribute Description
versions list of versions of OpenFlow protocol a device supports

Echo Request

class os_ken.ofproto.ofproto_v1_5_parser.OFPEchoRequest(datapath, data=None)

Echo request message

This message is handled by the OSKen framework, so the OSKen application do not need to process this typically.

Attribute Description
data An arbitrary length data

Example:

def send_echo_request(self, datapath, data):
    ofp_parser = datapath.ofproto_parser

    req = ofp_parser.OFPEchoRequest(datapath, data)
    datapath.send_msg(req)

@set_ev_cls(ofp_event.EventOFPEchoRequest,
            [HANDSHAKE_DISPATCHER, CONFIG_DISPATCHER, MAIN_DISPATCHER])
def echo_request_handler(self, ev):
    self.logger.debug('OFPEchoRequest received: data=%s',
                      utils.hex_array(ev.msg.data))

JSON Example:

{
   "OFPEchoRequest": {
      "data": ""
   }
}

Echo Reply

class os_ken.ofproto.ofproto_v1_5_parser.OFPEchoReply(datapath, data=None)

Echo reply message

This message is handled by the OSKen framework, so the OSKen application do not need to process this typically.

Attribute Description
data An arbitrary length data

Example:

def send_echo_reply(self, datapath, data):
    ofp_parser = datapath.ofproto_parser

    reply = ofp_parser.OFPEchoReply(datapath, data)
    datapath.send_msg(reply)

@set_ev_cls(ofp_event.EventOFPEchoReply,
            [HANDSHAKE_DISPATCHER, CONFIG_DISPATCHER, MAIN_DISPATCHER])
def echo_reply_handler(self, ev):
    self.logger.debug('OFPEchoReply received: data=%s',
                      utils.hex_array(ev.msg.data))

JSON Example:

{
   "OFPEchoReply": {
      "data": ""
   }
}

Error Message

class os_ken.ofproto.ofproto_v1_5_parser.OFPErrorMsg(datapath, type_=None, code=None, data=None, **kwargs)

Error message

The switch notifies controller of problems by this message.

Attribute Description
type High level type of error
code Details depending on the type
data Variable length data depending on the type and code

type attribute corresponds to type_ parameter of __init__.

Types and codes are defined in os_ken.ofproto.ofproto.

Type Code
OFPET_HELLO_FAILED OFPHFC_*
OFPET_BAD_REQUEST OFPBRC_*
OFPET_BAD_ACTION OFPBAC_*
OFPET_BAD_INSTRUCTION OFPBIC_*
OFPET_BAD_MATCH OFPBMC_*
OFPET_FLOW_MOD_FAILED OFPFMFC_*
OFPET_GROUP_MOD_FAILED OFPGMFC_*
OFPET_PORT_MOD_FAILED OFPPMFC_*
OFPET_TABLE_MOD_FAILED OFPTMFC_*
OFPET_QUEUE_OP_FAILED OFPQOFC_*
OFPET_SWITCH_CONFIG_FAILED OFPSCFC_*
OFPET_ROLE_REQUEST_FAILED OFPRRFC_*
OFPET_METER_MOD_FAILED OFPMMFC_*
OFPET_TABLE_FEATURES_FAILED OFPTFFC_*
OFPET_EXPERIMENTER N/A

If type == OFPET_EXPERIMENTER, this message has also the following attributes.

Attribute Description
exp_type Experimenter defined type
experimenter Experimenter ID

Example:

@set_ev_cls(ofp_event.EventOFPErrorMsg,
            [HANDSHAKE_DISPATCHER, CONFIG_DISPATCHER, MAIN_DISPATCHER])
def error_msg_handler(self, ev):
    msg = ev.msg

    self.logger.debug('OFPErrorMsg received: type=0x%02x code=0x%02x '
                      'message=%s',
                      msg.type, msg.code, utils.hex_array(msg.data))

JSON Example:

{
   "OFPErrorMsg": {
      "code": 6, 
      "data": "Bg4ACAAAAAA=", 
      "type": 4
   }
}

Experimenter

class os_ken.ofproto.ofproto_v1_5_parser.OFPExperimenter(datapath, experimenter=None, exp_type=None, data=None)

Experimenter extension message

Attribute Description
experimenter Experimenter ID
exp_type Experimenter defined
data Experimenter defined arbitrary additional data

JSON Example:

{
   "OFPErrorMsg": {
      "code": null,
      "data": "amlra2VuIGRhdGE=",
      "exp_type": 60000,
      "experimenter": 999999,
      "type": 65535
   }
}

Port Structures

class os_ken.ofproto.ofproto_v1_5_parser.OFPPort(port_no=None, length=None, hw_addr=None, name=None, config=None, state=None, properties=None)

Description of a port

Attribute Description
port_no Port number and it uniquely identifies a port within a switch.
length Length of ofp_port (excluding padding).
hw_addr MAC address for the port.
name Null-terminated string containing a human-readable name for the interface.
config

Bitmap of port configration flags.

OFPPC_PORT_DOWN
OFPPC_NO_RECV
OFPPC_NO_FWD
OFPPC_NO_PACKET_IN
state

Bitmap of port state flags.

OFPPS_LINK_DOWN
OFPPS_BLOCKED
OFPPS_LIVE
properties List of OFPPortDescProp subclass instance

Flow Match Structure

class os_ken.ofproto.ofproto_v1_5_parser.OFPMatch(type_=None, length=None, _ordered_fields=None, **kwargs)

Flow Match Structure

This class is implementation of the flow match structure having compose/query API.

You can define the flow match by the keyword arguments. The following arguments are available.

Argument Value Description
in_port Integer 32bit Switch input port
in_phy_port Integer 32bit Switch physical input port
metadata Integer 64bit Metadata passed between tables
eth_dst MAC address Ethernet destination address
eth_src MAC address Ethernet source address
eth_type Integer 16bit Ethernet frame type
vlan_vid Integer 16bit VLAN id
vlan_pcp Integer 8bit VLAN priority
ip_dscp Integer 8bit IP DSCP (6 bits in ToS field)
ip_ecn Integer 8bit IP ECN (2 bits in ToS field)
ip_proto Integer 8bit IP protocol
ipv4_src IPv4 address IPv4 source address
ipv4_dst IPv4 address IPv4 destination address
tcp_src Integer 16bit TCP source port
tcp_dst Integer 16bit TCP destination port
udp_src Integer 16bit UDP source port
udp_dst Integer 16bit UDP destination port
sctp_src Integer 16bit SCTP source port
sctp_dst Integer 16bit SCTP destination port
icmpv4_type Integer 8bit ICMP type
icmpv4_code Integer 8bit ICMP code
arp_op Integer 16bit ARP opcode
arp_spa IPv4 address ARP source IPv4 address
arp_tpa IPv4 address ARP target IPv4 address
arp_sha MAC address ARP source hardware address
arp_tha MAC address ARP target hardware address
ipv6_src IPv6 address IPv6 source address
ipv6_dst IPv6 address IPv6 destination address
ipv6_flabel Integer 32bit IPv6 Flow Label
icmpv6_type Integer 8bit ICMPv6 type
icmpv6_code Integer 8bit ICMPv6 code
ipv6_nd_target IPv6 address Target address for ND
ipv6_nd_sll MAC address Source link-layer for ND
ipv6_nd_tll MAC address Target link-layer for ND
mpls_label Integer 32bit MPLS label
mpls_tc Integer 8bit MPLS TC
mpls_bos Integer 8bit MPLS BoS bit
pbb_isid Integer 24bit PBB I-SID
tunnel_id Integer 64bit Logical Port Metadata
ipv6_exthdr Integer 16bit IPv6 Extension Header pseudo-field
pbb_uca Integer 8bit PBB UCA header field
tcp_flags Integer 16bit TCP flags
actset_output Integer 32bit Output port from action set metadata
packet_type Integer 32bit Packet type value

Example:

>>> # compose
>>> match = parser.OFPMatch(
...     in_port=1,
...     eth_type=0x86dd,
...     ipv6_src=('2001:db8:bd05:1d2:288a:1fc0:1:10ee',
...               'ffff:ffff:ffff:ffff::'),
...     ipv6_dst='2001:db8:bd05:1d2:288a:1fc0:1:10ee')
>>> # query
>>> if 'ipv6_src' in match:
...     print match['ipv6_src']
...
('2001:db8:bd05:1d2:288a:1fc0:1:10ee', 'ffff:ffff:ffff:ffff::')

Note

For the list of the supported Nicira experimenter matches, please refer to os_ken.ofproto.nx_match.

Note

For VLAN id match field, special values are defined in OpenFlow Spec.

  1. Packets with and without a VLAN tag

    • Example:

      match = parser.OFPMatch()
      
    • Packet Matching

      non-VLAN-tagged MATCH
      VLAN-tagged(vlan_id=3) MATCH
      VLAN-tagged(vlan_id=5) MATCH
  2. Only packets without a VLAN tag

    • Example:

      match = parser.OFPMatch(vlan_vid=0x0000)
      
    • Packet Matching

      non-VLAN-tagged MATCH
      VLAN-tagged(vlan_id=3) x
      VLAN-tagged(vlan_id=5) x
  3. Only packets with a VLAN tag regardless of its value

    • Example:

      match = parser.OFPMatch(vlan_vid=(0x1000, 0x1000))
      
    • Packet Matching

      non-VLAN-tagged x
      VLAN-tagged(vlan_id=3) MATCH
      VLAN-tagged(vlan_id=5) MATCH
  4. Only packets with VLAN tag and VID equal

    • Example:

      match = parser.OFPMatch(vlan_vid=(0x1000 | 3))
      
    • Packet Matching

      non-VLAN-tagged x
      VLAN-tagged(vlan_id=3) MATCH
      VLAN-tagged(vlan_id=5) x

Flow Stats Structures

class os_ken.ofproto.ofproto_v1_5_parser.OFPStats(length=None, _ordered_fields=None, **kwargs)

Flow Stats Structure

This class is implementation of the flow stats structure having compose/query API.

You can define the flow stats by the keyword arguments. The following arguments are available.

Argument Value Description
duration Integer 32bit*2 Time flow entry has been alive. This field is a tuple of two Integer 32bit. The first value is duration_sec and the second is duration_nsec.
idle_time Integer 32bit*2 Time flow entry has been idle.
flow_count Integer 32bit Number of aggregated flow entries.
packet_count Integer 64bit Number of packets matched by a flow entry.
byte_count Integer 64bit Number of bytes matched by a flow entry.

Example:

>>> # compose
>>> stats = parser.OFPStats(
...     packet_count=100,
...     duration=(100, 200)
>>> # query
>>> if 'duration' in stats:
...     print stats['duration']
...
(100, 200)

Flow Instruction Structures

class os_ken.ofproto.ofproto_v1_5_parser.OFPInstructionGotoTable(table_id, type_=None, len_=None)

Goto table instruction

This instruction indicates the next table in the processing pipeline.

Attribute Description
table_id Next table
class os_ken.ofproto.ofproto_v1_5_parser.OFPInstructionWriteMetadata(metadata, metadata_mask, type_=None, len_=None)

Write metadata instruction

This instruction writes the masked metadata value into the metadata field.

Attribute Description
metadata Metadata value to write
metadata_mask Metadata write bitmask
class os_ken.ofproto.ofproto_v1_5_parser.OFPInstructionActions(type_, actions=None, len_=None)

Actions instruction

This instruction writes/applies/clears the actions.

Attribute Description
type

One of following values.

OFPIT_WRITE_ACTIONS
OFPIT_APPLY_ACTIONS
OFPIT_CLEAR_ACTIONS
actions list of OpenFlow action class

type attribute corresponds to type_ parameter of __init__.

class os_ken.ofproto.ofproto_v1_5_parser.OFPInstructionStatTrigger(flags, thresholds, type_=None, len_=None)

Statistics triggers instruction

This instruction defines a set of statistics thresholds using OXS.

Attribute Description
flags

Bitmap of the following flags.

OFPSTF_PERIODIC
OFPSTF_ONLY_FIRST
thresholds Instance of OFPStats

Action Structures

class os_ken.ofproto.ofproto_v1_5_parser.OFPActionOutput(port, max_len=65509, type_=None, len_=None)

Output action

This action indicates output a packet to the switch port.

Attribute Description
port Output port
max_len Max length to send to controller
class os_ken.ofproto.ofproto_v1_5_parser.OFPActionCopyTtlOut(type_=None, len_=None)

Copy TTL Out action

This action copies the TTL from the next-to-outermost header with TTL to the outermost header with TTL.

class os_ken.ofproto.ofproto_v1_5_parser.OFPActionCopyTtlIn(type_=None, len_=None)

Copy TTL In action

This action copies the TTL from the outermost header with TTL to the next-to-outermost header with TTL.

class os_ken.ofproto.ofproto_v1_5_parser.OFPActionSetMplsTtl(mpls_ttl, type_=None, len_=None)

Set MPLS TTL action

This action sets the MPLS TTL.

Attribute Description
mpls_ttl MPLS TTL
class os_ken.ofproto.ofproto_v1_5_parser.OFPActionDecMplsTtl(type_=None, len_=None)

Decrement MPLS TTL action

This action decrements the MPLS TTL.

class os_ken.ofproto.ofproto_v1_5_parser.OFPActionPushVlan(ethertype=33024, type_=None, len_=None)

Push VLAN action

This action pushes a new VLAN tag to the packet.

Attribute Description
ethertype Ether type. The default is 802.1Q. (0x8100)
class os_ken.ofproto.ofproto_v1_5_parser.OFPActionPopVlan(type_=None, len_=None)

Pop VLAN action

This action pops the outermost VLAN tag from the packet.

class os_ken.ofproto.ofproto_v1_5_parser.OFPActionPushMpls(ethertype=34887, type_=None, len_=None)

Push MPLS action

This action pushes a new MPLS header to the packet.

Attribute Description
ethertype Ether type
class os_ken.ofproto.ofproto_v1_5_parser.OFPActionPopMpls(ethertype=2048, type_=None, len_=None)

Pop MPLS action

This action pops the MPLS header from the packet.

class os_ken.ofproto.ofproto_v1_5_parser.OFPActionSetQueue(queue_id, type_=None, len_=None)

Set queue action

This action sets the queue id that will be used to map a flow to an already-configured queue on a port.

Attribute Description
queue_id Queue ID for the packets
class os_ken.ofproto.ofproto_v1_5_parser.OFPActionGroup(group_id=0, type_=None, len_=None)

Group action

This action indicates the group used to process the packet.

Attribute Description
group_id Group identifier
class os_ken.ofproto.ofproto_v1_5_parser.OFPActionSetNwTtl(nw_ttl, type_=None, len_=None)

Set IP TTL action

This action sets the IP TTL.

Attribute Description
nw_ttl IP TTL
class os_ken.ofproto.ofproto_v1_5_parser.OFPActionDecNwTtl(type_=None, len_=None)

Decrement IP TTL action

This action decrements the IP TTL.

class os_ken.ofproto.ofproto_v1_5_parser.OFPActionSetField(field=None, **kwargs)

Set field action

This action modifies a header field in the packet.

The set of keywords available for this is same as OFPMatch which including with/without mask.

Example:

set_field = OFPActionSetField(eth_src="00:00:00:00:00:00")
set_field = OFPActionSetField(ipv4_src=("192.168.100.0",
                                        "255.255.255.0"))
class os_ken.ofproto.ofproto_v1_5_parser.OFPActionPushPbb(ethertype, type_=None, len_=None)

Push PBB action

This action pushes a new PBB header to the packet.

Attribute Description
ethertype Ether type
class os_ken.ofproto.ofproto_v1_5_parser.OFPActionPopPbb(type_=None, len_=None)

Pop PBB action

This action pops the outermost PBB service instance header from the packet.

class os_ken.ofproto.ofproto_v1_5_parser.OFPActionCopyField(n_bits=0, src_offset=0, dst_offset=0, oxm_ids=None, type_=None, len_=None)

Copy Field action

This action copy value between header and register.

Attribute Description
n_bits Number of bits to copy.
src_offset Starting bit offset in source.
dst_offset Starting bit offset in destination.
oxm_ids List of OFPOxmId instances. The first element of this list, src_oxm_id, identifies the field where the value is copied from. The second element of this list, dst_oxm_id, identifies the field where the value is copied to. The default is [].
class os_ken.ofproto.ofproto_v1_5_parser.OFPActionMeter(meter_id, type_=None, len_=None)

Meter action

This action applies meter (rate limiter)

Attribute Description
meter_id Meter instance
class os_ken.ofproto.ofproto_v1_5_parser.OFPActionExperimenter(experimenter)

Experimenter action

This action is an extensible action for the experimenter.

Attribute Description
experimenter Experimenter ID

Note

For the list of the supported Nicira experimenter actions, please refer to os_ken.ofproto.nx_actions.

Controller Status Structure

class os_ken.ofproto.ofproto_v1_5_parser.OFPControllerStatusStats(short_id=None, role=None, reason=None, channel_status=None, properties=None, length=None)

Controller status structure

Attribute Description
length Length of this entry.
short_id ID number which identifies the controller.
role

Bitmap of controller's role flags.

OFPCR_ROLE_NOCHANGE
OFPCR_ROLE_EQUAL
OFPCR_ROLE_MASTER
OFPCR_ROLE_SLAVE
reason

Bitmap of controller status reason flags.

OFPCSR_REQUEST
OFPCSR_CHANNEL_STATUS
OFPCSR_ROLE
OFPCSR_CONTROLLER_ADDED
OFPCSR_CONTROLLER_REMOVED
OFPCSR_SHORT_ID
OFPCSR_EXPERIMENTER
channel_status

Bitmap of control channel status flags.

OFPCT_STATUS_UP
OFPCT_STATUS_DOWN
properties List of OFPControllerStatusProp subclass instance
Creative Commons Attribution 3.0 License

Except where otherwise noted, this document is licensed under Creative Commons Attribution 3.0 License. See all OpenStack Legal Documents.