diff --git a/tests/daemon/fw/access-strategy.t.cpp b/tests/daemon/fw/access-strategy.t.cpp
index ddc0092..fa211a6 100644
--- a/tests/daemon/fw/access-strategy.t.cpp
+++ b/tests/daemon/fw/access-strategy.t.cpp
@@ -47,7 +47,8 @@
 // code style rule 3.25. This is necessary because some lines ends with '\' which
 // would cause "multi-line comment" compiler warning if '//' comments are used.
 
-BOOST_FIXTURE_TEST_SUITE(FwAccessStrategy, UnitTestTimeFixture)
+BOOST_AUTO_TEST_SUITE(Fw)
+BOOST_FIXTURE_TEST_SUITE(TestAccessStrategy, UnitTestTimeFixture)
 
 class TwoLaptopsFixture : public UnitTestTimeFixture
 {
@@ -65,14 +66,14 @@
      *      +---------+             +---------+
      */
 
-    router = topo.addForwarder();
-    laptopA = topo.addForwarder();
-    laptopB = topo.addForwarder();
+    router = topo.addForwarder("R");
+    laptopA = topo.addForwarder("A");
+    laptopB = topo.addForwarder("B");
 
     topo.setStrategy<fw::AccessStrategy>(router);
 
-    linkA = topo.addLink(time::milliseconds(10), {router, laptopA});
-    linkB = topo.addLink(time::milliseconds(20), {router, laptopB});
+    linkA = topo.addLink("RA", time::milliseconds(10), {router, laptopA});
+    linkB = topo.addLink("RB", time::milliseconds(20), {router, laptopB});
   }
 
 protected:
@@ -115,19 +116,19 @@
   topo.registerPrefix(router, linkA->getFace(router), "ndn:/laptops");
   topo.registerPrefix(router, linkB->getFace(router), "ndn:/laptops");
 
-  shared_ptr<TopologyAppLink> producer = topo.addAppFace(laptopA, "ndn:/laptops/A");
-  topo.addEchoProducer(*producer->getClientFace());
+  shared_ptr<TopologyAppLink> producer = topo.addAppFace("p", laptopA, "ndn:/laptops/A");
+  topo.addEchoProducer(producer->getClientFace());
 
-  shared_ptr<TopologyAppLink> consumer = topo.addAppFace(router);
-  topo.addIntervalConsumer(*consumer->getClientFace(), "ndn:/laptops/A",
+  shared_ptr<TopologyAppLink> consumer = topo.addAppFace("c", router);
+  topo.addIntervalConsumer(consumer->getClientFace(), "ndn:/laptops/A",
                            time::milliseconds(100), 100);
 
   this->advanceClocks(time::milliseconds(5), time::seconds(12));
 
   // most Interests should be satisfied, and few Interests can go to wrong laptop
-  BOOST_CHECK_GE(consumer->getForwarderFace()->m_sentDatas.size(), 97);
-  BOOST_CHECK_GE(linkA->getFace(router)->m_sentInterests.size(), 97);
-  BOOST_CHECK_LE(linkB->getFace(router)->m_sentInterests.size(), 5);
+  BOOST_CHECK_GE(consumer->getForwarderFace().getCounters().getNOutDatas(), 97);
+  BOOST_CHECK_GE(linkA->getFace(router).getCounters().getNOutInterests(), 97);
+  BOOST_CHECK_LE(linkB->getFace(router).getCounters().getNOutInterests(), 5);
 }
 
 BOOST_FIXTURE_TEST_CASE(FastSlowProducer, TwoLaptopsFixture)
@@ -160,21 +161,21 @@
   topo.registerPrefix(router, linkA->getFace(router), "ndn:/laptops");
   topo.registerPrefix(router, linkB->getFace(router), "ndn:/laptops");
 
-  shared_ptr<TopologyAppLink> producerA = topo.addAppFace(laptopA, "ndn:/laptops/BOTH");
-  topo.addEchoProducer(*producerA->getClientFace());
-  shared_ptr<TopologyAppLink> producerB = topo.addAppFace(laptopB, "ndn:/laptops/BOTH");
-  topo.addEchoProducer(*producerB->getClientFace());
+  shared_ptr<TopologyAppLink> producerA = topo.addAppFace("pA", laptopA, "ndn:/laptops/BOTH");
+  topo.addEchoProducer(producerA->getClientFace());
+  shared_ptr<TopologyAppLink> producerB = topo.addAppFace("pB", laptopB, "ndn:/laptops/BOTH");
+  topo.addEchoProducer(producerB->getClientFace());
 
-  shared_ptr<TopologyAppLink> consumer = topo.addAppFace(router);
-  topo.addIntervalConsumer(*consumer->getClientFace(), "ndn:/laptops/BOTH",
+  shared_ptr<TopologyAppLink> consumer = topo.addAppFace("c", router);
+  topo.addIntervalConsumer(consumer->getClientFace(), "ndn:/laptops/BOTH",
                            time::milliseconds(100), 100);
 
   this->advanceClocks(time::milliseconds(5), time::seconds(12));
 
   // most Interests should be satisfied, and few Interests can go to slower laptopB
-  BOOST_CHECK_GE(consumer->getForwarderFace()->m_sentDatas.size(), 97);
-  BOOST_CHECK_GE(linkA->getFace(router)->m_sentInterests.size(), 90);
-  BOOST_CHECK_LE(linkB->getFace(router)->m_sentInterests.size(), 15);
+  BOOST_CHECK_GE(consumer->getForwarderFace().getCounters().getNOutDatas(), 97);
+  BOOST_CHECK_GE(linkA->getFace(router).getCounters().getNOutInterests(), 90);
+  BOOST_CHECK_LE(linkB->getFace(router).getCounters().getNOutInterests(), 15);
 }
 
 BOOST_FIXTURE_TEST_CASE(ProducerMobility, TwoLaptopsFixture)
@@ -207,13 +208,13 @@
   topo.registerPrefix(router, linkA->getFace(router), "ndn:/laptops");
   topo.registerPrefix(router, linkB->getFace(router), "ndn:/laptops");
 
-  shared_ptr<TopologyAppLink> producerA = topo.addAppFace(laptopA, "ndn:/laptops/M");
-  topo.addEchoProducer(*producerA->getClientFace());
-  shared_ptr<TopologyAppLink> producerB = topo.addAppFace(laptopB, "ndn:/laptops/M");
-  topo.addEchoProducer(*producerB->getClientFace());
+  shared_ptr<TopologyAppLink> producerA = topo.addAppFace("pA", laptopA, "ndn:/laptops/M");
+  topo.addEchoProducer(producerA->getClientFace());
+  shared_ptr<TopologyAppLink> producerB = topo.addAppFace("pB", laptopB, "ndn:/laptops/M");
+  topo.addEchoProducer(producerB->getClientFace());
 
-  shared_ptr<TopologyAppLink> consumer = topo.addAppFace(router);
-  topo.addIntervalConsumer(*consumer->getClientFace(), "ndn:/laptops/M",
+  shared_ptr<TopologyAppLink> consumer = topo.addAppFace("c", router);
+  topo.addIntervalConsumer(consumer->getClientFace(), "ndn:/laptops/M",
                            time::milliseconds(100), 100);
 
   // producer is initially on laptopA
@@ -221,19 +222,19 @@
   this->advanceClocks(time::milliseconds(5), time::seconds(6));
 
   // few Interests can go to laptopB
-  BOOST_CHECK_LE(linkB->getFace(router)->m_sentInterests.size(), 5);
+  BOOST_CHECK_LE(linkB->getFace(router).getCounters().getNOutInterests(), 5);
 
   // producer moves to laptopB
   producerA->fail();
   producerB->recover();
-  linkA->getFace(router)->m_sentInterests.clear();
+  const_cast<FaceCounters&>(linkA->getFace(router).getCounters()).getNOutInterests().set(0);
   this->advanceClocks(time::milliseconds(5), time::seconds(6));
 
   // few additional Interests can go to laptopA
-  BOOST_CHECK_LE(linkA->getFace(router)->m_sentInterests.size(), 5);
+  BOOST_CHECK_LE(linkA->getFace(router).getCounters().getNOutInterests(), 5);
 
   // most Interests should be satisfied
-  BOOST_CHECK_GE(consumer->getForwarderFace()->m_sentDatas.size(), 97);
+  BOOST_CHECK_GE(consumer->getForwarderFace().getCounters().getNOutDatas(), 97);
 }
 
 BOOST_FIXTURE_TEST_CASE(Bidirectional, TwoLaptopsFixture)
@@ -263,23 +264,23 @@
   topo.registerPrefix(router, linkA->getFace(router), "ndn:/laptops");
   topo.registerPrefix(router, linkB->getFace(router), "ndn:/laptops");
 
-  shared_ptr<TopologyAppLink> producerA = topo.addAppFace(laptopA, "ndn:/laptops/A");
-  topo.addEchoProducer(*producerA->getClientFace());
-  shared_ptr<TopologyAppLink> producerB = topo.addAppFace(laptopB, "ndn:/laptops/B");
-  topo.addEchoProducer(*producerB->getClientFace());
+  shared_ptr<TopologyAppLink> producerA = topo.addAppFace("pA", laptopA, "ndn:/laptops/A");
+  topo.addEchoProducer(producerA->getClientFace());
+  shared_ptr<TopologyAppLink> producerB = topo.addAppFace("pB", laptopB, "ndn:/laptops/B");
+  topo.addEchoProducer(producerB->getClientFace());
 
-  shared_ptr<TopologyAppLink> consumerAB = topo.addAppFace(laptopA);
-  topo.addIntervalConsumer(*consumerAB->getClientFace(), "ndn:/laptops/B",
+  shared_ptr<TopologyAppLink> consumerAB = topo.addAppFace("cAB", laptopA);
+  topo.addIntervalConsumer(consumerAB->getClientFace(), "ndn:/laptops/B",
                            time::milliseconds(100), 100);
-  shared_ptr<TopologyAppLink> consumerBA = topo.addAppFace(laptopB);
-  topo.addIntervalConsumer(*consumerBA->getClientFace(), "ndn:/laptops/A",
+  shared_ptr<TopologyAppLink> consumerBA = topo.addAppFace("cBA", laptopB);
+  topo.addIntervalConsumer(consumerBA->getClientFace(), "ndn:/laptops/A",
                            time::milliseconds(100), 100);
 
   this->advanceClocks(time::milliseconds(5), time::seconds(12));
 
   // most Interests should be satisfied
-  BOOST_CHECK_GE(consumerAB->getForwarderFace()->m_sentDatas.size(), 97);
-  BOOST_CHECK_GE(consumerBA->getForwarderFace()->m_sentDatas.size(), 97);
+  BOOST_CHECK_GE(consumerAB->getForwarderFace().getCounters().getNOutDatas(), 97);
+  BOOST_CHECK_GE(consumerBA->getForwarderFace().getCounters().getNOutDatas(), 97);
 }
 
 BOOST_FIXTURE_TEST_CASE(PacketLoss, TwoLaptopsFixture)
@@ -308,25 +309,25 @@
   // laptopA has prefix in router FIB; laptopB is unused in this test case
   topo.registerPrefix(router, linkA->getFace(router), "ndn:/laptops");
 
-  shared_ptr<TopologyAppLink> producerA = topo.addAppFace(laptopA, "ndn:/laptops/A");
-  topo.addEchoProducer(*producerA->getClientFace());
+  shared_ptr<TopologyAppLink> producerA = topo.addAppFace("pA", laptopA, "ndn:/laptops/A");
+  topo.addEchoProducer(producerA->getClientFace());
 
-  shared_ptr<TopologyAppLink> consumer = topo.addAppFace(router);
+  shared_ptr<TopologyAppLink> consumer = topo.addAppFace("c", router);
 
   // Interest 1 completes normally
   shared_ptr<Interest> interest1 = makeInterest("ndn:/laptops/A/1");
   bool hasData1 = false;
-  consumer->getClientFace()->expressInterest(*interest1,
-                                             bind([&hasData1] { hasData1 = true; }));
+  consumer->getClientFace().expressInterest(*interest1,
+                                            bind([&hasData1] { hasData1 = true; }));
   this->advanceClocks(time::milliseconds(5), time::seconds(1));
   BOOST_CHECK_EQUAL(hasData1, true);
 
   // Interest 2 experiences a packet loss on initial transmission
   shared_ptr<Interest> interest2a = makeInterest("ndn:/laptops/A/2");
   bool hasData2a = false, hasTimeout2a = false;
-  consumer->getClientFace()->expressInterest(*interest2a,
-                                             bind([&hasData2a] { hasData2a = true; }),
-                                             bind([&hasTimeout2a] { hasTimeout2a = true; }));
+  consumer->getClientFace().expressInterest(*interest2a,
+                                            bind([&hasData2a] { hasData2a = true; }),
+                                            bind([&hasTimeout2a] { hasTimeout2a = true; }));
   producerA->fail();
   this->advanceClocks(time::milliseconds(5), time::milliseconds(60));
   BOOST_CHECK_EQUAL(hasData2a, false);
@@ -335,8 +336,8 @@
   // Interest 2 retransmission is suppressed
   shared_ptr<Interest> interest2b = makeInterest("ndn:/laptops/A/2");
   bool hasData2b = false;
-  consumer->getClientFace()->expressInterest(*interest2b,
-                                             bind([&hasData2b] { hasData2b = true; }));
+  consumer->getClientFace().expressInterest(*interest2b,
+                                            bind([&hasData2b] { hasData2b = true; }));
   producerA->recover();
   this->advanceClocks(time::milliseconds(5), time::seconds(1));
   BOOST_CHECK_EQUAL(hasData2b, false);
@@ -344,8 +345,8 @@
   // Interest 2 retransmission gets through, and is answered
   shared_ptr<Interest> interest2c = makeInterest("ndn:/laptops/A/2");
   bool hasData2c = false;
-  consumer->getClientFace()->expressInterest(*interest2c,
-                                             bind([&hasData2c] { hasData2c = true; }));
+  consumer->getClientFace().expressInterest(*interest2c,
+                                            bind([&hasData2c] { hasData2c = true; }));
   this->advanceClocks(time::milliseconds(5), time::seconds(1));
   BOOST_CHECK_EQUAL(hasData2c, true);
 }
