fw: remove best-route strategy version 1

Change-Id: I7e86d5c19c01db65a84fdc0f289e7534f0774f4e
This commit is contained in:
Davide Pesavento committed 2021-03-09 11:45:43 -05:00
1 parent 29abf4cda2
commit 580915891e
14 files changed
+21 -280

No files matched your search

+2 -2
View File
@@ -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.
+2 -25
View File
@@ -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 @@ wouldViolateScope(const Face& inFace, const Interest& interest, const Face& outF
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)
{
+3 -17
View File
@@ -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 @@ namespace fw {
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 @@ enum DuplicateNonceWhere {
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
-83
View File
@@ -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
-69
View File
@@ -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
+1 -1
View File
@@ -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
+1
View File
@@ -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"
+1 -22
View File
@@ -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_CASE(Localhop)
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>();
-41
View File
@@ -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
@@ -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 @@ public:
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>,
+5 -6
View File
@@ -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 @@ using Tests = boost::mpl::vector<
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);
@@ -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 @@ public:
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>
+4 -8
View File
@@ -53,11 +53,7 @@ template<typename S>
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 @@ public:
return name;
}
/** \brief signal emitted after each Action
/** \brief Signal emitted after each action
*/
signal::Signal<StrategyTester<S>> afterAction;
@@ -95,11 +91,11 @@ public:
++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;
@@ -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 @@ BOOST_AUTO_TEST_CASE(UnacceptableParameters)
{
strategy_choice
{
/ /localhost/nfd/strategy/best-route/%FD%01/param
/ /localhost/nfd/strategy/best-route/%FD%05/param
}
}
)CONFIG";