face: increment link layer byte counters in WebSocketFace
Change-Id: I88b7dea1cbd291765345982ce193700aacd73eb3
Refs: #1781
diff --git a/daemon/face/websocket-face.cpp b/daemon/face/websocket-face.cpp
index c0d6732..79faf73 100644
--- a/daemon/face/websocket-face.cpp
+++ b/daemon/face/websocket-face.cpp
@@ -48,6 +48,7 @@
this->onSendInterest(interest);
const Block& payload = interest.wireEncode();
+ this->getMutableCounters().getNOutBytes() += payload.size();
try {
m_server.send(m_handle, payload.wire(), payload.size(),
@@ -67,6 +68,7 @@
this->onSendData(data);
const Block& payload = data.wireEncode();
+ this->getMutableCounters().getNOutBytes() += payload.size();
try {
m_server.send(m_handle, payload.wire(), payload.size(),
@@ -97,6 +99,8 @@
// Copy message into Face internal buffer
BOOST_ASSERT(msg.size() <= MAX_NDN_PACKET_SIZE);
+ this->getMutableCounters().getNInBytes() += msg.size();
+
// Try to parse message data
bool isOk = true;
Block element;
diff --git a/tests/core/segment-publisher.cpp b/tests/core/segment-publisher.cpp
index da35376..f859408 100644
--- a/tests/core/segment-publisher.cpp
+++ b/tests/core/segment-publisher.cpp
@@ -37,7 +37,7 @@
NFD_LOG_INIT("SegmentPublisherTest");
-template<size_t N=10000>
+template<int64_t N=10000>
class TestSegmentPublisher : public SegmentPublisher<DummyFace>
{
public:
@@ -73,7 +73,7 @@
generate(ndn::EncodingBuffer& outBuffer)
{
size_t totalLength = 0;
- for (uint64_t i = 0; i < N; i++)
+ for (int64_t i = 0; i < N; i++)
{
totalLength += prependNonNegativeIntegerBlock(outBuffer, ndn::Tlv::Content, i);
}
@@ -85,7 +85,7 @@
size_t m_totalPayloadLength;
};
-template<size_t N>
+template<int64_t N>
class SegmentPublisherFixture : public BaseFixture
{
public:
diff --git a/tests/daemon/face/websocket.cpp b/tests/daemon/face/websocket.cpp
index 6eb8dc8..54b4813 100644
--- a/tests/daemon/face/websocket.cpp
+++ b/tests/daemon/face/websocket.cpp
@@ -192,8 +192,6 @@
websocketpp::connection_hdl handle;
std::vector<Interest> client1_receivedInterests;
std::vector<Data> client1_receivedDatas;
-
- std::list< shared_ptr<Face> > faces;
};
BOOST_FIXTURE_TEST_CASE(EndToEnd4, EndToEndFixture)
@@ -244,6 +242,8 @@
client1_sendData (*data2);
client1_sendData (*data2);
client1_sendData (*data2);
+ size_t nBytesSent = data1->wireEncode().size() + interest2->wireEncode().size();
+ size_t nBytesReceived = interest1->wireEncode().size() * 3 + data2->wireEncode().size() * 3;
BOOST_CHECK_MESSAGE(limitedIo.run(8, time::seconds(10)) == LimitedIo::EXCEED_OPS,
"WebSocketChannel error: cannot send or receive Interest/Data packets");
@@ -263,6 +263,8 @@
BOOST_CHECK_EQUAL(counters1.getNInDatas() , 3);
BOOST_CHECK_EQUAL(counters1.getNOutInterests(), 1);
BOOST_CHECK_EQUAL(counters1.getNOutDatas() , 1);
+ BOOST_CHECK_EQUAL(counters1.getNInBytes(), nBytesReceived);
+ BOOST_CHECK_EQUAL(counters1.getNOutBytes(), nBytesSent);
}
BOOST_AUTO_TEST_SUITE_END()