@@ -357,17 +358,18 @@
   topo.registerPrefix(router, linkA->getFace(router), "ndn:/net");
 
   // send Interests from laptopA to router
-  shared_ptr<TopologyAppLink> consumer = topo.addAppFace(laptopA);
-  topo.addIntervalConsumer(*consumer->getClientFace(), "ndn:/net",
+  shared_ptr<TopologyAppLink> consumer = topo.addAppFace("c", laptopA);
+  topo.addIntervalConsumer(consumer->getClientFace(), "ndn:/net",
                            time::milliseconds(100), 10);
 
   this->advanceClocks(time::milliseconds(5), time::seconds(2));
 
   // Interest shouldn't loop back from router
-  BOOST_CHECK_EQUAL(linkA->getFace(router)->m_sentInterests.size(), 0);
+  BOOST_CHECK_EQUAL(linkA->getFace(router).getCounters().getNOutInterests(), 0);
 }
 
-BOOST_AUTO_TEST_SUITE_END()
+BOOST_AUTO_TEST_SUITE_END() // TestAccessStrategy
+BOOST_AUTO_TEST_SUITE_END() // Fw
 
 } // namespace tests
 } // namespace fw
diff --git a/tests/daemon/fw/best-route-strategy2.t.cpp b/tests/daemon/fw/best-route-strategy2.t.cpp
index 8a2c3db..4ee43e9 100644
--- a/tests/daemon/fw/best-route-strategy2.t.cpp
+++ b/tests/daemon/fw/best-route-strategy2.t.cpp
@@ -24,10 +24,11 @@
  */
 
 #include "fw/best-route-strategy2.hpp"
-#include "strategy-tester.hpp"
 
 #include "tests/test-common.hpp"
 #include "tests/daemon/face/dummy-face.hpp"
