net.floodlightcontroller.routing
Class ForwardingBase

java.lang.Object
  extended by net.floodlightcontroller.routing.ForwardingBase
All Implemented Interfaces:
IListener<OFType>, IOFMessageListener
Direct Known Subclasses:
Forwarding

public abstract class ForwardingBase
extends java.lang.Object
implements IOFMessageListener

Abstract base class for implementing a forwarding module. Forwarding is responsible for programming flows to a switch in response to a policy decision.


Nested Class Summary
 
Nested classes/interfaces inherited from interface net.floodlightcontroller.core.IListener
IListener.Command
 
Field Summary
static long appCookie
           
 TimedCache<java.lang.Long> broadcastCache
           
protected  boolean broadcastCacheFeature
           
 java.util.Comparator<SwitchPort> clusterIdComparator
           
protected  ICounterStoreService counterStore
           
protected  IDeviceService deviceManager
           
protected  IFloodlightProviderService floodlightProvider
           
static short FLOWMOD_DEFAULT_HARD_TIMEOUT
           
static short FLOWMOD_DEFAULT_HARD_TIMEOUT_CONSTANT
           
static short FLOWMOD_DEFAULT_IDLE_TIMEOUT
           
static short FLOWMOD_DEFAULT_IDLE_TIMEOUT_CONSTANT
           
static int FORWARDING_APP_ID
           
protected static org.slf4j.Logger log
           
protected  OFMessageDamper messageDamper
           
protected static int OFMESSAGE_DAMPER_CAPACITY
           
protected static int OFMESSAGE_DAMPER_TIMEOUT
           
 int prime1
           
static int prime2
           
protected  IRoutingService routingEngine
           
protected  ITopologyService topology
           
 
Constructor Summary
ForwardingBase()
           
 
Method Summary
static boolean blockHost(IFloodlightProviderService floodlightProvider, SwitchPort sw_tup, long host_mac, short hardTimeout, long cookie)
           
 java.lang.String getName()
          Returns the application name "forwarding".
protected  void init()
          init data structures
 boolean isCallbackOrderingPostreq(OFType type, java.lang.String name)
          Check if the module called name is a callback ordering post-requisite for this module.
 boolean isCallbackOrderingPrereq(OFType type, java.lang.String name)
          Check if the module called name is a callback ordering prerequisite for this module.
protected  boolean isInBroadcastCache(IOFSwitch sw, OFPacketIn pi, FloodlightContext cntx)
           
protected  boolean isInSwitchBroadcastCache(IOFSwitch sw, OFPacketIn pi, FloodlightContext cntx)
           
 void packetOutMultiPort(byte[] packetData, IOFSwitch sw, int inPort, java.util.Set<java.lang.Integer> outPorts, FloodlightContext cntx)
          Write packetout message to sw with output actions to one or more output ports with inPort/outPorts passed in.
 void packetOutMultiPort(IPacket packet, IOFSwitch sw, int inPort, java.util.Set<java.lang.Integer> outPorts, FloodlightContext cntx)
           
 void packetOutMultiPort(OFPacketIn pi, IOFSwitch sw, int inPort, java.util.Set<java.lang.Integer> outPorts, FloodlightContext cntx)
           
abstract  IListener.Command processPacketInMessage(IOFSwitch sw, OFPacketIn pi, IRoutingDecision decision, FloodlightContext cntx)
          All subclasses must define this function if they want any specific forwarding action
protected  void pushPacket(IOFSwitch sw, OFPacketIn pi, boolean useBufferId, int outport, FloodlightContext cntx)
          Pushes a packet-out to a switch.
 boolean pushRoute(Route route, OFMatch match, java.util.EnumSet<OFOXMFieldType> nonWildcards, OFPacketIn pi, long pinSwitch, long cookie, FloodlightContext cntx, boolean reqeustFlowRemovedNotifn, boolean doFlush, byte flowModCommand)
          Push routes from back to front
 IListener.Command receive(IOFSwitch sw, OFMessage msg, FloodlightContext cntx)
          This is the method Floodlight uses to call listeners with OpenFlow messages
protected  void startUp()
          Adds a listener for devicemanager and registers for PacketIns.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

protected static org.slf4j.Logger log

OFMESSAGE_DAMPER_CAPACITY

protected static int OFMESSAGE_DAMPER_CAPACITY

OFMESSAGE_DAMPER_TIMEOUT

protected static int OFMESSAGE_DAMPER_TIMEOUT

FLOWMOD_DEFAULT_IDLE_TIMEOUT

public static short FLOWMOD_DEFAULT_IDLE_TIMEOUT

FLOWMOD_DEFAULT_HARD_TIMEOUT

public static short FLOWMOD_DEFAULT_HARD_TIMEOUT

FLOWMOD_DEFAULT_IDLE_TIMEOUT_CONSTANT

public static final short FLOWMOD_DEFAULT_IDLE_TIMEOUT_CONSTANT
See Also:
Constant Field Values

FLOWMOD_DEFAULT_HARD_TIMEOUT_CONSTANT

public static final short FLOWMOD_DEFAULT_HARD_TIMEOUT_CONSTANT
See Also:
Constant Field Values

floodlightProvider

protected IFloodlightProviderService floodlightProvider

deviceManager

protected IDeviceService deviceManager

routingEngine

protected IRoutingService routingEngine

topology

protected ITopologyService topology

counterStore

protected ICounterStoreService counterStore

messageDamper

protected OFMessageDamper messageDamper

broadcastCacheFeature

protected boolean broadcastCacheFeature

prime1

public final int prime1
See Also:
Constant Field Values

prime2

public static final int prime2
See Also:
Constant Field Values

