tools: Visualize per-face link-layer byte counts in nfd-status

refs #1768

Change-Id: Ic70567501903f6d386a9dc5fdc81e70eeb8c5fd7
diff --git a/docs/_static/nfd-status.xsd b/docs/_static/nfd-status.xsd
index 425bbd8..6a080a7 100644
--- a/docs/_static/nfd-status.xsd
+++ b/docs/_static/nfd-status.xsd
@@ -18,6 +18,13 @@
   </xs:sequence>
 </xs:complexType>
 
+<xs:complexType name="bidirectionalByteCountersType">
+  <xs:sequence>
+    <xs:element type="xs:nonNegativeInteger" name="incomingBytes"/>
+    <xs:element type="xs:nonNegativeInteger" name="outgoingBytes"/>
+  </xs:sequence>
+</xs:complexType>
+
 <xs:complexType name="generalStatusType">
   <xs:sequence>
     <xs:element type="xs:string" name="version"/>
@@ -59,6 +66,7 @@
     <xs:element type="xs:anyURI" name="localUri"/>
     <xs:element type="xs:duration" name="expirationPeriod" minOccurs="0"/>
     <xs:element type="nfd:bidirectionalPacketCountersType" name="packetCounters"/>
+    <xs:element type="nfd:bidirectionalByteCountersType" name="byteCounters"/>
     <xs:element type="nfd:faceFlagsType" name="flags" minOccurs="0"/>
   </xs:sequence>
 </xs:complexType>
diff --git a/docs/manpages/nfd-status.rst b/docs/manpages/nfd-status.rst
index 217fca5..a4d7c04 100644
--- a/docs/manpages/nfd-status.rst
+++ b/docs/manpages/nfd-status.rst
@@ -53,37 +53,46 @@
 Get all status information from NFD::
 
     $ nfd-status
+
     General NFD status:
-                   version=1000
-                 startTime=20140621T165241.938000
-               currentTime=20140621T170712.007000
-                    uptime=870 seconds
-          nNameTreeEntries=8
-               nFibEntries=2
+                   version=2000
+                 startTime=20140725T232341.374000
+               currentTime=20140725T233240
+                    uptime=538 seconds
+          nNameTreeEntries=10
+               nFibEntries=3
                nPitEntries=2
       nMeasurementsEntries=0
-                nCsEntries=24
-              nInInterests=33
-             nOutInterests=31
-                  nInDatas=24
-                 nOutDatas=18
+                nCsEntries=56
+              nInInterests=55
+             nOutInterests=54
+                  nInDatas=56
+                 nOutDatas=47
     Channels:
+      ws://[::]:9696
       unix:///private/var/run/nfd.sock
       udp6://[::]:6363
       udp4://0.0.0.0:6363
       tcp6://[::]:6363
       tcp4://0.0.0.0:6363
     Faces:
-      faceid=1 remote=internal:// local=internal:// counters={in={0i 26d} out={34i 0d}}
-      faceid=2 remote=udp4://224.0.23.170:56363 local=udp4://192.168.1.103:56363 counters={in={0i 0d} out={0i 0d}}
-      faceid=3 remote=udp4://224.0.23.170:56363 local=udp4://127.0.0.1:56363 counters={in={0i 0d} out={0i 0d}}
-      faceid=4 remote=ether://[01:00:5e:00:17:aa] local=dev://bridge0 counters={in={0i 0d} out={0i 0d}}
-      faceid=5 remote=ether://[01:00:5e:00:17:aa] local=dev://en0 counters={in={0i 0d} out={0i 0d}}
-      faceid=6 remote=ether://[01:00:5e:00:17:aa] local=dev://en1 counters={in={0i 0d} out={0i 0d}}
-      faceid=7 remote=fd://27 local=unix:///private/var/run/nfd.sock counters={in={23i 0d} out={0i 8d}}
-      faceid=10 remote=fd://28 local=unix:///private/var/run/nfd.sock counters={in={3i 0d} out={0i 2d}}
+      faceid=1 remote=internal:// local=internal:// counters={in={0i 52d 0B} out={51i 0d 0B}} local
+      faceid=254 remote=contentstore:// local=contentstore:// counters={in={0i 0d 0B} out={0i 0d 0B}} local
+      faceid=255 remote=null:// local=null:// counters={in={0i 0d 0B} out={0i 0d 0B}} local
+      faceid=256 remote=udp4://224.0.23.170:56363 local=udp4://129.82.138.211:56363 counters={in={0i 0d 0B} out={0i 0d 0B}}
+      faceid=257 remote=udp4://224.0.23.170:56363 local=udp4://127.0.0.1:56363 counters={in={0i 0d 0B} out={0i 0d 0B}}
+      faceid=258 remote=ether://[01:00:5e:00:17:aa] local=dev://bridge0 counters={in={0i 0d 0B} out={0i 0d 0B}}
+      faceid=259 remote=ether://[01:00:5e:00:17:aa] local=dev://en0 counters={in={0i 0d 0B} out={0i 0d 0B}}
+      faceid=260 remote=ether://[01:00:5e:00:17:aa] local=dev://en1 counters={in={0i 0d 0B} out={0i 0d 0B}}
+      faceid=261 remote=ether://[01:00:5e:00:17:aa] local=dev://en2 counters={in={0i 0d 0B} out={0i 0d 0B}}
+      faceid=262 remote=fd://30 local=unix:///private/var/run/nfd.sock counters={in={24i 6d 4880B} out={6i 16d 8417B}} local on-demand
+      faceid=268 remote=fd://31 local=unix:///private/var/run/nfd.sock counters={in={1i 0d 410B} out={0i 1d 764B}} local on-demand
+      faceid=269 remote=fd://32 local=unix:///private/var/run/nfd.sock counters={in={3i 0d 137B} out={0i 2d 925B}} local on-demand
     FIB:
       /localhost/nfd nexthops={faceid=1 (cost=0)}