+#include "strategy-tester.hpp"
+#include "topology-tester.hpp"
 
 namespace nfd {
 namespace fw {
@@ -35,33 +36,51 @@
 
 using namespace nfd::tests;
 
-BOOST_FIXTURE_TEST_SUITE(FwBestRouteStrategy2, UnitTestTimeFixture)
+BOOST_AUTO_TEST_SUITE(Fw)
+
+class BestRouteStrategy2Fixture : public UnitTestTimeFixture
+{
+protected:
+  BestRouteStrategy2Fixture()
+    : strategy(forwarder)
+    , fib(forwarder.getFib())
+    , pit(forwarder.getPit())
+    , face1(make_shared<DummyFace>())
+    , face2(make_shared<DummyFace>())
+    , face3(make_shared<DummyFace>())
+    , face4(make_shared<DummyFace>())
+    , face5(make_shared<DummyFace>())
+  {
+    forwarder.addFace(face1);
+    forwarder.addFace(face2);
+    forwarder.addFace(face3);
+    forwarder.addFace(face4);
+    forwarder.addFace(face5);
+  }
+
+public:
+  Forwarder forwarder;
+  StrategyTester<fw::BestRouteStrategy2> strategy;
+  Fib& fib;
+  Pit& pit;
+
+  shared_ptr<DummyFace> face1;
+  shared_ptr<DummyFace> face2;
+  shared_ptr<DummyFace> face3;
+  shared_ptr<DummyFace> face4;
+  shared_ptr<DummyFace> face5;
+};
+
+BOOST_FIXTURE_TEST_SUITE(TestBestRouteStrategy2, BestRouteStrategy2Fixture)
 
 BOOST_AUTO_TEST_CASE(Forward)
 {
-  Forwarder forwarder;
-  typedef StrategyTester<fw::BestRouteStrategy2> BestRouteStrategy2Tester;
-  BestRouteStrategy2Tester strategy(forwarder);
-
-  shared_ptr<DummyFace> face1 = make_shared<DummyFace>();
-  shared_ptr<DummyFace> face2 = make_shared<DummyFace>();
-  shared_ptr<DummyFace> face3 = make_shared<DummyFace>();
-  shared_ptr<DummyFace> face4 = make_shared<DummyFace>();
-  shared_ptr<DummyFace> face5 = make_shared<DummyFace>();
-  forwarder.addFace(face1);
-  forwarder.addFace(face2);
-  forwarder.addFace(face3);
-  forwarder.addFace(face4);
-  forwarder.addFace(face5);
-
-  Fib& fib = forwarder.getFib();
   shared_ptr<fib::Entry> fibEntry = fib.insert(Name()).first;
   fibEntry->addNextHop(face1, 10);
   fibEntry->addNextHop(face2, 20);
   fibEntry->addNextHop(face3, 30);
 
   shared_ptr<Interest> interest = makeInterest("ndn:/BzgFBchqA");
-  Pit& pit = forwarder.getPit();
   shared_ptr<pit::Entry> pitEntry = pit.insert(*interest).first;
 
   const time::nanoseconds TICK = time::duration_cast<time::nanoseconds>(
@@ -71,20 +90,20 @@
   // however face1 is downstream so it cannot be used
   pitEntry->insertOrUpdateInRecord(face1, *interest);
   strategy.afterReceiveInterest(*face1, *interest, fibEntry, pitEntry);
-  BOOST_REQUIRE_EQUAL(strategy.m_sendInterestHistory.size(), 1);
-  BOOST_CHECK_EQUAL(strategy.m_sendInterestHistory.back().get<1>(), face2);
+  BOOST_REQUIRE_EQUAL(strategy.sendInterestHistory.size(), 1);
+  BOOST_CHECK_EQUAL(strategy.sendInterestHistory.back().outFaceId, face2->getId());
 
   // downstream retransmits frequently, but the strategy should not send Interests
   // more often than DEFAULT_MIN_RETX_INTERVAL
   scheduler::EventId retxFrom4Evt;
-  size_t nSentLast = strategy.m_sendInterestHistory.size();
+  size_t nSentLast = strategy.sendInterestHistory.size();
   time::steady_clock::TimePoint timeSentLast = time::steady_clock::now();
   function<void()> periodicalRetxFrom4; // let periodicalRetxFrom4 lambda capture itself
   periodicalRetxFrom4 = [&] {
     pitEntry->insertOrUpdateInRecord(face4, *interest);
     strategy.afterReceiveInterest(*face4, *interest, fibEntry, pitEntry);
 
-    size_t nSent = strategy.m_sendInterestHistory.size();
+    size_t nSent = strategy.sendInterestHistory.size();
     if (nSent > nSentLast) {
       BOOST_CHECK_EQUAL(nSent - nSentLast, 1);
       time::steady_clock::TimePoint timeSent = time::steady_clock::now();
@@ -101,29 +120,346 @@
 
   // nexthops for accepted retransmissions: follow FIB cost,
   // later forward to an eligible upstream with earliest OutRecord
-  BOOST_REQUIRE_GE(strategy.m_sendInterestHistory.size(), 6);
-  BOOST_CHECK_EQUAL(strategy.m_sendInterestHistory[1].get<1>(), face1);
-  BOOST_CHECK_EQUAL(strategy.m_sendInterestHistory[2].get<1>(), face3);
-  BOOST_CHECK_EQUAL(strategy.m_sendInterestHistory[3].get<1>(), face2);
-  BOOST_CHECK_EQUAL(strategy.m_sendInterestHistory[4].get<1>(), face1);
-  BOOST_CHECK_EQUAL(strategy.m_sendInterestHistory[5].get<1>(), face3);
+  BOOST_REQUIRE_GE(strategy.sendInterestHistory.size(), 6);
+  BOOST_CHECK_EQUAL(strategy.sendInterestHistory[1].outFaceId, face1->getId());
+  BOOST_CHECK_EQUAL(strategy.sendInterestHistory[2].outFaceId, face3->getId());
+  BOOST_CHECK_EQUAL(strategy.sendInterestHistory[3].outFaceId, face2->getId());
+  BOOST_CHECK_EQUAL(strategy.sendInterestHistory[4].outFaceId, face1->getId());
+  BOOST_CHECK_EQUAL(strategy.sendInterestHistory[5].outFaceId, face3->getId());
 
   fibEntry->removeNextHop(face1);
 
-  strategy.m_sendInterestHistory.clear();
+  strategy.sendInterestHistory.clear();
   for (int i = 0; i < 3; ++i) {
     this->advanceClocks(TICK, fw::RetxSuppressionExponential::DEFAULT_MAX_INTERVAL * 2);
     pitEntry->insertOrUpdateInRecord(face5, *interest);
     strategy.afterReceiveInterest(*face5, *interest, fibEntry, pitEntry);
   }
-  BOOST_REQUIRE_EQUAL(strategy.m_sendInterestHistory.size(), 3);
-  BOOST_CHECK_NE(strategy.m_sendInterestHistory[0].get<1>(), face1);
-  BOOST_CHECK_NE(strategy.m_sendInterestHistory[1].get<1>(), face1);
-  BOOST_CHECK_NE(strategy.m_sendInterestHistory[2].get<1>(), face1);
+  BOOST_REQUIRE_EQUAL(strategy.sendInterestHistory.size(), 3);
+  BOOST_CHECK_NE(strategy.sendInterestHistory[0].outFaceId, face1->getId());
+  BOOST_CHECK_NE(strategy.sendInterestHistory[1].outFaceId, face1->getId());
+  BOOST_CHECK_NE(strategy.sendInterestHistory[2].outFaceId, face1->getId());
   // face1 cannot be used because it's gone from FIB entry
 }
 
-BOOST_AUTO_TEST_SUITE_END()
+BOOST_AUTO_TEST_SUITE(NoRouteNack) // send Nack-NoRoute if there's no usable FIB nexthop
+
+class EmptyNextHopList
+{
+public:
+  Name
+  getInterestName()
+  {
+    return "/P";
+  }
+
+  shared_ptr<fib::Entry>
+  makeFibEntry(BestRouteStrategy2Fixture* fixture)
+  {
+    return fixture->fib.insert(Name()).first;
+  }
+};
+
+class NextHopIsDownstream
+{
+public:
+  Name
+  getInterestName()
+  {
+    return "/P";
+  }
+
+  shared_ptr<fib::Entry>
+  makeFibEntry(BestRouteStrategy2Fixture* fixture)
+  {
+    shared_ptr<fib::Entry> fibEntry = fixture->fib.insert(Name()).first;
+    fibEntry->addNextHop(fixture->face1, 10);
+    return fibEntry;
+  }
+};
+
+class NextHopViolatesScope
+{
+public:
+  Name
+  getInterestName()
+  {
+    return "/localhop/P";
+  }
+
+  shared_ptr<fib::Entry>
+  makeFibEntry(BestRouteStrategy2Fixture* fixture)
+  {
+    shared_ptr<fib::Entry> fibEntry = fixture->fib.insert("/localhop").first;
+    fibEntry->addNextHop(fixture->face2, 10);
+    // face1 and face2 are both non-local; Interest from face1 cannot be forwarded to face2
+    return fibEntry;
+  }
+};
+
+typedef boost::mpl::vector<EmptyNextHopList, NextHopIsDownstream, NextHopViolatesScope> NoRouteScenarios;
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(IncomingInterest, Scenario, NoRouteScenarios)
+{
+  Scenario scenario;
+
+  shared_ptr<Interest> interest = makeInterest(scenario.getInterestName());
+  shared_ptr<pit::Entry> pitEntry = pit.insert(*interest).first;
+  pitEntry->insertOrUpdateInRecord(face1, *interest);
+
+  shared_ptr<fib::Entry> fibEntry = scenario.makeFibEntry(this);
+
+  strategy.afterReceiveInterest(*face1, *interest, fibEntry, pitEntry);
+
+  BOOST_REQUIRE_EQUAL(strategy.rejectPendingInterestHistory.size(), 1);
+  BOOST_CHECK_EQUAL(strategy.rejectPendingInterestHistory[0].pitEntry, pitEntry);
+
+  BOOST_REQUIRE_EQUAL(strategy.sendNackHistory.size(), 1);
+  BOOST_CHECK_EQUAL(strategy.sendNackHistory[0].pitEntry, pitEntry);
+  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(IncomingNack)
+
+BOOST_AUTO_TEST_CASE(OneUpstream) // one upstream, send Nack when Nack arrives
+{
+  shared_ptr<fib::Entry> fibEntry = fib.insert(Name()).first;
+  fibEntry->addNextHop(face3, 10);
+  fibEntry->addNextHop(face4, 20);
+  fibEntry->addNextHop(face5, 30);
+
+  shared_ptr<Interest> interest1 = makeInterest("/McQYjMbm", 992);
+  shared_ptr<Interest> interest2 = makeInterest("/McQYjMbm", 114);
+  shared_ptr<pit::Entry> pitEntry = pit.insert(*interest1).first;
+  pitEntry->insertOrUpdateInRecord(face1, *interest1);
+  pitEntry->insertOrUpdateInRecord(face2, *interest2);
+  pitEntry->insertOrUpdateOutRecord(face3, *interest1);
+
+  lp::Nack nack3 = makeNack("/McQYjMbm", 992, lp::NackReason::CONGESTION);
+  pitEntry->getOutRecord(*face3)->setIncomingNack(nack3);
+  strategy.afterReceiveNack(*face3, nack3, fibEntry, pitEntry);
+
+  BOOST_REQUIRE_EQUAL(strategy.sendNackHistory.size(), 2);
+  BOOST_CHECK_EQUAL(strategy.sendNackHistory[0].pitEntry, pitEntry);
+  BOOST_CHECK_EQUAL(strategy.sendNackHistory[0].header.getReason(), lp::NackReason::CONGESTION);
+  BOOST_CHECK_EQUAL(strategy.sendNackHistory[1].pitEntry, pitEntry);
+  BOOST_CHECK_EQUAL(strategy.sendNackHistory[1].header.getReason(), lp::NackReason::CONGESTION);
+  std::unordered_set<FaceId> nackFaceIds{strategy.sendNackHistory[0].outFaceId,
+                                         strategy.sendNackHistory[1].outFaceId};
+  std::unordered_set<FaceId> expectedNackFaceIds{face1->getId(), face2->getId()};
+  BOOST_CHECK_EQUAL_COLLECTIONS(nackFaceIds.begin(), nackFaceIds.end(),
+                                expectedNackFaceIds.begin(), expectedNackFaceIds.end());
+}
+
+BOOST_AUTO_TEST_CASE(TwoUpstreams) // two upstreams, send Nack when both Nacks arrive
+{
+  shared_ptr<fib::Entry> fibEntry = fib.insert(Name()).first;
+  fibEntry->addNextHop(face3, 10);
+  fibEntry->addNextHop(face4, 20);
+  fibEntry->addNextHop(face5, 30);
+
+  shared_ptr<Interest> interest1 = makeInterest("/aS9FAyUV19", 286);
+  shared_ptr<pit::Entry> pitEntry = pit.insert(*interest1).first;
+  pitEntry->insertOrUpdateInRecord(face1, *interest1);
+  pitEntry->insertOrUpdateOutRecord(face3, *interest1);
+  pitEntry->insertOrUpdateOutRecord(face4, *interest1);
+
+  lp::Nack nack3 = makeNack("/aS9FAyUV19", 286, lp::NackReason::CONGESTION);
+  pitEntry->getOutRecord(*face3)->setIncomingNack(nack3);
+  strategy.afterReceiveNack(*face3, nack3, fibEntry, pitEntry);
+
+  BOOST_CHECK_EQUAL(strategy.sendNackHistory.size(), 0); // don't send Nack until all upstreams have Nacked
+
+  lp::Nack nack4 = makeNack("/aS9FAyUV19", 286, lp::NackReason::CONGESTION);
+  pitEntry->getOutRecord(*face4)->setIncomingNack(nack4);
+  strategy.afterReceiveNack(*face4, nack4, fibEntry, pitEntry);
+
+  BOOST_REQUIRE_EQUAL(strategy.sendNackHistory.size(), 1);
+  BOOST_CHECK_EQUAL(strategy.sendNackHistory[0].pitEntry, pitEntry);
+  BOOST_CHECK_EQUAL(strategy.sendNackHistory[0].outFaceId, face1->getId());
+  BOOST_CHECK_EQUAL(strategy.sendNackHistory[0].header.getReason(), lp::NackReason::CONGESTION);
+}
+
+BOOST_AUTO_TEST_CASE(Timeout) // two upstreams, one times out, don't send Nack
+{
+  shared_ptr<fib::Entry> fibEntry = fib.insert(Name()).first;
+  fibEntry->addNextHop(face3, 10);
+  fibEntry->addNextHop(face4, 20);
+  fibEntry->addNextHop(face5, 30);
+
+  shared_ptr<Interest> interest1 = makeInterest("/sIYw0TXWDj", 115);
+  interest1->setInterestLifetime(time::milliseconds(400));
+  shared_ptr<pit::Entry> pitEntry = pit.insert(*interest1).first;
+  pitEntry->insertOrUpdateInRecord(face1, *interest1);
+  pitEntry->insertOrUpdateOutRecord(face3, *interest1);
+
+  this->advanceClocks(time::milliseconds(300));
+  shared_ptr<Interest> interest2 = makeInterest("/sIYw0TXWDj", 223);
+  pitEntry->insertOrUpdateInRecord(face1, *interest2);
+  pitEntry->insertOrUpdateOutRecord(face4, *interest2);
+
+  this->advanceClocks(time::milliseconds(200)); // face3 has timed out
+
+  lp::Nack nack4 = makeNack("/sIYw0TXWDj", 223, lp::NackReason::CONGESTION);
+  pitEntry->getOutRecord(*face4)->setIncomingNack(nack4);
+  strategy.afterReceiveNack(*face4, nack4, fibEntry, pitEntry);
+
+  BOOST_CHECK_EQUAL(strategy.sendNackHistory.size(), 0);
+}
+
+BOOST_FIXTURE_TEST_CASE(LiveDeadlock, UnitTestTimeFixture) // #3033 note-7
+{
+  /*
+   *           /----------\
+   *           | producer |
+   *           \----------/
+   *                |
+   *              +---+
+   *              | P |
+   *              +---+
+   *                |
+   *           failed link
+   *                |
+   *              +---+
+   *              | R |
+   *              +---+
+   *             ^     ^
+   *            /       \
+   *           /         \
+   *        +---+       +---+
+   *        | B | <---> | C |
+   *        +---+       +---+
+   *          ^           ^
+   *          |           |
+   *          |           |
+   *        +---+       +---+
+   *        | A |       | D |
+   *        +---+       +---+
+   *          ^           ^
+   *          |           |
+   *  /----------\     /----------\
+   *  | consumer |     | consumer |
+   *  \----------/     \----------/
+   */
+
+  TopologyTester topo;
+  TopologyNode nodeP = topo.addForwarder("P"),
+               nodeR = topo.addForwarder("R"),
+               nodeA = topo.addForwarder("A"),
+               nodeB = topo.addForwarder("B"),
+               nodeC = topo.addForwarder("C"),
+               nodeD = topo.addForwarder("D");
+
+  for (TopologyNode node : {nodeP, nodeR, nodeA, nodeB, nodeC, nodeD}) {
+    topo.setStrategy<BestRouteStrategy2>(node);
+  }
+
+  const time::milliseconds LINK_DELAY(10);
+  shared_ptr<TopologyLink> linkPR = topo.addLink("PR", LINK_DELAY, {nodeP, nodeR}),
+                           linkRB = topo.addLink("RB", LINK_DELAY, {nodeR, nodeB}),
+                           linkRC = topo.addLink("RC", LINK_DELAY, {nodeR, nodeC}),
+                           linkBC = topo.addLink("BC", LINK_DELAY, {nodeB, nodeC}),
+                           linkBA = topo.addLink("BA", LINK_DELAY, {nodeB, nodeA}),
+                           linkCD = topo.addLink("CD", LINK_DELAY, {nodeC, nodeD});
+
+  // TODO register the prefix on R->P but then set the face DOWN
+  // topo.registerPrefix(nodeR, linkPR->getFace(nodeR), "ndn:/P", 10);
+  topo.registerPrefix(nodeB, linkRB->getFace(nodeB), "ndn:/P", 20);
+  topo.registerPrefix(nodeB, linkBC->getFace(nodeB), "ndn:/P", 30);
+  topo.registerPrefix(nodeC, linkRC->getFace(nodeC), "ndn:/P", 20);
+  topo.registerPrefix(nodeC, linkBC->getFace(nodeC), "ndn:/P", 30);
+  topo.registerPrefix(nodeA, linkBA->getFace(nodeA), "ndn:/P", 30);
+  topo.registerPrefix(nodeD, linkCD->getFace(nodeD), "ndn:/P", 30);
+
+  ndn::Face& appA = topo.addAppFace("A", nodeA)->getClientFace();
+  ndn::Face& appD = topo.addAppFace("D", nodeD)->getClientFace();
+
+  int nNacksA = 0, nNacksD = 0;
+  appA.expressInterest(Interest("/P/1"), bind([]{}), bind([&nNacksA]{ ++nNacksA; }), bind([]{}));
+  appD.expressInterest(Interest("/P/1"), bind([]{}), bind([&nNacksD]{ ++nNacksD; }), bind([]{}));
+  this->advanceClocks(time::milliseconds(1), time::milliseconds(5));
+  appA.expressInterest(Interest("/P/1"), bind([]{}), bind([&nNacksA]{ ++nNacksA; }), bind([]{}));
+  appD.expressInterest(Interest("/P/1"), bind([]{}), bind([&nNacksD]{ ++nNacksD; }), bind([]{}));
+  this->advanceClocks(time::milliseconds(1), time::milliseconds(100));
+
+  // As long as at least one Nack arrives at each client, strategy behavior is correct.
+  // Whether both Interests are Nacked is a client face behavior, not strategy behavior.
+  BOOST_CHECK_GT(nNacksA, 0);
+  BOOST_CHECK_GT(nNacksD, 0);
+}
+
+template<lp::NackReason X, lp::NackReason Y, lp::NackReason R>
+struct NackReasonCombination
+{
+  lp::NackReason
+  getX() const
+  {
+    return X;
+  }
+
+  lp::NackReason
+  getY() const
+  {
+    return Y;
+  }
+
+  lp::NackReason
+  getExpectedResult() const
+  {
+    return R;
+  }
+};
+
+typedef boost::mpl::vector<
+    NackReasonCombination<lp::NackReason::CONGESTION, lp::NackReason::CONGESTION, lp::NackReason::CONGESTION>,
+    NackReasonCombination<lp::NackReason::CONGESTION, lp::NackReason::DUPLICATE, lp::NackReason::CONGESTION>,
+    NackReasonCombination<lp::NackReason::CONGESTION, lp::NackReason::NO_ROUTE, lp::NackReason::CONGESTION>,
+    NackReasonCombination<lp::NackReason::DUPLICATE, lp::NackReason::CONGESTION, lp::NackReason::CONGESTION>,
+    NackReasonCombination<lp::NackReason::DUPLICATE, lp::NackReason::DUPLICATE, lp::NackReason::DUPLICATE>,
+    NackReasonCombination<lp::NackReason::DUPLICATE, lp::NackReason::NO_ROUTE, lp::NackReason::DUPLICATE>,
+    NackReasonCombination<lp::NackReason::NO_ROUTE, lp::NackReason::CONGESTION, lp::NackReason::CONGESTION>,
+    NackReasonCombination<lp::NackReason::NO_ROUTE, lp::NackReason::DUPLICATE, lp::NackReason::DUPLICATE>,
+    NackReasonCombination<lp::NackReason::NO_ROUTE, lp::NackReason::NO_ROUTE, lp::NackReason::NO_ROUTE>
+  > NackReasonCombinations;
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(CombineReasons, Combination, NackReasonCombinations)
+{
+  Combination combination;
+
+  shared_ptr<fib::Entry> fibEntry = fib.insert(Name()).first;
+  fibEntry->addNextHop(face3, 10);
+  fibEntry->addNextHop(face4, 20);
+  fibEntry->addNextHop(face5, 30);
+
+  shared_ptr<Interest> interest1 = makeInterest("/F6sEwB24I", 282);
+  shared_ptr<pit::Entry> pitEntry = pit.insert(*interest1).first;
+  pitEntry->insertOrUpdateInRecord(face1, *interest1);
+  pitEntry->insertOrUpdateOutRecord(face3, *interest1);
+  pitEntry->insertOrUpdateOutRecord(face4, *interest1);
+
+  lp::Nack nack3 = makeNack("/F6sEwB24I", 282, combination.getX());
+  pitEntry->getOutRecord(*face3)->setIncomingNack(nack3);
+  strategy.afterReceiveNack(*face3, nack3, fibEntry, pitEntry);
+
+  BOOST_CHECK_EQUAL(strategy.sendNackHistory.size(), 0);
+
+  lp::Nack nack4 = makeNack("/F6sEwB24I", 282, combination.getY());
+  pitEntry->getOutRecord(*face4)->setIncomingNack(nack4);
+  strategy.afterReceiveNack(*face4, nack4, fibEntry, pitEntry);
+
+  BOOST_REQUIRE_EQUAL(strategy.sendNackHistory.size(), 1);
+  BOOST_CHECK_EQUAL(strategy.sendNackHistory[0].pitEntry, pitEntry);
+  BOOST_CHECK_EQUAL(strategy.sendNackHistory[0].outFaceId, face1->getId());
+  BOOST_CHECK_EQUAL(strategy.sendNackHistory[0].header.getReason(), combination.getExpectedResult());
+}
+
+BOOST_AUTO_TEST_SUITE_END() // IncomingNack
+
+BOOST_AUTO_TEST_SUITE_END() // TestBestRouteStrategy2
+BOOST_AUTO_TEST_SUITE_END() // Fw
 
 } // namespace tests
 } // namespace fw
diff --git a/tests/daemon/fw/client-control-strategy.t.cpp b/tests/daemon/fw/client-control-strategy.t.cpp
index ee3a362..189d42f 100644
--- a/tests/daemon/fw/client-control-strategy.t.cpp
+++ b/tests/daemon/fw/client-control-strategy.t.cpp
@@ -35,7 +35,8 @@
 
 using namespace nfd::tests;
 
-BOOST_FIXTURE_TEST_SUITE(FwClientControlStrategy, BaseFixture)
+BOOST_AUTO_TEST_SUITE(Fw)
+BOOST_FIXTURE_TEST_SUITE(TestClientControlStrategy, BaseFixture)
 
 BOOST_AUTO_TEST_CASE(Forward3)
 {
@@ -65,20 +66,20 @@
   shared_ptr<pit::Entry> pitEntry1 = pit.insert(*interest1).first;
   pitEntry1->insertOrUpdateInRecord(face4, *interest1);
 
-  strategy.m_sendInterestHistory.clear();
+  strategy.sendInterestHistory.clear();
   strategy.afterReceiveInterest(*face4, *interest1, fibEntry, pitEntry1);
-  BOOST_REQUIRE_EQUAL(strategy.m_sendInterestHistory.size(), 1);
-  BOOST_CHECK_EQUAL(strategy.m_sendInterestHistory[0].get<1>(), face1);
+  BOOST_REQUIRE_EQUAL(strategy.sendInterestHistory.size(), 1);
+  BOOST_CHECK_EQUAL(strategy.sendInterestHistory[0].outFaceId, face1->getId());
 
   // Interest without NextHopFaceId
   shared_ptr<Interest> interest2 = makeInterest("ndn:/y6JQADGVz");
   shared_ptr<pit::Entry> pitEntry2 = pit.insert(*interest2).first;
   pitEntry2->insertOrUpdateInRecord(face4, *interest2);
 
-  strategy.m_sendInterestHistory.clear();
+  strategy.sendInterestHistory.clear();
   strategy.afterReceiveInterest(*face4, *interest2, fibEntry, pitEntry2);
-  BOOST_REQUIRE_EQUAL(strategy.m_sendInterestHistory.size(), 1);
-  BOOST_CHECK_EQUAL(strategy.m_sendInterestHistory[0].get<1>(), face2);
+  BOOST_REQUIRE_EQUAL(strategy.sendInterestHistory.size(), 1);
+  BOOST_CHECK_EQUAL(strategy.sendInterestHistory[0].outFaceId, face2->getId());
 
   // Interest with invalid NextHopFaceId
   shared_ptr<Interest> interest3 = makeInterest("ndn:/0z8r6yDDe");
@@ -87,14 +88,15 @@
   pitEntry3->insertOrUpdateInRecord(face4, *interest3);
 
   face3->close(); // face3 is closed and its FaceId becomes invalid
-  strategy.m_sendInterestHistory.clear();
-  strategy.m_rejectPendingInterestHistory.clear();
+  strategy.sendInterestHistory.clear();
+  strategy.rejectPendingInterestHistory.clear();
   strategy.afterReceiveInterest(*face4, *interest3, fibEntry, pitEntry3);
-  BOOST_REQUIRE_EQUAL(strategy.m_sendInterestHistory.size(), 0);
-  BOOST_REQUIRE_EQUAL(strategy.m_rejectPendingInterestHistory.size(), 1);
+  BOOST_REQUIRE_EQUAL(strategy.sendInterestHistory.size(), 0);
+  BOOST_REQUIRE_EQUAL(strategy.rejectPendingInterestHistory.size(), 1);
 }
 
-BOOST_AUTO_TEST_SUITE_END()
+BOOST_AUTO_TEST_SUITE_END() // TestClientControlStrategy
+BOOST_AUTO_TEST_SUITE_END() // Fw
 
 } // namespace tests
 } // namespace fw
diff --git a/tests/daemon/fw/dummy-strategy.hpp b/tests/daemon/fw/dummy-strategy.hpp
index d078051..33d2656 100644
--- a/tests/daemon/fw/dummy-strategy.hpp
+++ b/tests/daemon/fw/dummy-strategy.hpp
@@ -33,7 +33,7 @@
 
 /** \brief strategy for unit testing
  *
- *  Triggers on DummyStrategy are recorded but does nothing
+ *  Unless otherwise indicated, triggers are recorded but does nothing.
  */
 class DummyStrategy : public fw::Strategy
 {
@@ -47,9 +47,13 @@
   {
   }
 
+  /** \brief after receive Interest trigger
+   *
+   *  If \p interestOutFace is not null, send Interest action is invoked with that face;
+   *  otherwise, reject pending Interest action is invoked.
+   */
   virtual void
-  afterReceiveInterest(const Face& inFace,
-                       const Interest& interest,
+  afterReceiveInterest(const Face& inFace, const Interest& interest,
                        shared_ptr<fib::Entry> fibEntry,
                        shared_ptr<pit::Entry> pitEntry) DECL_OVERRIDE
   {
@@ -59,7 +63,7 @@
         interest, fibEntry, pitEntry));
     }
 
-    if (static_cast<bool>(interestOutFace)) {
+    if (interestOutFace) {
       this->sendInterest(pitEntry, interestOutFace);
     }
     else {
@@ -80,16 +84,25 @@
     ++beforeExpirePendingInterest_count;
   }
 
+  virtual void
+  afterReceiveNack(const Face& inFace, const lp::Nack& nack,
+                   shared_ptr<fib::Entry> fibEntry,
+                   shared_ptr<pit::Entry> pitEntry) DECL_OVERRIDE
+  {
+    ++afterReceiveNack_count;
+  }
+
 public:
   int afterReceiveInterest_count;
   bool wantAfterReceiveInterestCalls;
   std::vector<std::tuple<FaceId, Interest, shared_ptr<fib::Entry>,
               shared_ptr<pit::Entry>>> afterReceiveInterestCalls;
+  shared_ptr<Face> interestOutFace;
+
   int beforeSatisfyInterest_count;
   int beforeExpirePendingInterest_count;
+  int afterReceiveNack_count;
 
-  /// outFace to use in afterReceiveInterest, nullptr to reject
-  shared_ptr<Face> interestOutFace;
 };
 
 } // namespace tests
diff --git a/tests/daemon/fw/forwarder.t.cpp b/tests/daemon/fw/forwarder.t.cpp
index d9d50d6..6a3509f 100644
--- a/tests/daemon/fw/forwarder.t.cpp
+++ b/tests/daemon/fw/forwarder.t.cpp
@@ -25,6 +25,8 @@
 
 #include "fw/forwarder.hpp"
 #include "tests/daemon/face/dummy-face.hpp"
+#include "tests/daemon/face/dummy-lp-face.hpp"
+#include "face/lp-face-wrapper.hpp"
 #include "dummy-strategy.hpp"
 
 #include "tests/test-common.hpp"
@@ -425,6 +427,225 @@
   BOOST_CHECK_EQUAL(face4->m_sentDatas.size(), 1);
 }
 
