Segment Routing ONS demo fixes: Includes traffic visualization fix
Change-Id: I5119271464b696fd145c6b63bee09d7f3ef109bd
diff --git a/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/IpHandler.java b/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/IpHandler.java
index a46fb57..81d00f5 100644
--- a/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/IpHandler.java
+++ b/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/IpHandler.java
@@ -121,6 +121,10 @@
* @param destIpAddress destination IP address
*/
public void forwardPackets(DeviceId deviceId, Ip4Address destIpAddress) {
+ if (ipPacketQueue.get(destIpAddress) == null) {
+ return;
+ }
+
for (IPv4 ipPacket : ipPacketQueue.get(destIpAddress)) {
Ip4Address destAddress = Ip4Address.valueOf(ipPacket.getDestinationAddress());
if (ipPacket != null && config.inSameSubnet(deviceId, destAddress)) {
diff --git a/incubator/net/src/main/java/org/onosproject/incubator/net/impl/PortStatisticsManager.java b/incubator/net/src/main/java/org/onosproject/incubator/net/impl/PortStatisticsManager.java
index be4915d..c403bb9 100644
--- a/incubator/net/src/main/java/org/onosproject/incubator/net/impl/PortStatisticsManager.java
+++ b/incubator/net/src/main/java/org/onosproject/incubator/net/impl/PortStatisticsManager.java
@@ -51,6 +51,7 @@
private static final long POLL_FREQUENCY = 10_000; // milliseconds
private static final long STALE_LIMIT = (long) (1.5 * POLL_FREQUENCY);
+ private static final int SECOND = 1_000; // milliseconds
@Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
protected DeviceService deviceService;
@@ -79,13 +80,11 @@
long now = System.currentTimeMillis();
if (c != null && p != null && (now - c.time < STALE_LIMIT)) {
- if (c.stats.durationSec() > p.stats.durationSec() &&
- c.stats.bytesSent() >= p.stats.bytesSent() &&
- c.stats.durationSec() >= POLL_FREQUENCY / 1_000) {
+ if ((c.time > p.time + SECOND) &&
+ (c.stats.bytesSent() >= p.stats.bytesSent())) {
return new DefaultLoad(c.stats.bytesSent(), p.stats.bytesSent(),
- c.stats.durationSec() - p.stats.durationSec());
+ (int) (c.time - p.time) / SECOND);
}
- return new DefaultLoad(c.stats.bytesSent(), 0, c.stats.durationSec());
}
return null;
}
diff --git a/providers/openflow/device/src/main/java/org/onosproject/provider/of/device/impl/OpenFlowDeviceProvider.java b/providers/openflow/device/src/main/java/org/onosproject/provider/of/device/impl/OpenFlowDeviceProvider.java
index 7ae6db1..5f0efa5 100644
--- a/providers/openflow/device/src/main/java/org/onosproject/provider/of/device/impl/OpenFlowDeviceProvider.java
+++ b/providers/openflow/device/src/main/java/org/onosproject/provider/of/device/impl/OpenFlowDeviceProvider.java
@@ -105,7 +105,7 @@
private final InternalDeviceProvider listener = new InternalDeviceProvider();
// TODO: We need to make the poll interval configurable.
- static final int POLL_INTERVAL = 10;
+ static final int POLL_INTERVAL = 5;
private HashMap<Dpid, PortStatsCollector> collectors = Maps.newHashMap();
@@ -245,7 +245,7 @@
private class InternalDeviceProvider implements OpenFlowSwitchListener, OpenFlowEventListener {
- private List<OFPortStatsEntry> portStatsReplies = Lists.newArrayList();
+ private HashMap<Dpid, List<OFPortStatsEntry>> portStatsReplies = new HashMap<>();
@Override
public void switchAdded(Dpid dpid) {
@@ -450,10 +450,15 @@
case STATS_REPLY:
if (((OFStatsReply) msg).getStatsType() == OFStatsType.PORT) {
OFPortStatsReply portStatsReply = (OFPortStatsReply) msg;
- portStatsReplies.addAll(portStatsReply.getEntries());
+ List<OFPortStatsEntry> portStatsReplyList = portStatsReplies.get(dpid);
+ if (portStatsReplyList == null) {
+ portStatsReplyList = Lists.newArrayList();
+ }
+ portStatsReplyList.addAll(portStatsReply.getEntries());
+ portStatsReplies.put(dpid, portStatsReplyList);
if (!portStatsReply.getFlags().contains(OFStatsReplyFlags.REPLY_MORE)) {
- pushPortMetrics(dpid, portStatsReplies);
- portStatsReplies.clear();
+ pushPortMetrics(dpid, portStatsReplies.get(dpid));
+ portStatsReplies.get(dpid).clear();
}
}
break;
diff --git a/tools/test/topos/cord.json b/tools/test/topos/cord.json
index ac31dfe..aba8276 100644
--- a/tools/test/topos/cord.json
+++ b/tools/test/topos/cord.json
@@ -1,19 +1,22 @@
{
"devices": [
- { "uri": "of:00010001e88b27e3", "mac": "0001e88b27e3", "annotations": { "name": "s101", "latitude": 41.996877, "longitude": -84.169273 }},
{ "uri": "of:00010001e88b9368", "mac": "0001e88b9368", "annotations": { "name": "s101", "latitude": 37.710742, "longitude": -103.975010 }},
- { "uri": "of:00010001e88b93ad", "mac": "0001e88b93ad", "annotations": { "name": "s101", "latitude": 37.634692, "longitude": -84.215821 }},
- { "uri": "of:00010001e88b93bc", "mac": "0001e88b93bc", "annotations": { "name": "s101", "latitude": 41.951018, "longitude": -103.853350 }},
- { "uri": "of:00010001e88b9398", "mac": "0001e88b9398", "annotations": { "name": "s101", "latitude": 41.952876, "longitude": -90.696484 }},
- { "uri": "of:00010001e88b938c", "mac": "0001e88b938c", "annotations": { "name": "s101", "latitude": 37.657851, "longitude": -90.778101 }},
- { "uri": "of:00010001e88b939b", "mac": "0001e88b939b", "annotations": { "name": "s101", "latitude": 37.756072, "longitude": -97.547678 }},
- { "uri": "of:00010001e88b93c2", "mac": "0001e88b93c2", "annotations": { "name": "s101", "latitude": 41.945684, "longitude": -97.526174 }}
+ { "uri": "of:00010001e88b939b", "mac": "0001e88b939b", "annotations": { "name": "s102", "latitude": 37.756072, "longitude": -97.547678 }},
+ { "uri": "of:00010001e88b938c", "mac": "0001e88b938c", "annotations": { "name": "s103", "latitude": 37.657851, "longitude": -90.778101 }},
+ { "uri": "of:00010001e88b93ad", "mac": "0001e88b93ad", "annotations": { "name": "s104", "latitude": 37.634692, "longitude": -84.215821 }},
+ { "uri": "of:00010001e88b93bc", "mac": "0001e88b93bc", "annotations": { "name": "s105", "latitude": 41.951018, "longitude": -103.853350 }},
+ { "uri": "of:00010001e88b93c2", "mac": "0001e88b93c2", "annotations": { "name": "s106", "latitude": 41.945684, "longitude": -97.526174 }},
+ { "uri": "of:00010001e88b9398", "mac": "0001e88b9398", "annotations": { "name": "s107", "latitude": 41.952876, "longitude": -90.696484 }},
+ { "uri": "of:00010001e88b27e3", "mac": "0001e88b27e3", "annotations": { "name": "s108", "latitude": 41.996877, "longitude": -84.169273 }}
],
"hosts": [
- { "id": "5A:66:A0:6F:10:A5/-1", "mac": "5A:66:A0:6F:10:A5", "vlan": -1, "location": "of:00010001e88b93ad/1", "ip": "1.2.3.4", "annotations": { "name": "h1", "latitude": 34.384830, "longitude": -104.019262 }},
- { "id": "D2:22:5A:E1:52:B7/-1", "mac": "D2:22:5A:E1:52:B7", "vlan": -1, "location": "of:00010001e88b93ad/1", "ip": "1.2.3.4", "annotations": { "name": "h1", "latitude": 34.133376, "longitude": -89.442032 }},
- { "id": "F2:25:F0:11:69:E2/-1", "mac": "F2:25:F0:11:69:E2", "vlan": -1, "location": "of:00010001e88b93ad/1", "ip": "1.2.3.4", "annotations": { "name": "h1", "latitude": 34.166625, "longitude": -91.983293 }},
- { "id": "52:1C:5E:A5:8C:E0/-1", "mac": "52:1C:5E:A5:8C:E0", "vlan": -1, "location": "of:00010001e88b93ad/1", "ip": "1.2.3.4", "annotations": { "name": "h1", "latitude": 34.225065, "longitude": -97.492882 }},
- { "id": "EA:11:0C:F7:49:D8/-1", "mac": "EA:11:0C:F7:49:D8", "vlan": -1, "location": "of:00010001e88b93ad/1", "ip": "1.2.3.4", "annotations": { "name": "h1", "latitude": 34.249236, "longitude": -84.253025 }}
+ { "id": "00:1f:29:e1:2c:36/-1", "mac": "00:1f:29:e1:2c:36", "vlan": -1, "location": "of:00010001e88b9368/46", "ip": "10.200.1.11", "annotations": { "name": "h1", "latitude": 34.384830, "longitude": -104.019262 }},
+ { "id": "00:1e:0b:cb:9d:64/-1", "mac": "00:1e:0b:cb:9d:64", "vlan": -1, "location": "of:00010001e88b9368/45", "ip": "10.200.1.12", "annotations": { "name": "h2", "latitude": 34.384830, "longitude": -104.019262 }},
+ { "id": "00:1c:c4:6b:d8:12/-1", "mac": "00:1c:c4:6b:d8:12", "vlan": -1, "location": "of:00010001e88b939b/46", "ip": "10.200.2.21", "annotations": { "name": "h3", "latitude": 34.133376, "longitude": -89.442032 }},
+ { "id": "00:1e:0b:ca:90:44/-1", "mac": "00:1e:0b:ca:90:44", "vlan": -1, "location": "of:00010001e88b939b/45", "ip": "10.200.2.22", "annotations": { "name": "h4", "latitude": 34.133376, "longitude": -89.442032 }},
+ { "id": "00:1e:0b:ca:e5:1a/-1", "mac": "00:1e:0b:ca:e5:1a", "vlan": -1, "location": "of:00010001e88b938c/46", "ip": "10.200.3.31", "annotations": { "name": "h5", "latitude": 34.166625, "longitude": -91.983293 }},
+ { "id": "52:1C:5E:A5:8C:E0/-1", "mac": "52:1C:5E:A5:8C:E0", "vlan": -1, "location": "of:00010001e88b938c/45", "ip": "10.200.3.32", "annotations": { "name": "h6", "latitude": 34.166625, "longitude": -91.983293 }},
+ { "id": "00:1e:0b:cb:3f:ac/-1", "mac": "00:1e:0b:cb:3f:ac", "vlan": -1, "location": "of:00010001e88b93ad/46", "ip": "10.200.4.41", "annotations": { "name": "h7", "latitude": 34.225065, "longitude": -97.492882 }},
+ { "id": "EA:11:0C:F7:49:D8/-1", "mac": "EA:11:0C:F7:49:D8", "vlan": -1, "location": "of:00010001e88b93ad/45", "ip": "10.200.4.42", "annotations": { "name": "h8", "latitude": 34.249236, "longitude": -84.253025 }}
]
}