net.floodlightcontroller.core
Interface IOFSwitch

All Known Implementing Classes:
OFSwitchBase, OFSwitchImpl

public interface IOFSwitch

Author:
David Erickson (daviderickson@cs.stanford.edu)

Nested Class Summary
static class IOFSwitch.OFPortType
           
static class IOFSwitch.PortChangeEvent
          Describes a change of an open flow port
static class IOFSwitch.PortChangeType
          the type of change that happened to an open flow port
 
Field Summary
static java.lang.String PROP_REQUIRES_L3_MATCH
           
static java.lang.String PROP_SUPPORTS_NETMASK_TBL
           
static java.lang.String PROP_SUPPORTS_OFPP_FLOOD
           
static java.lang.String PROP_SUPPORTS_OFPP_TABLE
           
static java.lang.String SWITCH_DESCRIPTION_FUTURE
           
static java.lang.String SWITCH_IS_CORE_SWITCH
           
static java.lang.String SWITCH_SUPPORTS_NX_ROLE
           
 
Method Summary
 boolean attributeEquals(java.lang.String name, java.lang.Object other)
          Check if the given attribute is present and if so whether it is equal to "other"
 void cancelAllStatisticsReplies()
          Cancel all statistics replies
 void cancelFeaturesReply(int transactionId)
           
 void cancelStatisticsReply(int transactionId)
          Cancel the statistics reply with the given transaction ID
 void clearAllFlowMods()
          Clear all flowmods on this switch
 OrderedCollection<IOFSwitch.PortChangeEvent> comparePorts(java.util.Collection<ImmutablePort> ports)
          Compute the changes that would be required to replace the old ports of this switch with the new ports
 void deliverOFFeaturesReply(OFMessage reply)
          Deliver the featuresReply future reply
 void deliverStatisticsReply(OFStatisticsReply reply)
          Deliver the statistics future reply
 void disconnectOutputStream()
           
 void flush()
          Flush all flows queued for this switch in the current thread.
 short getAccessFlowPriority()
          Get the suggested priority to use when installing access flows in this switch.
 int getActions()
           
 java.lang.Object getAttribute(java.lang.String name)
          Set properties for switch specific behavior
 java.util.Map<java.lang.Object,java.lang.Object> getAttributes()
          Retrieves attributes of this switch
 int getBuffers()
          Returns switch features from features Reply
 int getCapabilities()
           
 java.util.Date getConnectedSince()
          Retrieves the date the switch connected to this controller
 short getCoreFlowPriority()
          Get the suggested priority to use when installing core flows in this switch.
 OFDescriptionStatistics getDescriptionStatistics()
           
 java.util.Collection<java.lang.Integer> getEnabledPortNumbers()
          Get list of the port numbers of all enabled ports.
 java.util.Collection<ImmutablePort> getEnabledPorts()
          Get list of all enabled ports.
 IFloodlightProviderService.Role getHARole()
          Get the current role of the controller for the switch
 long getId()
          Get the datapathId of the switch
 java.net.SocketAddress getInetAddress()
          Get the IP Address for the switch
 int getNextTransactionId()
          Returns the next available transaction id
 ImmutablePort getPort(int portNumber)
          Retrieve the port object by the port number.
 ImmutablePort getPort(java.lang.String portName)
          Retrieve the port object by the port name.
 java.util.Map<java.lang.Integer,java.lang.Long> getPortBroadcastHits()
          Get the portBroadcastCacheHits
 java.util.Collection<ImmutablePort> getPorts()
          Get list of all ports.
 IOFSwitch.OFPortType getPortType(int port_num)
          Return the type of OFPort
 java.lang.String getStringId()
          Get a string version of the ID for this switch
 byte getTables()
           
 boolean hasAttribute(java.lang.String name)
          Checks if a specific switch property exists for this switch
 boolean inputThrottled(OFMessage ofm)
          Called when OFMessage enters pipeline.
 boolean isActive()
          Check if the switch is active.
 boolean isConnected()
          Check if the switch is connected to this controller.
 boolean isDriverHandshakeComplete()
          Check if the sub-handshake for this switch driver has been completed.
 boolean isFastPort(int port_num)
          Can the port be turned on without forming a new loop?
 boolean isOverloaded()
          Return if the switch is currently overloaded.
 boolean isWriteThrottleEnabled()
          Return whether write throttling is enabled on the switch
 boolean portEnabled(int portNumber)
           
 boolean portEnabled(java.lang.String portName)
           
 void processDriverHandshakeMessage(OFMessage m)
          Pass the given OFMessage to the driver as part of this driver's sub-handshake.
 OrderedCollection<IOFSwitch.PortChangeEvent> processOFPortStatus(OFPortStatus ps)
          Add or modify a switch port.
 java.util.concurrent.Future<java.util.List<OFStatistics>> queryStatistics(OFStatisticsRequest request)
          Returns a Future object that can be used to retrieve the asynchronous OFStatisticsReply when it is available.
 java.util.concurrent.Future<OFFeaturesReply> querySwitchFeaturesReply()
          Returns a Future object that can be used to retrieve the asynchronous OFStatisticsReply when it is available.
 java.lang.Object removeAttribute(java.lang.String name)
          Set properties for switch specific behavior
 void sendStatsQuery(OFStatisticsRequest request, int xid, IOFMessageListener caller)
          Send a flow statistics request to the switch.
 void setAccessFlowPriority(short prio)
          Set the suggested priority to use when installing access flows in this switch.
 void setAttribute(java.lang.String name, java.lang.Object value)
          Set properties for switch specific behavior
 void setChannel(org.jboss.netty.channel.Channel channel)
          Set the netty Channel this switch instance is associated with Called immediately after instantiation
 void setConnected(boolean connected)
          Set whether the switch is connected
 void setCoreFlowPriority(short prio)
          Set the suggested priority to use when installing core flows in this switch.
 void setDebugCounterService(IDebugCounterService debugCounters)
          Set debug counter service for per-switch counters Called immediately after instantiation
 void setFeaturesReply(OFFeaturesReply featuresReply)
          Set the OFFeaturesReply message returned by the switch during initial handshake.
 void setFloodlightProvider(Controller controller)
          Set IFloodlightProviderService for this switch instance Called immediately after instantiation
 void setHARole(IFloodlightProviderService.Role role)
          Set switch's HA role to role.
 void setPortDescriptions(java.util.List<OFPortDescription> portDescriptions)
          Set the OFFeaturesReply message returned by the switch during initial handshake.
 OrderedCollection<IOFSwitch.PortChangeEvent> setPorts(java.util.Collection<ImmutablePort> ports)
          Replace the ports of this switch with the given ports.
 void setSwitchProperties(OFDescriptionStatistics description)
          Set the SwitchProperties based on it's description
 void setTableFull(boolean isFull)
          Set the flow table full flag in the switch
 void setThreadPoolService(IThreadPoolService threadPool)
          Set IThreadPoolService for this switch instance Called immediately after instantiation
 void startDriverHandshake()
          Start this switch driver's sub handshake.
 boolean updateBroadcastCache(java.lang.Long entry, java.lang.Integer port)
          Update broadcast cache
 void write(java.util.List<OFMessage> msglist, FloodlightContext bc)
          Writes the list of messages to the output stream, bypassing rate limiting.
 void write(OFMessage m, FloodlightContext bc)
          Writes to the OFMessage to the output stream, bypassing rate limiting.
 void writeThrottled(java.util.List<OFMessage> msglist, FloodlightContext bc)
          Writes the list of messages to the output stream, subject to rate limiting.
 void writeThrottled(OFMessage msg, FloodlightContext cntx)
          Write OFMessage to the output stream, subject to switch rate limiting.
 

