Srikanth Vavilapalli
Committed by Gerrit Code Review

Segment Routing ONS demo:Traffic visualization fixes

Change-Id: Ib4960a0fe4666b8027614c8dd04df7883746b9b9
...@@ -80,11 +80,20 @@ public class PortStatisticsManager implements PortStatisticsService { ...@@ -80,11 +80,20 @@ public class PortStatisticsManager implements PortStatisticsService {
80 long now = System.currentTimeMillis(); 80 long now = System.currentTimeMillis();
81 81
82 if (c != null && p != null && (now - c.time < STALE_LIMIT)) { 82 if (c != null && p != null && (now - c.time < STALE_LIMIT)) {
83 - if ((c.time > p.time + SECOND) && 83 + if (c.time > p.time + SECOND) {
84 - (c.stats.bytesSent() >= p.stats.bytesSent())) { 84 + //Use max of either Tx or Rx load as the total load of a port
85 - return new DefaultLoad(c.stats.bytesSent(), p.stats.bytesSent(), 85 + Load load = null;
86 + if (c.stats.bytesSent() >= p.stats.bytesSent()) {
87 + load = new DefaultLoad(c.stats.bytesSent(), p.stats.bytesSent(),
86 (int) (c.time - p.time) / SECOND); 88 (int) (c.time - p.time) / SECOND);
87 } 89 }
90 + if (c.stats.bytesReceived() >= p.stats.bytesReceived()) {
91 + Load rcvLoad = new DefaultLoad(c.stats.bytesReceived(), p.stats.bytesReceived(),
92 + (int) (c.time - p.time) / SECOND);
93 + load = ((load == null) || (rcvLoad.rate() > load.rate())) ? rcvLoad : load;
94 + }
95 + return load;
96 + }
88 } 97 }
89 return null; 98 return null;
90 } 99 }
......
...@@ -10,13 +10,15 @@ ...@@ -10,13 +10,15 @@
10 { "uri": "of:00010001e88b27e3", "mac": "0001e88b27e3", "annotations": { "name": "s108", "latitude": 41.996877, "longitude": -84.169273 }} 10 { "uri": "of:00010001e88b27e3", "mac": "0001e88b27e3", "annotations": { "name": "s108", "latitude": 41.996877, "longitude": -84.169273 }}
11 ], 11 ],
12 "hosts": [ 12 "hosts": [
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 }}, 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": "h11", "latitude": 34.384830, "longitude": -104.019262 }},
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 }}, 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": "h12", "latitude": 34.384830, "longitude": -104.019262 }},
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 }}, 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": "h21", "latitude": 34.133376, "longitude": -89.442032 }},
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 }}, 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": "h22", "latitude": 34.133376, "longitude": -89.442032 }},
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 }}, 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": "h31", "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 }}, 18 + { "id": "2c:44:fd:e0:90:40/-1", "mac": "2c:44:fd:e0:90:40", "vlan": -1, "location": "of:00010001e88b938c/45", "ip": "10.200.3.32", "annotations": { "name": "h32", "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 }}, 19 + { "id": "2c:44:fd:e0:90:44/-1", "mac": "2c:44:fd:e0:90:44", "vlan": -1, "location": "of:00010001e88b938c/47", "ip": "10.200.3.33", "annotations": { "name": "h33", "latitude": 34.166625, "longitude": -91.983293 }},
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 }} 20 + { "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": "h41", "latitude": 34.225065, "longitude": -97.492882 }},
21 + { "id": "c8:1f:66:e2:9b:d0/-1", "mac": "c8:1f:66:e2:9b:d0", "vlan": -1, "location": "of:00010001e88b93ad/45", "ip": "10.200.4.42", "annotations": { "name": "h42", "latitude": 34.249236, "longitude": -84.253025 }},
22 + { "id": "c8:1f:66:e2:9b:d2/-1", "mac": "c8:1f:66:e2:9b:d2", "vlan": -1, "location": "of:00010001e88b93ad/47", "ip": "10.200.4.43", "annotations": { "name": "h43", "latitude": 34.249236, "longitude": -84.253025 }}
21 ] 23 ]
22 } 24 }
......
...@@ -117,17 +117,20 @@ public abstract class TopologyViewMessageHandlerBase extends UiMessageHandler { ...@@ -117,17 +117,20 @@ public abstract class TopologyViewMessageHandlerBase extends UiMessageHandler {
117 new ProviderId("core", "org.onosproject.core", true); 117 new ProviderId("core", "org.onosproject.core", true);
118 private static final String COMPACT = "%s/%s-%s/%s"; 118 private static final String COMPACT = "%s/%s-%s/%s";
119 119
120 - private static final double KB = 1024; 120 + private static final double KILO = 1024;
121 - private static final double MB = 1024 * KB; 121 + private static final double MEGA = 1024 * KILO;
122 - private static final double GB = 1024 * MB; 122 + private static final double GIGA = 1024 * MEGA;
123 - 123 +
124 - // TODO: change GB to Gb (when we compute bits/second) 124 + private static final String GBITS_UNIT = "Gb";
125 - private static final String GB_UNIT = "GB"; 125 + private static final String MBITS_UNIT = "Mb";
126 - private static final String MB_UNIT = "MB"; 126 + private static final String KBITS_UNIT = "Kb";
127 - private static final String KB_UNIT = "KB"; 127 + private static final String BITS_UNIT = "b";
128 - private static final String B_UNIT = "B"; 128 + private static final String GBYTES_UNIT = "GB";
129 - 129 + private static final String MBYTES_UNIT = "MB";
130 - private static final double BPS_THRESHOLD = 4 * KB; 130 + private static final String KBYTES_UNIT = "KB";
131 + private static final String BYTES_UNIT = "B";
132 + //4 Kilo Bytes as threshold
133 + private static final double BPS_THRESHOLD = 4 * KILO;
131 134
132 protected ServiceDirectory directory; 135 protected ServiceDirectory directory;
133 protected ClusterService clusterService; 136 protected ClusterService clusterService;
...@@ -576,13 +579,17 @@ public abstract class TopologyViewMessageHandlerBase extends UiMessageHandler { ...@@ -576,13 +579,17 @@ public abstract class TopologyViewMessageHandlerBase extends UiMessageHandler {
576 link.addLoad(getLinkLoad(link.one)); 579 link.addLoad(getLinkLoad(link.one));
577 link.addLoad(bi ? getLinkLoad(link.two) : null); 580 link.addLoad(bi ? getLinkLoad(link.two) : null);
578 } else if (type == PORT) { 581 } else if (type == PORT) {
579 - link.addLoad(portStatsService.load(link.one.src()), BPS_THRESHOLD); 582 + //For a bi-directional traffic links, use
580 - link.addLoad(portStatsService.load(link.one.dst()), BPS_THRESHOLD); 583 + //the max link rate of either direction
584 + link.addLoad(portStatsService.load(link.one.src()),
585 + BPS_THRESHOLD,
586 + portStatsService.load(link.one.dst()),
587 + BPS_THRESHOLD);
581 } 588 }
582 if (link.hasTraffic) { 589 if (link.hasTraffic) {
583 linksNodeT.add(compactLinkString(link.one)); 590 linksNodeT.add(compactLinkString(link.one));
584 labelsT.add(type == PORT ? 591 labelsT.add(type == PORT ?
585 - formatBytes(link.rate) + "ps" : 592 + formatBitRate(link.rate) + "ps" :
586 formatBytes(link.bytes)); 593 formatBytes(link.bytes));
587 } else { 594 } else {
588 linksNodeN.add(compactLinkString(link.one)); 595 linksNodeN.add(compactLinkString(link.one));
...@@ -745,21 +752,43 @@ public abstract class TopologyViewMessageHandlerBase extends UiMessageHandler { ...@@ -745,21 +752,43 @@ public abstract class TopologyViewMessageHandlerBase extends UiMessageHandler {
745 752
746 // Poor-mans formatting to get the labels with byte counts looking nice. 753 // Poor-mans formatting to get the labels with byte counts looking nice.
747 private String formatBytes(long bytes) { 754 private String formatBytes(long bytes) {
748 - // TODO: multiply everything by 8 to compute bits/second
749 String unit; 755 String unit;
750 double value; 756 double value;
751 - if (bytes > GB) { 757 + if (bytes > GIGA) {
752 - value = bytes / GB; 758 + value = bytes / GIGA;
753 - unit = GB_UNIT; 759 + unit = GBYTES_UNIT;
754 - } else if (bytes > MB) { 760 + } else if (bytes > MEGA) {
755 - value = bytes / MB; 761 + value = bytes / MEGA;
756 - unit = MB_UNIT; 762 + unit = MBYTES_UNIT;
757 - } else if (bytes > KB) { 763 + } else if (bytes > KILO) {
758 - value = bytes / KB; 764 + value = bytes / KILO;
759 - unit = KB_UNIT; 765 + unit = KBYTES_UNIT;
760 } else { 766 } else {
761 value = bytes; 767 value = bytes;
762 - unit = B_UNIT; 768 + unit = BYTES_UNIT;
769 + }
770 + DecimalFormat format = new DecimalFormat("#,###.##");
771 + return format.format(value) + " " + unit;
772 + }
773 +
774 + // Poor-mans formatting to get the labels with byte counts looking nice.
775 + private String formatBitRate(long bytes) {
776 + String unit;
777 + double value;
778 + //Convert to bits
779 + long bits = bytes * 8;
780 + if (bits > GIGA) {
781 + value = bits / GIGA;
782 + unit = GBITS_UNIT;
783 + } else if (bits > MEGA) {
784 + value = bits / MEGA;
785 + unit = MBITS_UNIT;
786 + } else if (bits > KILO) {
787 + value = bits / KILO;
788 + unit = KBITS_UNIT;
789 + } else {
790 + value = bits;
791 + unit = BITS_UNIT;
763 } 792 }
764 DecimalFormat format = new DecimalFormat("#,###.##"); 793 DecimalFormat format = new DecimalFormat("#,###.##");
765 return format.format(value) + " " + unit; 794 return format.format(value) + " " + unit;
...@@ -832,6 +861,26 @@ public abstract class TopologyViewMessageHandlerBase extends UiMessageHandler { ...@@ -832,6 +861,26 @@ public abstract class TopologyViewMessageHandlerBase extends UiMessageHandler {
832 } 861 }
833 } 862 }
834 863
864 + void addLoad(Load srcLinkLoad,
865 + double srcLinkThreshold,
866 + Load dstLinkLoad,
867 + double dstLinkThreshold) {
868 + //use the max of link load at source or destination
869 + if (srcLinkLoad != null) {
870 + this.hasTraffic = hasTraffic || srcLinkLoad.rate() > srcLinkThreshold;
871 + this.bytes = srcLinkLoad.latest();
872 + this.rate = srcLinkLoad.rate();
873 + }
874 +
875 + if (dstLinkLoad != null) {
876 + if (dstLinkLoad.rate() > this.rate) {
877 + this.bytes = dstLinkLoad.latest();
878 + this.rate = dstLinkLoad.rate();
879 + this.hasTraffic = hasTraffic || dstLinkLoad.rate() > dstLinkThreshold;
880 + }
881 + }
882 + }
883 +
835 void addClass(String trafficClass) { 884 void addClass(String trafficClass) {
836 classes.add(trafficClass); 885 classes.add(trafficClass);
837 } 886 }
......
...@@ -462,40 +462,40 @@ html[data-platform='iPad'] #topo-p-detail { ...@@ -462,40 +462,40 @@ html[data-platform='iPad'] #topo-p-detail {
462 stroke: rgba(121,231,158,0.5); 462 stroke: rgba(121,231,158,0.5);
463 } 463 }
464 464
465 -/* Port traffic color visualization for KBps, MBps, and GBps */ 465 +/* Port traffic color visualization for Kbps, Mbps, and Gbps */
466 466
467 -.light #ov-topo svg .link.secondary.port-traffic-KBps { 467 +.light #ov-topo svg .link.secondary.port-traffic-Kbps {
468 stroke: rgb(0,153,51); 468 stroke: rgb(0,153,51);
469 stroke-width: 5.0; 469 stroke-width: 5.0;
470 } 470 }
471 -.dark #ov-topo svg .link.secondary.port-traffic-KBps { 471 +.dark #ov-topo svg .link.secondary.port-traffic-Kbps {
472 stroke: rgb(98, 153, 118); 472 stroke: rgb(98, 153, 118);
473 stroke-width: 5.0; 473 stroke-width: 5.0;
474 } 474 }
475 475
476 -.light #ov-topo svg .link.secondary.port-traffic-MBps { 476 +.light #ov-topo svg .link.secondary.port-traffic-Mbps {
477 stroke: rgb(128,145,27); 477 stroke: rgb(128,145,27);
478 stroke-width: 6.5; 478 stroke-width: 6.5;
479 } 479 }
480 -.dark #ov-topo svg .link.secondary.port-traffic-MBps { 480 +.dark #ov-topo svg .link.secondary.port-traffic-Mbps {
481 stroke: rgb(91, 109, 54); 481 stroke: rgb(91, 109, 54);
482 stroke-width: 6.5; 482 stroke-width: 6.5;
483 } 483 }
484 484
485 -.light #ov-topo svg .link.secondary.port-traffic-GBps { 485 +.light #ov-topo svg .link.secondary.port-traffic-Gbps {
486 stroke: rgb(255, 137, 3); 486 stroke: rgb(255, 137, 3);
487 stroke-width: 8.0; 487 stroke-width: 8.0;
488 } 488 }
489 -.dark #ov-topo svg .link.secondary.port-traffic-GBps { 489 +.dark #ov-topo svg .link.secondary.port-traffic-Gbps {
490 stroke: rgb(174, 119, 55); 490 stroke: rgb(174, 119, 55);
491 stroke-width: 8.0; 491 stroke-width: 8.0;
492 } 492 }
493 493
494 -.light #ov-topo svg .link.secondary.port-traffic-GBps-choked { 494 +.light #ov-topo svg .link.secondary.port-traffic-Gbps-choked {
495 stroke: rgb(183, 30, 21); 495 stroke: rgb(183, 30, 21);
496 stroke-width: 8.0; 496 stroke-width: 8.0;
497 } 497 }
498 -.dark #ov-topo svg .link.secondary.port-traffic-GBps-choked { 498 +.dark #ov-topo svg .link.secondary.port-traffic-Gbps-choked {
499 stroke: rgb(127, 40, 39); 499 stroke: rgb(127, 40, 39);
500 stroke-width: 8.0; 500 stroke-width: 8.0;
501 } 501 }
......
...@@ -69,8 +69,7 @@ ...@@ -69,8 +69,7 @@
69 ldata.el.classed(p.class, true); 69 ldata.el.classed(p.class, true);
70 ldata.label = lab; 70 ldata.label = lab;
71 71
72 - // TODO: change this to 'bps' when we measure bits/sec 72 + if (fs.endsWith(lab, 'bps')) {
73 - if (fs.endsWith(lab, 'Bps')) {
74 // inject additional styling for port-based traffic 73 // inject additional styling for port-based traffic
75 units = lab.substring(lab.length-4); 74 units = lab.substring(lab.length-4);
76 portcls = 'port-traffic-' + units; 75 portcls = 'port-traffic-' + units;
......
...@@ -46,7 +46,7 @@ ...@@ -46,7 +46,7 @@
46 { "id": "rack", "pos":[800,600], "class":"blue1" } 46 { "id": "rack", "pos":[800,600], "class":"blue1" }
47 ], 47 ],
48 "labels": [ 48 "labels": [
49 - { "pos":[550,80], "text":"Segment Routing Demo", "class":"blue1", "size":1.4 } 49 + { "pos":[550,80], "text":"", "class":"blue1", "size":1.4 }
50 ] 50 ]
51 } 51 }
52 } 52 }
......