-      /localhost/nfd/rib nexthops={faceid=7 (cost=0)}
+      /example/testApp nexthops={faceid=268 (cost=0)}
+      /localhost/nfd/rib nexthops={faceid=262 (cost=0)}
+    Rib:
+     /example/testApp route={faceid=268 (origin=0 cost=0 flags=1)}
     Strategy choices:
       / strategy=/localhost/nfd/strategy/best-route
diff --git a/tools/nfd-status-http-server-files/nfd-status.xsl b/tools/nfd-status-http-server-files/nfd-status.xsl
index 37038c5..e7cc55a 100644
--- a/tools/nfd-status-http-server-files/nfd-status.xsl
+++ b/tools/nfd-status-http-server-files/nfd-status.xsl
@@ -143,8 +143,10 @@
         <th>Local URI</th>
         <th>In Interests</th>
         <th>In Data</th>
+        <th>In Bytes</th>
         <th>Out Interests</th>
         <th>Out Data</th>
+        <th>Out Bytes</th>
       </tr>
     </thead>
     <tbody>
@@ -163,8 +165,10 @@
         <td><xsl:value-of select="nfd:localUri"/></td>
         <td><xsl:value-of select="nfd:packetCounters/nfd:incomingPackets/nfd:nInterests"/></td>
         <td><xsl:value-of select="nfd:packetCounters/nfd:incomingPackets/nfd:nDatas"/></td>
+        <td><xsl:value-of select="nfd:byteCounters/nfd:incomingBytes"/></td>
         <td><xsl:value-of select="nfd:packetCounters/nfd:outgoingPackets/nfd:nInterests"/></td>
         <td><xsl:value-of select="nfd:packetCounters/nfd:outgoingPackets/nfd:nDatas"/></td>
+        <td><xsl:value-of select="nfd:byteCounters/nfd:outgoingBytes"/></td>
       </tr>
       </xsl:for-each>
     </tbody>
diff --git a/tools/nfd-status.cpp b/tools/nfd-status.cpp
index affd2d8..3262a28 100644
--- a/tools/nfd-status.cpp
+++ b/tools/nfd-status.cpp
@@ -401,6 +401,13 @@
             std::cout << "</outgoingPackets>";
             std::cout << "</packetCounters>";
 
+            std::cout << "<byteCounters>";
+            std::cout << "<incomingBytes>"    << faceStatus.getNInBytes()
+                      << "</incomingBytes>";
+            std::cout << "<outgoingBytes>"    << faceStatus.getNOutBytes()
+                      << "</outgoingBytes>";
+            std::cout << "</byteCounters>";
+
             if (faceStatus.getFlags() != 0) {
               std::cout << "<flags>";
               if (faceStatus.isLocal()) {
@@ -444,9 +451,11 @@
             }
             std::cout << " counters={"
                       << "in={" << faceStatus.getNInInterests() << "i "
-                      << faceStatus.getNInDatas() << "d}"
+                      << faceStatus.getNInDatas() << "d "
+                      << faceStatus.getNInBytes() << "B}"
                       << " out={" << faceStatus.getNOutInterests() << "i "
-                      << faceStatus.getNOutDatas() << "d}"
+                      << faceStatus.getNOutDatas() << "d "
+                      << faceStatus.getNOutBytes() << "B}"
                       << "}";
             if (faceStatus.isLocal())
               std::cout << " local";