Field Detail

SWITCH_DESCRIPTION_FUTURE

static final java.lang.String SWITCH_DESCRIPTION_FUTURE
See Also:
Constant Field Values

SWITCH_SUPPORTS_NX_ROLE

static final java.lang.String SWITCH_SUPPORTS_NX_ROLE
See Also:
Constant Field Values

SWITCH_IS_CORE_SWITCH

static final java.lang.String SWITCH_IS_CORE_SWITCH
See Also:
Constant Field Values

PROP_REQUIRES_L3_MATCH

static final java.lang.String PROP_REQUIRES_L3_MATCH
See Also:
Constant Field Values

PROP_SUPPORTS_OFPP_TABLE

static final java.lang.String PROP_SUPPORTS_OFPP_TABLE
See Also:
Constant Field Values

PROP_SUPPORTS_OFPP_FLOOD

static final java.lang.String PROP_SUPPORTS_OFPP_FLOOD
See Also:
Constant Field Values

PROP_SUPPORTS_NETMASK_TBL

static final java.lang.String PROP_SUPPORTS_NETMASK_TBL
See Also:
Constant Field Values
Method Detail

setFloodlightProvider

void setFloodlightProvider(Controller controller)
Set IFloodlightProviderService for this switch instance Called immediately after instantiation

Parameters:
controller -

setThreadPoolService

