fw: Nack in multicast strategy
refs: #3176
Change-Id: I1ef43c277a6a251170b652bf77d5516912a5d630
diff --git a/tests/daemon/fw/best-route-strategy2.t.cpp b/tests/daemon/fw/best-route-strategy2.t.cpp
index 69328ff..3ebe7f1 100644
--- a/tests/daemon/fw/best-route-strategy2.t.cpp
+++ b/tests/daemon/fw/best-route-strategy2.t.cpp
@@ -28,7 +28,6 @@
#include "tests/test-common.hpp"
#include "tests/daemon/face/dummy-face.hpp"
#include "strategy-tester.hpp"
-#include "topology-tester.hpp"
namespace nfd {
namespace fw {
@@ -145,81 +144,6 @@
// face1 cannot be used because it's gone from FIB entry
}
-BOOST_AUTO_TEST_SUITE(NoRouteNack) // send Nack-NoRoute if there's no usable FIB nexthop
-
-class EmptyNextHopList
-{
-public:
- Name
- getInterestName()
- {
- return "/P";
- }
-
- void
- insertFibEntry(BestRouteStrategy2Fixture* fixture)
- {
- fixture->fib.insert(Name());
- }
-};
-
-class NextHopIsDownstream
-{
-public:
- Name
- getInterestName()
- {
- return "/P";
- }
-
- void
- insertFibEntry(BestRouteStrategy2Fixture* fixture)
- {
- fixture->fib.insert(Name()).first->addNextHop(*fixture->face1, 10);
- }
-};
-
-class NextHopViolatesScope
-{
-public:
- Name
- getInterestName()
- {
- return "/localhop/P";
- }
-
- void
- insertFibEntry(BestRouteStrategy2Fixture* fixture)
- {
- fixture->fib.insert("/localhop").first->addNextHop(*fixture->face2, 10);
- // face1 and face2 are both non-local; Interest from face1 cannot be forwarded to face2
- }
-};
-
-typedef boost::mpl::vector<EmptyNextHopList, NextHopIsDownstream, NextHopViolatesScope> NoRouteScenarios;
-
-BOOST_AUTO_TEST_CASE_TEMPLATE(IncomingInterest, Scenario, NoRouteScenarios)
-{
- Scenario scenario;
- scenario.insertFibEntry(this);
-
- shared_ptr<Interest> interest = makeInterest(scenario.getInterestName());
- shared_ptr<pit::Entry> pitEntry = pit.insert(*interest).first;
- pitEntry->insertOrUpdateInRecord(*face1, *interest);
-
- strategy.afterReceiveInterest(*face1, *interest, pitEntry);
-
- BOOST_REQUIRE_EQUAL(strategy.rejectPendingInterestHistory.size(), 1);
- BOOST_CHECK_EQUAL(strategy.rejectPendingInterestHistory[0].pitInterest, pitEntry->getInterest());
-
- BOOST_REQUIRE_EQUAL(strategy.sendNackHistory.size(), 1);
- BOOST_CHECK_EQUAL(strategy.sendNackHistory[0].pitInterest, pitEntry->getInterest());
- BOOST_CHECK_EQUAL(strategy.sendNackHistory[0].outFaceId, face1->getId());
- BOOST_CHECK_EQUAL(strategy.sendNackHistory[0].header.getReason(), lp::NackReason::NO_ROUTE);
-}
-
-BOOST_AUTO_TEST_SUITE_END() // NoRouteNack
-
BOOST_AUTO_TEST_SUITE_END() // TestBestRouteStrategy2
BOOST_AUTO_TEST_SUITE_END() // Fw
diff --git a/tests/daemon/fw/multicast-strategy.t.cpp b/tests/daemon/fw/multicast-strategy.t.cpp
index de00ff6..be87930 100644
--- a/tests/daemon/fw/multicast-strategy.t.cpp
+++ b/tests/daemon/fw/multicast-strategy.t.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/**
- * Copyright (c) 2014-2016, Regents of the University of California,
+ * Copyright (c) 2014-2017, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -90,6 +90,10 @@
std::set<FaceId> expectedInterestFaceIds{face1->getId(), face2->getId()};
BOOST_CHECK_EQUAL_COLLECTIONS(sentInterestFaceIds.begin(), sentInterestFaceIds.end(),
expectedInterestFaceIds.begin(), expectedInterestFaceIds.end());
+
+ // Check retransmission suppression, sendInterestHistory should remain 2
+ strategy.afterReceiveInterest(*face3, *interest, pitEntry);
+ BOOST_CHECK_EQUAL(strategy.sendInterestHistory.size(), 2);
}
BOOST_AUTO_TEST_CASE(RejectScope)
diff --git a/tests/daemon/fw/strategy-nack-return.t.cpp b/tests/daemon/fw/strategy-nack-return.t.cpp
index 89902d3..b9c2421 100644
--- a/tests/daemon/fw/strategy-nack-return.t.cpp
+++ b/tests/daemon/fw/strategy-nack-return.t.cpp
@@ -29,6 +29,7 @@
// Strategies implementing recommended Nack processing procedure, sorted alphabetically.
#include "fw/best-route-strategy2.hpp"
+#include "fw/multicast-strategy.hpp"
#include "tests/test-common.hpp"
#include "tests/limited-io.hpp"
@@ -86,7 +87,8 @@
BOOST_AUTO_TEST_SUITE(TestStrategyNackReturn)
using Strategies = boost::mpl::vector<
- BestRouteStrategy2
+ BestRouteStrategy2,
+ MulticastStrategy
>;
// one upstream, send Nack when Nack arrives
diff --git a/tests/daemon/fw/strategy-no-route.t.cpp b/tests/daemon/fw/strategy-no-route.t.cpp
new file mode 100644
index 0000000..18f45a8
--- /dev/null
+++ b/tests/daemon/fw/strategy-no-route.t.cpp
@@ -0,0 +1,184 @@
+/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
+/**
+ * Copyright (c) 2014-2017, 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/>.
+ */
+
+/** \file
+ * This test suite checks that a strategy returns Nack-NoRoute
+ * when there is no usable FIB nexthop.
+ */
+
+// Strategies returning Nack-NoRoute when there is no usable FIB nexthop,
+// sorted alphabetically.
+#include "fw/asf-strategy.hpp"
+#include "fw/best-route-strategy2.hpp"
+#include "fw/multicast-strategy.hpp"
+
+#include "tests/test-common.hpp"
+#include "tests/limited-io.hpp"
+#include "choose-strategy.hpp"
+#include "strategy-tester.hpp"
+#include "tests/daemon/face/dummy-face.hpp"
+#include <boost/mpl/copy_if.hpp>
+#include <boost/mpl/vector.hpp>
+
+namespace nfd {
+namespace fw {
+namespace tests {
+
+using namespace nfd::tests;
+
+template<typename S>
+class StrategyNoRouteFixture : public UnitTestTimeFixture
+{
+public:
+ StrategyNoRouteFixture()
+ : limitedIo(this)
+ , strategy(choose<StrategyTester<S>>(forwarder))
+ , fib(forwarder.getFib())
+ , pit(forwarder.getPit())
+ , face1(make_shared<DummyFace>())
+ , face2(make_shared<DummyFace>())
+ {
+ forwarder.addFace(face1);
+ forwarder.addFace(face2);
+ }
+
+public:
+ LimitedIo limitedIo;
+
+ Forwarder forwarder;
+ StrategyTester<S>& strategy;
+ Fib& fib;
+ Pit& pit;
+
+ shared_ptr<Face> face1;
+ shared_ptr<Face> face2;
+};
+
+BOOST_AUTO_TEST_SUITE(Fw)
+BOOST_FIXTURE_TEST_SUITE(TestStrategyNoRoute, BaseFixture)
+
+template<typename S, typename C>
+class Test
+{
+public:
+ using Strategy = S;
+ using Case = C;
+};
+
+template<typename S>
+class EmptyNextHopList
+{
+public:
+ Name
+ getInterestName()
+ {
+ return "/P";
+ }
+
+ void
+ insertFibEntry(StrategyNoRouteFixture<S>* fixture)
+ {
+ fixture->fib.insert(Name());
+ }
+};
+
+template<typename S>
+class NextHopIsDownstream
+{
+public:
+ Name
+ getInterestName()
+ {
+ return "/P";
+ }
+
+ void
+ insertFibEntry(StrategyNoRouteFixture<S>* fixture)
+ {
+ fixture->fib.insert(Name()).first->addNextHop(*fixture->face1, 10);
+ }
+};
+
+template<typename S>
+class NextHopViolatesScope
+{
+public:
+ Name
+ getInterestName()
+ {
+ return "/localhop/P";
+ }
+
+ void
+ insertFibEntry(StrategyNoRouteFixture<S>* fixture)
+ {
+ fixture->fib.insert("/localhop").first->addNextHop(*fixture->face2, 10);
+ // face1 and face2 are both non-local; Interest from face1 cannot be forwarded to face2
+ }
+};
+
+using Tests = boost::mpl::vector<
+ Test<AsfStrategy, EmptyNextHopList<AsfStrategy>>,
+ Test<AsfStrategy, NextHopIsDownstream<AsfStrategy>>,
+ Test<AsfStrategy, NextHopViolatesScope<AsfStrategy>>,
+
+ Test<BestRouteStrategy2, EmptyNextHopList<BestRouteStrategy2>>,
+ Test<BestRouteStrategy2, NextHopIsDownstream<BestRouteStrategy2>>,
+ Test<BestRouteStrategy2, NextHopViolatesScope<BestRouteStrategy2>>,
+
+ Test<MulticastStrategy, EmptyNextHopList<MulticastStrategy>>,
+ Test<MulticastStrategy, NextHopIsDownstream<MulticastStrategy>>,
+ Test<MulticastStrategy, NextHopViolatesScope<MulticastStrategy>>
+>;
+
+BOOST_FIXTURE_TEST_CASE_TEMPLATE(IncomingInterest, T, Tests,
+ StrategyNoRouteFixture<typename T::Strategy>)
+{
+ typename T::Case scenario;
+ scenario.insertFibEntry(this);
+
+ shared_ptr<Interest> interest = makeInterest(scenario.getInterestName());
+ shared_ptr<pit::Entry> pitEntry = this->pit.insert(*interest).first;
+ pitEntry->insertOrUpdateInRecord(*this->face1, *interest);
+
+ BOOST_REQUIRE(this->strategy.waitForAction(
+ [&] { this->strategy.afterReceiveInterest(*this->face1, *interest, pitEntry); },
+ this->limitedIo, 2));
+
+ BOOST_REQUIRE_EQUAL(this->strategy.rejectPendingInterestHistory.size(), 1);
+ BOOST_CHECK_EQUAL(this->strategy.rejectPendingInterestHistory[0].pitInterest, pitEntry->getInterest());
+
+ BOOST_REQUIRE_EQUAL(this->strategy.sendNackHistory.size(), 1);
+ BOOST_CHECK_EQUAL(this->strategy.sendNackHistory[0].pitInterest, pitEntry->getInterest());
+ BOOST_CHECK_EQUAL(this->strategy.sendNackHistory[0].outFaceId, this->face1->getId());
+ BOOST_CHECK_EQUAL(this->strategy.sendNackHistory[0].header.getReason(), lp::NackReason::NO_ROUTE);
+}
+
+BOOST_AUTO_TEST_SUITE_END() // TestStrategyNoRoute
+BOOST_AUTO_TEST_SUITE_END() // Fw
+
+} // namespace tests
+} // namespace fw
+} // namespace nfd
diff --git a/tests/daemon/fw/strategy-scope-control.t.cpp b/tests/daemon/fw/strategy-scope-control.t.cpp
index 8a9b93d..4c6494a 100644
--- a/tests/daemon/fw/strategy-scope-control.t.cpp
+++ b/tests/daemon/fw/strategy-scope-control.t.cpp
@@ -110,7 +110,7 @@
Test<AsfStrategy, true, false>,
Test<BestRouteStrategy, false, false>,
Test<BestRouteStrategy2, true, true>,
- Test<MulticastStrategy, false, false>,
+ Test<MulticastStrategy, true, true>,
Test<NccStrategy, false, false>
>;