diff --git a/src/main/java/net/floodlightcontroller/accesscontrollist/web/ACLRuleResource.java b/src/main/java/net/floodlightcontroller/accesscontrollist/web/ACLRuleResource.java index 0a6661bb010020dc4b0b4820dfc16d4893190743..9878b6f7ecb67a6f0bec203a2c4d59340ef3bcab 100644 --- a/src/main/java/net/floodlightcontroller/accesscontrollist/web/ACLRuleResource.java +++ b/src/main/java/net/floodlightcontroller/accesscontrollist/web/ACLRuleResource.java @@ -136,7 +136,7 @@ public class ACLRuleResource extends ServerResource { JsonParser jp; try { - jp = f.createJsonParser(json); + jp = f.createParser(json); } catch (JsonParseException e) { throw new IOException(e); } diff --git a/src/main/java/net/floodlightcontroller/core/IOFConnection.java b/src/main/java/net/floodlightcontroller/core/IOFConnection.java index a14021fbd47b087495b57bdd3b1736966df0a798..21855fd33aeb96714451ae38d5dee1b88dc16383 100644 --- a/src/main/java/net/floodlightcontroller/core/IOFConnection.java +++ b/src/main/java/net/floodlightcontroller/core/IOFConnection.java @@ -1,11 +1,12 @@ package net.floodlightcontroller.core; import java.net.SocketAddress; - import java.util.Date; + import org.projectfloodlight.openflow.protocol.OFFactory; import org.projectfloodlight.openflow.types.DatapathId; import org.projectfloodlight.openflow.types.OFAuxId; +import org.projectfloodlight.openflow.types.U64; /** Contract for an openflow connection to a switch. @@ -58,5 +59,9 @@ public interface IOFConnection extends IOFMessageWriter { */ boolean isConnected(); - + /** + * Get the one-way latency from the switch to the controller. + * @return milliseconds + */ + public U64 getLatency(); } diff --git a/src/main/java/net/floodlightcontroller/core/IOFConnectionBackend.java b/src/main/java/net/floodlightcontroller/core/IOFConnectionBackend.java index 0ec7a9e1b2b081b34c813d5d9dd959028e1e49cc..aef346b86449910e59ddf0bd4938ba92cc34a8ea 100644 --- a/src/main/java/net/floodlightcontroller/core/IOFConnectionBackend.java +++ b/src/main/java/net/floodlightcontroller/core/IOFConnectionBackend.java @@ -1,5 +1,7 @@ package net.floodlightcontroller.core; +import org.projectfloodlight.openflow.types.U64; + import net.floodlightcontroller.core.internal.IOFConnectionListener; public interface IOFConnectionBackend extends IOFConnection { @@ -20,4 +22,21 @@ public interface IOFConnectionBackend extends IOFConnection { /** set the message/closing listener for this connection */ void setListener(IOFConnectionListener listener); + + /** + * Update the present latency between the switch and + * the controller. The latency should be in milliseconds + * and should be one-way. The caller must convert all + * round-trip values to one-way prior to invoking this + * function. + * + * The old link latency being updated will retain X% + * of the value, while the new link latency will attribute + * (100-X)%. This should allow new network configurations to + * quickly overtake old ones but will still allow + * outlier values to be absorbed. + * + * @param latency + */ + public void updateLatency(U64 latency); } diff --git a/src/main/java/net/floodlightcontroller/core/IOFSwitch.java b/src/main/java/net/floodlightcontroller/core/IOFSwitch.java index df2c58a743918cc6c27aa89ec7e94dd064b65ed6..4cc47498d8534a5cce3f24e78243f4cac7313394 100644 --- a/src/main/java/net/floodlightcontroller/core/IOFSwitch.java +++ b/src/main/java/net/floodlightcontroller/core/IOFSwitch.java @@ -35,6 +35,7 @@ import org.projectfloodlight.openflow.protocol.OFStatsRequest; import org.projectfloodlight.openflow.types.DatapathId; import org.projectfloodlight.openflow.types.OFPort; import org.projectfloodlight.openflow.types.TableId; +import org.projectfloodlight.openflow.types.U64; import com.google.common.collect.ImmutableList; import com.google.common.util.concurrent.ListenableFuture; @@ -362,5 +363,10 @@ public interface IOFSwitch extends IOFMessageWriter { * @return */ short getNumTables(); - -} + + /** + * Get the one-way latency from the switch to the controller. + * @return milliseconds + */ + public U64 getLatency(); +} \ No newline at end of file diff --git a/src/main/java/net/floodlightcontroller/core/NullConnection.java b/src/main/java/net/floodlightcontroller/core/NullConnection.java index 41a5a1591bf631e2bd419b2ed996e1294dc3748a..34f225e1343a1f32953f786a61555cf053438f8d 100644 --- a/src/main/java/net/floodlightcontroller/core/NullConnection.java +++ b/src/main/java/net/floodlightcontroller/core/NullConnection.java @@ -2,9 +2,10 @@ package net.floodlightcontroller.core; import java.net.SocketAddress; import java.util.List; - import java.util.Date; + import net.floodlightcontroller.core.internal.IOFConnectionListener; + import org.projectfloodlight.openflow.protocol.OFFactories; import org.projectfloodlight.openflow.protocol.OFFactory; import org.projectfloodlight.openflow.protocol.OFMessage; @@ -14,6 +15,7 @@ import org.projectfloodlight.openflow.protocol.OFStatsRequest; import org.projectfloodlight.openflow.protocol.OFVersion; import org.projectfloodlight.openflow.types.DatapathId; import org.projectfloodlight.openflow.types.OFAuxId; +import org.projectfloodlight.openflow.types.U64; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -111,4 +113,13 @@ public class NullConnection implements IOFConnectionBackend, IOFMessageWriter { public void setListener(IOFConnectionListener listener) { } + @Override + public U64 getLatency() { + return U64.ZERO; + } + + @Override + public void updateLatency(U64 latency) { + // noop + } } \ No newline at end of file diff --git a/src/main/java/net/floodlightcontroller/core/OFConnection.java b/src/main/java/net/floodlightcontroller/core/OFConnection.java index 36efb215975f38dbe22b41433485c0ba2a49d9b1..009b31bb9310b0d4110634fabbbf2b271b5b0b3c 100644 --- a/src/main/java/net/floodlightcontroller/core/OFConnection.java +++ b/src/main/java/net/floodlightcontroller/core/OFConnection.java @@ -51,6 +51,7 @@ import org.projectfloodlight.openflow.protocol.OFStatsRequest; import org.projectfloodlight.openflow.protocol.OFType; import org.projectfloodlight.openflow.types.DatapathId; import org.projectfloodlight.openflow.types.OFAuxId; +import org.projectfloodlight.openflow.types.U64; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -85,9 +86,10 @@ public class OFConnection implements IOFConnection, IOFConnectionBackend{ private static final long DELIVERABLE_TIME_OUT = 60; private static final TimeUnit DELIVERABLE_TIME_OUT_UNIT = TimeUnit.SECONDS; - private final OFConnectionCounters counters; private IOFConnectionListener listener; + + private volatile U64 latency; public OFConnection(@Nonnull DatapathId dpid, @Nonnull OFFactory factory, @@ -110,6 +112,7 @@ public class OFConnection implements IOFConnection, IOFConnectionBackend{ this.xidDeliverableMap = new ConcurrentHashMap<>(); this.counters = new OFConnectionCounters(debugCounters, dpid, this.auxId); this.timer = timer; + this.latency = U64.ZERO; } @Override @@ -380,6 +383,27 @@ public class OFConnection implements IOFConnection, IOFConnectionBackend{ listener.messageReceived(this, m); } } + + @Override + public U64 getLatency() { + return this.latency; + } + + @Override + public void updateLatency(U64 latency) { + if (latency == null) { + logger.error("Latency must be non-null. Ignoring null latency value."); + return; + } else if (this.latency.equals(U64.ZERO)) { + logger.debug("Recording previously 0ms switch {} latency as {}ms", this.getDatapathId(), latency.getValue()); + this.latency = latency; + return; + } else { + double oldWeight = 0.30; + this.latency = U64.of((long) (this.latency.getValue() * oldWeight + latency.getValue() * (1 - oldWeight))); + logger.debug("Switch {} latency updated to {}ms", this.getDatapathId(), this.latency.getValue()); + } + } /** A dummy connection listener that just logs warn messages. Saves us a few null checks * @author Andreas Wundsam <andreas.wundsam@bigswitch.com> @@ -409,6 +433,5 @@ public class OFConnection implements IOFConnection, IOFConnectionBackend{ // TODO Auto-generated method stub } - } } diff --git a/src/main/java/net/floodlightcontroller/core/OFSwitch.java b/src/main/java/net/floodlightcontroller/core/OFSwitch.java index 146bfe19179531501d1f36c66a0404575f70c7ce..16684795ec488d7b0cdc71ba32218d462a8f1ad3 100644 --- a/src/main/java/net/floodlightcontroller/core/OFSwitch.java +++ b/src/main/java/net/floodlightcontroller/core/OFSwitch.java @@ -69,6 +69,7 @@ import org.projectfloodlight.openflow.types.DatapathId; import org.projectfloodlight.openflow.types.OFAuxId; import org.projectfloodlight.openflow.types.OFPort; import org.projectfloodlight.openflow.types.TableId; +import org.projectfloodlight.openflow.types.U64; import net.floodlightcontroller.util.LinkedHashSetWrapper; import net.floodlightcontroller.util.OrderedCollection; @@ -124,7 +125,7 @@ public class OFSwitch implements IOFSwitchBackend { private SwitchStatus status; public static final int OFSWITCH_APP_ID = ident(5); - + private TableId maxTableToGetTableMissFlow = TableId.of(4); /* this should cover most HW switches that have a couple SW flow tables */ static { @@ -759,7 +760,7 @@ public class OFSwitch implements IOFSwitchBackend { public void write(Iterable<OFMessage> msglist, LogicalOFMessageCategory category) { if (isActive()) { this.getConnection(category).write(msglist); - + for(OFMessage m : msglist) { switchManager.handleOutgoingMessage(this, m); } @@ -793,7 +794,7 @@ public class OFSwitch implements IOFSwitchBackend { public void write(Iterable<OFMessage> msglist) { if (isActive()) { connections.get(OFAuxId.MAIN).write(msglist); - + for(OFMessage m : msglist) { switchManager.handleOutgoingMessage(this, m); } @@ -831,7 +832,7 @@ public class OFSwitch implements IOFSwitchBackend { /* OF1.3+ Per-table actions are set later in the OFTableFeaturesRequest/Reply */ this.actions = featuresReply.getActions(); } - + this.nTables = featuresReply.getNTables(); } @@ -986,7 +987,7 @@ public class OFSwitch implements IOFSwitchBackend { private <REPLY extends OFStatsReply> ListenableFuture<List<REPLY>> addInternalStatsReplyListener(final ListenableFuture<List<REPLY>> future, OFStatsRequest<REPLY> request) { switch (request.getStatsType()) { case TABLE_FEATURES: - /* case YOUR_CASE_HERE */ + /* case YOUR_CASE_HERE */ future.addListener(new Runnable() { /* * We know the reply will be a list of OFStatsReply. @@ -1009,7 +1010,7 @@ public class OFSwitch implements IOFSwitchBackend { case TABLE_FEATURES: processOFTableFeatures((List<OFTableFeaturesStatsReply>) future.get()); break; - /* case YOUR_CASE_HERE */ + /* case YOUR_CASE_HERE */ default: throw new Exception("Received an invalid OFStatsReply of " + replies.get(0).getStatsType().toString() + ". Expected TABLE_FEATURES."); @@ -1097,7 +1098,7 @@ public class OFSwitch implements IOFSwitchBackend { public Collection<TableId> getTables() { return new ArrayList<TableId>(tables); } - + @Override public short getNumTables() { return this.nTables; @@ -1236,7 +1237,7 @@ public class OFSwitch implements IOFSwitchBackend { public TableId getMaxTableForTableMissFlow() { return maxTableToGetTableMissFlow; } - + @Override public TableId setMaxTableForTableMissFlow(TableId max) { if (max.getValue() >= nTables) { @@ -1246,4 +1247,9 @@ public class OFSwitch implements IOFSwitchBackend { } return maxTableToGetTableMissFlow; } -} + + @Override + public U64 getLatency() { + return this.connections.get(OFAuxId.MAIN).getLatency(); + } +} \ No newline at end of file diff --git a/src/main/java/net/floodlightcontroller/core/internal/OFChannelHandler.java b/src/main/java/net/floodlightcontroller/core/internal/OFChannelHandler.java index a6702b74f6b014a498c41c0f9263e5cba8742eaa..8f3cbedb6d168729a0582c41e0630d95fb4c599b 100644 --- a/src/main/java/net/floodlightcontroller/core/internal/OFChannelHandler.java +++ b/src/main/java/net/floodlightcontroller/core/internal/OFChannelHandler.java @@ -53,6 +53,7 @@ import org.projectfloodlight.openflow.protocol.ver13.OFHelloElemTypeSerializerVe import org.projectfloodlight.openflow.protocol.ver14.OFHelloElemTypeSerializerVer14; import org.projectfloodlight.openflow.types.OFAuxId; import org.projectfloodlight.openflow.types.U32; +import org.projectfloodlight.openflow.types.U64; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -84,6 +85,8 @@ class OFChannelHandler extends IdleStateAwareChannelHandler { * We will count down */ private long handshakeTransactionIds = 0x00FFFFFFFFL; + + private volatile long echoSendTime; /** @@ -107,11 +110,12 @@ class OFChannelHandler extends IdleStateAwareChannelHandler { void processOFEchoReply(OFEchoReply m) throws IOException { - // do nothing + /* Update the latency -- halve it for one-way time */ + updateLatency(U64.of( (System.currentTimeMillis() - echoSendTime) / 2) ); } void processOFError(OFErrorMsg m) { - logErrorDisconnect(m); + logErrorDisconnect(m); } void processOFExperimenter(OFExperimenter m) { @@ -880,13 +884,15 @@ class OFChannelHandler extends IdleStateAwareChannelHandler { .build(); channel.write(Collections.singletonList(m)); - log.debug("Send hello: {}", m); + log.debug("Send hello: {}", m); } private void sendEchoRequest() { OFEchoRequest request = factory.buildEchoRequest() .setXid(handshakeTransactionIds--) .build(); + /* Record for latency calculation */ + echoSendTime = System.currentTimeMillis(); channel.write(Collections.singletonList(request)); } @@ -910,4 +916,9 @@ class OFChannelHandler extends IdleStateAwareChannelHandler { return this.pipeline; } + private void updateLatency(U64 latency) { + if (connection != null) { + connection.updateLatency(latency); + } + } } diff --git a/src/main/java/net/floodlightcontroller/core/internal/OFSwitchHandshakeHandler.java b/src/main/java/net/floodlightcontroller/core/internal/OFSwitchHandshakeHandler.java index 0e6c15daebc9bb3ba5266359eeae403f01f0af6c..6ce132a0a362b8dc455102fd26414b96837597a7 100644 --- a/src/main/java/net/floodlightcontroller/core/internal/OFSwitchHandshakeHandler.java +++ b/src/main/java/net/floodlightcontroller/core/internal/OFSwitchHandshakeHandler.java @@ -73,7 +73,6 @@ import org.projectfloodlight.openflow.protocol.OFType; import org.projectfloodlight.openflow.protocol.OFVersion; import org.projectfloodlight.openflow.protocol.action.OFAction; import org.projectfloodlight.openflow.protocol.actionid.OFActionId; -import org.projectfloodlight.openflow.protocol.actionid.OFActionIdOutput; import org.projectfloodlight.openflow.protocol.errormsg.OFBadRequestErrorMsg; import org.projectfloodlight.openflow.protocol.errormsg.OFFlowModFailedErrorMsg; import org.projectfloodlight.openflow.protocol.instruction.OFInstruction; diff --git a/src/main/java/net/floodlightcontroller/core/web/SwitchRoleResource.java b/src/main/java/net/floodlightcontroller/core/web/SwitchRoleResource.java index fda8f188a6db59d6835c0a284c6a0f8c1a6c9836..ea0bc19900b9f9fde327acae6affddb91ebc718d 100644 --- a/src/main/java/net/floodlightcontroller/core/web/SwitchRoleResource.java +++ b/src/main/java/net/floodlightcontroller/core/web/SwitchRoleResource.java @@ -106,7 +106,7 @@ public class SwitchRoleResource extends ServerResource { try { try { - jp = f.createJsonParser(json); + jp = f.createParser(json); } catch (IOException e) { e.printStackTrace(); } diff --git a/src/main/java/net/floodlightcontroller/firewall/FirewallRulesResource.java b/src/main/java/net/floodlightcontroller/firewall/FirewallRulesResource.java index d90fa90a42883d0a295b5662eaee6bd9c196aad2..bfdf5f88df6d671657ea828ec091c6390df0248f 100644 --- a/src/main/java/net/floodlightcontroller/firewall/FirewallRulesResource.java +++ b/src/main/java/net/floodlightcontroller/firewall/FirewallRulesResource.java @@ -135,7 +135,7 @@ public class FirewallRulesResource extends ServerResource { JsonParser jp; try { try { - jp = f.createJsonParser(fmJson); + jp = f.createParser(fmJson); } catch (JsonParseException e) { throw new IOException(e); } diff --git a/src/main/java/net/floodlightcontroller/firewall/FirewallSubnetMaskResource.java b/src/main/java/net/floodlightcontroller/firewall/FirewallSubnetMaskResource.java index 6912acbdae523e2316cfbc63a46d7d2b145bcd9c..10a5f5bd299c1cbf5a81658e414a156106814289 100644 --- a/src/main/java/net/floodlightcontroller/firewall/FirewallSubnetMaskResource.java +++ b/src/main/java/net/floodlightcontroller/firewall/FirewallSubnetMaskResource.java @@ -73,7 +73,7 @@ public class FirewallSubnetMaskResource extends FirewallResourceBase { JsonParser jp; try { - jp = f.createJsonParser(fmJson); + jp = f.createParser(fmJson); } catch (JsonParseException e) { throw new IOException(e); } diff --git a/src/main/java/net/floodlightcontroller/linkdiscovery/ILinkDiscovery.java b/src/main/java/net/floodlightcontroller/linkdiscovery/ILinkDiscovery.java index d1dee02a9347d5d5fd185dd9bc17356a57240365..051f2d41267616703829963e1d3991948f4b474f 100644 --- a/src/main/java/net/floodlightcontroller/linkdiscovery/ILinkDiscovery.java +++ b/src/main/java/net/floodlightcontroller/linkdiscovery/ILinkDiscovery.java @@ -21,6 +21,7 @@ import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; import org.projectfloodlight.openflow.types.DatapathId; import org.projectfloodlight.openflow.types.OFPort; +import org.projectfloodlight.openflow.types.U64; public interface ILinkDiscovery { @@ -52,17 +53,19 @@ public interface ILinkDiscovery { protected DatapathId dst; protected OFPort dstPort; protected SwitchType srcType; + protected U64 latency; protected LinkType type; protected UpdateOperation operation; public LDUpdate(DatapathId src, OFPort srcPort, - DatapathId dst, OFPort dstPort, + DatapathId dst, OFPort dstPort, U64 latency, ILinkDiscovery.LinkType type, UpdateOperation operation) { this.src = src; this.srcPort = srcPort; this.dst = dst; this.dstPort = dstPort; + this.latency = latency; this.type = type; this.operation = operation; } @@ -73,6 +76,7 @@ public interface ILinkDiscovery { this.dst = old.dst; this.dstPort = old.dstPort; this.srcType = old.srcType; + this.latency = old.latency; this.type = old.type; this.operation = old.operation; } @@ -106,6 +110,10 @@ public interface ILinkDiscovery { public OFPort getDstPort() { return dstPort; } + + public U64 getLatency() { + return latency; + } public SwitchType getSrcType() { return srcType; @@ -133,6 +141,7 @@ public interface ILinkDiscovery { + ", srcPort=" + srcPort.toString() + ", dst=" + dst.toString() + ", dstPort=" + dstPort.toString() + + ", latency=" + latency.toString() + ", type=" + type + "]"; case PORT_DOWN: case PORT_UP: diff --git a/src/main/java/net/floodlightcontroller/linkdiscovery/internal/LinkDiscoveryManager.java b/src/main/java/net/floodlightcontroller/linkdiscovery/internal/LinkDiscoveryManager.java index 4f41f919b0e3f6dda32c12facc0a168a9bc8a55b..26dd12e59f4bbe46364e9e669d0fb941d86a9656 100644 --- a/src/main/java/net/floodlightcontroller/linkdiscovery/internal/LinkDiscoveryManager.java +++ b/src/main/java/net/floodlightcontroller/linkdiscovery/internal/LinkDiscoveryManager.java @@ -103,6 +103,7 @@ import org.projectfloodlight.openflow.types.EthType; import org.projectfloodlight.openflow.types.MacAddress; import org.projectfloodlight.openflow.types.OFBufferId; import org.projectfloodlight.openflow.types.OFPort; +import org.projectfloodlight.openflow.types.U64; import org.projectfloodlight.openflow.util.HexString; import org.projectfloodlight.openflow.protocol.OFType; import org.projectfloodlight.openflow.protocol.action.OFAction; @@ -255,7 +256,7 @@ IFloodlightModule, IInfoProvider { protected LinkedBlockingQueue<NodePortTuple> maintenanceQueue; protected LinkedBlockingQueue<NodePortTuple> toRemoveFromQuarantineQueue; protected LinkedBlockingQueue<NodePortTuple> toRemoveFromMaintenanceQueue; - + /** * Quarantine task */ @@ -290,12 +291,12 @@ IFloodlightModule, IInfoProvider { @Override public OFPacketOut generateLLDPMessage(IOFSwitch iofSwitch, OFPort port, boolean isStandard, boolean isReverse) { - + OFPortDesc ofpPort = iofSwitch.getPort(port); if (log.isTraceEnabled()) { - log.trace("Sending LLDP packet out of swich: {}, port: {}", - iofSwitch.getId().toString(), port); + log.trace("Sending LLDP packet out of swich: {}, port: {}, reverse: {}", + new Object[] {iofSwitch.getId().toString(), port.toString(), Boolean.toString(isReverse)}); } // using "nearest customer bridge" MAC address for broadest possible @@ -308,7 +309,7 @@ IFloodlightModule, IInfoProvider { // later byte[] portId = new byte[] { 2, 0, 0 }; // filled in later byte[] ttlValue = new byte[] { 0, 0x78 }; - // OpenFlow OUI - 00-26-E1 + // OpenFlow OUI - 00-26-E1-00 byte[] dpidTLVValue = new byte[] { 0x0, 0x26, (byte) 0xe1, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; LLDPTLV dpidTLV = new LLDPTLV().setType((byte) 127) @@ -341,10 +342,6 @@ IFloodlightModule, IInfoProvider { // set the portId to the outgoing port portBB.putShort(port.getShortPortNumber()); - if (log.isTraceEnabled()) { - log.trace("Sending LLDP out of interface: {}/{}", - iofSwitch.getId().toString(), port); - } LLDP lldp = new LLDP(); lldp.setChassisId(new LLDPTLV().setType((byte) 1) @@ -365,6 +362,32 @@ IFloodlightModule, IInfoProvider { } else { lldp.getOptionalTLVList().add(forwardTLV); } + + /* + * Introduce a new TLV for med-granularity link latency detection. + * If same controller, can assume system clock is the same, but + * cannot guarantee processing time or account for network congestion. + * + * Need to include our OpenFlow OUI - 00-26-E1-01 (note 01; 00 is DPID); + * save last 8 bytes for long (time in ms). + * + * Note Long.SIZE is in bits (64). + */ + byte[] timestampTLVValue = ByteBuffer.allocate(Long.SIZE / 8 + 4) + .put((byte) 0x00) + .put((byte) 0x26) + .put((byte) 0xe1) + .put((byte) 0x01) /* 0x01 is what we'll use to differentiate DPID (0x00) from time (0x01) */ + .putLong(System.currentTimeMillis() + iofSwitch.getLatency().getValue() /* account for our switch's one-way latency */) + .array(); + + LLDPTLV timestampTLV = new LLDPTLV() + .setType((byte) 127) + .setLength((short) timestampTLVValue.length) + .setValue(timestampTLVValue); + + /* Now add TLV to our LLDP packet */ + lldp.getOptionalTLVList().add(timestampTLV); Ethernet ethernet; if (isStandard) { @@ -583,19 +606,19 @@ IFloodlightModule, IInfoProvider { } else if (eth.getPayload() instanceof LLDP) { return handleLldp((LLDP) eth.getPayload(), sw, inPort, true, cntx); } else if (eth.getEtherType().getValue() < 1536 && eth.getEtherType().getValue() >= 17) { - long destMac = eth.getDestinationMACAddress().getLong(); - if ((destMac & LINK_LOCAL_MASK) == LINK_LOCAL_VALUE) { - ctrLinkLocalDrops.increment(); - if (log.isTraceEnabled()) { - log.trace("Ignoring packet addressed to 802.1D/Q " - + "reserved address."); - } - return Command.STOP; - } - } else if (eth.getEtherType().getValue() < 17) { - log.error("Received invalid ethertype of {}.", eth.getEtherType()); - return Command.STOP; - } + long destMac = eth.getDestinationMACAddress().getLong(); + if ((destMac & LINK_LOCAL_MASK) == LINK_LOCAL_VALUE) { + ctrLinkLocalDrops.increment(); + if (log.isTraceEnabled()) { + log.trace("Ignoring packet addressed to 802.1D/Q " + + "reserved address."); + } + return Command.STOP; + } + } else if (eth.getEtherType().getValue() < 17) { + log.error("Received invalid ethertype of {}.", eth.getEtherType()); + return Command.STOP; + } if (ignorePacketInFromSource(eth.getSourceMACAddress())) { ctrIgnoreSrcMacDrops.increment(); @@ -632,6 +655,8 @@ IFloodlightModule, IInfoProvider { // If LLDP is suppressed on this port, ignore received packet as well IOFSwitch iofSwitch = switchService.getSwitch(sw); + log.warn("Received LLDP packet on sw {}, port {}", sw, inPort); + if (!isIncomingDiscoveryAllowed(sw, inPort, isStandard)) return Command.STOP; @@ -650,7 +675,8 @@ IFloodlightModule, IInfoProvider { OFPort remotePort = OFPort.of(portBB.getShort()); IOFSwitch remoteSwitch = null; - + long timestamp = 0; + // Verify this LLDP packet matches what we're looking for for (LLDPTLV lldptlv : lldp.getOptionalTLVList()) { if (lldptlv.getType() == 127 && lldptlv.getLength() == 12 @@ -660,6 +686,13 @@ IFloodlightModule, IInfoProvider { && lldptlv.getValue()[3] == 0x0) { ByteBuffer dpidBB = ByteBuffer.wrap(lldptlv.getValue()); remoteSwitch = switchService.getSwitch(DatapathId.of(dpidBB.getLong(4))); + } else if (lldptlv.getType() == 127 && lldptlv.getLength() == 12 + && lldptlv.getValue()[0] == 0x0 + && lldptlv.getValue()[1] == 0x26 + && lldptlv.getValue()[2] == (byte) 0xe1 + && lldptlv.getValue()[3] == 0x01) { /* 0x01 for timestamp */ + ByteBuffer tsBB = ByteBuffer.wrap(lldptlv.getValue()); /* skip OpenFlow OUI (4 bytes above) */ + timestamp = tsBB.getLong(4) + iofSwitch.getLatency().getValue(); /* include the RX switch latency to "subtract" it */ } else if (lldptlv.getType() == 12 && lldptlv.getLength() == 8) { otherId = ByteBuffer.wrap(lldptlv.getValue()).getLong(); if (myId == otherId) myLLDP = true; @@ -735,8 +768,9 @@ IFloodlightModule, IInfoProvider { // Store the time of update to this link, and push it out to // routingEngine + U64 latency = timestamp != 0 ? U64.of(System.currentTimeMillis() - timestamp) : U64.ZERO; Link lt = new Link(remoteSwitch.getId(), remotePort, - iofSwitch.getId(), inPort); + iofSwitch.getId(), inPort, latency); /* we assume 0 latency is undefined */ if (!isLinkAllowed(lt.getSrc(), lt.getSrcPort(), lt.getDst(), lt.getDstPort())) @@ -765,7 +799,7 @@ IFloodlightModule, IInfoProvider { newLinkInfo = links.get(lt); if (newLinkInfo != null && isStandard && isReverse == false) { Link reverseLink = new Link(lt.getDst(), lt.getDstPort(), - lt.getSrc(), lt.getSrcPort()); + lt.getSrc(), lt.getSrcPort(), U64.ZERO); /* latency not used; not important what the value is, since it's intentionally not in equals() */ LinkInfo reverseInfo = links.get(reverseLink); if (reverseInfo == null) { // the reverse link does not exist. @@ -781,7 +815,7 @@ IFloodlightModule, IInfoProvider { // link as well. if (!isStandard) { Link reverseLink = new Link(lt.getDst(), lt.getDstPort(), - lt.getSrc(), lt.getSrcPort()); + lt.getSrc(), lt.getSrcPort(), latency); // srcPortState and dstPort state are reversed. LinkInfo reverseInfo = new LinkInfo(firstSeenTime, lastLldpTime, @@ -795,7 +829,7 @@ IFloodlightModule, IInfoProvider { lt.getSrcPort()); NodePortTuple nptDst = new NodePortTuple(lt.getDst(), lt.getDstPort()); - + flagToRemoveFromQuarantineQueue(nptSrc); flagToRemoveFromMaintenanceQueue(nptSrc); flagToRemoveFromQuarantineQueue(nptDst); @@ -1036,7 +1070,7 @@ IFloodlightModule, IInfoProvider { } else { operation = UpdateOperation.PORT_DOWN; } - + updates.add(new LDUpdate(sw, port, operation)); } @@ -1163,17 +1197,13 @@ IFloodlightModule, IInfoProvider { return; OFPortDesc ofpPort = iofSwitch.getPort(port); - if (log.isTraceEnabled()) { - log.trace("Sending LLDP packet out of swich: {}, port: {}", - sw.toString(), port.getPortNumber()); - } OFPacketOut po = generateLLDPMessage(iofSwitch, port, isStandard, isReverse); OFPacketOut.Builder pob = po.createBuilder(); // Add actions List<OFAction> actions = getDiscoveryActions(iofSwitch, ofpPort.getPortNo()); pob.setActions(actions); - + // no need to set length anymore // send @@ -1194,10 +1224,10 @@ IFloodlightModule, IInfoProvider { if (!iofSwitch.isActive()) continue; /* can't do anything if the switch is SLAVE */ if (iofSwitch.getEnabledPorts() != null) { for (OFPortDesc ofp : iofSwitch.getEnabledPorts()) { - if (isLinkDiscoverySuppressed(sw, ofp.getPortNo())) { + if (isLinkDiscoverySuppressed(sw, ofp.getPortNo())) { continue; } - + log.trace("Enabled port: {}", ofp); sendDiscoveryMessage(sw, ofp.getPortNo(), true, false); // If the switch port is not already in the maintenance @@ -1373,6 +1403,7 @@ IFloodlightModule, IInfoProvider { // find out if the link was added or removed here. updates.add(new LDUpdate(lt.getSrc(), lt.getSrcPort(), lt.getDst(), lt.getDstPort(), + lt.getLatency(), getLinkType(lt, newInfo), updateOperation)); } @@ -1456,6 +1487,7 @@ IFloodlightModule, IInfoProvider { lt.getSrcPort(), lt.getDst(), lt.getDstPort(), + lt.getLatency(), linkType, UpdateOperation.LINK_REMOVED)); @@ -1547,7 +1579,7 @@ IFloodlightModule, IInfoProvider { eraseList.add(entry.getKey()); } else if (linkChanged) { updates.add(new LDUpdate(lt.getSrc(), lt.getSrcPort(), - lt.getDst(), lt.getDstPort(), + lt.getDst(), lt.getDstPort(), lt.getLatency(), getLinkType(lt, info), UpdateOperation.LINK_UPDATED)); } @@ -1656,33 +1688,33 @@ IFloodlightModule, IInfoProvider { @Override public void switchRemoved(DatapathId sw) { - List<Link> eraseList = new ArrayList<Link>(); - lock.writeLock().lock(); - try { - if (switchLinks.containsKey(sw)) { - if (log.isTraceEnabled()) { - log.trace("Handle switchRemoved. Switch {}; removing links {}", sw.toString(), switchLinks.get(sw)); - } - - List<LDUpdate> updateList = new ArrayList<LDUpdate>(); - updateList.add(new LDUpdate(sw, SwitchType.BASIC_SWITCH, UpdateOperation.SWITCH_REMOVED)); - // add all tuples with an endpoint on this switch to erase list - eraseList.addAll(switchLinks.get(sw)); - - // Sending the updateList, will ensure the updates in this - // list will be added at the end of all the link updates. - // Thus, it is not necessary to explicitly add these updates - // to the queue. - deleteLinks(eraseList, "Switch Removed", updateList); - } else { - // Switch does not have any links. - updates.add(new LDUpdate(sw, SwitchType.BASIC_SWITCH, UpdateOperation.SWITCH_REMOVED)); - } - } finally { - lock.writeLock().unlock(); - } - - } + List<Link> eraseList = new ArrayList<Link>(); + lock.writeLock().lock(); + try { + if (switchLinks.containsKey(sw)) { + if (log.isTraceEnabled()) { + log.trace("Handle switchRemoved. Switch {}; removing links {}", sw.toString(), switchLinks.get(sw)); + } + + List<LDUpdate> updateList = new ArrayList<LDUpdate>(); + updateList.add(new LDUpdate(sw, SwitchType.BASIC_SWITCH, UpdateOperation.SWITCH_REMOVED)); + // add all tuples with an endpoint on this switch to erase list + eraseList.addAll(switchLinks.get(sw)); + + // Sending the updateList, will ensure the updates in this + // list will be added at the end of all the link updates. + // Thus, it is not necessary to explicitly add these updates + // to the queue. + deleteLinks(eraseList, "Switch Removed", updateList); + } else { + // Switch does not have any links. + updates.add(new LDUpdate(sw, SwitchType.BASIC_SWITCH, UpdateOperation.SWITCH_REMOVED)); + } + } finally { + lock.writeLock().unlock(); + } + + } @Override @@ -1730,11 +1762,11 @@ IFloodlightModule, IInfoProvider { @Override public void rowsModified(String tableName, Set<Object> rowKeys) { - if (tableName.equals(TOPOLOGY_TABLE_NAME)) { - readTopologyConfigFromStorage(); - return; - } - } + if (tableName.equals(TOPOLOGY_TABLE_NAME)) { + readTopologyConfigFromStorage(); + return; + } + } @Override public void rowsDeleted(String tableName, Set<Object> rowKeys) { diff --git a/src/main/java/net/floodlightcontroller/linkdiscovery/web/ExternalLinksResource.java b/src/main/java/net/floodlightcontroller/linkdiscovery/web/ExternalLinksResource.java index c3dea4918245d2f30002315a229288202a388373..daf46642e0b2de4b50bcf545b0cab498475ebdb6 100644 --- a/src/main/java/net/floodlightcontroller/linkdiscovery/web/ExternalLinksResource.java +++ b/src/main/java/net/floodlightcontroller/linkdiscovery/web/ExternalLinksResource.java @@ -29,6 +29,7 @@ import net.floodlightcontroller.routing.Link; import org.projectfloodlight.openflow.types.DatapathId; import org.projectfloodlight.openflow.types.OFPort; +import org.projectfloodlight.openflow.types.U64; import org.restlet.resource.Get; import org.restlet.resource.ServerResource; @@ -53,7 +54,7 @@ public class ExternalLinksResource extends ServerResource { DatapathId dst = link.getDst(); OFPort srcPort = link.getSrcPort(); OFPort dstPort = link.getDstPort(); - Link otherLink = new Link(dst, dstPort, src, srcPort); + Link otherLink = new Link(dst, dstPort, src, srcPort, U64.ZERO /* not important in lookup */); LinkInfo otherInfo = links.get(otherLink); LinkType otherType = null; if (otherInfo != null) diff --git a/src/main/java/net/floodlightcontroller/linkdiscovery/web/LinksResource.java b/src/main/java/net/floodlightcontroller/linkdiscovery/web/LinksResource.java index c766fb179a228adb4050caf8d878435e0260ef8f..e7d85f79ffe4bee5d76de5f0e81523c3a43f8201 100644 --- a/src/main/java/net/floodlightcontroller/linkdiscovery/web/LinksResource.java +++ b/src/main/java/net/floodlightcontroller/linkdiscovery/web/LinksResource.java @@ -29,6 +29,7 @@ import net.floodlightcontroller.routing.Link; import org.projectfloodlight.openflow.types.DatapathId; import org.projectfloodlight.openflow.types.OFPort; +import org.projectfloodlight.openflow.types.U64; import org.restlet.resource.Get; import org.restlet.resource.ServerResource; @@ -53,7 +54,7 @@ public class LinksResource extends ServerResource { DatapathId dst = link.getDst(); OFPort srcPort = link.getSrcPort(); OFPort dstPort = link.getDstPort(); - Link otherLink = new Link(dst, dstPort, src, srcPort); + Link otherLink = new Link(dst, dstPort, src, srcPort, U64.ZERO /* not important in lookup */); LinkInfo otherInfo = links.get(otherLink); LinkType otherType = null; if (otherInfo != null) diff --git a/src/main/java/net/floodlightcontroller/loadbalancer/MembersResource.java b/src/main/java/net/floodlightcontroller/loadbalancer/MembersResource.java index b18ad040f4e7bdbb1b07b42176413573893d0b5e..c7301aca513d6ef6d22d93f87699e35d47197970 100644 --- a/src/main/java/net/floodlightcontroller/loadbalancer/MembersResource.java +++ b/src/main/java/net/floodlightcontroller/loadbalancer/MembersResource.java @@ -90,7 +90,7 @@ public class MembersResource extends ServerResource { LBMember member = new LBMember(); try { - jp = f.createJsonParser(json); + jp = f.createParser(json); } catch (JsonParseException e) { throw new IOException(e); } diff --git a/src/main/java/net/floodlightcontroller/loadbalancer/MonitorsResource.java b/src/main/java/net/floodlightcontroller/loadbalancer/MonitorsResource.java index 94e722cfdce9aec875f7f327d54ee4a8c3a01596..3b139b748c356e3a1ce4458e4ef177cb6bf1cc71 100644 --- a/src/main/java/net/floodlightcontroller/loadbalancer/MonitorsResource.java +++ b/src/main/java/net/floodlightcontroller/loadbalancer/MonitorsResource.java @@ -88,7 +88,7 @@ public class MonitorsResource extends ServerResource { LBMonitor monitor = new LBMonitor(); try { - jp = f.createJsonParser(json); + jp = f.createParser(json); } catch (JsonParseException e) { throw new IOException(e); } diff --git a/src/main/java/net/floodlightcontroller/loadbalancer/PoolsResource.java b/src/main/java/net/floodlightcontroller/loadbalancer/PoolsResource.java index a0ec7b117c52c47e5b678f29a91d453ef77a72ab..82a041a20751fe32b5556c80cc5683234e9efb43 100644 --- a/src/main/java/net/floodlightcontroller/loadbalancer/PoolsResource.java +++ b/src/main/java/net/floodlightcontroller/loadbalancer/PoolsResource.java @@ -92,7 +92,7 @@ public class PoolsResource extends ServerResource { LBPool pool = new LBPool(); try { - jp = f.createJsonParser(json); + jp = f.createParser(json); } catch (JsonParseException e) { throw new IOException(e); } diff --git a/src/main/java/net/floodlightcontroller/loadbalancer/VipsResource.java b/src/main/java/net/floodlightcontroller/loadbalancer/VipsResource.java index 7a5a563dc0f764c0666288509ded67e6a2f6b9f7..5160392f68069b7f30a015089265d312b82f9be9 100644 --- a/src/main/java/net/floodlightcontroller/loadbalancer/VipsResource.java +++ b/src/main/java/net/floodlightcontroller/loadbalancer/VipsResource.java @@ -94,7 +94,7 @@ public class VipsResource extends ServerResource { LBVip vip = new LBVip(); try { - jp = f.createJsonParser(json); + jp = f.createParser(json); } catch (JsonParseException e) { throw new IOException(e); } diff --git a/src/main/java/net/floodlightcontroller/routing/Link.java b/src/main/java/net/floodlightcontroller/routing/Link.java index cf649dc8932753af2fd3ae68585d7d9c355ed407..a4017836cbbf93527721320eb6e3fbd22d7b229b 100755 --- a/src/main/java/net/floodlightcontroller/routing/Link.java +++ b/src/main/java/net/floodlightcontroller/routing/Link.java @@ -21,6 +21,7 @@ import com.fasterxml.jackson.annotation.JsonProperty; import org.projectfloodlight.openflow.types.DatapathId; import org.projectfloodlight.openflow.types.OFPort; +import org.projectfloodlight.openflow.types.U64; public class Link implements Comparable<Link> { @JsonProperty("src-switch") @@ -31,13 +32,15 @@ public class Link implements Comparable<Link> { private DatapathId dst; @JsonProperty("dst-port") private OFPort dstPort; + @JsonProperty("latency") + private U64 latency; /* we intentionally exclude the latency from hashcode and equals */ - - public Link(DatapathId srcId, OFPort srcPort, DatapathId dstId, OFPort dstPort) { + public Link(DatapathId srcId, OFPort srcPort, DatapathId dstId, OFPort dstPort, U64 latency) { this.src = srcId; this.srcPort = srcPort; this.dst = dstId; this.dstPort = dstPort; + this.latency = latency; } /* @@ -63,6 +66,10 @@ public class Link implements Comparable<Link> { public OFPort getDstPort() { return dstPort; } + + public U64 getLatency() { + return latency; + } public void setSrc(DatapathId src) { this.src = src; @@ -79,6 +86,10 @@ public class Link implements Comparable<Link> { public void setDstPort(OFPort dstPort) { this.dstPort = dstPort; } + + public void setLatency(U64 latency) { + this.latency = latency; + } @Override public int hashCode() { @@ -88,7 +99,7 @@ public class Link implements Comparable<Link> { result = prime * result + dstPort.getPortNumber(); result = prime * result + (int) (src.getLong() ^ (src.getLong() >>> 32)); result = prime * result + srcPort.getPortNumber(); - return result; + return result; /* do not include latency */ } @Override @@ -108,7 +119,7 @@ public class Link implements Comparable<Link> { return false; if (!srcPort.equals(other.srcPort)) return false; - return true; + return true; /* do not include latency */ } diff --git a/src/main/java/net/floodlightcontroller/staticflowentry/StaticFlowEntries.java b/src/main/java/net/floodlightcontroller/staticflowentry/StaticFlowEntries.java index 36e8d8e16a0b3536c70d70cc4a6af58749dcab6f..c7b421c4a6cfd6aedce9248adb299c08d20c35be 100644 --- a/src/main/java/net/floodlightcontroller/staticflowentry/StaticFlowEntries.java +++ b/src/main/java/net/floodlightcontroller/staticflowentry/StaticFlowEntries.java @@ -108,7 +108,7 @@ public class StaticFlowEntries { JsonParser jp; try { - jp = f.createJsonParser(fmJson); + jp = f.createParser(fmJson); } catch (JsonParseException e) { throw new IOException(e); } @@ -614,7 +614,7 @@ public class StaticFlowEntries { String ipProto = "NOT_SPECIFIED"; try { - jp = f.createJsonParser(fmJson); + jp = f.createParser(fmJson); } catch (JsonParseException e) { throw new IOException(e); } diff --git a/src/main/java/net/floodlightcontroller/testmodule/TestModule.java b/src/main/java/net/floodlightcontroller/testmodule/TestModule.java index 4c16876ec66614833d154b9aa351666c8cfb07b4..c9a8f3eed99a7e60a847280c1e15cc07f77fc87e 100644 --- a/src/main/java/net/floodlightcontroller/testmodule/TestModule.java +++ b/src/main/java/net/floodlightcontroller/testmodule/TestModule.java @@ -2,85 +2,29 @@ package net.floodlightcontroller.testmodule; import java.util.ArrayList; import java.util.Collection; -import java.util.Collections; -import java.util.HashSet; -import java.util.List; import java.util.Map; -import java.util.concurrent.ExecutionException; -import org.projectfloodlight.openflow.protocol.OFFactories; import org.projectfloodlight.openflow.protocol.OFFactory; -import org.projectfloodlight.openflow.protocol.OFFlowAdd; import org.projectfloodlight.openflow.protocol.OFFlowMod; -import org.projectfloodlight.openflow.protocol.OFMeterBandStats; -import org.projectfloodlight.openflow.protocol.OFMeterBandType; -import org.projectfloodlight.openflow.protocol.OFMeterConfig; -import org.projectfloodlight.openflow.protocol.OFMeterMod; -import org.projectfloodlight.openflow.protocol.OFMeterModCommand; -import org.projectfloodlight.openflow.protocol.OFMeterStats; -import org.projectfloodlight.openflow.protocol.OFMeterStatsReply; -import org.projectfloodlight.openflow.protocol.OFMeterStatsRequest; -import org.projectfloodlight.openflow.protocol.OFOxmClass; import org.projectfloodlight.openflow.protocol.OFPortDesc; -import org.projectfloodlight.openflow.protocol.OFSetConfig; -import org.projectfloodlight.openflow.protocol.OFTableConfig; -import org.projectfloodlight.openflow.protocol.OFTableFeaturePropWriteActions; -import org.projectfloodlight.openflow.protocol.OFTableFeaturePropWriteSetfield; -import org.projectfloodlight.openflow.protocol.OFTableMod; -import org.projectfloodlight.openflow.protocol.OFTableModProp; -import org.projectfloodlight.openflow.protocol.OFTableModPropEviction; -import org.projectfloodlight.openflow.protocol.OFTableModPropEvictionFlag; -import org.projectfloodlight.openflow.protocol.OFVersion; import org.projectfloodlight.openflow.protocol.action.OFAction; -import org.projectfloodlight.openflow.protocol.action.OFActionOutput; import org.projectfloodlight.openflow.protocol.action.OFActionPushVlan; import org.projectfloodlight.openflow.protocol.action.OFActionSetField; -import org.projectfloodlight.openflow.protocol.action.OFActionSetNwSrc; import org.projectfloodlight.openflow.protocol.action.OFActions; import org.projectfloodlight.openflow.protocol.instruction.OFInstruction; import org.projectfloodlight.openflow.protocol.instruction.OFInstructionApplyActions; -import org.projectfloodlight.openflow.protocol.instruction.OFInstructionClearActions; -import org.projectfloodlight.openflow.protocol.instruction.OFInstructionExperimenter; -import org.projectfloodlight.openflow.protocol.instruction.OFInstructionGotoTable; -import org.projectfloodlight.openflow.protocol.instruction.OFInstructionMeter; -import org.projectfloodlight.openflow.protocol.instruction.OFInstructionWriteActions; import org.projectfloodlight.openflow.protocol.instruction.OFInstructions; import org.projectfloodlight.openflow.protocol.match.Match; import org.projectfloodlight.openflow.protocol.match.MatchField; -import org.projectfloodlight.openflow.protocol.meterband.OFMeterBand; -import org.projectfloodlight.openflow.protocol.meterband.OFMeterBandDrop; -import org.projectfloodlight.openflow.protocol.oxm.OFOxm; -import org.projectfloodlight.openflow.protocol.oxm.OFOxmEthSrc; import org.projectfloodlight.openflow.protocol.oxm.OFOxms; -import org.projectfloodlight.openflow.protocol.ver13.OFMeterModCommandSerializerVer13; -import org.projectfloodlight.openflow.types.ArpOpcode; import org.projectfloodlight.openflow.types.DatapathId; import org.projectfloodlight.openflow.types.EthType; -import org.projectfloodlight.openflow.types.ICMPv4Code; -import org.projectfloodlight.openflow.types.ICMPv4Type; -import org.projectfloodlight.openflow.types.IPv4Address; -import org.projectfloodlight.openflow.types.IpDscp; -import org.projectfloodlight.openflow.types.IpEcn; -import org.projectfloodlight.openflow.types.IpProtocol; import org.projectfloodlight.openflow.types.MacAddress; -import org.projectfloodlight.openflow.types.OFBufferId; -import org.projectfloodlight.openflow.types.OFMetadata; import org.projectfloodlight.openflow.types.OFPort; -import org.projectfloodlight.openflow.types.OFValueType; import org.projectfloodlight.openflow.types.OFVlanVidMatch; -import org.projectfloodlight.openflow.types.TableId; -import org.projectfloodlight.openflow.types.TransportPort; -import org.projectfloodlight.openflow.types.U32; -import org.projectfloodlight.openflow.types.U64; -import org.projectfloodlight.openflow.types.U8; -import org.projectfloodlight.openflow.types.VlanPcp; -import org.projectfloodlight.openflow.types.VlanVid; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import com.google.common.collect.ImmutableList; -import com.google.common.util.concurrent.ListenableFuture; - import net.floodlightcontroller.core.IOFSwitchListener; import net.floodlightcontroller.core.PortChangeType; import net.floodlightcontroller.core.internal.IOFSwitchService; diff --git a/src/main/java/net/floodlightcontroller/topology/ITopologyService.java b/src/main/java/net/floodlightcontroller/topology/ITopologyService.java index d6bd177550852501cded815cc2132abc9dc868b0..e1330bc70d62236ab1737bb2158669b4eb6c374b 100644 --- a/src/main/java/net/floodlightcontroller/topology/ITopologyService.java +++ b/src/main/java/net/floodlightcontroller/topology/ITopologyService.java @@ -210,4 +210,4 @@ public interface ITopologyService extends IFloodlightService { * has only quarantined ports. Will never return null. */ public Set<OFPort> getPorts(DatapathId sw); -} +} \ No newline at end of file diff --git a/src/main/java/net/floodlightcontroller/topology/TopologyInstance.java b/src/main/java/net/floodlightcontroller/topology/TopologyInstance.java index 7568dad7d11139915ac8b480eca1cb837d677005..4122bfb4c23be6b34a36858841dd4bb5a9e0cba9 100644 --- a/src/main/java/net/floodlightcontroller/topology/TopologyInstance.java +++ b/src/main/java/net/floodlightcontroller/topology/TopologyInstance.java @@ -845,4 +845,3 @@ public class TopologyInstance { return null; } } - diff --git a/src/main/java/net/floodlightcontroller/topology/TopologyManager.java b/src/main/java/net/floodlightcontroller/topology/TopologyManager.java index 08c88ac31eb28f3102506a5a99edcfad9ed4bca5..4d23837bd28d397ebcfb3be0bd18ce0a88b57a56 100644 --- a/src/main/java/net/floodlightcontroller/topology/TopologyManager.java +++ b/src/main/java/net/floodlightcontroller/topology/TopologyManager.java @@ -1125,7 +1125,7 @@ public class TopologyManager implements IFloodlightModule, ITopologyService, IRo switch (update.getOperation()) { case LINK_UPDATED: addOrUpdateLink(update.getSrc(), update.getSrcPort(), - update.getDst(), update.getDstPort(), + update.getDst(), update.getDstPort(), update.getLatency(), update.getType()); break; case LINK_REMOVED: @@ -1399,13 +1399,13 @@ public class TopologyManager implements IFloodlightModule, ITopologyService, IRo } protected void addOrUpdateTunnelLink(DatapathId srcId, OFPort srcPort, DatapathId dstId, - OFPort dstPort) { + OFPort dstPort, U64 latency) { // If you need to handle tunnel links, this is a placeholder. } public void addOrUpdateLink(DatapathId srcId, OFPort srcPort, DatapathId dstId, - OFPort dstPort, LinkType type) { - Link link = new Link(srcId, srcPort, dstId, dstPort); + OFPort dstPort, U64 latency, LinkType type) { + Link link = new Link(srcId, srcPort, dstId, dstPort, latency); if (type.equals(LinkType.MULTIHOP_LINK)) { addPortToSwitch(srcId, srcPort); @@ -1425,7 +1425,7 @@ public class TopologyManager implements IFloodlightModule, ITopologyService, IRo dtLinksUpdated = true; linksUpdated = true; } else if (type.equals(LinkType.TUNNEL)) { - addOrUpdateTunnelLink(srcId, srcPort, dstId, dstPort); + addOrUpdateTunnelLink(srcId, srcPort, dstId, dstPort, latency); } } @@ -1463,7 +1463,7 @@ public class TopologyManager implements IFloodlightModule, ITopologyService, IRo public void removeLink(DatapathId srcId, OFPort srcPort, DatapathId dstId, OFPort dstPort) { - Link link = new Link(srcId, srcPort, dstId, dstPort); + Link link = new Link(srcId, srcPort, dstId, dstPort, U64.ZERO /* not needed for lookup */); removeLink(link); } @@ -1531,4 +1531,4 @@ public class TopologyManager implements IFloodlightModule, ITopologyService, IRo return ports; } -} +} \ No newline at end of file diff --git a/src/main/java/net/floodlightcontroller/virtualnetwork/HostResource.java b/src/main/java/net/floodlightcontroller/virtualnetwork/HostResource.java index b2eae7c74e3f09990e1e40fd7a1611832a6d7d2c..42b9582b98d4e0788364695d08684ff7cd011358 100644 --- a/src/main/java/net/floodlightcontroller/virtualnetwork/HostResource.java +++ b/src/main/java/net/floodlightcontroller/virtualnetwork/HostResource.java @@ -45,7 +45,7 @@ public class HostResource extends org.restlet.resource.ServerResource { JsonParser jp; try { - jp = f.createJsonParser(json); + jp = f.createParser(json); } catch (JsonParseException e) { throw new IOException(e); } diff --git a/src/main/java/net/floodlightcontroller/virtualnetwork/NetworkResource.java b/src/main/java/net/floodlightcontroller/virtualnetwork/NetworkResource.java index 735415d828e8e4f7d577405a796fbccfd2e44aef..d10645e8e4b9a8afcd8571ff91f93e3ba8b6290c 100644 --- a/src/main/java/net/floodlightcontroller/virtualnetwork/NetworkResource.java +++ b/src/main/java/net/floodlightcontroller/virtualnetwork/NetworkResource.java @@ -48,7 +48,7 @@ public class NetworkResource extends ServerResource { JsonParser jp; try { - jp = f.createJsonParser(json); + jp = f.createParser(json); } catch (JsonParseException e) { throw new IOException(e); } diff --git a/src/main/java/org/sdnplatform/sync/client/SyncClient.java b/src/main/java/org/sdnplatform/sync/client/SyncClient.java index 3110efcd79afb0bb99727801c5a573c4d4f6cd44..305a906ea0e1d8bf1a8381884fe488429f6057a7 100644 --- a/src/main/java/org/sdnplatform/sync/client/SyncClient.java +++ b/src/main/java/org/sdnplatform/sync/client/SyncClient.java @@ -143,7 +143,7 @@ public class SyncClient extends SyncClientBase { StringReader sr = new StringReader(line); while (sr.read() != ' '); - JsonParser jp = mjf.createJsonParser(sr); + JsonParser jp = mjf.createParser(sr); JsonNode keyNode = validateJson(jp); if (keyNode == null) return false; @@ -216,8 +216,8 @@ public class SyncClient extends SyncClientBase { Versioned<JsonNode> value) throws Exception { if (value.getValue() == null) return; ObjectNode n = mapper.createObjectNode(); - n.put("key", keyNode); - n.put("value", value.getValue()); + n.putPOJO("key", keyNode); + n.putPOJO("value", value.getValue()); out.println(writer.writeValueAsString(n)); } @@ -244,7 +244,7 @@ public class SyncClient extends SyncClientBase { StringReader sr = new StringReader(line); while (sr.read() != ' '); - JsonParser jp = mjf.createJsonParser(sr); + JsonParser jp = mjf.createParser(sr); JsonNode keyNode = validateJson(jp); if (keyNode == null) return false; @@ -286,7 +286,7 @@ public class SyncClient extends SyncClientBase { StringReader sr = new StringReader(line); while (sr.read() != ' '); - JsonParser jp = mjf.createJsonParser(sr); + JsonParser jp = mjf.createParser(sr); JsonNode keyNode = validateJson(jp); if (keyNode == null) return false; diff --git a/src/main/java/org/sdnplatform/sync/internal/rpc/TProtocolUtil.java b/src/main/java/org/sdnplatform/sync/internal/rpc/TProtocolUtil.java index 11c62247fc52298aa2c68616ce3b1cfbc2b76036..9e3822b980ee42d8739526d379b71d87f6687579 100644 --- a/src/main/java/org/sdnplatform/sync/internal/rpc/TProtocolUtil.java +++ b/src/main/java/org/sdnplatform/sync/internal/rpc/TProtocolUtil.java @@ -77,7 +77,8 @@ public class TProtocolUtil { * @param value the versioned values * @return the thrift object */ - public static KeyedValues getTKeyedValues(ByteArray key, + @SafeVarargs + public static KeyedValues getTKeyedValues(ByteArray key, Versioned<byte[]>... value) { KeyedValues kv = new KeyedValues(); kv.setKey(key.get()); diff --git a/src/main/java/org/sdnplatform/sync/internal/version/ChainedResolver.java b/src/main/java/org/sdnplatform/sync/internal/version/ChainedResolver.java index a3b98d93fe197f842a6988ccd09497eac9d9df2f..d3b2867375db1d7cfbf01d9daa8ab8aa50a587d8 100644 --- a/src/main/java/org/sdnplatform/sync/internal/version/ChainedResolver.java +++ b/src/main/java/org/sdnplatform/sync/internal/version/ChainedResolver.java @@ -32,7 +32,8 @@ public class ChainedResolver<T> implements IInconsistencyResolver<T> { private List<IInconsistencyResolver<T>> resolvers; - public ChainedResolver(IInconsistencyResolver<T>... resolvers) { + @SafeVarargs + public ChainedResolver(IInconsistencyResolver<T>... resolvers) { this.resolvers = new ArrayList<IInconsistencyResolver<T>>(resolvers.length); for(IInconsistencyResolver<T> resolver: resolvers) this.resolvers.add(resolver); diff --git a/src/main/resources/logback-test.xml b/src/main/resources/logback-test.xml index 21c48f39c6a6b94e501b3bafd9a97528b25f2b02..b5e3bfd8093df991c049e5f86e873a9834d12747 100644 --- a/src/main/resources/logback-test.xml +++ b/src/main/resources/logback-test.xml @@ -15,9 +15,9 @@ <logger name="net.floodlightcontroller" level="INFO"/> <logger name="org.sdnplatform" level="INFO"></logger> <logger name="net.floodlightcontroller.devicemanager" level="INFO"></logger> - <logger name="net.floodlightcontroller.packet" level="INFO"></logger> + <logger name="net.floodlightcontroller.linkdiscovery" level="INFO"></logger> <logger name="net.floodlightcontroller.forwarding" level="INFO"></logger> - <logger name="net.floodlightcontroller.core.internal" level="INFO"></logger> - <logger level="INFO" name="net.floodlightcontroller.learningswitch"></logger> - <logger level="INFO" name="org.projectfloodlight.openflow"></logger> + <logger name="net.floodlightcontroller.core" level="INFO"></logger> + <logger name="net.floodlightcontroller.topology" level="INFO" ></logger> + <logger name="org.projectfloodlight.openflow" level="INFO" ></logger> </configuration> diff --git a/src/test/java/net/floodlightcontroller/core/internal/MockOFConnection.java b/src/test/java/net/floodlightcontroller/core/internal/MockOFConnection.java index 64631b78afd5cfe93e065ddac678717aec507579..c1eab8ba8baedd748aaddeb089504befb4cad6a0 100644 --- a/src/test/java/net/floodlightcontroller/core/internal/MockOFConnection.java +++ b/src/test/java/net/floodlightcontroller/core/internal/MockOFConnection.java @@ -7,9 +7,10 @@ import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; - import java.util.Date; + import net.floodlightcontroller.core.IOFConnectionBackend; + import org.projectfloodlight.openflow.protocol.OFFactory; import org.projectfloodlight.openflow.protocol.OFMessage; import org.projectfloodlight.openflow.protocol.OFRequest; @@ -17,6 +18,7 @@ import org.projectfloodlight.openflow.protocol.OFStatsReply; import org.projectfloodlight.openflow.protocol.OFStatsRequest; import org.projectfloodlight.openflow.types.DatapathId; import org.projectfloodlight.openflow.types.OFAuxId; +import org.projectfloodlight.openflow.types.U64; import com.google.common.collect.Iterables; import com.google.common.util.concurrent.ListenableFuture; @@ -214,4 +216,16 @@ public class MockOFConnection implements IOFConnectionBackend { public OFMessage retrieveMessage() { return this.messages.remove(0); } + + @Override + public U64 getLatency() { + // TODO Auto-generated method stub + return null; + } + + @Override + public void updateLatency(U64 latency) { + // TODO Auto-generated method stub + + } } diff --git a/src/test/java/net/floodlightcontroller/core/internal/OFSwitchHandshakeHandlerVer13Test.java b/src/test/java/net/floodlightcontroller/core/internal/OFSwitchHandshakeHandlerVer13Test.java index 3d78ab6fc07bc836d32f96d1b000e6696ae5e337..9cb4c82167651f09f48588bc085e460103220e23 100644 --- a/src/test/java/net/floodlightcontroller/core/internal/OFSwitchHandshakeHandlerVer13Test.java +++ b/src/test/java/net/floodlightcontroller/core/internal/OFSwitchHandshakeHandlerVer13Test.java @@ -132,7 +132,8 @@ public class OFSwitchHandshakeHandlerVer13Test extends OFSwitchHandlerTestBase { verify(sw, switchManager); } - public void handleTableFeatures(boolean subHandShakeComplete) throws Exception { + @SuppressWarnings("unchecked") + public void handleTableFeatures(boolean subHandShakeComplete) throws Exception { // build the table features stats reply OFTableFeaturesStatsReply tf = createTableFeaturesStatsReply(); diff --git a/src/test/java/net/floodlightcontroller/linkdiscovery/internal/LinkDiscoveryManagerTest.java b/src/test/java/net/floodlightcontroller/linkdiscovery/internal/LinkDiscoveryManagerTest.java index 3597bcc7209809c09165334ef9306426ce80f2e1..cd7fe7ae38caec6fa499d4fcec08155cf2631ce3 100644 --- a/src/test/java/net/floodlightcontroller/linkdiscovery/internal/LinkDiscoveryManagerTest.java +++ b/src/test/java/net/floodlightcontroller/linkdiscovery/internal/LinkDiscoveryManagerTest.java @@ -83,6 +83,7 @@ import org.projectfloodlight.openflow.types.EthType; import org.projectfloodlight.openflow.types.MacAddress; import org.projectfloodlight.openflow.types.OFBufferId; import org.projectfloodlight.openflow.types.OFPort; +import org.projectfloodlight.openflow.types.U64; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -174,7 +175,7 @@ public class LinkDiscoveryManagerTest extends FloodlightTestCase { public void testAddOrUpdateLink() throws Exception { LinkDiscoveryManager linkDiscovery = getLinkDiscoveryManager(); - Link lt = new Link(DatapathId.of(1L), OFPort.of(2), DatapathId.of(2L), OFPort.of(1)); + Link lt = new Link(DatapathId.of(1L), OFPort.of(2), DatapathId.of(2L), OFPort.of(1), U64.ZERO); LinkInfo info = new LinkInfo(new Date(), new Date(), null); linkDiscovery.addOrUpdateLink(lt, info); @@ -197,7 +198,7 @@ public class LinkDiscoveryManagerTest extends FloodlightTestCase { public void testDeleteLink() throws Exception { LinkDiscoveryManager linkDiscovery = getLinkDiscoveryManager(); - Link lt = new Link(DatapathId.of(1L), OFPort.of(2), DatapathId.of(2L), OFPort.of(1)); + Link lt = new Link(DatapathId.of(1L), OFPort.of(2), DatapathId.of(2L), OFPort.of(1), U64.ZERO); LinkInfo info = new LinkInfo(new Date(), new Date(), null); linkDiscovery.addOrUpdateLink(lt, info); @@ -215,7 +216,7 @@ public class LinkDiscoveryManagerTest extends FloodlightTestCase { public void testAddOrUpdateLinkToSelf() throws Exception { LinkDiscoveryManager linkDiscovery = getLinkDiscoveryManager(); - Link lt = new Link(DatapathId.of(1L), OFPort.of(2), DatapathId.of(2L), OFPort.of(3)); + Link lt = new Link(DatapathId.of(1L), OFPort.of(2), DatapathId.of(2L), OFPort.of(3), U64.ZERO); NodePortTuple srcNpt = new NodePortTuple(DatapathId.of(1L), OFPort.of(2)); NodePortTuple dstNpt = new NodePortTuple(DatapathId.of(2L), OFPort.of(3)); @@ -237,7 +238,7 @@ public class LinkDiscoveryManagerTest extends FloodlightTestCase { public void testDeleteLinkToSelf() throws Exception { LinkDiscoveryManager linkDiscovery = getLinkDiscoveryManager(); - Link lt = new Link(DatapathId.of(1L), OFPort.of(2), DatapathId.of(1L), OFPort.of(3)); + Link lt = new Link(DatapathId.of(1L), OFPort.of(2), DatapathId.of(1L), OFPort.of(3), U64.ZERO); NodePortTuple srcNpt = new NodePortTuple(DatapathId.of(1L), OFPort.of(2)); NodePortTuple dstNpt = new NodePortTuple(DatapathId.of(2L), OFPort.of(3)); @@ -258,7 +259,7 @@ public class LinkDiscoveryManagerTest extends FloodlightTestCase { public void testRemovedSwitch() { LinkDiscoveryManager linkDiscovery = getLinkDiscoveryManager(); - Link lt = new Link(DatapathId.of(1L), OFPort.of(2), DatapathId.of(2L), OFPort.of(1)); + Link lt = new Link(DatapathId.of(1L), OFPort.of(2), DatapathId.of(2L), OFPort.of(1), U64.ZERO); NodePortTuple srcNpt = new NodePortTuple(DatapathId.of(1L), OFPort.of(2)); NodePortTuple dstNpt = new NodePortTuple(DatapathId.of(2L), OFPort.of(1)); LinkInfo info = new LinkInfo(new Date(), @@ -284,7 +285,7 @@ public class LinkDiscoveryManagerTest extends FloodlightTestCase { LinkDiscoveryManager linkDiscovery = getLinkDiscoveryManager(); IOFSwitch sw1 = createMockSwitch(1L); replay(sw1); - Link lt = new Link(DatapathId.of(1L), OFPort.of(2), DatapathId.of(1L), OFPort.of(3)); + Link lt = new Link(DatapathId.of(1L), OFPort.of(2), DatapathId.of(1L), OFPort.of(3), U64.ZERO); LinkInfo info = new LinkInfo(new Date(), new Date(), null); linkDiscovery.addOrUpdateLink(lt, info); @@ -304,7 +305,7 @@ public class LinkDiscoveryManagerTest extends FloodlightTestCase { public void testAddUpdateLinks() throws Exception { LinkDiscoveryManager linkDiscovery = getLinkDiscoveryManager(); - Link lt = new Link(DatapathId.of(1L), OFPort.of(1), DatapathId.of(2L), OFPort.of(1)); + Link lt = new Link(DatapathId.of(1L), OFPort.of(1), DatapathId.of(2L), OFPort.of(1), U64.ZERO); NodePortTuple srcNpt = new NodePortTuple(DatapathId.of(1L), OFPort.of(1)); NodePortTuple dstNpt = new NodePortTuple(DatapathId.of(2L), OFPort.of(1)); @@ -368,7 +369,7 @@ public class LinkDiscoveryManagerTest extends FloodlightTestCase { assertTrue(linkDiscovery.links.get(lt) == null); // Start clean and see if loops are also added. - lt = new Link(DatapathId.of(1L), OFPort.of(1), DatapathId.of(1L), OFPort.of(2)); + lt = new Link(DatapathId.of(1L), OFPort.of(1), DatapathId.of(1L), OFPort.of(2), U64.ZERO); srcNpt = new NodePortTuple(DatapathId.of(1L), OFPort.of(1)); dstNpt = new NodePortTuple(DatapathId.of(1L), OFPort.of(2)); info = new LinkInfo(new Date(System.currentTimeMillis() - 40000), @@ -377,7 +378,7 @@ public class LinkDiscoveryManagerTest extends FloodlightTestCase { // Start clean and see if loops are also added. - lt = new Link(DatapathId.of(1L), OFPort.of(1), DatapathId.of(1L), OFPort.of(3)); + lt = new Link(DatapathId.of(1L), OFPort.of(1), DatapathId.of(1L), OFPort.of(3), U64.ZERO); srcNpt = new NodePortTuple(DatapathId.of(1L), OFPort.of(1)); dstNpt = new NodePortTuple(DatapathId.of(1L), OFPort.of(3)); info = new LinkInfo(new Date(System.currentTimeMillis() - 40000), @@ -385,7 +386,7 @@ public class LinkDiscoveryManagerTest extends FloodlightTestCase { linkDiscovery.addOrUpdateLink(lt, info); // Start clean and see if loops are also added. - lt = new Link(DatapathId.of(1L), OFPort.of(4), DatapathId.of(1L), OFPort.of(5)); + lt = new Link(DatapathId.of(1L), OFPort.of(4), DatapathId.of(1L), OFPort.of(5), U64.ZERO); srcNpt = new NodePortTuple(DatapathId.of(1L), OFPort.of(4)); dstNpt = new NodePortTuple(DatapathId.of(1L), OFPort.of(5)); info = new LinkInfo(new Date(System.currentTimeMillis() - 40000), @@ -393,7 +394,7 @@ public class LinkDiscoveryManagerTest extends FloodlightTestCase { linkDiscovery.addOrUpdateLink(lt, info); // Start clean and see if loops are also added. - lt = new Link(DatapathId.of(1L), OFPort.of(3), DatapathId.of(1L), OFPort.of(5)); + lt = new Link(DatapathId.of(1L), OFPort.of(3), DatapathId.of(1L), OFPort.of(5), U64.ZERO); srcNpt = new NodePortTuple(DatapathId.of(1L), OFPort.of(3)); dstNpt = new NodePortTuple(DatapathId.of(1L), OFPort.of(5)); info = new LinkInfo(new Date(System.currentTimeMillis() - 40000), @@ -407,7 +408,7 @@ public class LinkDiscoveryManagerTest extends FloodlightTestCase { IOFSwitch sw1 = createMockSwitch(1L); IOFSwitch sw2 = createMockSwitch(2L); replay(sw1, sw2); - Link lt = new Link(DatapathId.of(1L), OFPort.of(2), DatapathId.of(2L), OFPort.of(1)); + Link lt = new Link(DatapathId.of(1L), OFPort.of(2), DatapathId.of(2L), OFPort.of(1), U64.ZERO); NodePortTuple srcNpt = new NodePortTuple(DatapathId.of(1L), OFPort.of(2)); NodePortTuple dstNpt = new NodePortTuple(DatapathId.of(2L), OFPort.of(1)); LinkInfo info = new LinkInfo(new Date(), @@ -467,6 +468,7 @@ public class LinkDiscoveryManagerTest extends FloodlightTestCase { expect(sw1.getEnabledPortNumbers()).andReturn(ports).anyTimes(); expect(sw1.getPort(OFPort.of(EasyMock.anyInt()))).andReturn(ofpp).anyTimes(); expect(sw1.getOFFactory()).andReturn(OFFactories.getFactory(OFVersion.OF_13)).anyTimes(); + expect(sw1.getLatency()).andReturn(U64.ZERO).anyTimes(); sw1.write(capture(wc)); expectLastCall().anyTimes(); replay(sw1); diff --git a/src/test/java/net/floodlightcontroller/topology/TopologyInstanceTest.java b/src/test/java/net/floodlightcontroller/topology/TopologyInstanceTest.java index dc5c5b6d0f0ff1c79ce092b17a2f84219f82265b..445e4c00cae2b951928c2919ad7c4a449deb9933 100644 --- a/src/test/java/net/floodlightcontroller/topology/TopologyInstanceTest.java +++ b/src/test/java/net/floodlightcontroller/topology/TopologyInstanceTest.java @@ -43,6 +43,7 @@ import org.junit.Before; import org.junit.Test; import org.projectfloodlight.openflow.types.DatapathId; import org.projectfloodlight.openflow.types.OFPort; +import org.projectfloodlight.openflow.types.U64; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -153,7 +154,7 @@ public class TopologyInstanceTest { else if (r[4] == TUNNEL_LINK) type = ILinkDiscovery.LinkType.TUNNEL; - topologyManager.addOrUpdateLink(DatapathId.of(r[0]), OFPort.of(r[1]), DatapathId.of(r[2]), OFPort.of(r[3]), type); + topologyManager.addOrUpdateLink(DatapathId.of(r[0]), OFPort.of(r[1]), DatapathId.of(r[2]), OFPort.of(r[3]), U64.ZERO, type); } topologyManager.createNewInstance(); } diff --git a/src/test/java/net/floodlightcontroller/topology/TopologyManagerTest.java b/src/test/java/net/floodlightcontroller/topology/TopologyManagerTest.java index 905acbb052bbfae4366b9552895ab7ac4075276c..dabfaa196fd8b9ac01feae2ddc225d93b3974a3d 100644 --- a/src/test/java/net/floodlightcontroller/topology/TopologyManagerTest.java +++ b/src/test/java/net/floodlightcontroller/topology/TopologyManagerTest.java @@ -33,6 +33,7 @@ import org.junit.Before; import org.junit.Test; import org.projectfloodlight.openflow.types.DatapathId; import org.projectfloodlight.openflow.types.OFPort; +import org.projectfloodlight.openflow.types.U64; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -59,7 +60,7 @@ public class TopologyManagerTest extends FloodlightTestCase { @Test public void testBasic1() throws Exception { - tm.addOrUpdateLink(DatapathId.of(1), OFPort.of(1), DatapathId.of(2), OFPort.of(1), ILinkDiscovery.LinkType.DIRECT_LINK); + tm.addOrUpdateLink(DatapathId.of(1), OFPort.of(1), DatapathId.of(2), OFPort.of(1), U64.ZERO, ILinkDiscovery.LinkType.DIRECT_LINK); assertTrue(tm.getSwitchPorts().size() == 2); // for two nodes. assertTrue(tm.getSwitchPorts().get(DatapathId.of(1)).size()==1); assertTrue(tm.getSwitchPorts().get(DatapathId.of(2)).size()==1); @@ -67,7 +68,7 @@ public class TopologyManagerTest extends FloodlightTestCase { assertTrue(tm.getPortBroadcastDomainLinks().size()==0); assertTrue(tm.getTunnelPorts().size()==0); - tm.addOrUpdateLink(DatapathId.of(1), OFPort.of(2), DatapathId.of(2), OFPort.of(2), ILinkDiscovery.LinkType.MULTIHOP_LINK); + tm.addOrUpdateLink(DatapathId.of(1), OFPort.of(2), DatapathId.of(2), OFPort.of(2), U64.ZERO, ILinkDiscovery.LinkType.MULTIHOP_LINK); assertTrue(tm.getSwitchPorts().size() == 2); // for two nodes. assertTrue(tm.getSwitchPorts().get(DatapathId.of(1)).size()==2); assertTrue(tm.getSwitchPorts().get(DatapathId.of(2)).size()==2); @@ -90,8 +91,8 @@ public class TopologyManagerTest extends FloodlightTestCase { @Test public void testBasic2() throws Exception { - tm.addOrUpdateLink(DatapathId.of(1), OFPort.of(1), DatapathId.of(2), OFPort.of(1), ILinkDiscovery.LinkType.DIRECT_LINK); - tm.addOrUpdateLink(DatapathId.of(2), OFPort.of(2), DatapathId.of(3), OFPort.of(1), ILinkDiscovery.LinkType.MULTIHOP_LINK); + tm.addOrUpdateLink(DatapathId.of(1), OFPort.of(1), DatapathId.of(2), OFPort.of(1), U64.ZERO, ILinkDiscovery.LinkType.DIRECT_LINK); + tm.addOrUpdateLink(DatapathId.of(2), OFPort.of(2), DatapathId.of(3), OFPort.of(1), U64.ZERO, ILinkDiscovery.LinkType.MULTIHOP_LINK); assertTrue(tm.getSwitchPorts().size() == 3); // for two nodes. assertTrue(tm.getSwitchPorts().get(DatapathId.of(1)).size()==1); assertTrue(tm.getSwitchPorts().get(DatapathId.of(2)).size()==2); diff --git a/src/test/java/net/floodlightcontroller/util/OFMessageDamperMockSwitch.java b/src/test/java/net/floodlightcontroller/util/OFMessageDamperMockSwitch.java index 1416e8353b59fb7b82bf42a5ad95a8d37c2eb10e..c4005b32aaec719cfd0f4f43732bacc941f75bb3 100644 --- a/src/test/java/net/floodlightcontroller/util/OFMessageDamperMockSwitch.java +++ b/src/test/java/net/floodlightcontroller/util/OFMessageDamperMockSwitch.java @@ -44,6 +44,7 @@ import org.projectfloodlight.openflow.protocol.OFStatsRequest; import org.projectfloodlight.openflow.types.DatapathId; import org.projectfloodlight.openflow.types.OFPort; import org.projectfloodlight.openflow.types.TableId; +import org.projectfloodlight.openflow.types.U64; import com.google.common.collect.ImmutableList; import com.google.common.util.concurrent.ListenableFuture; @@ -348,4 +349,10 @@ public class OFMessageDamperMockSwitch implements IOFSwitch { // TODO Auto-generated method stub return null; } + + @Override + public U64 getLatency() { + // TODO Auto-generated method stub + return null; + } }