void setThreadPoolService(IThreadPoolService threadPool)
Set IThreadPoolService for this switch instance Called immediately after instantiation

Parameters:
threadPool -

setDebugCounterService

void setDebugCounterService(IDebugCounterService debugCounters)
                            throws IDebugCounterService.CounterException
Set debug counter service for per-switch counters Called immediately after instantiation

Parameters:
debugCounters -
Throws:
IDebugCounterService.CounterException

setChannel

void setChannel(org.jboss.netty.channel.Channel channel)
Set the netty Channel this switch instance is associated with Called immediately after instantiation

Parameters:
channel -

inputThrottled

boolean inputThrottled(OFMessage ofm)
Called when OFMessage enters pipeline. Returning true cause the message to be dropped.

Parameters:
ofm -
Returns:

isOverloaded

boolean isOverloaded()
Return if the switch is currently overloaded. The definition of overload refers to excessive traffic in the control path, namely a high packet in rate.

Returns:

writeThrottled

void writeThrottled(OFMessage msg,
                    FloodlightContext cntx)
                    throws java.io.IOException
Write OFMessage to the output stream, subject to switch rate limiting. The message will be handed to the floodlightProvider for possible filtering and processing by message listeners

Parameters:
msg -
cntx -
Throws:
java.io.IOException

writeThrottled

void writeThrottled(java.util.List<OFMessage> msglist,
                    FloodlightContext bc)
                    throws java.io.IOException
Writes the list of messages to the output stream, subject to rate limiting. The message will be handed to the floodlightProvider for possible filtering and processing by message listeners.

Parameters:
msglist -
bc -
Throws:
java.io.IOException

write

void write(OFMessage m,
           FloodlightContext bc)
           throws java.io.IOException
Writes to the OFMessage to the output stream, bypassing rate limiting. The message will be handed to the floodlightProvider for possible filtering and processing by message listeners

Parameters:
m -
bc -
Throws:
java.io.IOException

write

void write(java.util.List<OFMessage> msglist,
           FloodlightContext bc)
           throws java.io.IOException
Writes the list of messages to the output stream, bypassing rate limiting. The message will be handed to the floodlightProvider for possible filtering and processing by message listeners.

Parameters:
msglist -
bc -
Throws:
java.io.IOException

disconnectOutputStream

void disconnectOutputStream()
Throws:
java.io.IOException

getBuffers

int getBuffers()
Returns switch features from features Reply

Returns:

getActions

int getActions()

getCapabilities

int getCapabilities()

getTables

byte getTables()

getDescriptionStatistics

OFDescriptionStatistics getDescriptionStatistics()
Returns:
a copy of the description statistics for this switch

setFeaturesReply

void setFeaturesReply(OFFeaturesReply featuresReply)
Set the OFFeaturesReply message returned by the switch during initial handshake.

Parameters:
featuresReply -

setPortDescriptions

void setPortDescriptions(java.util.List<OFPortDescription> portDescriptions)
Set the OFFeaturesReply message returned by the switch during initial handshake.

Parameters:
featuresReply -

getEnabledPorts

java.util.Collection<ImmutablePort> getEnabledPorts()
Get list of all enabled ports. This will typically be different from the list of ports in the OFPortDescription rpely, since that one is a static snapshot of the ports at the time the switch connected to the controller whereas this port list also reflects the port status messages that have been received.

Returns:
Unmodifiable list of ports not backed by the underlying collection

getEnabledPortNumbers

java.util.Collection<java.lang.Integer> getEnabledPortNumbers()
Get list of the port numbers of all enabled ports. This will typically be different from the list of ports in the OFFeaturesReply, since that one is a static snapshot of the ports at the time the switch connected to the controller whereas this port list also reflects the port status messages that have been received.

Returns:
Unmodifiable list of ports not backed by the underlying collection

getPort

ImmutablePort getPort(int portNumber)
Retrieve the port object by the port number. The port object is the one that reflects the port status updates that have been received, not the one from the features reply.

Parameters:
portNumber -
Returns:
port object

getPort

ImmutablePort getPort(java.lang.String portName)
Retrieve the port object by the port name. The port object is the one that reflects the port status updates that have been received, not the one from the features reply. Port names are case insentive

Parameters:
portName -
Returns:
port object

processOFPortStatus

OrderedCollection<IOFSwitch.PortChangeEvent> processOFPortStatus(OFPortStatus ps)
Add or modify a switch port. This is called by the core controller code in response to a OFPortStatus message. It should not typically be called by other floodlight applications. OFPPR_MODIFY and OFPPR_ADD will be treated as equivalent. The OpenFlow spec is not clear on whether portNames are portNumbers are considered authoritative identifiers. We treat portNames <-> portNumber mappings as fixed. If they change, we delete all previous conflicting ports and add all new ports.

