fw: remove best-route strategy version 1
Change-Id: I7e86d5c19c01db65a84fdc0f289e7534f0774f4e
diff --git a/daemon/fw/access-strategy.hpp b/daemon/fw/access-strategy.hpp
index a766239..d6688fc 100644
--- a/daemon/fw/access-strategy.hpp
+++ b/daemon/fw/access-strategy.hpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2020, Regents of the University of California,
+ * Copyright (c) 2014-2021, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -34,7 +34,7 @@
namespace nfd {
namespace fw {
-/** \brief Access Router Strategy version 1
+/** \brief Access Router strategy
*
* This strategy is designed for the last hop on the NDN testbed,
* where each nexthop connects to a laptop, links are lossy, and FIB is mostly correct.
diff --git a/daemon/fw/algorithm.cpp b/daemon/fw/algorithm.cpp
index 7dada21..a5d692f 100644
--- a/daemon/fw/algorithm.cpp
+++ b/daemon/fw/algorithm.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2020, Regents of the University of California,
+ * Copyright (c) 2014-2021, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -24,6 +24,7 @@
*/
#include "algorithm.hpp"
+#include "scope-prefix.hpp"
namespace nfd {
namespace fw {
@@ -50,30 +51,6 @@
return false;
}
-bool
-canForwardToLegacy(const pit::Entry& pitEntry, const Face& face)
-{
- time::steady_clock::TimePoint now = time::steady_clock::now();
-
- bool hasUnexpiredOutRecord = std::any_of(pitEntry.out_begin(), pitEntry.out_end(),
- [&face, &now] (const pit::OutRecord& outRecord) {
- return &outRecord.getFace() == &face && outRecord.getExpiry() >= now;
- });
- if (hasUnexpiredOutRecord) {
- return false;
- }
-
- bool hasUnexpiredOtherInRecord = std::any_of(pitEntry.in_begin(), pitEntry.in_end(),
- [&face, &now] (const pit::InRecord& inRecord) {
- return &inRecord.getFace() != &face && inRecord.getExpiry() >= now;
- });
- if (!hasUnexpiredOtherInRecord) {
- return false;
- }
-
- return true;
-}
-
int
findDuplicateNonce(const pit::Entry& pitEntry, Interest::Nonce nonce, const Face& face)
{
diff --git a/daemon/fw/algorithm.hpp b/daemon/fw/algorithm.hpp
index 8a6b849..b37d540 100644
--- a/daemon/fw/algorithm.hpp
+++ b/daemon/fw/algorithm.hpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2020, Regents of the University of California,
+ * Copyright (c) 2014-2021, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -26,8 +26,7 @@
#ifndef NFD_DAEMON_FW_ALGORITHM_HPP
#define NFD_DAEMON_FW_ALGORITHM_HPP
-#include "fw/scope-prefix.hpp"
-#include "table/fib.hpp"
+#include "table/fib-entry.hpp"
#include "table/pit-entry.hpp"
/** \file
@@ -43,19 +42,6 @@
bool
wouldViolateScope(const Face& inFace, const Interest& interest, const Face& outFace);
-/** \brief decide whether Interest can be forwarded to face
- *
- * \return true if out-record of this face does not exist or has expired,
- * and there is an in-record not of this face
- *
- * \note This algorithm has a weakness that it does not permit consumer retransmissions
- * before out-record expires. Therefore, it's not recommended to use this function
- * in new strategies.
- * \todo find a better name for this function
- */
-bool
-canForwardToLegacy(const pit::Entry& pitEntry, const Face& face);
-
/** \brief indicates where duplicate Nonces are found
*/
enum DuplicateNonceWhere {
@@ -63,7 +49,7 @@
DUPLICATE_NONCE_IN_SAME = (1 << 0), ///< in-record of same face
DUPLICATE_NONCE_IN_OTHER = (1 << 1), ///< in-record of other face
DUPLICATE_NONCE_OUT_SAME = (1 << 2), ///< out-record of same face
- DUPLICATE_NONCE_OUT_OTHER = (1 << 3) ///< out-record of other face
+ DUPLICATE_NONCE_OUT_OTHER = (1 << 3), ///< out-record of other face
};
/** \brief determine whether \p pitEntry has duplicate Nonce \p nonce
diff --git a/daemon/fw/best-route-strategy.cpp b/daemon/fw/best-route-strategy.cpp
deleted file mode 100644
index 82a3f56..0000000
--- a/daemon/fw/best-route-strategy.cpp
+++ /dev/null
@@ -1,83 +0,0 @@
-/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/*
- * Copyright (c) 2014-2020, Regents of the University of California,
- * Arizona Board of Regents,
- * Colorado State University,
- * University Pierre & Marie Curie, Sorbonne University,
- * Washington University in St. Louis,
- * Beijing Institute of Technology,
- * The University of Memphis.
- *
- * This file is part of NFD (Named Data Networking Forwarding Daemon).
- * See AUTHORS.md for complete list of NFD authors and contributors.
- *
- * NFD is free software: you can redistribute it and/or modify it under the terms
- * of the GNU General Public License as published by the Free Software Foundation,
- * either version 3 of the License, or (at your option) any later version.
- *
- * NFD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
- * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
- * PURPOSE. See the GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along with
- * NFD, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include "best-route-strategy.hpp"
-#include "algorithm.hpp"
-
-namespace nfd {
-namespace fw {
-
-BestRouteStrategyBase::BestRouteStrategyBase(Forwarder& forwarder)
- : Strategy(forwarder)
-{
-}
-
-void
-BestRouteStrategyBase::afterReceiveInterest(const FaceEndpoint& ingress, const Interest& interest,
- const shared_ptr<pit::Entry>& pitEntry)
-{
- if (hasPendingOutRecords(*pitEntry)) {
- // not a new Interest, don't forward
- return;
- }
-
- const fib::Entry& fibEntry = this->lookupFib(*pitEntry);
- for (const auto& nexthop : fibEntry.getNextHops()) {
- Face& outFace = nexthop.getFace();
- if (!wouldViolateScope(ingress.face, interest, outFace) &&
- canForwardToLegacy(*pitEntry, outFace)) {
- this->sendInterest(pitEntry, outFace, interest);
- return;
- }
- }
-
- this->rejectPendingInterest(pitEntry);
-}
-
-NFD_REGISTER_STRATEGY(BestRouteStrategy);
-
-BestRouteStrategy::BestRouteStrategy(Forwarder& forwarder, const Name& name)
- : BestRouteStrategyBase(forwarder)
-{
- ParsedInstanceName parsed = parseInstanceName(name);
- if (!parsed.parameters.empty()) {
- NDN_THROW(std::invalid_argument("BestRouteStrategy does not accept parameters"));
- }
- if (parsed.version && *parsed.version != getStrategyName()[-1].toVersion()) {
- NDN_THROW(std::invalid_argument(
- "BestRouteStrategy does not support version " + to_string(*parsed.version)));
- }
- this->setInstanceName(makeInstanceName(name, getStrategyName()));
-}
-
-const Name&
-BestRouteStrategy::getStrategyName()
-{
- static Name strategyName("/localhost/nfd/strategy/best-route/%FD%01");
- return strategyName;
-}
-
-} // namespace fw
-} // namespace nfd
diff --git a/daemon/fw/best-route-strategy.hpp b/daemon/fw/best-route-strategy.hpp
deleted file mode 100644
index 2c5be36..0000000
--- a/daemon/fw/best-route-strategy.hpp
+++ /dev/null
@@ -1,69 +0,0 @@
-/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/*
- * Copyright (c) 2014-2020, Regents of the University of California,
- * Arizona Board of Regents,
- * Colorado State University,
- * University Pierre & Marie Curie, Sorbonne University,
- * Washington University in St. Louis,
- * Beijing Institute of Technology,
- * The University of Memphis.
- *
- * This file is part of NFD (Named Data Networking Forwarding Daemon).
- * See AUTHORS.md for complete list of NFD authors and contributors.
- *
- * NFD is free software: you can redistribute it and/or modify it under the terms
- * of the GNU General Public License as published by the Free Software Foundation,
- * either version 3 of the License, or (at your option) any later version.
- *
- * NFD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
- * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
- * PURPOSE. See the GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along with
- * NFD, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef NFD_DAEMON_FW_BEST_ROUTE_STRATEGY_HPP
-#define NFD_DAEMON_FW_BEST_ROUTE_STRATEGY_HPP
-
-#include "strategy.hpp"
-
-namespace nfd {
-namespace fw {
-
-class BestRouteStrategyBase : public Strategy
-{
-public:
- void
- afterReceiveInterest(const FaceEndpoint& ingress, const Interest& interest,
- const shared_ptr<pit::Entry>& pitEntry) override;
-
-protected:
- BestRouteStrategyBase(Forwarder& forwarder);
-};
-
-/** \brief Best Route strategy version 1
- *
- * This strategy forwards a new Interest to the lowest-cost nexthop
- * that is not same as the downstream, and does not violate scope.
- * Subsequent similar Interests or consumer retransmissions are suppressed
- * until after InterestLifetime expiry.
- *
- * \note This strategy is superceded by Best Route strategy version 2,
- * which allows consumer retransmissions. This version is kept for
- * comparison purposes and is not recommended for general usage.
- */
-class BestRouteStrategy : public BestRouteStrategyBase
-{
-public:
- explicit
- BestRouteStrategy(Forwarder& forwarder, const Name& name = getStrategyName());
-
- static const Name&
- getStrategyName();
-};
-
-} // namespace fw
-} // namespace nfd
-
-#endif // NFD_DAEMON_FW_BEST_ROUTE_STRATEGY_HPP
diff --git a/daemon/fw/best-route-strategy2.hpp b/daemon/fw/best-route-strategy2.hpp
index 79c6c0d..438ecd8 100644
--- a/daemon/fw/best-route-strategy2.hpp
+++ b/daemon/fw/best-route-strategy2.hpp
@@ -33,7 +33,7 @@
namespace nfd {
namespace fw {
-/** \brief Best Route strategy version 4
+/** \brief Best Route strategy
*
* This strategy forwards a new Interest to the lowest-cost nexthop (except downstream).
* After that, if consumer retransmits the Interest (and is not suppressed according to
diff --git a/daemon/fw/forwarder.cpp b/daemon/fw/forwarder.cpp
index e5c0c20..387ac0d 100644
--- a/daemon/fw/forwarder.cpp
+++ b/daemon/fw/forwarder.cpp
@@ -27,6 +27,7 @@
#include "algorithm.hpp"
#include "best-route-strategy2.hpp"
+#include "scope-prefix.hpp"
#include "strategy.hpp"
#include "common/global.hpp"
#include "common/logger.hpp"
diff --git a/tests/daemon/fw/algorithm.t.cpp b/tests/daemon/fw/algorithm.t.cpp
index 903a4aa..b998ec2 100644
--- a/tests/daemon/fw/algorithm.t.cpp
+++ b/tests/daemon/fw/algorithm.t.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2019, Regents of the University of California,
+ * Copyright (c) 2014-2021, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -90,27 +90,6 @@
BOOST_AUTO_TEST_SUITE_END() // WouldViolateScope
-BOOST_AUTO_TEST_CASE(CanForwardToLegacy)
-{
- auto interest = makeInterest("ndn:/WDsuBLIMG");
- pit::Entry entry(*interest);
-
- auto face1 = make_shared<DummyFace>();
- auto face2 = make_shared<DummyFace>();
-
- entry.insertOrUpdateInRecord(*face1, *interest);
- BOOST_CHECK_EQUAL(canForwardToLegacy(entry, *face1), false);
- BOOST_CHECK_EQUAL(canForwardToLegacy(entry, *face2), true);
-
- entry.insertOrUpdateInRecord(*face2, *interest);
- BOOST_CHECK_EQUAL(canForwardToLegacy(entry, *face1), true);
- BOOST_CHECK_EQUAL(canForwardToLegacy(entry, *face2), true);
-
- entry.insertOrUpdateOutRecord(*face1, *interest);
- BOOST_CHECK_EQUAL(canForwardToLegacy(entry, *face1), false);
- BOOST_CHECK_EQUAL(canForwardToLegacy(entry, *face2), true);
-}
-
BOOST_AUTO_TEST_CASE(Nonce)
{
auto face1 = make_shared<DummyFace>();
diff --git a/tests/daemon/fw/best-route-strategy.t.cpp b/tests/daemon/fw/best-route-strategy.t.cpp
deleted file mode 100644
index b11cdae..0000000
--- a/tests/daemon/fw/best-route-strategy.t.cpp
+++ /dev/null
@@ -1,41 +0,0 @@
-/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/*
- * Copyright (c) 2014-2019, Regents of the University of California,
- * Arizona Board of Regents,
- * Colorado State University,
- * University Pierre & Marie Curie, Sorbonne University,
- * Washington University in St. Louis,
- * Beijing Institute of Technology,
- * The University of Memphis.
- *
- * This file is part of NFD (Named Data Networking Forwarding Daemon).
- * See AUTHORS.md for complete list of NFD authors and contributors.
- *
- * NFD is free software: you can redistribute it and/or modify it under the terms
- * of the GNU General Public License as published by the Free Software Foundation,
- * either version 3 of the License, or (at your option) any later version.
- *
- * NFD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
- * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
- * PURPOSE. See the GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along with
- * NFD, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include "fw/best-route-strategy.hpp"
-
-#include "tests/test-common.hpp"
-#include "strategy-tester.hpp"
-
-namespace nfd {
-namespace fw {
-namespace tests {
-
-// The tester is unused in this file, but it's used in various templated test suites.
-using BestRouteStrategyTester = StrategyTester<BestRouteStrategy>;
-NFD_REGISTER_STRATEGY(BestRouteStrategyTester);
-
-} // namespace tests
-} // namespace fw
-} // namespace nfd
diff --git a/tests/daemon/fw/strategy-instantiation.t.cpp b/tests/daemon/fw/strategy-instantiation.t.cpp
index cd057bc..6bbcebb 100644
--- a/tests/daemon/fw/strategy-instantiation.t.cpp
+++ b/tests/daemon/fw/strategy-instantiation.t.cpp
@@ -30,7 +30,6 @@
// All strategies, sorted alphabetically.
#include "fw/access-strategy.hpp"
#include "fw/asf-strategy.hpp"
-#include "fw/best-route-strategy.hpp"
#include "fw/best-route-strategy2.hpp"
#include "fw/multicast-strategy.hpp"
#include "fw/self-learning-strategy.hpp"
@@ -75,7 +74,6 @@
using Tests = boost::mpl::vector<
Test<AccessStrategy, false, 1>,
Test<AsfStrategy, true, 3>,
- Test<BestRouteStrategy, false, 1>,
Test<BestRouteStrategy2, false, 5>,
Test<MulticastStrategy, false, 4>,
Test<SelfLearningStrategy, false, 1>,
diff --git a/tests/daemon/fw/strategy-no-route.t.cpp b/tests/daemon/fw/strategy-no-route.t.cpp
index 2952259..c5a4f89 100644
--- a/tests/daemon/fw/strategy-no-route.t.cpp
+++ b/tests/daemon/fw/strategy-no-route.t.cpp
@@ -24,11 +24,11 @@
*/
/** \file
- * This test suite checks that a strategy returns Nack-NoRoute
- * when there is no usable FIB nexthop.
+ * This test suite checks that a strategy returns Nack-NoRoute when there are
+ * no usable FIB nexthops.
*/
-// Strategies returning Nack-NoRoute when there is no usable FIB nexthop,
+// Strategies returning Nack-NoRoute when there are no usable FIB nexthops,
// sorted alphabetically.
#include "fw/asf-strategy.hpp"
#include "fw/best-route-strategy2.hpp"
@@ -39,7 +39,6 @@
#include "choose-strategy.hpp"
#include "strategy-tester.hpp"
-#include <boost/mpl/copy_if.hpp>
#include <boost/mpl/vector.hpp>
namespace nfd {
@@ -155,8 +154,8 @@
Test<RandomStrategy, NextHopViolatesScope<RandomStrategy>>
>;
-BOOST_FIXTURE_TEST_CASE_TEMPLATE(IncomingInterest, T, Tests,
- StrategyNoRouteFixture<typename T::Strategy>)
+BOOST_FIXTURE_TEST_CASE_TEMPLATE(IncomingInterest,
+ T, Tests, StrategyNoRouteFixture<typename T::Strategy>)
{
typename T::Case scenario;
scenario.insertFibEntry(this);
diff --git a/tests/daemon/fw/strategy-scope-control.t.cpp b/tests/daemon/fw/strategy-scope-control.t.cpp
index a707a46..7b0a271 100644
--- a/tests/daemon/fw/strategy-scope-control.t.cpp
+++ b/tests/daemon/fw/strategy-scope-control.t.cpp
@@ -30,7 +30,6 @@
// Strategies implementing namespace-based scope control, sorted alphabetically.
#include "fw/access-strategy.hpp"
#include "fw/asf-strategy.hpp"
-#include "fw/best-route-strategy.hpp"
#include "fw/best-route-strategy2.hpp"
#include "fw/multicast-strategy.hpp"
#include "fw/random-strategy.hpp"
@@ -113,7 +112,6 @@
using Tests = boost::mpl::vector<
Test<AccessStrategy, false, false, true>,
Test<AsfStrategy, true, false, true>,
- Test<BestRouteStrategy, false, false, true>,
Test<BestRouteStrategy2, true, true, true>,
Test<MulticastStrategy, false, false, false>,
Test<RandomStrategy, true, true, true>
diff --git a/tests/daemon/fw/strategy-tester.hpp b/tests/daemon/fw/strategy-tester.hpp
index eab4069..b9ed2ff 100644
--- a/tests/daemon/fw/strategy-tester.hpp
+++ b/tests/daemon/fw/strategy-tester.hpp
@@ -53,11 +53,7 @@
class StrategyTester : public S
{
public:
- explicit
- StrategyTester(Forwarder& forwarder, const Name& name = getStrategyName())
- : S(forwarder, name)
- {
- }
+ using S::S;
static Name
getStrategyName()
@@ -76,7 +72,7 @@
return name;
}
- /** \brief signal emitted after each Action
+ /** \brief Signal emitted after each action
*/
signal::Signal<StrategyTester<S>> afterAction;
@@ -95,11 +91,11 @@
++nActions;
});
- f();
+ std::forward<F>(f)();
if (nActions < nExpectedActions) {
// If strategy doesn't forward anything (e.g., decides not to forward an Interest), the number
- // of expected actions should be 0; otherwise the test will stuck.
+ // of expected actions should be 0; otherwise the test will get stuck.
return limitedIo.run(nExpectedActions - nActions, LimitedIo::UNLIMITED_TIME) == LimitedIo::EXCEED_OPS;
}
return nActions == nExpectedActions;
diff --git a/tests/daemon/mgmt/tables-config-section.t.cpp b/tests/daemon/mgmt/tables-config-section.t.cpp
index dfce51e..789d64f 100644
--- a/tests/daemon/mgmt/tables-config-section.t.cpp
+++ b/tests/daemon/mgmt/tables-config-section.t.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2019, Regents of the University of California,
+ * Copyright (c) 2014-2021, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -403,7 +403,7 @@
{
strategy_choice
{
- / /localhost/nfd/strategy/best-route/%FD%01/param
+ / /localhost/nfd/strategy/best-route/%FD%05/param
}
}
)CONFIG";