PSync: use interest lifetime as initialRto in SegmentFetcher

refs: #4945

Change-Id: If9e3d268da3dbffda3f4a7d67039413954628d2b
This commit is contained in:
Ashlesh Gawande
2019-05-19 16:15:33 -07:00
parent f9adc5a7d3
commit 584e120f3c
5 changed files with 49 additions and 10 deletions
+4
View File
@@ -68,6 +68,8 @@ Consumer::addSubscription(const ndn::Name& prefix)
void
Consumer::stop()
{
m_scheduler.cancelAllEvents();
if (m_syncFetcher) {
m_syncFetcher->stop();
m_syncFetcher.reset();
@@ -93,6 +95,7 @@ Consumer::sendHelloInterest()
SegmentFetcher::Options options;
options.interestLifetime = m_helloInterestLifetime;
options.maxTimeout = m_helloInterestLifetime;
options.rttOptions.initialRto = m_syncInterestLifetime;
m_helloFetcher = SegmentFetcher::start(m_face, helloInterest,
ndn::security::v2::getAcceptAllValidator(), options);
@@ -179,6 +182,7 @@ Consumer::sendSyncInterest()
SegmentFetcher::Options options;
options.interestLifetime = m_syncInterestLifetime;
options.maxTimeout = m_syncInterestLifetime;;
options.rttOptions.initialRto = m_syncInterestLifetime;
m_syncFetcher = SegmentFetcher::start(m_face, syncInterest,
ndn::security::v2::getAcceptAllValidator(), options);
+5 -8
View File
@@ -107,6 +107,7 @@ FullProducer::sendSyncInterest()
SegmentFetcher::Options options;
options.interestLifetime = m_syncInterestLifetime;
options.maxTimeout = m_syncInterestLifetime;
options.rttOptions.initialRto = m_syncInterestLifetime;
m_fetcher = SegmentFetcher::start(m_face, syncInterest,
ndn::security::v2::getAcceptAllValidator(), options);
@@ -341,14 +342,10 @@ FullProducer::isFutureHash(const ndn::Name& prefix, const std::set<uint32_t>& ne
void
FullProducer::deletePendingInterests(const ndn::Name& interestName)
{
for (auto it = m_pendingEntries.begin(); it != m_pendingEntries.end();) {
if (it->first == interestName) {
NDN_LOG_TRACE("Delete pending interest: " << interestName);
it = m_pendingEntries.erase(it);
}
else {
++it;
}
auto it = m_pendingEntries.find(interestName);
if (it != m_pendingEntries.end()) {
NDN_LOG_TRACE("Delete pending interest: " << interestName);
it = m_pendingEntries.erase(it);
}
}
+1 -2
View File
@@ -97,7 +97,7 @@ public:
void
publishName(const ndn::Name& prefix, ndn::optional<uint64_t> seq = ndn::nullopt);
private:
PSYNC_PUBLIC_WITH_TESTS_ELSE_PRIVATE:
/**
* @brief Send sync interest for full synchronization
*
@@ -108,7 +108,6 @@ private:
void
sendSyncInterest();
PSYNC_PUBLIC_WITH_TESTS_ELSE_PRIVATE:
/**
* @brief Process sync interest from other parties
*
+24
View File
@@ -18,6 +18,7 @@
**/
#include "PSync/consumer.hpp"
#include "unit-test-time-fixture.hpp"
#include <boost/test/unit_test.hpp>
#include <ndn-cxx/name.hpp>
@@ -56,6 +57,29 @@ BOOST_AUTO_TEST_CASE(AddSubscription)
BOOST_CHECK(!consumer.addSubscription(subscription));
}
BOOST_FIXTURE_TEST_CASE(ConstantTimeoutForFirstSegment, ndn::tests::UnitTestTimeFixture)
{
util::DummyClientFace face(io, {true, true});
Consumer consumer(Name("/psync"), face,
[] (const vector<Name>&) {},
[] (const vector<MissingDataInfo>&) {},
40, 0.001,
ndn::time::milliseconds(4000),
ndn::time::milliseconds(4000));
consumer.sendHelloInterest();
advanceClocks(ndn::time::milliseconds(4000));
BOOST_CHECK_EQUAL(face.sentInterests.size(), 1);
face.sentInterests.clear();
consumer.stop();
consumer.m_iblt = ndn::Name("test");
consumer.sendSyncInterest();
advanceClocks(ndn::time::milliseconds(4000));
BOOST_CHECK_EQUAL(face.sentInterests.size(), 1);
consumer.stop();
}
BOOST_AUTO_TEST_SUITE_END()
} // namespace psync
+15
View File
@@ -18,6 +18,7 @@
**/
#include "PSync/full-producer.hpp"
#include "unit-test-time-fixture.hpp"
#include <boost/test/unit_test.hpp>
#include <ndn-cxx/name.hpp>
@@ -50,6 +51,20 @@ BOOST_AUTO_TEST_CASE(OnInterest)
BOOST_REQUIRE_NO_THROW(node.onSyncInterest(syncPrefix, Interest(syncInterestName)));
}
BOOST_FIXTURE_TEST_CASE(ConstantTimeoutForFirstSegment, ndn::tests::UnitTestTimeFixture)
{
Name syncPrefix("/psync"), userNode("/testUser");
util::DummyClientFace face(io, {true, true});
FullProducer node(40, face, syncPrefix, userNode, nullptr, ndn::time::milliseconds(8000));
advanceClocks(ndn::time::milliseconds(10));
face.sentInterests.clear();
// full sync sends the next one in interest lifetime / 2 +- jitter
advanceClocks(ndn::time::milliseconds(6000));
BOOST_CHECK_EQUAL(face.sentInterests.size(), 1);
}
BOOST_AUTO_TEST_SUITE_END()
} // namespace psync