+BOOST_AUTO_TEST_CASE(IncomingNack)
+{
+  Forwarder forwarder;
+  auto face1 = make_shared<DummyFace>();
+  auto face2 = make_shared<DummyFace>();
+  auto face3 = make_shared<face::LpFaceWrapper>(make_unique<DummyLpFace>(
+               "dummy://", "dummy://",
+               ndn::nfd::FACE_SCOPE_NON_LOCAL,
+               ndn::nfd::FACE_PERSISTENCY_PERSISTENT,
+               ndn::nfd::LINK_TYPE_MULTI_ACCESS));
+  forwarder.addFace(face1);
+  forwarder.addFace(face2);
+  forwarder.addFace(face3);
+
+  StrategyChoice& strategyChoice = forwarder.getStrategyChoice();
+  shared_ptr<DummyStrategy> strategyP = make_shared<DummyStrategy>(
+                                        ref(forwarder), "ndn:/strategyP");
+  shared_ptr<DummyStrategy> strategyQ = make_shared<DummyStrategy>(
+                                        ref(forwarder), "ndn:/strategyQ");
+  strategyChoice.install(strategyP);
+  strategyChoice.install(strategyQ);
+  strategyChoice.insert("ndn:/" , strategyP->getName());
+  strategyChoice.insert("ndn:/B", strategyQ->getName());
+
+  Pit& pit = forwarder.getPit();
+
+  // dispatch to the correct strategy
+  shared_ptr<Interest> interest1 = makeInterest("/A/AYJqayrzF", 562);
+  shared_ptr<pit::Entry> pit1 = pit.insert(*interest1).first;
+  pit1->insertOrUpdateOutRecord(face1, *interest1);
+  shared_ptr<Interest> interest2 = makeInterest("/B/EVyP73ru", 221);
+  shared_ptr<pit::Entry> pit2 = pit.insert(*interest2).first;
+  pit2->insertOrUpdateOutRecord(face1, *interest2);
+
+  lp::Nack nack1 = makeNack("/A/AYJqayrzF", 562, lp::NackReason::CONGESTION);
+  strategyP->afterReceiveNack_count = 0;
+  strategyQ->afterReceiveNack_count = 0;
+  forwarder.onIncomingNack(*face1, nack1);
+  BOOST_CHECK_EQUAL(strategyP->afterReceiveNack_count, 1);
+  BOOST_CHECK_EQUAL(strategyQ->afterReceiveNack_count, 0);
+
+  lp::Nack nack2 = makeNack("/B/EVyP73ru", 221, lp::NackReason::CONGESTION);
+  strategyP->afterReceiveNack_count = 0;
+  strategyQ->afterReceiveNack_count = 0;
+  forwarder.onIncomingNack(*face1, nack2);
+  BOOST_CHECK_EQUAL(strategyP->afterReceiveNack_count, 0);
+  BOOST_CHECK_EQUAL(strategyQ->afterReceiveNack_count, 1);
+
+  // record Nack on PIT out-record
+  pit::OutRecordCollection::const_iterator outRecord1 = pit1->getOutRecord(*face1);
+  BOOST_REQUIRE(outRecord1 != pit1->getOutRecords().end());
+  BOOST_REQUIRE(outRecord1->getIncomingNack() != nullptr);
+  BOOST_CHECK_EQUAL(outRecord1->getIncomingNack()->getReason(), lp::NackReason::CONGESTION);
+
+  // drop if no PIT entry
+  lp::Nack nack3 = makeNack("/yEcw5HhdM", 243, lp::NackReason::CONGESTION);
+  strategyP->afterReceiveNack_count = 0;
+  strategyQ->afterReceiveNack_count = 0;
+  forwarder.onIncomingNack(*face1, nack3);
+  BOOST_CHECK_EQUAL(strategyP->afterReceiveNack_count, 0);
+  BOOST_CHECK_EQUAL(strategyQ->afterReceiveNack_count, 0);
+
+  // drop if no out-record
+  shared_ptr<Interest> interest4 = makeInterest("/Etab4KpY", 157);
+  shared_ptr<pit::Entry> pit4 = pit.insert(*interest4).first;
+  pit4->insertOrUpdateOutRecord(face1, *interest4);
+
+  lp::Nack nack4a = makeNack("/Etab4KpY", 157, lp::NackReason::CONGESTION);
+  strategyP->afterReceiveNack_count = 0;
+  strategyQ->afterReceiveNack_count = 0;
+  forwarder.onIncomingNack(*face2, nack4a);
+  BOOST_CHECK_EQUAL(strategyP->afterReceiveNack_count, 0);
+  BOOST_CHECK_EQUAL(strategyQ->afterReceiveNack_count, 0);
+
+  // drop if Nonce does not match out-record
+  lp::Nack nack4b = makeNack("/Etab4KpY", 294, lp::NackReason::CONGESTION);
+  strategyP->afterReceiveNack_count = 0;
+  strategyQ->afterReceiveNack_count = 0;
+  forwarder.onIncomingNack(*face1, nack4b);
+  BOOST_CHECK_EQUAL(strategyP->afterReceiveNack_count, 0);
+  BOOST_CHECK_EQUAL(strategyQ->afterReceiveNack_count, 0);
+
+  // drop if inFace is multi-access
+  pit4->insertOrUpdateOutRecord(face3, *interest4);
+  strategyP->afterReceiveNack_count = 0;
+  strategyQ->afterReceiveNack_count = 0;
+  forwarder.onIncomingNack(*face3, nack4a);
+  BOOST_CHECK_EQUAL(strategyP->afterReceiveNack_count, 0);
+  BOOST_CHECK_EQUAL(strategyQ->afterReceiveNack_count, 0);
+}
+
+BOOST_AUTO_TEST_CASE(OutgoingNack)
+{
+  Forwarder forwarder;
+  auto face1w = make_shared<face::LpFaceWrapper>(make_unique<DummyLpFace>());
+  auto face1 = static_cast<DummyLpFace*>(face1w->getLpFace());
+  auto face2w = make_shared<face::LpFaceWrapper>(make_unique<DummyLpFace>());
+  auto face2 = static_cast<DummyLpFace*>(face2w->getLpFace());
+  auto face3w = make_shared<face::LpFaceWrapper>(make_unique<DummyLpFace>(
+                "dummy://", "dummy://",
+                ndn::nfd::FACE_SCOPE_NON_LOCAL,
+                ndn::nfd::FACE_PERSISTENCY_PERSISTENT,
+                ndn::nfd::LINK_TYPE_MULTI_ACCESS));
+  auto face3 = static_cast<DummyLpFace*>(face3w->getLpFace());
+  forwarder.addFace(face1w);
+  forwarder.addFace(face2w);
+  forwarder.addFace(face3w);
+  // TODO#3172 eliminate wrapper
+
+  Pit& pit = forwarder.getPit();
+
+  lp::NackHeader nackHeader;
+  nackHeader.setReason(lp::NackReason::CONGESTION);
+
+  // don't send Nack if there's no in-record
+  shared_ptr<Interest> interest1 = makeInterest("/fM5IVEtC", 719);
+  shared_ptr<pit::Entry> pit1 = pit.insert(*interest1).first;
+  pit1->insertOrUpdateInRecord(face1w, *interest1);
+
+  face2->sentNacks.clear();
+  forwarder.onOutgoingNack(pit1, *face2w, nackHeader);
+  BOOST_CHECK_EQUAL(face2->sentNacks.size(), 0);
+
+  // send Nack with correct Nonce
+  shared_ptr<Interest> interest2a = makeInterest("/Vi8tRm9MG3", 152);
+  shared_ptr<pit::Entry> pit2 = pit.insert(*interest2a).first;
+  pit2->insertOrUpdateInRecord(face1w, *interest2a);
+  shared_ptr<Interest> interest2b = makeInterest("/Vi8tRm9MG3", 808);
+  pit2->insertOrUpdateInRecord(face2w, *interest2b);
+
+  face1->sentNacks.clear();
+  forwarder.onOutgoingNack(pit2, *face1w, nackHeader);
+  BOOST_REQUIRE_EQUAL(face1->sentNacks.size(), 1);
+  BOOST_CHECK_EQUAL(face1->sentNacks.back().getReason(), lp::NackReason::CONGESTION);
+  BOOST_CHECK_EQUAL(face1->sentNacks.back().getInterest().getNonce(), 152);
+
+  // erase in-record
+  pit::InRecordCollection::const_iterator inRecord2a = pit2->getInRecord(*face1w);
+  BOOST_CHECK(inRecord2a == pit2->getInRecords().end());
+
+  // send Nack with correct Nonce
+  face2->sentNacks.clear();
+  forwarder.onOutgoingNack(pit2, *face2w, nackHeader);
+  BOOST_REQUIRE_EQUAL(face2->sentNacks.size(), 1);
+  BOOST_CHECK_EQUAL(face2->sentNacks.back().getReason(), lp::NackReason::CONGESTION);
+  BOOST_CHECK_EQUAL(face2->sentNacks.back().getInterest().getNonce(), 808);
+
+  // erase in-record
+  pit::InRecordCollection::const_iterator inRecord2b = pit2->getInRecord(*face1w);
+  BOOST_CHECK(inRecord2b == pit2->getInRecords().end());
+
+  // don't send Nack to multi-access face
+  shared_ptr<Interest> interest2c = makeInterest("/Vi8tRm9MG3", 228);
+  pit2->insertOrUpdateInRecord(face3w, *interest2c);
+
+  face3->sentNacks.clear();
+  forwarder.onOutgoingNack(pit1, *face3w, nackHeader);
+  BOOST_CHECK_EQUAL(face3->sentNacks.size(), 0);
+}
+
+BOOST_AUTO_TEST_CASE(InterestLoopNack)
+{
+  Forwarder forwarder;
+  auto face1w = make_shared<face::LpFaceWrapper>(make_unique<DummyLpFace>());
+  auto face1 = static_cast<DummyLpFace*>(face1w->getLpFace());
+  auto face2w = make_shared<face::LpFaceWrapper>(make_unique<DummyLpFace>());
+  auto face2 = static_cast<DummyLpFace*>(face2w->getLpFace());
+  auto face3w = make_shared<face::LpFaceWrapper>(make_unique<DummyLpFace>(
+                "dummy://", "dummy://",
+                ndn::nfd::FACE_SCOPE_NON_LOCAL,
+                ndn::nfd::FACE_PERSISTENCY_PERSISTENT,
+                ndn::nfd::LINK_TYPE_MULTI_ACCESS));
+  auto face3 = static_cast<DummyLpFace*>(face3w->getLpFace());
+  auto face4 = make_shared<DummyFace>();
+  forwarder.addFace(face1w);
+  forwarder.addFace(face2w);
+  forwarder.addFace(face3w);
+  forwarder.addFace(face4);
+  // TODO#3172 eliminate wrapper
+
+  Fib& fib = forwarder.getFib();
+  shared_ptr<fib::Entry> fibEntry = fib.insert(Name("/zT4XwK0Hnx")).first;
+  fibEntry->addNextHop(face4, 0);
+
+  // receive Interest on face1
+  face1->sentNacks.clear();
+  shared_ptr<Interest> interest1a = makeInterest("/zT4XwK0Hnx/28JBUvbEzc", 732);
+  face1->receiveInterest(*interest1a);
+  BOOST_CHECK(face1->sentNacks.empty());
+
+  // receive Interest with duplicate Nonce on face1
+  face1->sentNacks.clear();
+  shared_ptr<Interest> interest1b = makeInterest("/zT4XwK0Hnx/28JBUvbEzc", 732);
+  face1->receiveInterest(*interest1b);
+  BOOST_REQUIRE_EQUAL(face1->sentNacks.size(), 1);
+  BOOST_CHECK_EQUAL(face1->sentNacks.back().getInterest(), *interest1b);
+  BOOST_CHECK_EQUAL(face1->sentNacks.back().getReason(), lp::NackReason::DUPLICATE);
+
+  // receive Interest with duplicate Nonce on face2
+  face2->sentNacks.clear();
+  shared_ptr<Interest> interest2a = makeInterest("/zT4XwK0Hnx/28JBUvbEzc", 732);
+  face2->receiveInterest(*interest2a);
+  BOOST_REQUIRE_EQUAL(face2->sentNacks.size(), 1);
+  BOOST_CHECK_EQUAL(face2->sentNacks.back().getInterest(), *interest2a);
+  BOOST_CHECK_EQUAL(face2->sentNacks.back().getReason(), lp::NackReason::DUPLICATE);
+
+  // receive Interest with new Nonce on face2
+  face2->sentNacks.clear();
+  shared_ptr<Interest> interest2b = makeInterest("/zT4XwK0Hnx/28JBUvbEzc", 944);
+  face2->receiveInterest(*interest2b);
+  BOOST_CHECK(face2->sentNacks.empty());
+
+  // receive Interest with duplicate Nonce on face3, don't send Nack to multi-access face
+  face3->sentNacks.clear();
+  shared_ptr<Interest> interest3a = makeInterest("/zT4XwK0Hnx/28JBUvbEzc", 732);
+  face3->receiveInterest(*interest3a);
+  BOOST_CHECK(face3->sentNacks.empty());
+}
+
 BOOST_FIXTURE_TEST_CASE(InterestLoopWithShortLifetime, UnitTestTimeFixture) // Bug 1953
 {
   Forwarder forwarder;
diff --git a/tests/daemon/fw/multicast-strategy.t.cpp b/tests/daemon/fw/multicast-strategy.t.cpp
index c67c408..3476cd3 100644
--- a/tests/daemon/fw/multicast-strategy.t.cpp
+++ b/tests/daemon/fw/multicast-strategy.t.cpp
@@ -35,7 +35,8 @@
 
 using namespace nfd::tests;
 
-BOOST_FIXTURE_TEST_SUITE(FwMulticastStrategy, BaseFixture)
+BOOST_AUTO_TEST_SUITE(Fw)
+BOOST_FIXTURE_TEST_SUITE(TestMulticastStrategy, BaseFixture)
 
 BOOST_AUTO_TEST_CASE(Forward2)
 {
@@ -62,21 +63,17 @@
   pitEntry->insertOrUpdateInRecord(face3, *interest);
 
   strategy.afterReceiveInterest(*face3, *interest, fibEntry, pitEntry);
-  BOOST_CHECK_EQUAL(strategy.m_rejectPendingInterestHistory.size(), 0);
-  BOOST_CHECK_EQUAL(strategy.m_sendInterestHistory.size(), 2);
-  bool hasFace1 = false;
-  bool hasFace2 = false;
-  for (std::vector<MulticastStrategyTester::SendInterestArgs>::iterator it =
-       strategy.m_sendInterestHistory.begin();
-       it != strategy.m_sendInterestHistory.end(); ++it) {
-    if (it->get<1>() == face1) {
-      hasFace1 = true;
-    }
-    if (it->get<1>() == face2) {
-      hasFace2 = true;
-    }
-  }
-  BOOST_CHECK(hasFace1 && hasFace2);
+  BOOST_CHECK_EQUAL(strategy.rejectPendingInterestHistory.size(), 0);
+  BOOST_CHECK_EQUAL(strategy.sendInterestHistory.size(), 2);
+  std::set<FaceId> sentInterestFaceIds;
+  std::transform(strategy.sendInterestHistory.begin(), strategy.sendInterestHistory.end(),
+                 std::inserter(sentInterestFaceIds, sentInterestFaceIds.end()),
+                 [] (const MulticastStrategyTester::SendInterestArgs& args) {
+                   return args.outFaceId;
+                 });
+  std::set<FaceId> expectedInterestFaceIds{face1->getId(), face2->getId()};
+  BOOST_CHECK_EQUAL_COLLECTIONS(sentInterestFaceIds.begin(), sentInterestFaceIds.end(),
+                                expectedInterestFaceIds.begin(), expectedInterestFaceIds.end());
 }
 
 BOOST_AUTO_TEST_CASE(RejectScope)
@@ -100,8 +97,8 @@
   pitEntry->insertOrUpdateInRecord(face1, *interest);
 
   strategy.afterReceiveInterest(*face1, *interest, fibEntry, pitEntry);
-  BOOST_CHECK_EQUAL(strategy.m_rejectPendingInterestHistory.size(), 1);
-  BOOST_CHECK_EQUAL(strategy.m_sendInterestHistory.size(), 0);
+  BOOST_CHECK_EQUAL(strategy.rejectPendingInterestHistory.size(), 1);
+  BOOST_CHECK_EQUAL(strategy.sendInterestHistory.size(), 0);
 }
 
 BOOST_AUTO_TEST_CASE(RejectLoopback)
