interfaces package

Submodules

interfaces.base module

Module ‘base’ serves as a base for communication modules for SDN controllers.

This module defines classes that are to ensure communication with an SDN controller and store retrieved data. It is of an abstract nature and not meant to be used itself. Instead, it should be used to create modules tailored for particular controllers.

class interfaces.base.BaseNetwork

Bases: object

Defines methods for controller communication.

This abstract class is to be subclassed by a controller-specific communication interface. It defines methods that have to be implemented, and gathers data structures for storing data retrieved from the controller.

add_flow(datapath, src_ip, dst_ip, in_port, out_port, priority, idle_timeout, hard_timeout, **kwargs)

Push a flow entry of the given parameters into the given datapath.

This method has to be overriden.

Parameters:
  • datapath (Datapath) – Datapath to install the new flow entry.
  • src_ip (string) – Source IPv4 address to match.
  • dst_ip (string) – Destination IPv4 address to match.
  • in_port (int) – Packet ingress port to match.
  • out_port (int) – Port to send the packet out.
  • priority (int) – Priority (0-65535).
  • idle_timeout (int) – Idle timeout (0-65535).
  • hard_timeout (int) – Hard timeout (0-65535).
  • **kwargs – Listed below.
Keyword Arguments:
 
  • protocol (enums.IpProtocol) – IP protocol.
  • tcp_src (int) – TCP source port.
  • tcp_dst (int) – TCP destination port.
  • udp_src (int) – UDP source port.
  • udp_dst (int) – UDP destination port.
connect(server, user, password)

Connect to a controller.

This method has to be overriden.

Parameters:
  • server (string) – IP address of the server running the controller software.
  • user (string) – Username to log in to the controller.
  • password (string) – Password to log in to the controller.
datapath_by_dpid(dpid)

Return a Datapath object for the given DPID.

Returns:
  • Datapath – When a datapath with the given DPID exists in the network.
  • None – When a datapath with the given DPID does not exist in the network.
datapaths

Get list of Datapath objects.

Get set of Link objects.

load()

Load network information into instance variables.

This method has to be overriden.

node_by_mac(mac)

Return a Node object for the given MAC address.

Returns:
  • Node – When a node with the given MAC address exists in the network.
  • None – When a node with the given MAC address does not exist in the network.
nodes

Get list of Node objects.

update(interval)

Update network information and return the differences.

This method has to be overriden.

Parameters:interval (int) – Interval in which network updates are performed.
Returns:A summary of changes in the network - devices to add or remove, links to connect or disconnect.
Return type:Update
class interfaces.base.Datapath(dpid, ip, of_version)

Bases: object

A representation of a networking device - a datapath.

connect(port, device)

Connect the given device to the given port.

Parameters:
  • port (int) – Port number.
  • device (Datapath or Node) – Device to connect.
disconnect_device(device)

Disconnect the given device from the datapath.

Parameters:device (Datapath or Node) – Device to disconnect.
disconnect_port(port)

Disconnect the device connected to the given port.

Parameters:port (int) – Port number.
has_connected(device)

Return whether the given device is connected to the datapath.

Parameters:device (Datapath or Node) – Device to inquire.
Returns:True when the device is connected to the datapath, False otherwise.
Return type:bool
port_of_device(device)

Return the port to which the given device is connected.

Parameters:device (Datapath or Node) – Device to inquire.
Returns:
  • int – Port number.
  • None – In case the device is not connected to the datapath.
port_stats(port)

Return port statistics for the given port.

Parameters:port (int) – Port number.
Returns:
  • PortStats – Port statistics.
  • None – In case the port is not alive.
update_port_stats(port, interval, rx_bytes, tx_bytes)

Update port statistics for the given port.

Parameters:
  • port (int) – Port number.
  • interval (int) – Interval between individual updates in seconds.
  • rx_bytes (int) – Received bytes.
  • tx_bytes (int) – Transmitted bytes.

Bases: object

A representation of a connection between two devices.

class interfaces.base.Node(mac, ip, parent, parent_port)

Bases: object

A representation of an end-node device.

class interfaces.base.PortStats

Bases: object

A data container to hold statistics for a datapath port.

class interfaces.base.Update

Bases: object

A data container to hold changes in the network for a single update.

interfaces.factory module

Module ‘factory’ provides the means to access available interface modules.

interfaces.factory.create(name)

Return an instance of the Network class of a particular module.

Parameters:name (string) – Name of the particular interface module.
Returns:A fresh instance of the Network class of the interface module of the given name
Return type:Network

interfaces.hpe module

Module ‘hpe’ is an interface for communication with the HPE VAN SDN Controller.

This module is based on the ‘base’ module - it implements the BaseNetwork abstract class and its abstract methods. It implements the functionality to establish a connection with the controller, to retrieve required data, and to push data back to the controller.

class interfaces.hpe.Network

Bases: interfaces.base.BaseNetwork

Defines methods for controller communication.

add_flow(datapath, src_ip, dst_ip, in_port, out_port, priority, idle_timeout, hard_timeout, **kwargs)

Push a flow entry of the given parameters into the given datapath.

Parameters:
  • datapath (Datapath) – Datapath to install the new flow entry.
  • src_ip (string) – Source IPv4 address to match.
  • dst_ip (string) – Destination IPv4 address to match.
  • in_port (int) – Packet ingress port to match.
  • out_port (int) – Port to send the packet out.
  • priority (int) – Priority (0-65535).
  • idle_timeout (int) – Idle timeout (0-65535).
  • hard_timeout (int) – Hard timeout (0-65535).
  • **kwargs – Listed below.
Keyword Arguments:
 
  • protocol (enums.IpProtocol) – IP protocol.
  • tcp_src (int) – TCP source port.
  • tcp_dst (int) – TCP destination port.
  • udp_src (int) – UDP source port.
  • udp_dst (int) – UDP destination port.
connect(server, user, password)

Connect to a controller.

This method has to be overriden.

Parameters:
  • server (string) – IP address of the server running the controller software.
  • user (string) – Username to log in to the controller.
  • password (string) – Password to log in to the controller.
load()

Load network information into instance variables.

update(interval)

Update network information and return the differences.

Parameters:interval (int) – Interval in which network updates are performed.
Returns:A summary of changes in the network - devices to add or remove, links to connect or disconnect.
Return type:Update

Module contents