public class OFMLinkDiscovery extends OFModule implements ILinkDiscoveryService
OFMTopologyManager
.Modifier and Type | Class and Description |
---|---|
private class |
OFMLinkDiscovery.Disconnection
structure that holds a disconnected switches temporarily.
|
Modifier and Type | Field and Description |
---|---|
protected int |
BDDP_TASK_INTERVAL
Quarantine Task. 100ms.
|
protected int |
BDDP_TASK_SIZE
Quarantine Task. # of ports per iteration.
|
protected LLDPTLV |
controllerTLV |
private java.util.Set<OFMLinkDiscovery.Disconnection> |
disconnections
This is a set to hold information about disconnected switches and their ports temporarily.
|
protected int |
DISCOVERY_TASK_INTERVAL |
private static LLDPTLV |
forwardTLV |
private static long |
LINK_LOCAL_MASK |
private static long |
LINK_LOCAL_VALUE |
private java.util.ArrayList<ILinkDiscoveryListener> |
linkDiscoveryAware
topology aware components are called in the order they were added to the
the array
|
private Links |
links
Model of this module. initialized within initialize()
|
private static java.lang.String |
LLDP_BSN_DST_MAC_STRING |
private static byte[] |
LLDP_STANDARD_DST_MAC_STRING
LLDP Data Units (LLDPDUs) are sent to the destination MAC address 01:80:c2:00:00:0e.
|
protected int |
LLDP_TO_ALL_INTERVAL |
protected int |
LLDP_TO_KNOWN_INTERVAL
LLDP frequency for known links.
|
protected long |
lldpClock |
protected java.util.concurrent.LinkedBlockingQueue<NodePortTuple> |
maintenanceQueue |
private OFProtocol |
protocol |
protected java.util.concurrent.LinkedBlockingQueue<NodePortTuple> |
quarantineQueue
A list of ports that are quarantined for discovering links through
them.
|
private static LLDPTLV |
reverseTLV |
private static short |
TLV_DIRECTION_LENGTH |
private static byte |
TLV_DIRECTION_TYPE |
private static byte[] |
TLV_DIRECTION_VALUE_FORWARD |
private static byte[] |
TLV_DIRECTION_VALUE_REVERSE |
protected java.util.concurrent.BlockingQueue<ILinkDiscoveryListener.LDUpdate> |
updates |
controller
Constructor and Description |
---|
OFMLinkDiscovery()
Constructor that does nothing.
|
Modifier and Type | Method and Description |
---|---|
void |
addLinkUpdate(Link lt,
LinkInfo info)
This method is called by Links object to pass link update event to its listeners.
|
void |
addLinkUpdate(Link lt,
LinkInfo info,
ILinkDiscoveryListener.UpdateOperation operation)
This method is called by Links object to pass link update event to its listeners.
|
void |
addLinkUpdate(long switchId,
int portNum,
ILinkDiscoveryListener.UpdateOperation op)
Add a new LDUpdate object to the
updates queue. |
void |
addLinkUpdate(long switchId,
int portNum,
int status)
Add a new LDUpdate object to the
updates queue. |
void |
addListener(ILinkDiscoveryListener listener)
register listeners to the
ILinkDiscoveryService . |
private void |
addToMaintenanceQueue(NodePortTuple npt)
Add a switch port to maintenance queue.
|
private void |
addToQuarantineQueue(NodePortTuple npt)
Add a switch port to the quarantine queue.
|
void |
AddToSuppressLLDPs(long sw,
int port)
Adds a switch port to suppress lldp set
|
private void |
cleanDisconnectedSwitches()
This function removes link information on ports from the disconnected switches.
|
private void |
discoverLinks() |
private void |
discoverOnAllPorts()
Send LLDPs to all switch-ports
|
private void |
generateSwitchPortStatusUpdate(IOFSwitch sw,
short port) |
protected int |
getInputPort(org.openflow.protocol.interfaces.OFPacketIn pi) |
java.util.Map<Link,LinkInfo> |
getLinks()
Retrieves a map of all known link connections between OpenFlow switches
and the associated info (valid time, port states) for the link.
|
ILinkDiscovery.LinkType |
getLinkType(Link lt,
LinkInfo info)
Returns link type of a given link.
|
OFModel[] |
getModels()
returns the array of all
OFModel objects associated with this module. |
java.util.Set<java.lang.Integer> |
getQuarantinedPorts(long sw)
Get the set of quarantined ports on a switch
|
java.util.Set<NodePortTuple> |
getSuppressLLDPsInfo()
Retrieves a set of all switch ports on which lldps are suppressed.
|
java.util.Map<java.lang.Long,java.util.Set<Link>> |
getSwitchLinks()
Returns an unmodifiable map from switch id to a set of all links with it
as an endpoint.
|
private ILinkDiscoveryListener.UpdateOperation |
getUpdateOperation(int srcPortState) |
private ILinkDiscoveryListener.UpdateOperation |
getUpdateOperation(int srcPortState,
int dstPortState) |
protected boolean |
handleDisconnect(Connection conn)
Process the disconnection event from a switch.
|
protected boolean |
handleHandshakedEvent(Connection conn,
MessageContext context)
An abstract method that all subclasses should implement.
|
private boolean |
handleLldp(LLDP lldp,
IOFSwitch sw,
org.openflow.protocol.interfaces.OFPacketIn pi,
boolean isStandard,
java.util.List<org.openflow.protocol.OFMessage> outgoing)
From the LLDP packet received, this method first extract following information:
remote switch information
controller id (if this message is created by a controller)
direction of the message
The business logic of this method are as follows:
if the message is a standard LLDP which is not created by this controller, then drop it.
|
protected boolean |
handleMessage(Connection conn,
MessageContext context,
org.openflow.protocol.OFMessage msg,
java.util.List<org.openflow.protocol.OFMessage> outgoing)
Handle incoming messages that pass the test of filters.
|
private boolean |
handlePacketIn(IOFSwitch sw,
MessageContext context,
org.openflow.protocol.interfaces.OFPacketIn pi,
java.util.List<org.openflow.protocol.OFMessage> outgoing)
This method handles a PACKET_IN message as follows:
First, decapsulate the Ethernet part of the PACKET_IN payload.
|
private boolean |
handlePortStatus(IOFSwitch sw,
MessageContext context,
org.openflow.protocol.interfaces.OFPortStatus ps,
java.util.List<org.openflow.protocol.OFMessage> outgoing)
Handle PORT_STATUS message.
|
void |
initialize()
Initialize this module to receive
PACKET_IN messages with LLDP packets (Ethertype 0x88cc)
PORT_STATUS messages
Periodic tasks are also initiated.
|
private void |
initiatePeriodicDiscovery() |
private void |
initiatePeriodicQuarantineWorker() |
private void |
initiatePeriodicTopologyUpdate() |
boolean |
isAutoPortFastFeature()
Get the status of auto port fast feature.
|
private void |
processNewPort(IOFSwitch sw,
int portnum)
Process a new port.
|
private void |
removeFromMaintenanceQueue(NodePortTuple npt)
Remove a switch port from maintenance queue.
|
private void |
removeFromQuarantineQueue(NodePortTuple npt)
Remove a switch port from the quarantine queue.
|
void |
RemoveFromSuppressLLDPs(long sw,
int port)
Removes a switch port from suppress lldp set
|
private boolean |
sendDiscoveryMessage(IOFSwitch sw,
int port,
boolean isStandard,
boolean isReverse)
Send link discovery message out of a given switch port.
|
void |
sendDiscoveryMessage(long switchId,
short destinationPort,
boolean isStandard,
boolean isReverse)
This method is called by Links object to make manager to send link discovery messages to peers.
|
void |
setAutoPortFastFeature(boolean autoPortFastFeature)
Set the state for auto port fast feature.
|
private void |
setControllerTLV()
This is an initialization routine for
controllerTLV . |
java.lang.String |
toString() |
getController, getModule, init, processDisconnect, processHandshakeFinished, processMessage, registerFilter, registerModule
private static final byte[] LLDP_STANDARD_DST_MAC_STRING
private static final long LINK_LOCAL_MASK
private static final long LINK_LOCAL_VALUE
private static final java.lang.String LLDP_BSN_DST_MAC_STRING
private static final byte TLV_DIRECTION_TYPE
private static final short TLV_DIRECTION_LENGTH
private static final byte[] TLV_DIRECTION_VALUE_FORWARD
private static final byte[] TLV_DIRECTION_VALUE_REVERSE
protected final int DISCOVERY_TASK_INTERVAL
protected final int LLDP_TO_ALL_INTERVAL
protected long lldpClock
protected final int LLDP_TO_KNOWN_INTERVAL
protected final int BDDP_TASK_INTERVAL
protected final int BDDP_TASK_SIZE
private static final LLDPTLV forwardTLV
private static final LLDPTLV reverseTLV
protected LLDPTLV controllerTLV
protected java.util.concurrent.LinkedBlockingQueue<NodePortTuple> quarantineQueue
protected java.util.concurrent.LinkedBlockingQueue<NodePortTuple> maintenanceQueue
protected java.util.concurrent.BlockingQueue<ILinkDiscoveryListener.LDUpdate> updates
private java.util.ArrayList<ILinkDiscoveryListener> linkDiscoveryAware
private java.util.Set<OFMLinkDiscovery.Disconnection> disconnections
private Links links
private OFProtocol protocol
protected int getInputPort(org.openflow.protocol.interfaces.OFPacketIn pi)
public void initialize()
initialize
in class OFModule
public void addLinkUpdate(Link lt, LinkInfo info)
Links.addOrUpdateLink(Link, LinkInfo)
(2) Links.timeoutLinks()
(3) Links.updatePortStatus(Long, int, OFPortStatus)
lt
- Link objectinfo
- LinkInfo objectpublic void addLinkUpdate(Link lt, LinkInfo info, ILinkDiscoveryListener.UpdateOperation operation)
lt
- Link objectinfo
- LinkInfo objectoperation
- UpdateOperation valuepublic void addLinkUpdate(long switchId, int portNum, ILinkDiscoveryListener.UpdateOperation op)
updates
queue.switchId
- identifier of the switchportNum
- number of the portop
- update operation. see ILinkDiscoveryService
public void addLinkUpdate(long switchId, int portNum, int status)
updates
queue.switchId
- identifier of the switchportNum
- port numberstatus
- status of the link. with this value, UpdateOperation is calculated.public void sendDiscoveryMessage(long switchId, short destinationPort, boolean isStandard, boolean isReverse)
sendDiscoveryMessage(IOFSwitch, int, boolean, boolean)
.switchId
- ask this switch to send discovery messagedestinationPort
- to which port to send the discovery messageisStandard
- LLDP(true) or BDDP(false)isReverse
- reverse(true) or non-reverse(false)public void addListener(ILinkDiscoveryListener listener)
ILinkDiscoveryService
.addListener
in interface ILinkDiscoveryService
listener
- The listener that wants the notificationsprivate void setControllerTLV()
controllerTLV
.private void initiatePeriodicDiscovery()
private void cleanDisconnectedSwitches()
private void initiatePeriodicQuarantineWorker()
private void generateSwitchPortStatusUpdate(IOFSwitch sw, short port)
private void initiatePeriodicTopologyUpdate()
private void addToQuarantineQueue(NodePortTuple npt)
npt
- private void removeFromQuarantineQueue(NodePortTuple npt)
private void addToMaintenanceQueue(NodePortTuple npt)
npt
- NodePortTuple
object.private void removeFromMaintenanceQueue(NodePortTuple npt)
npt
- NodePortTuple
object.public ILinkDiscovery.LinkType getLinkType(Link lt, LinkInfo info)
ILinkDiscoveryService
getLinkType
in interface ILinkDiscoveryService
lt
- Link objectinfo
- LinkInfo objectprivate void discoverLinks()
private ILinkDiscoveryListener.UpdateOperation getUpdateOperation(int srcPortState)
private ILinkDiscoveryListener.UpdateOperation getUpdateOperation(int srcPortState, int dstPortState)
private void discoverOnAllPorts()
private boolean sendDiscoveryMessage(IOFSwitch sw, int port, boolean isStandard, boolean isReverse)
sw
- port
- isStandard
- indicates standard or modified LLDPisReverse
- indicates whether the LLDP was sent as a responseprotected boolean handleHandshakedEvent(Connection conn, MessageContext context)
OFModule
OFModule.processHandshakeFinished(Connection, MessageContext)
.
Normally, most of modules have very simple implementation for this method,
only returning true.handleHandshakedEvent
in class OFModule
conn
- connection that the event has occurredcontext
- message context for the handshaking messagesprotected boolean handleDisconnect(Connection conn)
OFModule
OFModule.processDisconnect(Connection)
.
All subclasses of OFModule should implement this method.handleDisconnect
in class OFModule
conn
- connection that the event has occurredprotected boolean handleMessage(Connection conn, MessageContext context, org.openflow.protocol.OFMessage msg, java.util.List<org.openflow.protocol.OFMessage> outgoing)
OFModule
OFModule.processMessage(Connection, MessageContext, OFMessage, List)
.handleMessage
in class OFModule
conn
- connection that the message has arrivedcontext
- message context for the messagemsg
- the actual message objectoutgoing
- responses for the message arrived, which is filled by the handleMessage implementationprivate boolean handlePacketIn(IOFSwitch sw, MessageContext context, org.openflow.protocol.interfaces.OFPacketIn pi, java.util.List<org.openflow.protocol.OFMessage> outgoing)
handleLldp(LLDP, IOFSwitch, OFPacketIn, boolean, List)
.
handleLldp(LLDP, IOFSwitch, OFPacketIn, boolean, List)
.
initialize()
has been coded only to accept the standard LLDP
packets with Ethertype 0x88cc, there are other cases that never be executed.sw
- IOFSwitch objectcontext
- MessageContext objectpi
- packet-in messageoutgoing
- messages to send to switch in resultprivate boolean handleLldp(LLDP lldp, IOFSwitch sw, org.openflow.protocol.interfaces.OFPacketIn pi, boolean isStandard, java.util.List<org.openflow.protocol.OFMessage> outgoing)
Links#addOrUpdateLink(long, short, OFPhysicalPort, long, int, OFPhysicalPort, boolean, boolean)
,
remove the node & port pair (both side) from the Quarantine and Maintenance Queue and drop the message.
lldp
- LLDP packet to processsw
- the switch that the lldp packet is receivedpi
- OFPacketIn message itselfisStandard
- true(standard LLDP), or falseoutgoing
- list of OFMessage objects to be delivered to switches after this method ends the executionprivate boolean handlePortStatus(IOFSwitch sw, MessageContext context, org.openflow.protocol.interfaces.OFPortStatus ps, java.util.List<org.openflow.protocol.OFMessage> outgoing)
Links.deleteLinksOnPort(NodePortTuple)
.
Links.updatePortStatus(Long, int, OFPortStatus)
.
processNewPort(IOFSwitch, int)
.
sw
- IOFSwitch objectcontext
- MesasgeContext objectps
- OFPortStatus objectoutgoing
- messages to send to switch in resultprivate void processNewPort(IOFSwitch sw, int portnum)
sw
- portnum
- public java.lang.String toString()
toString
in class java.lang.Object
public java.util.Map<Link,LinkInfo> getLinks()
ILinkDiscoveryService
getLinks
in interface ILinkDiscoveryService
public java.util.Map<java.lang.Long,java.util.Set<Link>> getSwitchLinks()
ILinkDiscoveryService
getSwitchLinks
in interface ILinkDiscoveryService
public java.util.Set<NodePortTuple> getSuppressLLDPsInfo()
ILinkDiscoveryService
getSuppressLLDPsInfo
in interface ILinkDiscoveryService
public void AddToSuppressLLDPs(long sw, int port)
ILinkDiscoveryService
AddToSuppressLLDPs
in interface ILinkDiscoveryService
public void RemoveFromSuppressLLDPs(long sw, int port)
ILinkDiscoveryService
RemoveFromSuppressLLDPs
in interface ILinkDiscoveryService
public java.util.Set<java.lang.Integer> getQuarantinedPorts(long sw)
ILinkDiscoveryService
getQuarantinedPorts
in interface ILinkDiscoveryService
public boolean isAutoPortFastFeature()
ILinkDiscoveryService
isAutoPortFastFeature
in interface ILinkDiscoveryService
public void setAutoPortFastFeature(boolean autoPortFastFeature)
ILinkDiscoveryService
setAutoPortFastFeature
in interface ILinkDiscoveryService