@@ -123,11 +120,12 @@
   pitEntry->insertOrUpdateInRecord(face1, *interest);
 
   strategy.afterReceiveInterest(*face1, *interest, fibEntry, pitEntry);
-  BOOST_CHECK_EQUAL(strategy.m_rejectPendingInterestHistory.size(), 1);
-  BOOST_CHECK_EQUAL(strategy.m_sendInterestHistory.size(), 0);
+  BOOST_CHECK_EQUAL(strategy.rejectPendingInterestHistory.size(), 1);
+  BOOST_CHECK_EQUAL(strategy.sendInterestHistory.size(), 0);
 }
 
-BOOST_AUTO_TEST_SUITE_END()
+BOOST_AUTO_TEST_SUITE_END() // TestMulticastStrategy
+BOOST_AUTO_TEST_SUITE_END() // Fw
 
 } // namespace tests
 } // namespace fw
diff --git a/tests/daemon/fw/ncc-strategy.t.cpp b/tests/daemon/fw/ncc-strategy.t.cpp
index a10fc47..889b2e2 100644
--- a/tests/daemon/fw/ncc-strategy.t.cpp
+++ b/tests/daemon/fw/ncc-strategy.t.cpp
@@ -36,7 +36,8 @@
 
 using namespace nfd::tests;
 