Parameters:
ps - the port status message
Returns:
the ordered Collection of changes "applied" to the old ports of the switch according to the PortStatus message. A single PortStatus message can result in multiple changes. If portName <-> portNumber mappings have changed, the iteration order ensures that delete events for old conflicting appear before before events adding new ports

getPorts

java.util.Collection<ImmutablePort> getPorts()
Get list of all ports. This will typically be different from the list of ports in the OFFeaturesReply, since that one is a static snapshot of the ports at the time the switch connected to the controller whereas this port list also reflects the port status messages that have been received.

Returns:
Unmodifiable list of ports

portEnabled

boolean portEnabled(int portNumber)
Parameters:
portNumber -
Returns:
Whether a port is enabled per latest port status message (not configured down nor link down nor in spanning tree blocking state)

portEnabled

boolean portEnabled(java.lang.String portName)
Parameters:
portNumber -
Returns:
Whether a port is enabled per latest port status message (not configured down nor link down nor in spanning tree blocking state)

comparePorts

OrderedCollection<IOFSwitch.PortChangeEvent> comparePorts(java.util.Collection<ImmutablePort> ports)
Compute the changes that would be required to replace the old ports of this switch with the new ports

Parameters:
ports - new ports to set
Returns:
the ordered collection of changes "applied" to the old ports of the switch in order to set them to the new set. If portName <-> portNumber mappings have changed, the iteration order ensures that delete events for old conflicting appear before before events adding new ports

setPorts

OrderedCollection<IOFSwitch.PortChangeEvent> setPorts(java.util.Collection<ImmutablePort> ports)
Replace the ports of this switch with the given ports.

Parameters:
ports - new ports to set
Returns:
the ordered collection of changes "applied" to the old ports of the switch in order to set them to the new set. If portName <-> portNumber mappings have changed, the iteration order ensures that delete events for old conflicting appear before before events adding new ports

getId

long getId()
Get the datapathId of the switch

Returns:

getStringId

java.lang.String getStringId()
Get a string version of the ID for this switch

Returns:

getInetAddress

java.net.SocketAddress getInetAddress()
Get the IP Address for the switch

Returns:
the inet address

getAttributes

java.util.Map<java.lang.Object,java.lang.Object> getAttributes()
Retrieves attributes of this switch

Returns:

getConnectedSince

java.util.Date getConnectedSince()
Retrieves the date the switch connected to this controller

Returns:
the date

getNextTransactionId

int getNextTransactionId()
Returns the next available transaction id

Returns:

queryStatistics

java.util.concurrent.Future<java.util.List<OFStatistics>> queryStatistics(OFStatisticsRequest request)
                                                                          throws java.io.IOException
Returns a Future object that can be used to retrieve the asynchronous OFStatisticsReply when it is available.

Parameters:
request - statistics request
Returns:
Future object wrapping OFStatisticsReply
Throws:
java.io.IOException

querySwitchFeaturesReply

java.util.concurrent.Future<OFFeaturesReply> querySwitchFeaturesReply()
                                                                      throws java.io.IOException
Returns a Future object that can be used to retrieve the asynchronous OFStatisticsReply when it is available.

Parameters:
request - statistics request
Returns:
Future object wrapping OFStatisticsReply
Throws:
java.io.IOException

deliverOFFeaturesReply

void deliverOFFeaturesReply(OFMessage reply)
Deliver the featuresReply future reply

Parameters:
reply - the reply to deliver

cancelFeaturesReply

void cancelFeaturesReply(int transactionId)

isConnected

boolean isConnected()
Check if the switch is connected to this controller. Whether a switch is connected is independent of whether the switch is active

Returns:
whether the switch is still disconnected

isActive

boolean isActive()
Check if the switch is active. I.e., the switch is connected to this controller and is in master role

Returns:

setConnected

void setConnected(boolean connected)
Set whether the switch is connected

Parameters:
connected - whether the switch is connected

getHARole

IFloodlightProviderService.Role getHARole()
Get the current role of the controller for the switch

Returns:
the role of the controller

setHARole

void setHARole(IFloodlightProviderService.Role role)
Set switch's HA role to role. The haRoleReplyReceived indicates if a reply was received from the switch (error replies excluded). If role is null, the switch should close the channel connection.

Parameters:
role -
haRoleReplyReceived -

deliverStatisticsReply

void deliverStatisticsReply(OFStatisticsReply reply)
Deliver the statistics future reply

