Segment Routing ONS demo:Traffic visualization fixes

Change-Id: Ib4960a0fe4666b8027614c8dd04df7883746b9b9
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 c403bb9..1a61548 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
@@ -80,10 +80,19 @@
         long now = System.currentTimeMillis();
 
         if (c != null && p != null && (now - c.time < STALE_LIMIT)) {
-            if ((c.time > p.time + SECOND) &&
-                (c.stats.bytesSent() >= p.stats.bytesSent())) {
-                return new DefaultLoad(c.stats.bytesSent(), p.stats.bytesSent(),
-                                       (int) (c.time - p.time) / SECOND);
+            if (c.time > p.time + SECOND) {
+                //Use max of either Tx or Rx load as the total load of a port
+                Load load = null;
+                if (c.stats.bytesSent() >= p.stats.bytesSent()) {
+                    load = new DefaultLoad(c.stats.bytesSent(), p.stats.bytesSent(),
+                                                    (int) (c.time - p.time) / SECOND);
+                }
+                if (c.stats.bytesReceived() >= p.stats.bytesReceived()) {
+                    Load rcvLoad = new DefaultLoad(c.stats.bytesReceived(), p.stats.bytesReceived(),
+                                                    (int) (c.time - p.time) / SECOND);
+                    load = ((load == null) || (rcvLoad.rate() > load.rate())) ? rcvLoad : load;
+                }
+                return load;
             }
         }
         return null;