-BOOST_FIXTURE_TEST_SUITE(FwNccStrategy, UnitTestTimeFixture)
+BOOST_AUTO_TEST_SUITE(Fw)
+BOOST_FIXTURE_TEST_SUITE(TestNccStrategy, UnitTestTimeFixture)
 
 // NccStrategy is fairly complex.
 // The most important property is:
@@ -48,7 +49,7 @@
   Forwarder forwarder;
   typedef StrategyTester<fw::NccStrategy> NccStrategyTester;
   shared_ptr<NccStrategyTester> strategy = make_shared<NccStrategyTester>(ref(forwarder));
-  strategy->onAction.connect(bind(&LimitedIo::afterOp, &limitedIo));
+  strategy->afterAction.connect(bind(&LimitedIo::afterOp, &limitedIo));
 
   shared_ptr<DummyFace> face1 = make_shared<DummyFace>();
   shared_ptr<DummyFace> face2 = make_shared<DummyFace>();
@@ -79,13 +80,13 @@
 
   // forwards to face1 because routing says it's best
   // (no io run here: afterReceiveInterest has already sent the Interest)
-  BOOST_REQUIRE_EQUAL(strategy->m_sendInterestHistory.size(), 1);
-  BOOST_CHECK_EQUAL(strategy->m_sendInterestHistory[0].get<1>(), face1);
+  BOOST_REQUIRE_EQUAL(strategy->sendInterestHistory.size(), 1);
+  BOOST_CHECK_EQUAL(strategy->sendInterestHistory[0].outFaceId, face1->getId());
 
   // forwards to face2 because face1 doesn't respond
   limitedIo.run(1, time::milliseconds(500), time::milliseconds(10));
-  BOOST_REQUIRE_EQUAL(strategy->m_sendInterestHistory.size(), 2);
-  BOOST_CHECK_EQUAL(strategy->m_sendInterestHistory[1].get<1>(), face2);
+  BOOST_REQUIRE_EQUAL(strategy->sendInterestHistory.size(), 2);
+  BOOST_CHECK_EQUAL(strategy->sendInterestHistory[1].outFaceId, face2->getId());
 
   // face2 responds
   shared_ptr<Data> data1p = makeData("ndn:/0Jm1ajrW/%00");
@@ -104,8 +105,8 @@
 
   // forwards to face2 because it responds previously
   this->advanceClocks(time::milliseconds(1));
-  BOOST_REQUIRE_GE(strategy->m_sendInterestHistory.size(), 3);
-  BOOST_CHECK_EQUAL(strategy->m_sendInterestHistory[2].get<1>(), face2);
+  BOOST_REQUIRE_GE(strategy->sendInterestHistory.size(), 3);
+  BOOST_CHECK_EQUAL(strategy->sendInterestHistory[2].outFaceId, face2->getId());
 }
 
 BOOST_AUTO_TEST_CASE(Bug1853)
@@ -140,8 +141,8 @@
   strategy->afterReceiveInterest(*face3, *interest1, fibEntry, pitEntry1);
 
   this->advanceClocks(time::milliseconds(1));
-  BOOST_REQUIRE_EQUAL(strategy->m_sendInterestHistory.size(), 1);
-  BOOST_CHECK_EQUAL(strategy->m_sendInterestHistory[0].get<1>(), face1);
+  BOOST_REQUIRE_EQUAL(strategy->sendInterestHistory.size(), 1);
+  BOOST_CHECK_EQUAL(strategy->sendInterestHistory[0].outFaceId, face1->getId());
 
   // face1 responds
   shared_ptr<Data> data1 = makeData("ndn:/nztwIvHX/%00");
@@ -168,7 +169,7 @@
   Forwarder forwarder;
   typedef StrategyTester<fw::NccStrategy> NccStrategyTester;
   shared_ptr<NccStrategyTester> strategy = make_shared<NccStrategyTester>(ref(forwarder));
-  strategy->onAction.connect(bind(&LimitedIo::afterOp, &limitedIo));
+  strategy->afterAction.connect(bind(&LimitedIo::afterOp, &limitedIo));
 
   shared_ptr<DummyFace> face1 = make_shared<DummyFace>();
   shared_ptr<DummyFace> face2 = make_shared<DummyFace>();
@@ -195,11 +196,11 @@
 
   pitEntry1->insertOrUpdateInRecord(face3, *interest1);
   strategy->afterReceiveInterest(*face3, *interest1, fibEntry, pitEntry1);
-  limitedIo.run(2 - strategy->m_sendInterestHistory.size(),
+  limitedIo.run(2 - strategy->sendInterestHistory.size(),
                 time::milliseconds(2000), time::milliseconds(10));
-  BOOST_REQUIRE_EQUAL(strategy->m_sendInterestHistory.size(), 2);
-  BOOST_CHECK_EQUAL(strategy->m_sendInterestHistory[0].get<1>(), face1);
-  BOOST_CHECK_EQUAL(strategy->m_sendInterestHistory[1].get<1>(), face2);
+  BOOST_REQUIRE_EQUAL(strategy->sendInterestHistory.size(), 2);
+  BOOST_CHECK_EQUAL(strategy->sendInterestHistory[0].outFaceId, face1->getId());
+  BOOST_CHECK_EQUAL(strategy->sendInterestHistory[1].outFaceId, face2->getId());
 
   // face1 responds
   shared_ptr<Data> data1 = makeData("ndn:/seRMz5a6/%00");
@@ -217,11 +218,11 @@
 
   pitEntry2->insertOrUpdateInRecord(face3, *interest2);
   strategy->afterReceiveInterest(*face3, *interest2, fibEntry, pitEntry2);
-  limitedIo.run(3 - strategy->m_sendInterestHistory.size(),
+  limitedIo.run(3 - strategy->sendInterestHistory.size(),
                 time::milliseconds(2000), time::milliseconds(10));
 
-  BOOST_REQUIRE_GE(strategy->m_sendInterestHistory.size(), 3);
-  BOOST_CHECK_EQUAL(strategy->m_sendInterestHistory[2].get<1>(), face1);
+  BOOST_REQUIRE_GE(strategy->sendInterestHistory.size(), 3);
+  BOOST_CHECK_EQUAL(strategy->sendInterestHistory[2].outFaceId, face1->getId());
 }
 
 BOOST_AUTO_TEST_CASE(Bug1971)
@@ -230,7 +231,7 @@
   Forwarder forwarder;
   typedef StrategyTester<fw::NccStrategy> NccStrategyTester;
   shared_ptr<NccStrategyTester> strategy = make_shared<NccStrategyTester>(ref(forwarder));
-  strategy->onAction.connect(bind(&LimitedIo::afterOp, &limitedIo));
+  strategy->afterAction.connect(bind(&LimitedIo::afterOp, &limitedIo));
 
   shared_ptr<DummyFace> face1 = make_shared<DummyFace>();
   shared_ptr<DummyFace> face2 = make_shared<DummyFace>();
@@ -254,10 +255,10 @@
 
   pitEntry1->insertOrUpdateInRecord(face1, *interest1);
   strategy->afterReceiveInterest(*face1, *interest1, fibEntry, pitEntry1);
-  limitedIo.run(1 - strategy->m_sendInterestHistory.size(),
+  limitedIo.run(1 - strategy->sendInterestHistory.size(),
                 time::milliseconds(2000), time::milliseconds(10));
-  BOOST_REQUIRE_EQUAL(strategy->m_sendInterestHistory.size(), 1);
-  BOOST_CHECK_EQUAL(strategy->m_sendInterestHistory[0].get<1>(), face2);
+  BOOST_REQUIRE_EQUAL(strategy->sendInterestHistory.size(), 1);
+  BOOST_CHECK_EQUAL(strategy->sendInterestHistory[0].outFaceId, face2->getId());
 
   // face2 responds
   shared_ptr<Data> data1 = makeData("ndn:/M4mBXCsd");
@@ -270,10 +271,10 @@
   // similar Interest: strategy should still forward it
   pitEntry1->insertOrUpdateInRecord(face1, *interest1);
   strategy->afterReceiveInterest(*face1, *interest1, fibEntry, pitEntry1);
-  limitedIo.run(2 - strategy->m_sendInterestHistory.size(),
+  limitedIo.run(2 - strategy->sendInterestHistory.size(),
                 time::milliseconds(2000), time::milliseconds(10));
-  BOOST_REQUIRE_EQUAL(strategy->m_sendInterestHistory.size(), 2);
-  BOOST_CHECK_EQUAL(strategy->m_sendInterestHistory[1].get<1>(), face2);
+  BOOST_REQUIRE_EQUAL(strategy->sendInterestHistory.size(), 2);
+  BOOST_CHECK_EQUAL(strategy->sendInterestHistory[1].outFaceId, face2->getId());
 }
 
 BOOST_AUTO_TEST_CASE(Bug1998)
@@ -306,11 +307,12 @@
   strategy->afterReceiveInterest(*face1, *interest1, fibEntry, pitEntry1);
 
   // Interest shall go to face2, not loop back to face1
-  BOOST_REQUIRE_EQUAL(strategy->m_sendInterestHistory.size(), 1);
-  BOOST_CHECK_EQUAL(strategy->m_sendInterestHistory[0].get<1>(), face2);
+  BOOST_REQUIRE_EQUAL(strategy->sendInterestHistory.size(), 1);
+  BOOST_CHECK_EQUAL(strategy->sendInterestHistory[0].outFaceId, face2->getId());
 }
 
-BOOST_AUTO_TEST_SUITE_END()
+BOOST_AUTO_TEST_SUITE_END() // TestNccStrategy
+BOOST_AUTO_TEST_SUITE_END() // Fw
 
 } // namespace tests
 } // namespace fw
diff --git a/tests/daemon/fw/retx-suppression.t.cpp b/tests/daemon/fw/retx-suppression.t.cpp
index 2d1b146..266f168 100644
--- a/tests/daemon/fw/retx-suppression.t.cpp
+++ b/tests/daemon/fw/retx-suppression.t.cpp
@@ -26,7 +26,6 @@
 #include "fw/retx-suppression.hpp"
 #include "fw/retx-suppression-fixed.hpp"
 #include "fw/retx-suppression-exponential.hpp"
-#include "strategy-tester.hpp"
 
 #include "tests/test-common.hpp"
 #include "tests/daemon/face/dummy-face.hpp"