broadcastCache

public TimedCache<java.lang.Long> broadcastCache

FORWARDING_APP_ID

public static final int FORWARDING_APP_ID
See Also:
Constant Field Values

appCookie

public static final long appCookie

clusterIdComparator

public java.util.Comparator<SwitchPort> clusterIdComparator
Constructor Detail

ForwardingBase

public ForwardingBase()
Method Detail

init

protected void init()
init data structures


startUp

protected void startUp()
Adds a listener for devicemanager and registers for PacketIns.


getName

public java.lang.String getName()
Returns the application name "forwarding".

Specified by:
getName in interface IListener<OFType>
Returns:

processPacketInMessage

public abstract IListener.Command processPacketInMessage(IOFSwitch sw,
                                                         OFPacketIn pi,
                                                         IRoutingDecision decision,
                                                         FloodlightContext cntx)
All subclasses must define this function if they want any specific forwarding action

Parameters:
sw - Switch that the packet came in from
pi - The packet that came in
decision - Any decision made by a policy engine

receive

public IListener.Command receive(IOFSwitch sw,
                                 OFMessage msg,
                                 FloodlightContext cntx)
Description copied from interface: IOFMessageListener
This is the method Floodlight uses to call listeners with OpenFlow messages

Specified by:
receive in interface IOFMessageListener
Parameters:
sw - the OpenFlow switch that sent this message
msg - the message
cntx - a Floodlight message context object you can use to pass information between listeners
Returns:
the command to continue or stop the execution

pushRoute

public boolean pushRoute(Route route,
                         OFMatch match,
                         java.util.EnumSet<OFOXMFieldType> nonWildcards,
                         OFPacketIn pi,
                         long pinSwitch,
                         long cookie,
                         FloodlightContext cntx,
                         boolean reqeustFlowRemovedNotifn,
                         boolean doFlush,
                         byte flowModCommand)
Push routes from back to front

Parameters:
route - Route to push
match - OpenFlow fields to match on
srcSwPort - Source switch port for the first hop
dstSwPort - Destination switch port for final hop
cookie - The cookie to set in each flow_mod
cntx - The floodlight context
reqeustFlowRemovedNotifn - if set to true then the switch would send a flow mod removal notification when the flow mod expires
doFlush - if set to true then the flow mod would be immediately written to the switch
flowModCommand - flow mod. command to use, e.g. OFFlowMod.OFPFC_ADD, OFFlowMod.OFPFC_MODIFY etc.
Returns:
srcSwitchIincluded True if the source switch is included in this route

pushPacket

protected void pushPacket(IOFSwitch sw,
                          OFPacketIn pi,
                          boolean useBufferId,
                          int outport,
                          FloodlightContext cntx)
Pushes a packet-out to a switch. If bufferId != BUFFER_ID_NONE we assume that the packetOut switch is the same as the packetIn switch and we will use the bufferId. In this case the packet can be null Caller needs to make sure that inPort and outPort differs

Parameters:
packet - packet data to send.
sw - switch from which packet-out is sent
bufferId - bufferId
inPort - input port
outPort - output port
cntx - context of the packet
flush - force to flush the packet.

packetOutMultiPort

public void packetOutMultiPort(byte[] packetData,
                               IOFSwitch sw,
                               int inPort,
                               java.util.Set<java.lang.Integer> outPorts,
                               FloodlightContext cntx)
Write packetout message to sw with output actions to one or more output ports with inPort/outPorts passed in.

Parameters:
packetData -
sw -
inPort -
ports -
cntx -

packetOutMultiPort

public void packetOutMultiPort(OFPacketIn pi,
                               IOFSwitch sw,
                               int inPort,
                               java.util.Set<java.lang.Integer> outPorts,
                               FloodlightContext cntx)
See Also:
Accepts a PacketIn instead of raw packet data. Note that the inPort and switch can be different than the packet in switch/port

packetOutMultiPort

public void packetOutMultiPort(IPacket packet,
                               IOFSwitch sw,
                               int inPort,
                               java.util.Set<java.lang.Integer> outPorts,
                               FloodlightContext cntx)
See Also:
Accepts an IPacket instead of raw packet data. Note that the inPort and switch can be different than the packet in switch/port

isInBroadcastCache

protected boolean isInBroadcastCache(IOFSwitch sw,
                                     OFPacketIn pi,
                                     FloodlightContext cntx)

isInSwitchBroadcastCache

protected boolean isInSwitchBroadcastCache(IOFSwitch sw,
                                           OFPacketIn pi,
                                           FloodlightContext cntx)

blockHost

public static boolean blockHost(IFloodlightProviderService floodlightProvider,
                                SwitchPort sw_tup,
                                long host_mac,
                                short hardTimeout,
                                long cookie)

isCallbackOrderingPrereq

public boolean isCallbackOrderingPrereq(OFType type,
                                        java.lang.String name)
Description copied from interface: IListener
Check if the module called name is a callback ordering prerequisite for this module. In other words, if this function returns true for the given name, then this listener will be called after that message listener.

Specified by:
isCallbackOrderingPrereq in interface IListener<OFType>
Parameters:
type - the object type to which this applies
name - the name of the module
Returns:
whether name is a prerequisite.

isCallbackOrderingPostreq

public boolean isCallbackOrderingPostreq(OFType type,
                                         java.lang.String name)
Description copied from interface: IListener
Check if the module called name is a callback ordering post-requisite for this module. In other words, if this function returns true for the given name, then this listener will be called before that message listener.

Specified by:
isCallbackOrderingPostreq in interface IListener<OFType>
Parameters:
type - the object type to which this applies
name - the name of the module
Returns:
whether name is a post-requisite.