Committed by
Gerrit Code Review
Segment Routing ONS demo fixes: Includes traffic visualization fix
Change-Id: I5119271464b696fd145c6b63bee09d7f3ef109bd
Showing
4 changed files
with
33 additions
and
22 deletions
... | @@ -121,6 +121,10 @@ public class IpHandler { | ... | @@ -121,6 +121,10 @@ public class IpHandler { |
121 | * @param destIpAddress destination IP address | 121 | * @param destIpAddress destination IP address |
122 | */ | 122 | */ |
123 | public void forwardPackets(DeviceId deviceId, Ip4Address destIpAddress) { | 123 | public void forwardPackets(DeviceId deviceId, Ip4Address destIpAddress) { |
124 | + if (ipPacketQueue.get(destIpAddress) == null) { | ||
125 | + return; | ||
126 | + } | ||
127 | + | ||
124 | for (IPv4 ipPacket : ipPacketQueue.get(destIpAddress)) { | 128 | for (IPv4 ipPacket : ipPacketQueue.get(destIpAddress)) { |
125 | Ip4Address destAddress = Ip4Address.valueOf(ipPacket.getDestinationAddress()); | 129 | Ip4Address destAddress = Ip4Address.valueOf(ipPacket.getDestinationAddress()); |
126 | if (ipPacket != null && config.inSameSubnet(deviceId, destAddress)) { | 130 | if (ipPacket != null && config.inSameSubnet(deviceId, destAddress)) { | ... | ... |
... | @@ -51,6 +51,7 @@ public class PortStatisticsManager implements PortStatisticsService { | ... | @@ -51,6 +51,7 @@ public class PortStatisticsManager implements PortStatisticsService { |
51 | 51 | ||
52 | private static final long POLL_FREQUENCY = 10_000; // milliseconds | 52 | private static final long POLL_FREQUENCY = 10_000; // milliseconds |
53 | private static final long STALE_LIMIT = (long) (1.5 * POLL_FREQUENCY); | 53 | private static final long STALE_LIMIT = (long) (1.5 * POLL_FREQUENCY); |
54 | + private static final int SECOND = 1_000; // milliseconds | ||
54 | 55 | ||
55 | @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) | 56 | @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) |
56 | protected DeviceService deviceService; | 57 | protected DeviceService deviceService; |
... | @@ -79,13 +80,11 @@ public class PortStatisticsManager implements PortStatisticsService { | ... | @@ -79,13 +80,11 @@ public class PortStatisticsManager implements PortStatisticsService { |
79 | long now = System.currentTimeMillis(); | 80 | long now = System.currentTimeMillis(); |
80 | 81 | ||
81 | if (c != null && p != null && (now - c.time < STALE_LIMIT)) { | 82 | if (c != null && p != null && (now - c.time < STALE_LIMIT)) { |
82 | - if (c.stats.durationSec() > p.stats.durationSec() && | 83 | + if ((c.time > p.time + SECOND) && |
83 | - c.stats.bytesSent() >= p.stats.bytesSent() && | 84 | + (c.stats.bytesSent() >= p.stats.bytesSent())) { |
84 | - c.stats.durationSec() >= POLL_FREQUENCY / 1_000) { | ||
85 | return new DefaultLoad(c.stats.bytesSent(), p.stats.bytesSent(), | 85 | return new DefaultLoad(c.stats.bytesSent(), p.stats.bytesSent(), |
86 | - c.stats.durationSec() - p.stats.durationSec()); | 86 | + (int) (c.time - p.time) / SECOND); |
87 | } | 87 | } |
88 | - return new DefaultLoad(c.stats.bytesSent(), 0, c.stats.durationSec()); | ||
89 | } | 88 | } |
90 | return null; | 89 | return null; |
91 | } | 90 | } | ... | ... |
... | @@ -105,7 +105,7 @@ public class OpenFlowDeviceProvider extends AbstractProvider implements DevicePr | ... | @@ -105,7 +105,7 @@ public class OpenFlowDeviceProvider extends AbstractProvider implements DevicePr |
105 | private final InternalDeviceProvider listener = new InternalDeviceProvider(); | 105 | private final InternalDeviceProvider listener = new InternalDeviceProvider(); |
106 | 106 | ||
107 | // TODO: We need to make the poll interval configurable. | 107 | // TODO: We need to make the poll interval configurable. |
108 | - static final int POLL_INTERVAL = 10; | 108 | + static final int POLL_INTERVAL = 5; |
109 | 109 | ||
110 | private HashMap<Dpid, PortStatsCollector> collectors = Maps.newHashMap(); | 110 | private HashMap<Dpid, PortStatsCollector> collectors = Maps.newHashMap(); |
111 | 111 | ||
... | @@ -245,7 +245,7 @@ public class OpenFlowDeviceProvider extends AbstractProvider implements DevicePr | ... | @@ -245,7 +245,7 @@ public class OpenFlowDeviceProvider extends AbstractProvider implements DevicePr |
245 | 245 | ||
246 | private class InternalDeviceProvider implements OpenFlowSwitchListener, OpenFlowEventListener { | 246 | private class InternalDeviceProvider implements OpenFlowSwitchListener, OpenFlowEventListener { |
247 | 247 | ||
248 | - private List<OFPortStatsEntry> portStatsReplies = Lists.newArrayList(); | 248 | + private HashMap<Dpid, List<OFPortStatsEntry>> portStatsReplies = new HashMap<>(); |
249 | 249 | ||
250 | @Override | 250 | @Override |
251 | public void switchAdded(Dpid dpid) { | 251 | public void switchAdded(Dpid dpid) { |
... | @@ -450,10 +450,15 @@ public class OpenFlowDeviceProvider extends AbstractProvider implements DevicePr | ... | @@ -450,10 +450,15 @@ public class OpenFlowDeviceProvider extends AbstractProvider implements DevicePr |
450 | case STATS_REPLY: | 450 | case STATS_REPLY: |
451 | if (((OFStatsReply) msg).getStatsType() == OFStatsType.PORT) { | 451 | if (((OFStatsReply) msg).getStatsType() == OFStatsType.PORT) { |
452 | OFPortStatsReply portStatsReply = (OFPortStatsReply) msg; | 452 | OFPortStatsReply portStatsReply = (OFPortStatsReply) msg; |
453 | - portStatsReplies.addAll(portStatsReply.getEntries()); | 453 | + List<OFPortStatsEntry> portStatsReplyList = portStatsReplies.get(dpid); |
454 | + if (portStatsReplyList == null) { | ||
455 | + portStatsReplyList = Lists.newArrayList(); | ||
456 | + } | ||
457 | + portStatsReplyList.addAll(portStatsReply.getEntries()); | ||
458 | + portStatsReplies.put(dpid, portStatsReplyList); | ||
454 | if (!portStatsReply.getFlags().contains(OFStatsReplyFlags.REPLY_MORE)) { | 459 | if (!portStatsReply.getFlags().contains(OFStatsReplyFlags.REPLY_MORE)) { |
455 | - pushPortMetrics(dpid, portStatsReplies); | 460 | + pushPortMetrics(dpid, portStatsReplies.get(dpid)); |
456 | - portStatsReplies.clear(); | 461 | + portStatsReplies.get(dpid).clear(); |
457 | } | 462 | } |
458 | } | 463 | } |
459 | break; | 464 | break; | ... | ... |
1 | { | 1 | { |
2 | "devices": [ | 2 | "devices": [ |
3 | - { "uri": "of:00010001e88b27e3", "mac": "0001e88b27e3", "annotations": { "name": "s101", "latitude": 41.996877, "longitude": -84.169273 }}, | ||
4 | { "uri": "of:00010001e88b9368", "mac": "0001e88b9368", "annotations": { "name": "s101", "latitude": 37.710742, "longitude": -103.975010 }}, | 3 | { "uri": "of:00010001e88b9368", "mac": "0001e88b9368", "annotations": { "name": "s101", "latitude": 37.710742, "longitude": -103.975010 }}, |
5 | - { "uri": "of:00010001e88b93ad", "mac": "0001e88b93ad", "annotations": { "name": "s101", "latitude": 37.634692, "longitude": -84.215821 }}, | 4 | + { "uri": "of:00010001e88b939b", "mac": "0001e88b939b", "annotations": { "name": "s102", "latitude": 37.756072, "longitude": -97.547678 }}, |
6 | - { "uri": "of:00010001e88b93bc", "mac": "0001e88b93bc", "annotations": { "name": "s101", "latitude": 41.951018, "longitude": -103.853350 }}, | 5 | + { "uri": "of:00010001e88b938c", "mac": "0001e88b938c", "annotations": { "name": "s103", "latitude": 37.657851, "longitude": -90.778101 }}, |
7 | - { "uri": "of:00010001e88b9398", "mac": "0001e88b9398", "annotations": { "name": "s101", "latitude": 41.952876, "longitude": -90.696484 }}, | 6 | + { "uri": "of:00010001e88b93ad", "mac": "0001e88b93ad", "annotations": { "name": "s104", "latitude": 37.634692, "longitude": -84.215821 }}, |
8 | - { "uri": "of:00010001e88b938c", "mac": "0001e88b938c", "annotations": { "name": "s101", "latitude": 37.657851, "longitude": -90.778101 }}, | 7 | + { "uri": "of:00010001e88b93bc", "mac": "0001e88b93bc", "annotations": { "name": "s105", "latitude": 41.951018, "longitude": -103.853350 }}, |
9 | - { "uri": "of:00010001e88b939b", "mac": "0001e88b939b", "annotations": { "name": "s101", "latitude": 37.756072, "longitude": -97.547678 }}, | 8 | + { "uri": "of:00010001e88b93c2", "mac": "0001e88b93c2", "annotations": { "name": "s106", "latitude": 41.945684, "longitude": -97.526174 }}, |
10 | - { "uri": "of:00010001e88b93c2", "mac": "0001e88b93c2", "annotations": { "name": "s101", "latitude": 41.945684, "longitude": -97.526174 }} | 9 | + { "uri": "of:00010001e88b9398", "mac": "0001e88b9398", "annotations": { "name": "s107", "latitude": 41.952876, "longitude": -90.696484 }}, |
10 | + { "uri": "of:00010001e88b27e3", "mac": "0001e88b27e3", "annotations": { "name": "s108", "latitude": 41.996877, "longitude": -84.169273 }} | ||
11 | ], | 11 | ], |
12 | "hosts": [ | 12 | "hosts": [ |
13 | - { "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 }}, | 13 | + { "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 }}, |
14 | - { "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 }}, | 14 | + { "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 }}, |
15 | - { "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 }}, | 15 | + { "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 }}, |
16 | - { "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 }}, | 16 | + { "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 }}, |
17 | - { "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 }} | 17 | + { "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 }}, |
18 | + { "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 }}, | ||
19 | + { "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 }}, | ||
20 | + { "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 }} | ||
18 | ] | 21 | ] |
19 | } | 22 | } | ... | ... |
-
Please register or login to post a comment