diff --git a/tests/daemon/fw/strategy-tester.hpp b/tests/daemon/fw/strategy-tester.hpp
index 9cf4855..26c29c1 100644
--- a/tests/daemon/fw/strategy-tester.hpp
+++ b/tests/daemon/fw/strategy-tester.hpp
@@ -33,8 +33,7 @@
 namespace fw {
 namespace tests {
 
-/** \class StrategyTester
- *  \brief extends strategy S for unit testing
+/** \brief extends strategy S for unit testing
  *
  *  Actions invoked by S are recorded but not passed to forwarder
  */
@@ -49,7 +48,7 @@
   }
 
   /// fires after each Action
-  signal::Signal<StrategyTester<S>> onAction;
+  signal::Signal<StrategyTester<S>> afterAction;
 
 protected:
   virtual void
@@ -60,12 +59,32 @@
   virtual void
   rejectPendingInterest(shared_ptr<pit::Entry> pitEntry) DECL_OVERRIDE;
 
-public:
-  typedef boost::tuple<shared_ptr<pit::Entry>, shared_ptr<Face>> SendInterestArgs;
-  std::vector<SendInterestArgs> m_sendInterestHistory;
+  virtual void
+  sendNack(shared_ptr<pit::Entry> pitEntry, const Face& outFace,
+           const lp::NackHeader& header) DECL_OVERRIDE;
 
-  typedef boost::tuple<shared_ptr<pit::Entry>> RejectPendingInterestArgs;
-  std::vector<RejectPendingInterestArgs> m_rejectPendingInterestHistory;
+public:
+  struct SendInterestArgs
+  {
+    shared_ptr<pit::Entry> pitEntry;
+    FaceId outFaceId;
+    bool wantNewNonce;
+  };
+  std::vector<SendInterestArgs> sendInterestHistory;
+
+  struct RejectPendingInterestArgs
+  {
+    shared_ptr<pit::Entry> pitEntry;
+  };
+  std::vector<RejectPendingInterestArgs> rejectPendingInterestHistory;
+
+  struct SendNackArgs
+  {
+    shared_ptr<pit::Entry> pitEntry;
+    FaceId outFaceId;
+    lp::NackHeader header;
+  };
+  std::vector<SendNackArgs> sendNackHistory;
 };
 
 
@@ -75,17 +94,30 @@
                                 shared_ptr<Face> outFace,
                                 bool wantNewNonce)
 {
-  m_sendInterestHistory.push_back(SendInterestArgs(pitEntry, outFace));
+  SendInterestArgs args{pitEntry, outFace->getId()};
+  sendInterestHistory.push_back(args);
   pitEntry->insertOrUpdateOutRecord(outFace, pitEntry->getInterest());
-  onAction();
+  afterAction();
 }
 
 template<typename S>
 inline void
 StrategyTester<S>::rejectPendingInterest(shared_ptr<pit::Entry> pitEntry)
 {
-  m_rejectPendingInterestHistory.push_back(RejectPendingInterestArgs(pitEntry));
-  onAction();
+  RejectPendingInterestArgs args{pitEntry};
+  rejectPendingInterestHistory.push_back(args);
+  afterAction();
+}
+
+template<typename S>
+inline void
+StrategyTester<S>::sendNack(shared_ptr<pit::Entry> pitEntry, const Face& outFace,
+                            const lp::NackHeader& header)
+{
+  SendNackArgs args{pitEntry, outFace.getId(), header};
+  sendNackHistory.push_back(args);
+  pitEntry->deleteInRecord(outFace);
+  afterAction();
 }
 
 } // namespace tests
diff --git a/tests/daemon/fw/topology-tester.cpp b/tests/daemon/fw/topology-tester.cpp
new file mode 100644
index 0000000..10a0b31
--- /dev/null
+++ b/tests/daemon/fw/topology-tester.cpp
@@ -0,0 +1,260 @@
+/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
+/**
+ * Copyright (c) 2014-2015,  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 "topology-tester.hpp"
+#include <ndn-cxx/encoding/encoding-buffer-fwd.hpp>
+#include "face/generic-link-service.hpp"
+
+namespace nfd {
+namespace fw {
+namespace tests {
+
+using face::LpFaceWrapper;
+
+TopologyForwarderTransport::TopologyForwarderTransport(
+    const FaceUri& localUri, const FaceUri& remoteUri,
+    ndn::nfd::FaceScope scope, ndn::nfd::LinkType linkType)
+{
+  this->setLocalUri(localUri);
+  this->setRemoteUri(remoteUri);
+  this->setScope(scope);
+  this->setPersistency(ndn::nfd::FACE_PERSISTENCY_PERMANENT);
+  this->setLinkType(linkType);
+}
+
+void
+TopologyForwarderTransport::receiveFromTopology(const Block& packet)
+{
+  Packet p;
+  p.packet = packet;
+  this->receive(std::move(p));
+}
+
+void
+TopologyForwarderTransport::doSend(Packet&& packet)
+{
+  this->emitSignal(afterSend, packet.packet);
+}
+
+void
+TopologyClientTransport::receiveFromTopology(const Block& packet)
+{
+  if (m_receiveCallback) {
+    m_receiveCallback(packet);
+  }
+}
+
+void
+TopologyClientTransport::send(const Block& wire)
+{
+  this->emitSignal(afterSend, wire);
+}
+
+void
+TopologyClientTransport::send(const Block& header, const Block& payload)
+{
+  ndn::EncodingBuffer encoder(header.size() + payload.size(), header.size() + payload.size());
+  encoder.appendByteArray(header.wire(), header.size());
+  encoder.appendByteArray(payload.wire(), payload.size());
+
+  this->send(encoder.block());
+}
+
+TopologyLinkBase::TopologyLinkBase()
+  : m_isUp(true)
+{
+}
+
+void
+TopologyLinkBase::attachTransport(TopologyNode i, TopologyTransportBase* transport)
+{
+  BOOST_ASSERT(transport != nullptr);
+  BOOST_ASSERT(m_transports.count(i) == 0);
+
+  m_transports[i] = transport;
+  transport->afterSend.connect([this, i] (const Block& packet) { this->transmit(i, packet); });
+}
+
+void
+TopologyLinkBase::transmit(TopologyNode i, const Block& packet)
+{
+  if (!m_isUp) {
+    return;
+  }
+
+  for (auto&& p : m_transports) {
+    if (p.first == i) {
+      continue;
+    }
+
+    TopologyTransportBase* recipient = p.second;
+    this->scheduleReceive(recipient, packet);
+  }
+}
+
+TopologyLink::TopologyLink(const time::nanoseconds& delay)
+  : m_delay(delay)
+{
+  BOOST_ASSERT(delay > time::nanoseconds::zero());
+  // zero delay does not work on OSX
+}
+
+void
+TopologyLink::addFace(TopologyNode i, shared_ptr<LpFaceWrapper> face)
+{
+  this->attachTransport(i, dynamic_cast<TopologyTransportBase*>(face->getLpFace()->getTransport()));
+  m_faces[i] = face;
+}
+
+void
+TopologyLink::scheduleReceive(TopologyTransportBase* recipient, const Block& packet)
+{
+  scheduler::schedule(m_delay, [packet, recipient] {
+    recipient->receiveFromTopology(packet);
+  });
+}
+
+TopologyAppLink::TopologyAppLink(shared_ptr<LpFaceWrapper> face)
+  : m_face(face)
+{
+  this->attachTransport(0, dynamic_cast<TopologyTransportBase*>(face->getLpFace()->getTransport()));
+
+  auto clientTransport = make_shared<TopologyClientTransport>();
+  m_client = make_shared<ndn::Face>(clientTransport, getGlobalIoService());
+  this->attachTransport(1, clientTransport.get());
+}
+
+void
+TopologyAppLink::scheduleReceive(TopologyTransportBase* recipient, const Block& packet)
+{
+  getGlobalIoService().post([packet, recipient] {
+    recipient->receiveFromTopology(packet);
+  });
+}
+
+TopologyNode
+TopologyTester::addForwarder(const std::string& label)
+{
+  size_t i = m_forwarders.size();
+  m_forwarders.push_back(std::move(make_unique<Forwarder>()));
+  m_forwarderLabels.push_back(label);
+  BOOST_ASSERT(m_forwarders.size() == m_forwarderLabels.size());
+  return i;
+}
+
+shared_ptr<TopologyLink>
+TopologyTester::addLink(const std::string& label, const time::nanoseconds& delay,
+                        std::initializer_list<TopologyNode> forwarders,
+                        bool forceMultiAccessFace)
+{
+  auto link = make_shared<TopologyLink>(delay);
+  FaceUri remoteUri("topology://link/" + label);
+  ndn::nfd::LinkType linkType = (forceMultiAccessFace || forwarders.size() > 2) ?
+                                ndn::nfd::LINK_TYPE_MULTI_ACCESS :
+                                ndn::nfd::LINK_TYPE_POINT_TO_POINT;
+
+  for (TopologyNode i : forwarders) {
+    Forwarder& forwarder = this->getForwarder(i);
+    FaceUri localUri("topology://" + m_forwarderLabels.at(i) + "/" + label);
+
+    auto service = make_unique<face::GenericLinkService>();
+    auto transport = make_unique<TopologyForwarderTransport>(localUri, remoteUri,
+                     ndn::nfd::FACE_SCOPE_NON_LOCAL, linkType);
+    auto face = make_unique<LpFace>(std::move(service), std::move(transport));
+    auto faceW = make_shared<LpFaceWrapper>(std::move(face));
+
+    forwarder.addFace(faceW);
+    link->addFace(i, faceW);
+  }
+
+  m_links.push_back(link); // keep a shared_ptr so callers don't have to
+  return link;
+}
+
+shared_ptr<TopologyAppLink>
+TopologyTester::addAppFace(const std::string& label, TopologyNode i)
+{
+  Forwarder& forwarder = this->getForwarder(i);
+  FaceUri localUri("topology://" + m_forwarderLabels.at(i) + "/local/" + label);
+  FaceUri remoteUri("topology://" + m_forwarderLabels.at(i) + "/app/" + label);
+
+  auto service = make_unique<face::GenericLinkService>();
+  auto transport = make_unique<TopologyForwarderTransport>(localUri, remoteUri,
+                   ndn::nfd::FACE_SCOPE_LOCAL, ndn::nfd::LINK_TYPE_POINT_TO_POINT);
+  auto face = make_unique<LpFace>(std::move(service), std::move(transport));
+  auto faceW = make_shared<LpFaceWrapper>(std::move(face));
+
+  forwarder.addFace(faceW);
+
+  auto al = make_shared<TopologyAppLink>(faceW);
+  m_appLinks.push_back(al); // keep a shared_ptr so callers don't have to
+  return al;
+}
+
+shared_ptr<TopologyAppLink>
+TopologyTester::addAppFace(const std::string& label, TopologyNode i, const Name& prefix, uint64_t cost)
+{
+  shared_ptr<TopologyAppLink> al = this->addAppFace(label, i);
+  this->registerPrefix(i, al->getForwarderFace(), prefix, cost);
+  return al;
+}
+
+void
+TopologyTester::registerPrefix(TopologyNode i, const Face& face, const Name& prefix, uint64_t cost)
+{
+  Forwarder& forwarder = this->getForwarder(i);
+  Fib& fib = forwarder.getFib();
+  shared_ptr<fib::Entry> fibEntry = fib.insert(prefix).first;
+  fibEntry->addNextHop(const_cast<Face&>(face).shared_from_this(), cost);
+}
+
+void
+TopologyTester::addEchoProducer(ndn::Face& face, const Name& prefix)
+{
+  face.setInterestFilter(prefix,
+      [&face] (const ndn::InterestFilter&, const Interest& interest) {
+        shared_ptr<Data> data = makeData(interest.getName());
+        face.put(*data);
+      });
+}
+
+void
+TopologyTester::addIntervalConsumer(ndn::Face& face, const Name& prefix,
+                                    const time::nanoseconds& interval, size_t n)
+{
+  Name name(prefix);
+  name.appendTimestamp();
+  shared_ptr<Interest> interest = makeInterest(name);
+  face.expressInterest(*interest, bind([]{}));
+
+  if (n > 1) {
+    scheduler::schedule(interval, bind(&TopologyTester::addIntervalConsumer, this,
+                                       ref(face), prefix, interval, n - 1));
+  }
+}
+
+} // namespace tests
+} // namespace fw
+} // namespace nfd
diff --git a/tests/daemon/fw/topology-tester.hpp b/tests/daemon/fw/topology-tester.hpp
index 406c6b1..dd6d77d 100644
--- a/tests/daemon/fw/topology-tester.hpp
+++ b/tests/daemon/fw/topology-tester.hpp
@@ -30,19 +30,86 @@
 #ifndef NFD_TESTS_NFD_FW_TOPOLOGY_TESTER_HPP
 #define NFD_TESTS_NFD_FW_TOPOLOGY_TESTER_HPP
 
-#include <unordered_map>
-#include <ndn-cxx/util/dummy-client-face.hpp>
+#include <ndn-cxx/face.hpp>
+#include <ndn-cxx/transport/transport.hpp>
+#include "face/lp-face-wrapper.hpp"
 #include "fw/strategy.hpp"
 #include "tests/test-common.hpp"
-#include "../face/dummy-face.hpp"
 
 namespace nfd {
 namespace fw {
 namespace tests {
 
-using ndn::util::DummyClientFace;
 using namespace nfd::tests;
 
+/** \brief abstracts a Transport used in TopologyTester
+ */
+class TopologyTransportBase
+{
+public:
+  /** \brief causes the transport to receive a link-layer packet
+   */
+  virtual void
+  receiveFromTopology(const Block& packet) = 0;
+
+  signal::Signal<TopologyTransportBase, Block> afterSend;
+
+protected:
+  DECLARE_SIGNAL_EMIT(afterSend)
+};
+
+/** \brief implements a forwarder-side Transport used in TopologyTester
+ */
+class TopologyForwarderTransport : public face::Transport, public TopologyTransportBase
+{
+public:
+  TopologyForwarderTransport(const FaceUri& localUri, const FaceUri& remoteUri,
+                             ndn::nfd::FaceScope scope, ndn::nfd::LinkType linkType);
+
+  virtual void
+  receiveFromTopology(const Block& packet) DECL_OVERRIDE;
+
+protected:
+  virtual void
+  doClose() DECL_OVERRIDE
+  {
+  }
+
+private:
+  virtual void
+  doSend(Packet&& packet) DECL_OVERRIDE;
+};
+
+/** \brief implements a client-side Transport used in TopologyTester
+ */
+class TopologyClientTransport : public ndn::Transport, public TopologyTransportBase
+{
+public:
+  virtual void
+  receiveFromTopology(const Block& packet) DECL_OVERRIDE;
+
+  virtual void
+  close() DECL_OVERRIDE
+  {
+  }
+
+  virtual void
+  pause() DECL_OVERRIDE
+  {
+  }
+
+  virtual void
+  resume() DECL_OVERRIDE
+  {
+  }
+
+  virtual void
+  send(const Block& wire) DECL_OVERRIDE;
+
+  virtual void
+  send(const Block& header, const Block& payload) DECL_OVERRIDE;
+};
+
 /** \brief identifies a node (forwarder) in the topology
  */
 typedef size_t TopologyNode;
