fw: use RetxSuppressionExponential in best-route
Retransmission suppression algorithm of best route strategy
is changed from fixed interval to exponential backoff.
This is a semantical change which requires an increment of the
strategy's version number from 2 to 3.
Version 2 is not retained because it's mostly same as version 3.
refs #1913
Change-Id: I0f18511a3b96384b071024864e638ae3b3ec7080
diff --git a/daemon/fw/best-route-strategy2.cpp b/daemon/fw/best-route-strategy2.cpp
index d243a37..2ec786c 100644
--- a/daemon/fw/best-route-strategy2.cpp
+++ b/daemon/fw/best-route-strategy2.cpp
@@ -31,7 +31,7 @@
NFD_LOG_INIT("BestRouteStrategy2");
-const Name BestRouteStrategy2::STRATEGY_NAME("ndn:/localhost/nfd/strategy/best-route/%FD%02");
+const Name BestRouteStrategy2::STRATEGY_NAME("ndn:/localhost/nfd/strategy/best-route/%FD%03");
NFD_REGISTER_STRATEGY(BestRouteStrategy2);
BestRouteStrategy2::BestRouteStrategy2(Forwarder& forwarder, const Name& name)
diff --git a/daemon/fw/best-route-strategy2.hpp b/daemon/fw/best-route-strategy2.hpp
index 603be0e..bf3eba2 100644
--- a/daemon/fw/best-route-strategy2.hpp
+++ b/daemon/fw/best-route-strategy2.hpp
@@ -27,18 +27,18 @@
#define NFD_DAEMON_FW_BEST_ROUTE_STRATEGY2_HPP
#include "strategy.hpp"
-#include "retx-suppression-fixed.hpp"
+#include "retx-suppression-exponential.hpp"
namespace nfd {
namespace fw {
-/** \brief Best Route strategy version 2
+/** \brief Best Route strategy version 3
*
* This strategy forwards a new Interest to the lowest-cost nexthop (except downstream).
- * After that, it recognizes consumer retransmission:
- * if a similar Interest arrives from any downstream after MIN_RETRANSMISSION_INTERVAL,
- * the strategy forwards the Interest again to the lowest-cost nexthop (except downstream)
- * that is not previously used. If all nexthops have been used, the strategy starts over.
+ * After that, if consumer retransmits the Interest (and is not suppressed according to
+ * exponential backoff algorithm), the strategy forwards the Interest again to
+ * the lowest-cost nexthop (except downstream) that is not previously used.
+ * If all nexthops have been used, the strategy starts over.
*/
class BestRouteStrategy2 : public Strategy
{
@@ -55,7 +55,7 @@
static const Name STRATEGY_NAME;
private:
- RetxSuppressionFixed m_retxSuppression;
+ RetxSuppressionExponential m_retxSuppression;
};
} // namespace fw
diff --git a/tests/daemon/fw/best-route-strategy2.t.cpp b/tests/daemon/fw/best-route-strategy2.t.cpp
index 385e774..8a2c3db 100644
--- a/tests/daemon/fw/best-route-strategy2.t.cpp
+++ b/tests/daemon/fw/best-route-strategy2.t.cpp
@@ -65,13 +65,7 @@
shared_ptr<pit::Entry> pitEntry = pit.insert(*interest).first;
const time::nanoseconds TICK = time::duration_cast<time::nanoseconds>(
- fw::RetxSuppressionFixed::DEFAULT_MIN_RETX_INTERVAL * 0.01);
- const time::nanoseconds RETRANSMISSION_10P = time::duration_cast<time::nanoseconds>(
- fw::RetxSuppressionFixed::DEFAULT_MIN_RETX_INTERVAL * 0.1); // 10%
- const time::nanoseconds RETRANSMISSION_70P = time::duration_cast<time::nanoseconds>(
- fw::RetxSuppressionFixed::DEFAULT_MIN_RETX_INTERVAL * 0.7); // 70%
- const time::nanoseconds RETRANSMISSION_2 = time::duration_cast<time::nanoseconds>(
- fw::RetxSuppressionFixed::DEFAULT_MIN_RETX_INTERVAL * 2.0); // x2
+ fw::RetxSuppressionExponential::DEFAULT_INITIAL_INTERVAL * 0.1);
// first Interest goes to nexthop with lowest FIB cost,
// however face1 is downstream so it cannot be used
@@ -94,15 +88,15 @@
if (nSent > nSentLast) {
BOOST_CHECK_EQUAL(nSent - nSentLast, 1);
time::steady_clock::TimePoint timeSent = time::steady_clock::now();
- BOOST_CHECK_GE(timeSent - timeSentLast, RETRANSMISSION_70P);
+ BOOST_CHECK_GE(timeSent - timeSentLast, TICK * 8);
nSentLast = nSent;
timeSentLast = timeSent;
}
- retxFrom4Evt = scheduler::schedule(RETRANSMISSION_10P, periodicalRetxFrom4);
+ retxFrom4Evt = scheduler::schedule(TICK * 5, periodicalRetxFrom4);
};
periodicalRetxFrom4();
- this->advanceClocks(TICK, fw::RetxSuppressionFixed::DEFAULT_MIN_RETX_INTERVAL * 16);
+ this->advanceClocks(TICK, fw::RetxSuppressionExponential::DEFAULT_MAX_INTERVAL * 16);
scheduler::cancel(retxFrom4Evt);
// nexthops for accepted retransmissions: follow FIB cost,
@@ -118,7 +112,7 @@
strategy.m_sendInterestHistory.clear();
for (int i = 0; i < 3; ++i) {
- this->advanceClocks(TICK, RETRANSMISSION_2);
+ this->advanceClocks(TICK, fw::RetxSuppressionExponential::DEFAULT_MAX_INTERVAL * 2);
pitEntry->insertOrUpdateInRecord(face5, *interest);
strategy.afterReceiveInterest(*face5, *interest, fibEntry, pitEntry);
}