Parameters:
reply - the reply to deliver

cancelStatisticsReply

void cancelStatisticsReply(int transactionId)
Cancel the statistics reply with the given transaction ID

Parameters:
transactionId - the transaction ID

cancelAllStatisticsReplies

void cancelAllStatisticsReplies()
Cancel all statistics replies


hasAttribute

boolean hasAttribute(java.lang.String name)
Checks if a specific switch property exists for this switch

Parameters:
name - name of property
Returns:
value for name

getAttribute

java.lang.Object getAttribute(java.lang.String name)
Set properties for switch specific behavior

Parameters:
name - name of property
Returns:
value for name

attributeEquals

boolean attributeEquals(java.lang.String name,
                        java.lang.Object other)
Check if the given attribute is present and if so whether it is equal to "other"

Parameters:
name - the name of the attribute to check
other - the object to compare the attribute against.
Returns:
true iff the specified attribute is set and equals() the given other object.

setAttribute

void setAttribute(java.lang.String name,
                  java.lang.Object value)
Set properties for switch specific behavior

Parameters:
name - name of property
value - value for name

removeAttribute

java.lang.Object removeAttribute(java.lang.String name)
Set properties for switch specific behavior

Parameters:
name - name of property
Returns:
current value for name or null (if not present)

clearAllFlowMods

void clearAllFlowMods()
Clear all flowmods on this switch


updateBroadcastCache

boolean updateBroadcastCache(java.lang.Long entry,
                             java.lang.Integer port)
Update broadcast cache

Parameters:
data -
Returns:
true if there is a cache hit false if there is no cache hit.

getPortBroadcastHits

java.util.Map<java.lang.Integer,java.lang.Long> getPortBroadcastHits()
Get the portBroadcastCacheHits

Returns:

sendStatsQuery

void sendStatsQuery(OFStatisticsRequest request,
                    int xid,
                    IOFMessageListener caller)
                    throws java.io.IOException
Send a flow statistics request to the switch. This call returns after sending the stats. request to the switch.

Parameters:
request - flow statistics request message
xid - transaction id, must be obtained by using the getXid() API.
caller - the caller of the API. receive() callback of this caller would be called when the reply from the switch is received.
Throws:
java.io.IOException

flush

void flush()
Flush all flows queued for this switch in the current thread. NOTE: The contract is limited to the current thread


setSwitchProperties

void setSwitchProperties(OFDescriptionStatistics description)
Set the SwitchProperties based on it's description

Parameters:
description -

getPortType

IOFSwitch.OFPortType getPortType(int port_num)
Return the type of OFPort

Parameters:
port_num -
Returns:

isFastPort

boolean isFastPort(int port_num)
Can the port be turned on without forming a new loop?

Parameters:
port_num -
Returns:

isWriteThrottleEnabled

boolean isWriteThrottleEnabled()
Return whether write throttling is enabled on the switch


setTableFull

void setTableFull(boolean isFull)
Set the flow table full flag in the switch


setAccessFlowPriority

void setAccessFlowPriority(short prio)
Set the suggested priority to use when installing access flows in this switch.


setCoreFlowPriority

void setCoreFlowPriority(short prio)
Set the suggested priority to use when installing core flows in this switch.


getAccessFlowPriority

short getAccessFlowPriority()
Get the suggested priority to use when installing access flows in this switch.


getCoreFlowPriority

short getCoreFlowPriority()
Get the suggested priority to use when installing core flows in this switch.


startDriverHandshake

void startDriverHandshake()
Start this switch driver's sub handshake. This might be a no-op but this method must be called at least once for the switch to be become ready. This method must only be called from the I/O thread

Throws:
SwitchDriverSubHandshakeAlreadyStarted - if the sub-handshake has already been started

isDriverHandshakeComplete

boolean isDriverHandshakeComplete()
Check if the sub-handshake for this switch driver has been completed. This method can only be called after startDriverHandshake() This methods must only be called from the I/O thread

Returns:
true if the sub-handshake has been completed. False otherwise
Throws:
SwitchDriverSubHandshakeNotStarted - if startDriverHandshake() has not been called yet.

processDriverHandshakeMessage

void processDriverHandshakeMessage(OFMessage m)
Pass the given OFMessage to the driver as part of this driver's sub-handshake. Must not be called after the handshake has been completed This methods must only be called from the I/O thread

Parameters:
m - The message that the driver should process
Throws:
SwitchDriverSubHandshakeCompleted - if isDriverHandshake() returns false before this method call
SwitchDriverSubHandshakeNotStarted - if startDriverHandshake() has not been called yet.