switches module¶
This module is part of the nmeta suite running on top of Ryu SDN controller.
It provides classes that abstract the details of OpenFlow switches
-
class
switches.Switches(config)¶ Bases:
baseclass.BaseClassThis class provides an abstraction for a set of OpenFlow Switches.
It stores instances of the Switch class in a dictionary keyed by DPID. The switch instances are accessible externally.
A standard (not capped) MongoDB database collection is used to record switch details so that they can be accessed via the external API.
-
add(datapath)¶ Add a switch to the Switches class
-
stats_reply(msg)¶ Read in a switch stats reply
-
delete(datapath)¶ Delete a switch from the Switches class
-
-
class
switches.Switch(config, datapath, offset)¶ Bases:
baseclass.BaseClassThis class provides an abstraction for an OpenFlow Switch
-
dbdict()¶ Return a dictionary object of switch parameters for storing in the database
-
request_switch_desc()¶ Send an OpenFlow request to the switch asking it to send us it’s description data
-
set_switch_config(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.
-
packet_out(data, in_port, out_port, out_queue, no_queue=0)¶ Sends a supplied packet out switch port(s) in specific queue.
Set no_queue=1 if want no queueing specified (i.e. for a flooded packet). Also use for Zodiac FX compatibility.
Does not use Buffer IDs as they are unreliable resource.
-
set_switch_table_miss(miss_send_len)¶ Set a table miss rule on table 0 to send packets to the controller. This is required for OF versions higher than v1.0
-
-
class
switches.FlowTables(config, datapath, offset)¶ Bases:
baseclass.BaseClassThis class provides an abstraction for the flow tables on an OpenFlow Switch
-
suppress_flow(msg, in_port, out_port, out_queue)¶ Add flow entries to a switch to suppress further packet-in events while the flow is active.
Prefer to do fine-grained match where possible. Install reverse matches as well for TCP flows.
Do not install suppression for these types of flow: - DNS (want to harvest identity) - ARP (want to harvest identity) - DHCP (want to harvest identity) - LLDP (want to harvest identity)
-
drop_flow(msg)¶ Add flow entry to a switch to suppress further packet-in events for a particular flow.
Prefer to do fine-grained match where possible.
TCP or UDP source ports are not matched as ephemeral
-
add_flow(match_d, actions, priority, idle_timeout, hard_timeout, cookie)¶ Add a flow entry to a switch
-
actions(out_port, out_queue, no_queue=0)¶ Create actions for a switch flow entry. Specify the out port and QoS queue, and set no_queue=1 if don’t want QoS set. Returns a list of action objects
-
match_ipv4_tcp(ipv4_src, ipv4_dst, tcp_src, tcp_dst)¶ Match an IPv4 TCP flow on a switch. Passed IPv4 and TCP parameters and return an OpenFlow match object for this flow
-
match_ipv4_udp(ipv4_src, ipv4_dst, udp_src, udp_dst)¶ Match an IPv4 UDP flow on a switch. Passed IPv4 and UDP parameters and return an OpenFlow match object for this flow
-
match_ipv6_tcp(ipv6_src, ipv6_dst, tcp_src, tcp_dst)¶ Match an IPv6 TCP flow on a switch. Passed IPv6 and TCP parameters and return an OpenFlow match object for this flow
-
match_ipv6_udp(ipv6_src, ipv6_dst, udp_src, udp_dst)¶ Match an IPv6 UDP flow on a switch. Passed IPv6 and UDP parameters and return an OpenFlow match object for this flow
-
match_ipv4(ipv4_src, ipv4_dst, ip_proto)¶ Match an IPv4 flow on a switch. Passed IPv4 parameters and return an OpenFlow match object for this flow
-
match_ipv6(ipv6_src, ipv6_dst)¶ Match an IPv6 flow on a switch. Passed IPv6 parameters and return an OpenFlow match object for this flow
-
-
switches._ipv4_t2i(ip_text)¶ Turns an IPv4 address in text format into an integer. Borrowed from rest_router.py code