@@ -52,10 +119,7 @@
 class TopologyLinkBase : noncopyable
 {
 public:
-  TopologyLinkBase()
-    : m_isUp(true)
-  {
-  }
+  TopologyLinkBase();
 
   /** \brief fail the link, cause packets to be dropped silently
    */
@@ -74,7 +138,21 @@
   }
 
 protected:
+  /** \brief attach a Transport onto this link
+   */
+  void
+  attachTransport(TopologyNode i, TopologyTransportBase* transport);
+
+private:
+  void
+  transmit(TopologyNode i, const Block& packet);
+
+  virtual void
+  scheduleReceive(TopologyTransportBase* recipient, const Block& packet) = 0;
+
+protected:
   bool m_isUp;
+  std::unordered_map<TopologyNode, TopologyTransportBase*> m_transports;
 };
 
 /** \brief represents a network link in the topology which connects two or more nodes
@@ -82,90 +160,27 @@
 class TopologyLink : public TopologyLinkBase
 {
 public:
+  explicit
+  TopologyLink(const time::nanoseconds& delay);
+
+  void
+  addFace(TopologyNode i, shared_ptr<face::LpFaceWrapper> face);
+
   /** \return a face of forwarder \p i which is attached to this link
    */
-  shared_ptr<DummyFace>
+  Face&
   getFace(TopologyNode i)
   {
-    return m_faces.at(i)->face;
+    return *m_faces.at(i);
   }
 
 private:
-  explicit
-  TopologyLink(const time::nanoseconds& delay)
-    : m_delay(delay)
-  {
-    BOOST_ASSERT(delay >= time::nanoseconds::zero());
-  }
-
-  struct LinkFace
-  {
-    shared_ptr<DummyFace> face;
-  };
-
-  void
-  addFace(TopologyNode i, shared_ptr<DummyFace> face)
-  {
-    BOOST_ASSERT(m_faces.count(i) == 0);
-
-    LinkFace* lf = new LinkFace();
-    lf->face = face;
-    face->onSendInterest.connect(bind(&TopologyLink::transmitInterest, this, i, _1));
-    face->onSendData.connect(bind(&TopologyLink::transmitData, this, i, _1));
-
-    m_faces[i].reset(lf);
-  }
-
-  friend class TopologyTester;
-
-private:
-  void
-  transmitInterest(TopologyNode i, const Interest& interest)
-  {
-    if (!m_isUp) {
-      return;
-    }
-
-    // Interest object cannot be shared between faces because
-    // Forwarder can set different IncomingFaceId.
-    Block wire = interest.wireEncode();
-    for (auto&& p : m_faces) {
-      if (p.first == i) {
-        continue;
-      }
-      shared_ptr<DummyFace> face = p.second->face;
-      scheduler::schedule(m_delay, [wire, face] {
-        auto interest = make_shared<Interest>(wire);
-        face->receiveInterest(*interest);
-      });
-    }
-  }
-
-  void
-  transmitData(TopologyNode i, const Data& data)
-  {
-    if (!m_isUp) {
-      return;
-    }
-
-    // Data object cannot be shared between faces because
-    // Forwarder can set different IncomingFaceId.
-    Block wire = data.wireEncode();
-    for (auto&& p : m_faces) {
-      if (p.first == i) {
-        continue;
-      }
-      shared_ptr<DummyFace> face = p.second->face;
-      scheduler::schedule(m_delay, [wire, face] {
-        auto data = make_shared<Data>(wire);
-        face->receiveData(*data);
-      });
-    }
-  }
+  virtual void
+  scheduleReceive(TopologyTransportBase* recipient, const Block& packet) DECL_OVERRIDE;
 
 private:
   time::nanoseconds m_delay;
-  std::unordered_map<TopologyNode, unique_ptr<LinkFace>> m_faces;
+  std::unordered_map<TopologyNode, shared_ptr<face::LpFaceWrapper>> m_faces;
 };
 
 /** \brief represents a link to a local application
@@ -173,66 +188,32 @@
 class TopologyAppLink : public TopologyLinkBase
 {
 public:
+  explicit
+  TopologyAppLink(shared_ptr<face::LpFaceWrapper> face);
+
   /** \return face on forwarder side
    */
-  shared_ptr<DummyLocalFace>
+  Face&
   getForwarderFace()
   {
-    return m_face;
+    return *m_face;
   }
 
   /** \return face on application side
    */
-  shared_ptr<DummyClientFace>
+  ndn::Face&
   getClientFace()
   {
-    return m_client;
+    return *m_client;
   }
 
 private:
-  explicit
-  TopologyAppLink(shared_ptr<DummyLocalFace> face)
-    : m_face(face)
-    , m_client(ndn::util::makeDummyClientFace(getGlobalIoService(), {false, false}))
-  {
-    m_client->onSendInterest.connect([this] (const Interest& interest) {
-      if (!m_isUp) {
-        return;
-      }
-      auto interest2 = interest.shared_from_this();
-      getGlobalIoService().post([=] { m_face->receiveInterest(*interest2); });
-    });
-
-    m_client->onSendData.connect([this] (const Data& data) {
-      if (!m_isUp) {
-        return;
-      }
-      auto data2 = data.shared_from_this();
-      getGlobalIoService().post([=] { m_face->receiveData(*data2); });
-    });
-
-    m_face->onSendInterest.connect([this] (const Interest& interest) {
-      if (!m_isUp) {
-        return;
-      }
-      auto interest2 = interest.shared_from_this();
-      getGlobalIoService().post([=] { m_client->receive(*interest2); });
-    });
-
-    m_face->onSendData.connect([this] (const Data& data) {
-      if (!m_isUp) {
-        return;
-      }
-      auto data2 = data.shared_from_this();
-      getGlobalIoService().post([=] { m_client->receive(*data2); });
-    });
-  }
-
-  friend class TopologyTester;
+  virtual void
+  scheduleReceive(TopologyTransportBase* recipient, const Block& packet) DECL_OVERRIDE;
 
 private:
-  shared_ptr<DummyLocalFace> m_face;
-  shared_ptr<DummyClientFace> m_client;
+  shared_ptr<face::LpFaceWrapper> m_face;
+  shared_ptr<ndn::Face> m_client;
 };
 
 /** \brief builds a topology for forwarding tests
@@ -244,12 +225,7 @@
    *  \return index of new forwarder
    */
   TopologyNode
-  addForwarder()
-  {
-    size_t i = m_forwarders.size();
-    m_forwarders.push_back(make_unique<Forwarder>());
-    return i;
-  }
+  addForwarder(const std::string& label);
 
   /** \return forwarder instance \p i
    */
@@ -281,85 +257,42 @@
    *  this packet will be received by all other faces on this link after \p delay .
    */
   shared_ptr<TopologyLink>
-  addLink(const time::nanoseconds& delay, std::initializer_list<TopologyNode> forwarders)
-  {
-    auto link = shared_ptr<TopologyLink>(new TopologyLink(delay));
-    for (TopologyNode i : forwarders) {
-      Forwarder& forwarder = this->getForwarder(i);
-      shared_ptr<DummyFace> face = make_shared<DummyFace>();
-      forwarder.addFace(face);
-      link->addFace(i, face);
-    }
-    return link;
-  }
+  addLink(const std::string& label, const time::nanoseconds& delay,
+          std::initializer_list<TopologyNode> forwarders,
+          bool forceMultiAccessFace = false);
 
   /** \brief makes a link to local application
    */
   shared_ptr<TopologyAppLink>
-  addAppFace(TopologyNode i)
-  {
-    Forwarder& forwarder = this->getForwarder(i);
-    auto face = make_shared<DummyLocalFace>();
-    forwarder.addFace(face);
-
-    return shared_ptr<TopologyAppLink>(new TopologyAppLink(face));
-  }
+  addAppFace(const std::string& label, TopologyNode i);
 
   /** \brief makes a link to local application, and register a prefix
    */
   shared_ptr<TopologyAppLink>
-  addAppFace(TopologyNode i, const Name& prefix, uint64_t cost = 0)
-  {
-    shared_ptr<TopologyAppLink> al = this->addAppFace(i);
-    this->registerPrefix(i, al->getForwarderFace(), prefix, cost);
-    return al;
-  }
+  addAppFace(const std::string& label, TopologyNode i, const Name& prefix, uint64_t cost = 0);
 
-  /** \brief registers a prefix on a face
-   *  \tparam F either DummyFace or DummyLocalFace
+  /** \brief registers a prefix on a forwarder face
    */
-  template<typename F>
   void
-  registerPrefix(TopologyNode i, shared_ptr<F> face, const Name& prefix, uint64_t cost = 0)
-  {
-    Forwarder& forwarder = this->getForwarder(i);
-    Fib& fib = forwarder.getFib();
-    shared_ptr<fib::Entry> fibEntry = fib.insert(prefix).first;
-    fibEntry->addNextHop(face, cost);
-  }
+  registerPrefix(TopologyNode i, const Face& face, const Name& prefix, uint64_t cost = 0);
 
   /** \brief creates a producer application that answers every Interest with Data of same Name
    */
   void
-  addEchoProducer(DummyClientFace& face, const Name& prefix = "/")
-  {
-    face.setInterestFilter(prefix,
-        [&face] (const ndn::InterestFilter&, const Interest& interest) {
-          shared_ptr<Data> data = makeData(interest.getName());
-          face.put(*data);
-        });
-  }
+  addEchoProducer(ndn::Face& face, const Name& prefix = "/");
 
   /** \brief creates a consumer application that sends \p n Interests under \p prefix
    *         at \p interval fixed rate.
    */
   void
-  addIntervalConsumer(DummyClientFace& face, const Name& prefix,
-                      const time::nanoseconds& interval, size_t n)
-  {
-    Name name(prefix);
-    name.appendTimestamp();
-    shared_ptr<Interest> interest = makeInterest(name);
-    face.expressInterest(*interest, bind([]{}));
-
-    if (n > 1) {
-      scheduler::schedule(interval, bind(&TopologyTester::addIntervalConsumer, this,
-                                         ref(face), prefix, interval, n - 1));
-    }
-  }
+  addIntervalConsumer(ndn::Face& face, const Name& prefix,
+                      const time::nanoseconds& interval, size_t n);
 
 private:
   std::vector<unique_ptr<Forwarder>> m_forwarders;
+  std::vector<std::string> m_forwarderLabels;
+  std::vector<shared_ptr<TopologyLink>> m_links;
+  std::vector<shared_ptr<TopologyAppLink>> m_appLinks;
 };
 
 } // namespace tests
