face: increment link layer byte counters in StreamFace and DatagramFace

refs #1766

Change-Id: I69377fa561ae1ee845808aa02ae1b85b1771899e
diff --git a/tests/daemon/face/tcp.cpp b/tests/daemon/face/tcp.cpp
index 2861be3..fa527e9 100644
--- a/tests/daemon/face/tcp.cpp
+++ b/tests/daemon/face/tcp.cpp
@@ -261,6 +261,7 @@
   face1->sendInterest(*interest1);
   face1->sendInterest(*interest1);
   face1->sendData    (*data1    );
+  size_t nBytesSent1 = interest1->wireEncode().size() * 3 + data1->wireEncode().size();
   face2->sendInterest(*interest2);
   face2->sendData    (*data2    );
   face2->sendData    (*data2    );
@@ -269,7 +270,6 @@
   BOOST_CHECK_MESSAGE(limitedIo.run(8, time::seconds(10)) == LimitedIo::EXCEED_OPS,
                       "TcpChannel error: cannot send or receive Interest/Data packets");
 
-
   BOOST_REQUIRE_EQUAL(face1_receivedInterests.size(), 1);
   BOOST_REQUIRE_EQUAL(face1_receivedDatas    .size(), 3);
   BOOST_REQUIRE_EQUAL(face2_receivedInterests.size(), 3);
@@ -280,17 +280,22 @@
   BOOST_CHECK_EQUAL(face2_receivedInterests[0].getName(), interest1->getName());
   BOOST_CHECK_EQUAL(face2_receivedDatas    [0].getName(), data1->getName());
 
+  // needed to ensure NOutBytes counters are accurate
+  limitedIo.run(LimitedIo::UNLIMITED_OPS, time::seconds(1));
+
   const FaceCounters& counters1 = face1->getCounters();
   BOOST_CHECK_EQUAL(counters1.getNInInterests() , 1);
   BOOST_CHECK_EQUAL(counters1.getNInDatas()     , 3);
   BOOST_CHECK_EQUAL(counters1.getNOutInterests(), 3);
   BOOST_CHECK_EQUAL(counters1.getNOutDatas()    , 1);
+  BOOST_CHECK_EQUAL(counters1.getNOutBytes(), nBytesSent1);
 
   const FaceCounters& counters2 = face2->getCounters();
   BOOST_CHECK_EQUAL(counters2.getNInInterests() , 3);
   BOOST_CHECK_EQUAL(counters2.getNInDatas()     , 1);
   BOOST_CHECK_EQUAL(counters2.getNOutInterests(), 1);
   BOOST_CHECK_EQUAL(counters2.getNOutDatas()    , 3);
+  BOOST_CHECK_EQUAL(counters2.getNInBytes(), nBytesSent1);
 }
 
 BOOST_FIXTURE_TEST_CASE(EndToEnd6, EndToEndFixture)
diff --git a/tests/daemon/face/udp.cpp b/tests/daemon/face/udp.cpp
index f2d3417..40485ca 100644
--- a/tests/daemon/face/udp.cpp
+++ b/tests/daemon/face/udp.cpp
@@ -379,6 +379,8 @@
   BOOST_CHECK_EQUAL(face2->getRemoteUri().toString(), "udp4://127.0.0.1:20070");
   BOOST_CHECK_EQUAL(face2->getLocalUri().toString(), "udp4://127.0.0.1:20071");
   BOOST_CHECK_EQUAL(face2->isLocal(), false);
+  BOOST_CHECK_EQUAL(face2->getCounters().getNOutBytes(), 0);
+  BOOST_CHECK_EQUAL(face2->getCounters().getNInBytes(), 0);
   // face1 is not created yet
 
   shared_ptr<UdpChannel> channel1 = factory.createChannel("127.0.0.1", "20070");
@@ -410,6 +412,7 @@
   face2->sendData    (data2    );
   face2->sendData    (data2    );
   face2->sendData    (data2    );
