switch_abstraction module

This module is part of the nmeta suite running on top of Ryu SDN controller. It provides functions that abstract the details of OpenFlow calls, including differences between OpenFlow versions where practical

class switch_abstraction.SwitchAbstract(config)

Bases: baseclass.BaseClass

This class is instantiated by various other modules and provides methods for interacting with switches that are safe to use without need to for the calling program to know calls specific to the version of OpenFlow that the switch runs (where practical...)

add_flow(datapath, match, actions, **kwargs)

Add a flow table entry to a switch. Returns 1 for success or 0 for any type of error

Required kwargs are:
priority (0) buffer_id (None) idle_timeout (5) hard_timeout (0)
add_flow_eth(datapath, msg, **kwargs)

Add an ethernet (non-IP) flow table entry to a switch. Returns 1 for success or 0 for any type of error Uses Ethertype in match to prevent matching against IPv4 or IPv6 flows

add_flow_ip(datapath, msg, **kwargs)

Add an IP (v4 or v6) flow table entry to a switch. Returns 1 for success or 0 for any type of error Uses IP protocol number to prevent matching on TCP flows

add_flow_tcp(datapath, msg, **kwargs)

Add a TCP flow table entry to a switch. Returns 1 for success or 0 for any type of error

get_actions(datapath, ofv, out_port, out_queue)

Passed a datapath, an OpenFlow version an out port, an out queue and flood port # and build and return an appropriate set of actions for this

get_flow_match(datapath, ofproto, **kwargs)

Passed a OF protocol version and a Flow Match keyword arguments dict and return an OF match tailored for the OF version otherwise 0 (false) if compatibility not possible. TBD: validating values...

get_friendly_of_version(ofproto)

Passed an OF Protocol object and return a human-friendly version of the protocol revision number

get_in_port(msg, datapath, ofproto)

Passed a msg, datapath and OF protocol version and return the port that the packet came in on (version specific)

packet_out(datapath, msg, in_port, out_port, out_queue, nq=0)

Sends a supplied packet out switch port(s) in specific queue. Set nq=1 if want no queueing specified (i.e. for a flooded packet)

request_switch_desc(datapath)

Request that a switch send us it’s description data

set_switch_config(datapath, config_flags, miss_send_len)

Set config on a switch including config flags that instruct fragment handling behaviour and miss_send_len which controls the number of bytes sent to the controller when the output port is specified as the controller

set_switch_table_miss(datapath, miss_send_len, hw_desc, sw_desc)

Set a table miss rule on table 0 to send packets to the controller. This is required for OF versions higher than v1.0. Do not set on older OpenvSwitch as it causes packets to be sent to controller with no buffer and OpenvSwitch doesn’t need this rule as it punts to the controller regardless (contrary to specification?) Note: OVS 2.5.0 doesn’t do this, but not sure what point fix was applied to OVS, somewhere between 2.0.2 and 2.5.0