face: use ndn-cxx's RttEstimator in LpReliability
Refs: #4887
Change-Id: Iaf8b04e33de363bae2c99f10f3866773c900f30d
diff --git a/tests/daemon/face/lp-reliability.t.cpp b/tests/daemon/face/lp-reliability.t.cpp
index 5e73c03..e814042 100644
--- a/tests/daemon/face/lp-reliability.t.cpp
+++ b/tests/daemon/face/lp-reliability.t.cpp
@@ -40,8 +40,6 @@
using namespace nfd::tests;
-BOOST_AUTO_TEST_SUITE(Face)
-
class DummyLpReliabilityLinkService : public GenericLinkService
{
public:
@@ -58,11 +56,11 @@
Interest interest("/test/prefix");
interest.setCanBePrefix(false);
lp::Packet pkt;
- pkt.add<lp::FragmentField>(make_pair(interest.wireEncode().begin(), interest.wireEncode().end()));
+ pkt.add<lp::FragmentField>({interest.wireEncode().begin(), interest.wireEncode().end()});
m_reliability.handleOutgoing(frags, std::move(pkt), true);
}
- for (lp::Packet frag : frags) {
+ for (auto frag : frags) {
this->sendLpPacket(std::move(frag), 0);
}
}
@@ -116,9 +114,7 @@
netPktHasUnackedFrag(const shared_ptr<LpReliability::NetPkt>& netPkt, lp::Sequence txSeq)
{
return std::any_of(netPkt->unackedFrags.begin(), netPkt->unackedFrags.end(),
- [txSeq] (const LpReliability::UnackedFrags::iterator& frag) {
- return frag->first == txSeq;
- });
+ [txSeq] (auto fragIt) { return fragIt->first == txSeq; });
}
/** \brief make an LpPacket with fragment of specified size
@@ -134,7 +130,7 @@
lp::Packet pkt;
ndn::Buffer buf(payloadSize);
std::memcpy(buf.data(), &pktNo, sizeof(pktNo));
- pkt.set<lp::FragmentField>(make_pair(buf.cbegin(), buf.cend()));
+ pkt.set<lp::FragmentField>({buf.cbegin(), buf.cend()});
return pkt;
}
@@ -164,6 +160,7 @@
LpReliability* reliability;
};
+BOOST_AUTO_TEST_SUITE(Face)
BOOST_FIXTURE_TEST_SUITE(TestLpReliability, LpReliabilityFixture)
BOOST_AUTO_TEST_CASE(SendNoFragmentField)
@@ -715,7 +712,7 @@
BOOST_AUTO_TEST_CASE(ProcessIncomingPacket)
{
- BOOST_CHECK(!reliability->m_isIdleAckTimerRunning);
+ BOOST_CHECK(!reliability->m_idleAckTimer);
BOOST_CHECK_EQUAL(reliability->m_ackQueue.size(), 0);
lp::Packet pkt1 = makeFrag(100, 40);
@@ -723,7 +720,7 @@
reliability->processIncomingPacket(pkt1);
- BOOST_CHECK(reliability->m_isIdleAckTimerRunning);
+ BOOST_CHECK(reliability->m_idleAckTimer);
BOOST_REQUIRE_EQUAL(reliability->m_ackQueue.size(), 1);
BOOST_CHECK_EQUAL(reliability->m_ackQueue.front(), 765432);
@@ -732,14 +729,14 @@
reliability->processIncomingPacket(pkt2);
- BOOST_CHECK(reliability->m_isIdleAckTimerRunning);
+ BOOST_CHECK(reliability->m_idleAckTimer);
BOOST_REQUIRE_EQUAL(reliability->m_ackQueue.size(), 2);
BOOST_CHECK_EQUAL(reliability->m_ackQueue.front(), 765432);
BOOST_CHECK_EQUAL(reliability->m_ackQueue.back(), 234567);
// T+5ms
advanceClocks(1_ms, 5);
- BOOST_CHECK(!reliability->m_isIdleAckTimerRunning);
+ BOOST_CHECK(!reliability->m_idleAckTimer);
}
BOOST_AUTO_TEST_CASE(PiggybackAcks)
@@ -820,38 +817,38 @@
BOOST_AUTO_TEST_CASE(StartIdleAckTimer)
{
- BOOST_CHECK(!reliability->m_isIdleAckTimerRunning);
+ BOOST_CHECK(!reliability->m_idleAckTimer);
lp::Packet pkt1 = makeFrag(1, 100);
pkt1.add<lp::TxSequenceField>(12);
reliability->processIncomingPacket({pkt1});
- BOOST_CHECK(reliability->m_isIdleAckTimerRunning);
+ BOOST_CHECK(reliability->m_idleAckTimer);
// T+1ms
advanceClocks(1_ms, 1);
- BOOST_CHECK(reliability->m_isIdleAckTimerRunning);
+ BOOST_CHECK(reliability->m_idleAckTimer);
lp::Packet pkt2 = makeFrag(2, 100);
pkt2.add<lp::TxSequenceField>(13);
reliability->processIncomingPacket({pkt2});
- BOOST_CHECK(reliability->m_isIdleAckTimerRunning);
+ BOOST_CHECK(reliability->m_idleAckTimer);
// T+5ms
advanceClocks(1_ms, 4);
- BOOST_CHECK(!reliability->m_isIdleAckTimerRunning);
+ BOOST_CHECK(!reliability->m_idleAckTimer);
lp::Packet pkt3 = makeFrag(3, 100);
pkt3.add<lp::TxSequenceField>(15);
reliability->processIncomingPacket({pkt3});
- BOOST_CHECK(reliability->m_isIdleAckTimerRunning);
+ BOOST_CHECK(reliability->m_idleAckTimer);
// T+9ms
advanceClocks(1_ms, 4);
- BOOST_CHECK(reliability->m_isIdleAckTimerRunning);
+ BOOST_CHECK(reliability->m_idleAckTimer);
// T+10ms
advanceClocks(1_ms, 1);
- BOOST_CHECK(!reliability->m_isIdleAckTimerRunning);
+ BOOST_CHECK(!reliability->m_idleAckTimer);
}
BOOST_AUTO_TEST_CASE(IdleAckTimer)
@@ -862,13 +859,13 @@
reliability->m_ackQueue.push(i);
expectedAcks.insert(i);
}
- BOOST_CHECK(!reliability->m_isIdleAckTimerRunning);
+ BOOST_CHECK(!reliability->m_idleAckTimer);
reliability->startIdleAckTimer();
- BOOST_CHECK(reliability->m_isIdleAckTimerRunning);
+ BOOST_CHECK(reliability->m_idleAckTimer);
// T+4ms: idle ack timer has not yet expired, no IDLE packet generated
advanceClocks(1_ms, 4);
- BOOST_CHECK(reliability->m_isIdleAckTimerRunning);
+ BOOST_CHECK(reliability->m_idleAckTimer);
BOOST_CHECK_EQUAL(reliability->m_ackQueue.size(), 500);
BOOST_CHECK_EQUAL(reliability->m_ackQueue.front(), 1000);
BOOST_CHECK_EQUAL(reliability->m_ackQueue.back(), 1499);
@@ -876,7 +873,7 @@
// T+5ms: idle ack timer expires, IDLE packet generated
advanceClocks(1_ms, 1);
- BOOST_CHECK(!reliability->m_isIdleAckTimerRunning);
+ BOOST_CHECK(!reliability->m_idleAckTimer);
BOOST_CHECK_EQUAL(reliability->m_ackQueue.size(), 0);
BOOST_REQUIRE_EQUAL(transport->sentPackets.size(), 1);
@@ -898,13 +895,13 @@
reliability->m_ackQueue.push(i);
expectedAcks.insert(i);
}
- BOOST_CHECK(!reliability->m_isIdleAckTimerRunning);
+ BOOST_CHECK(!reliability->m_idleAckTimer);
reliability->startIdleAckTimer();
- BOOST_CHECK(reliability->m_isIdleAckTimerRunning);
+ BOOST_CHECK(reliability->m_idleAckTimer);
// T+4ms: idle ack timer has not yet expired, no IDLE packet generated
advanceClocks(1_ms, 4);
- BOOST_CHECK(reliability->m_isIdleAckTimerRunning);
+ BOOST_CHECK(reliability->m_idleAckTimer);
BOOST_CHECK_EQUAL(reliability->m_ackQueue.size(), 500);
BOOST_CHECK_EQUAL(reliability->m_ackQueue.front(), 1000);
BOOST_CHECK_EQUAL(reliability->m_ackQueue.back(), 1499);
@@ -912,7 +909,7 @@
// T+5ms: idle ack timer expires, IDLE packets generated
advanceClocks(1_ms, 1);
- BOOST_CHECK(!reliability->m_isIdleAckTimerRunning);
+ BOOST_CHECK(!reliability->m_idleAckTimer);
BOOST_CHECK_EQUAL(reliability->m_ackQueue.size(), 0);
// MTU is 1500. LpPacket TL occupies 4 octets. Each Ack header is 12 octets. There are room for