+  size_t nBytesSent2 = interest2.wireEncode().size() + data2.wireEncode().size() * 3;
 
   BOOST_CHECK_MESSAGE(limitedIo.run(5,//4 send + 1 listen return
                       time::seconds(4)) == LimitedIo::EXCEED_OPS,
@@ -428,7 +431,6 @@
   BOOST_CHECK_MESSAGE(limitedIo.run(4, time::seconds(4)) == LimitedIo::EXCEED_OPS,
                       "UdpChannel error: cannot send or receive Interest/Data packets");
 
-
   BOOST_REQUIRE_EQUAL(face1_receivedInterests.size(), 1);
   BOOST_REQUIRE_EQUAL(face1_receivedDatas    .size(), 3);
   BOOST_REQUIRE_EQUAL(face2_receivedInterests.size(), 3);
@@ -445,6 +447,7 @@
 
   face2->sendData    (data3    );
   face2->sendInterest(interest3);
+  nBytesSent2 += data3.wireEncode().size() + interest3.wireEncode().size();
 
   BOOST_CHECK_MESSAGE(limitedIo.run(2, time::seconds(1)) == LimitedIo::EXCEED_OPS,
                       "UdpChannel error: cannot send or receive Interest/Data packets");
@@ -460,12 +463,14 @@
   BOOST_CHECK_EQUAL(counters1.getNInDatas()     , 4);
   BOOST_CHECK_EQUAL(counters1.getNOutInterests(), 3);
   BOOST_CHECK_EQUAL(counters1.getNOutDatas()    , 1);
+  BOOST_CHECK_EQUAL(counters1.getNInBytes(), nBytesSent2);
 
   const FaceCounters& counters2 = face2->getCounters();
   BOOST_CHECK_EQUAL(counters2.getNInInterests() , 3);
   BOOST_CHECK_EQUAL(counters2.getNInDatas()     , 1);
   BOOST_CHECK_EQUAL(counters2.getNOutInterests(), 2);
   BOOST_CHECK_EQUAL(counters2.getNOutDatas()    , 4);
+  BOOST_CHECK_EQUAL(counters2.getNOutBytes(), nBytesSent2);
 }
 
 BOOST_FIXTURE_TEST_CASE(EndToEnd6, EndToEndFixture)
diff --git a/tests/daemon/face/unix-stream.cpp b/tests/daemon/face/unix-stream.cpp
index cb48db4..24154ec 100644
--- a/tests/daemon/face/unix-stream.cpp
+++ b/tests/daemon/face/unix-stream.cpp
@@ -213,10 +213,12 @@
   face1->sendInterest(*interest1);
   face1->sendInterest(*interest1);
   face1->sendData    (*data1    );
+  size_t nBytesSent1 = interest1->wireEncode().size() * 3 + data1->wireEncode().size();
   face2->sendInterest(*interest2);
   face2->sendData    (*data2    );
   face2->sendData    (*data2    );
   face2->sendData    (*data2    );
+  size_t nBytesSent2 = interest2->wireEncode().size() + data2->wireEncode().size() * 3;
 
   BOOST_CHECK_MESSAGE(limitedIo.run(8, time::seconds(1)) == LimitedIo::EXCEED_OPS,
                       "UnixStreamChannel error: cannot send or receive Interest/Data packets");
@@ -231,11 +233,16 @@
   BOOST_CHECK_EQUAL(face2_receivedInterests[0].getName(), interest1->getName());
   BOOST_CHECK_EQUAL(face2_receivedDatas    [0].getName(), data1->getName());
 
+  // needed to ensure NOutBytes counters are accurate
+  limitedIo.run(LimitedIo::UNLIMITED_OPS, time::seconds(1));
+
   const FaceCounters& counters1 = face1->getCounters();
   BOOST_CHECK_EQUAL(counters1.getNInInterests() , 1);
   BOOST_CHECK_EQUAL(counters1.getNInDatas()     , 3);
   BOOST_CHECK_EQUAL(counters1.getNOutInterests(), 3);
   BOOST_CHECK_EQUAL(counters1.getNOutDatas()    , 1);
+  BOOST_CHECK_EQUAL(counters1.getNInBytes(), nBytesSent2);
+  BOOST_CHECK_EQUAL(counters1.getNOutBytes(), nBytesSent1);
 
   const FaceCounters& counters2 = face2->getCounters();
   BOOST_CHECK_EQUAL(counters2.getNInInterests() , 3);