diff --git a/tests/daemon/fw/topology-tester.cpp b/tests/daemon/fw/topology-tester.cpp
index ad68447..fef3080 100644
--- a/tests/daemon/fw/topology-tester.cpp
+++ b/tests/daemon/fw/topology-tester.cpp
@@ -36,36 +36,43 @@
 using face::InternalClientTransport;
 using face::GenericLinkService;
 
-TopologyLink::TopologyLink(const time::nanoseconds& delay)
+TopologyLink::TopologyLink(time::nanoseconds delay)
   : m_isUp(true)
 {
   this->setDelay(delay);
 }
 
 void
-TopologyLink::setDelay(const time::nanoseconds& delay)
+TopologyLink::block(TopologyNode i, TopologyNode j)
 {
-  BOOST_ASSERT(delay > time::nanoseconds::zero());
-  // zero delay does not work on OSX
+  m_transports.at(i).blockedDestinations.insert(j);
+}
 
+void
+TopologyLink::unblock(TopologyNode i, TopologyNode j)
+{
+  m_transports.at(i).blockedDestinations.erase(j);
+}
+
+void
+TopologyLink::setDelay(time::nanoseconds delay)
+{
+  BOOST_ASSERT(delay > time::nanoseconds::zero()); // zero delay does not work on macOS
   m_delay = delay;
 }
 
 void
 TopologyLink::addFace(TopologyNode i, shared_ptr<Face> face)
 {
-  this->attachTransport(i, dynamic_cast<InternalTransportBase*>(face->getTransport()));
-  m_faces[i] = face;
-}
-
-void
-TopologyLink::attachTransport(TopologyNode i, InternalTransportBase* transport)
-{
-  BOOST_ASSERT(transport != nullptr);
   BOOST_ASSERT(m_transports.count(i) == 0);
+  auto& nodeTransport = m_transports[i];
 
-  m_transports[i] = transport;
-  transport->afterSend.connect([this, i] (const Block& packet) { this->transmit(i, packet); });
+  nodeTransport.face = face;
+
+  nodeTransport.transport = dynamic_cast<InternalTransportBase*>(face->getTransport());
+  BOOST_ASSERT(nodeTransport.transport != nullptr);
+  nodeTransport.transport->afterSend.connect(
+    [this, i] (const Block& packet) { this->transmit(i, packet); });
 }
 
 void
@@ -75,12 +82,14 @@
     return;
   }
 
+  const auto& blockedDestinations = m_transports.at(i).blockedDestinations;
+
   for (const auto& p : m_transports) {
-    if (p.first == i) {
+    if (p.first == i || blockedDestinations.count(p.first) > 0) {
       continue;
     }
 
-    InternalTransportBase* recipient = p.second;
+    InternalTransportBase* recipient = p.second.transport;
     this->scheduleReceive(recipient, packet);
   }
 }
@@ -156,15 +165,17 @@
 }
 
 shared_ptr<TopologyLink>
-TopologyTester::addLink(const std::string& label, const time::nanoseconds& delay,
+TopologyTester::addLink(const std::string& label, time::nanoseconds delay,
                         std::initializer_list<TopologyNode> forwarders,
-                        bool forceMultiAccessFace)
+                        ndn::nfd::LinkType linkType)
 {
   auto link = std::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;
+  if (linkType == ndn::nfd::LINK_TYPE_NONE) {
+    linkType = forwarders.size() > 2 ? ndn::nfd::LINK_TYPE_MULTI_ACCESS :
+                                       ndn::nfd::LINK_TYPE_POINT_TO_POINT;
+  }
+  BOOST_ASSERT(forwarders.size() <= 2 || linkType != ndn::nfd::LINK_TYPE_POINT_TO_POINT);
 
   for (TopologyNode i : forwarders) {
     Forwarder& forwarder = this->getForwarder(i);
@@ -244,16 +255,23 @@
 
 void
 TopologyTester::addIntervalConsumer(ndn::Face& face, const Name& prefix,
-                                    const time::nanoseconds& interval, size_t n)
+                                    time::nanoseconds interval, size_t n, int seq)
 {
   Name name(prefix);
-  name.appendTimestamp();
+  if (seq >= 0) {
+    name.appendSequenceNumber(seq);
+    ++seq;
+  }
+  else {
+    name.appendTimestamp();
+  }
+
   shared_ptr<Interest> interest = makeInterest(name);
   face.expressInterest(*interest, nullptr, nullptr, nullptr);
 
   if (n > 1) {
     scheduler::schedule(interval, bind(&TopologyTester::addIntervalConsumer, this,
-                                       ref(face), prefix, interval, n - 1));
+                                       ref(face), prefix, interval, n - 1, seq));
   }
 }
 
