diff --git a/src/common.hpp b/src/common.hpp
index 3337520..cd6dc18 100644
--- a/src/common.hpp
+++ b/src/common.hpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
 /**
- * Copyright (c) 2014-2017,  The University of Memphis,
+ * Copyright (c) 2014-2018,  The University of Memphis,
  *                           Regents of the University of California
  *
  * This file is part of NLSR (Named-data Link State Routing).
@@ -27,7 +27,6 @@
 #ifndef NLSR_COMMON_HPP
 #define NLSR_COMMON_HPP
 
-#include <ndn-cxx/common.hpp>
 #include <ndn-cxx/util/time.hpp>
 #include <ndn-cxx/name.hpp>
 
diff --git a/src/lsa-segment-storage.cpp b/src/lsa-segment-storage.cpp
index dfe92d7..830906d 100644
--- a/src/lsa-segment-storage.cpp
+++ b/src/lsa-segment-storage.cpp
@@ -97,21 +97,8 @@
       NLSR_LOG_TRACE("The received segment is already in the storage.");
     }
 
-    std::string content(reinterpret_cast<const char*>(lsaSegment.getContent().value()),
-                        lsaSegment.getContent().value_size());
-
     ndn::time::seconds expirationTime(LSA_REFRESH_TIME_DEFAULT);
 
-    std::vector<std::string> options;
-    boost::split(options, content, boost::is_any_of("|"));
-
-    try {
-      expirationTime = ndn::time::duration_cast<ndn::time::seconds>
-                       (ndn::time::fromIsoString(options.at(3)) - ndn::time::system_clock::now());
-    } catch (const std::exception& e) {
-      NLSR_LOG_ERROR("Cannot extract expiration time from LSA content: " << e.what());
-    }
-
     // schedule the segment deletion
     scheduleLsaSegmentDeletion(lsaSegmentsKey, expirationTime);
   }
diff --git a/src/lsdb.cpp b/src/lsdb.cpp
index b8cda8e..1507a08 100644
--- a/src/lsdb.cpp
+++ b/src/lsdb.cpp
@@ -24,7 +24,6 @@
 #include "logger.hpp"
 #include "lsa-segment-storage.hpp"
 #include "nlsr.hpp"
-#include "publisher/segment-publisher.hpp"
 #include "utility/name-helper.hpp"
 
 #include <ndn-cxx/security/signing-helpers.hpp>
@@ -33,31 +32,6 @@
 
 INIT_LOGGER(Lsdb);
 
-class LsaContentPublisher : public SegmentPublisher<ndn::Face>
-{
-public:
-  LsaContentPublisher(ndn::Face& face,
-                      ndn::KeyChain& keyChain,
-                      const ndn::security::SigningInfo& signingInfo,
-                      const ndn::time::milliseconds& freshnessPeriod,
-                      const std::string& content)
-    : SegmentPublisher(face, keyChain, signingInfo, freshnessPeriod)
-    , m_content(content)
-  {
-  }
-
-  virtual size_t
-  generate(ndn::EncodingBuffer& outBuffer) {
-    size_t totalLength = 0;
-    totalLength += outBuffer.prependByteArray(reinterpret_cast<const uint8_t*>(m_content.c_str()),
-                                              m_content.size());
-    return totalLength;
-  }
-
-private:
-  const std::string m_content;
-};
-
 const ndn::Name::Component Lsdb::NAME_COMPONENT = ndn::Name::Component("lsdb");
 const ndn::time::seconds Lsdb::GRACE_PERIOD = ndn::time::seconds(10);
 const ndn::time::steady_clock::TimePoint Lsdb::DEFAULT_LSA_RETRIEVAL_DEADLINE =
@@ -76,11 +50,12 @@
   , m_adjLsaBuildInterval(ADJ_LSA_BUILD_INTERVAL_DEFAULT)
   , m_sequencingManager()
   , m_onNewLsaConnection(m_sync.onNewLsa->connect(
-      [this] (const ndn::Name& updateName, const uint64_t& sequenceNumber) {
+      [this] (const ndn::Name& updateName, uint64_t sequenceNumber) {
         ndn::Name lsaInterest{updateName};
         lsaInterest.appendNumber(sequenceNumber);
         expressInterest(lsaInterest, 0);
       }))
+  , m_segmentPublisher(m_nlsr.getNlsrFace(), m_nlsr.getKeyChain())
 {
 }
 
@@ -127,7 +102,7 @@
 Lsdb::afterFetchLsa(const ndn::ConstBufferPtr& bufferPtr, const ndn::Name& interestName)
 {
   std::shared_ptr<ndn::Data> data = std::make_shared<ndn::Data>(ndn::Name(interestName));
-  data->setContent(bufferPtr);
+  data->setContent(ndn::Block(bufferPtr));
 
   NLSR_LOG_DEBUG("Received data for LSA(name): " << data->getName());
 
@@ -1050,48 +1025,53 @@
 void
 Lsdb::processInterest(const ndn::Name& name, const ndn::Interest& interest)
 {
+  ndn::Name interestName(interest.getName());
+  NLSR_LOG_DEBUG("Interest received for LSA: " << interestName);
+
+  if (interestName[-2].isVersion()) {
+    // Interest for particular segment
+    if (m_segmentPublisher.replyFromStore(interestName)) {
+      NLSR_LOG_TRACE("Reply from SegmentPublisher storage");
+      return;
+    }
+    // Remove version and segment
+    interestName = interestName.getSubName(0, interestName.size() - 2);
+    NLSR_LOG_TRACE("Interest w/o segment and version: " << interestName);
+  }
+
   // increment RCV_LSA_INTEREST
   lsaIncrementSignal(Statistics::PacketType::RCV_LSA_INTEREST);
 
-  const ndn::Name& interestName(interest.getName());
-  NLSR_LOG_DEBUG("Interest received for LSA: " << interestName);
-
   std::string chkString("LSA");
-  int32_t lsaPosition = util::getNameComponentPosition(interest.getName(), chkString);
+  int32_t lsaPosition = util::getNameComponentPosition(interestName, chkString);
 
   // Forms the name of the router that the Interest packet came from.
   ndn::Name originRouter = m_nlsr.getConfParameter().getNetwork();
   originRouter.append(interestName.getSubName(lsaPosition + 1,
-                                              interest.getName().size() - lsaPosition - 3));
+                                              interestName.size() - lsaPosition - 3));
 
   // if the interest is for this router's LSA
-  if (originRouter == m_nlsr.getConfParameter().getRouterPrefix()) {
+  if (originRouter == m_nlsr.getConfParameter().getRouterPrefix() && lsaPosition >= 0) {
+    uint64_t seqNo = interestName[-1].toNumber();
+    NLSR_LOG_DEBUG("LSA sequence number from interest: " << seqNo);
 
-    if (lsaPosition >= 0) {
+    std::string lsaType = interestName[-2].toUri();
+    Lsa::Type interestedLsType;
+    std::istringstream(lsaType) >> interestedLsType;
 
-      uint64_t seqNo = interestName[-1].toNumber();
-      NLSR_LOG_DEBUG("LSA sequence number from interest: " << seqNo);
-
-      Lsa::Type interestedLsType;
-      std::istringstream(interestName[-2].toUri()) >> interestedLsType;
-
-      if (interestedLsType == Lsa::Type::NAME) {
-        processInterestForNameLsa(interest, originRouter.append(std::to_string(interestedLsType)),
-                                  seqNo);
-      }
-      else if (interestedLsType == Lsa::Type::ADJACENCY) {
-        processInterestForAdjacencyLsa(interest, originRouter.append(std::to_string(interestedLsType)),
-                                       seqNo);
-      }
-      else if (interestedLsType == Lsa::Type::COORDINATE) {
-        processInterestForCoordinateLsa(interest, originRouter.append(std::to_string(interestedLsType)),
-                                        seqNo);
-      }
-      else {
-        NLSR_LOG_WARN("Received unrecognized LSA type: " << interestedLsType);
-      }
-      lsaIncrementSignal(Statistics::PacketType::SENT_LSA_DATA);
+    if (interestedLsType == Lsa::Type::NAME) {
+      processInterestForNameLsa(interest, originRouter.append(lsaType), seqNo);
     }
+    else if (interestedLsType == Lsa::Type::ADJACENCY) {
+      processInterestForAdjacencyLsa(interest, originRouter.append(lsaType), seqNo);
+    }
+    else if (interestedLsType == Lsa::Type::COORDINATE) {
+      processInterestForCoordinateLsa(interest, originRouter.append(lsaType), seqNo);
+    }
+    else {
+      NLSR_LOG_WARN("Received unrecognized LSA type: " << interestedLsType);
+    }
+    lsaIncrementSignal(Statistics::PacketType::SENT_LSA_DATA);
   }
   else { // else the interest is for other router's lsa, serve from LsaSegmentStorage
     const ndn::Data* lsaSegment = m_lsaStorage.getLsaSegment(interest);
@@ -1100,27 +1080,11 @@
       m_nlsr.getNlsrFace().put(*lsaSegment);
     }
     else {
-      NLSR_LOG_TRACE(interest << "  was not found in this lsa storage.");
+      NLSR_LOG_TRACE(interest << " was not found in this lsa storage.");
     }
   }
 }
 
-  // \brief Sends LSA data.
-  // \param interest The Interest that warranted the data.
-  // \param content The data that the Interest was seeking.
-void
-Lsdb::putLsaData(const ndn::Interest& interest, const std::string& content)
-{
-  LsaContentPublisher publisher(m_nlsr.getNlsrFace(),
-                                m_nlsr.getKeyChain(),
-                                m_nlsr.getSigningInfo(),
-                                m_lsaRefreshTime,
-                                content);
-  NLSR_LOG_DEBUG("Sending requested data ( " << content << ")  for interest (" << interest
-             << ") to be published and added to face.");
-  publisher.publish(interest.getName());
-}
-
   // \brief Finds and sends a requested name LSA.
   // \param interest The interest that seeks the name LSA.
   // \param lsaKey The LSA that the Interest is seeking.
@@ -1134,17 +1098,15 @@
   // increment RCV_NAME_LSA_INTEREST
   lsaIncrementSignal(Statistics::PacketType::RCV_NAME_LSA_INTEREST);
   NLSR_LOG_DEBUG("nameLsa interest " << interest << " received");
-  NameLsa*  nameLsa = m_nlsr.getLsdb().findNameLsa(lsaKey);
+  NameLsa* nameLsa = m_nlsr.getLsdb().findNameLsa(lsaKey);
   if (nameLsa != nullptr) {
     NLSR_LOG_TRACE("Verifying SeqNo for NameLsa is same as requested.");
     if (nameLsa->getLsSeqNo() == seqNo) {
-      // if requested lsa belongs to this router then sign it and serve it
       std::string content = nameLsa->serialize();
-      putLsaData(interest,content);
-      // else the requested belongs to neighboring routers, so serve the
-      // original data packet corresponding to the lsa
+      m_segmentPublisher.publish(interest.getName(), interest.getName(),
+                                 ndn::encoding::makeStringBlock(ndn::tlv::Content, content),
+                                 m_lsaRefreshTime, m_nlsr.getSigningInfo());
 
-      // increment SENT_NAME_LSA_DATA
       lsaIncrementSignal(Statistics::PacketType::SENT_NAME_LSA_DATA);
     }
     else {
@@ -1170,7 +1132,6 @@
     NLSR_LOG_ERROR("Received interest for an adjacency LSA when hyperbolic routing is enabled");
   }
 
-  // increment RCV_ADJ_LSA_INTEREST
   lsaIncrementSignal(Statistics::PacketType::RCV_ADJ_LSA_INTEREST);
   NLSR_LOG_DEBUG("AdjLsa interest " << interest << " received");
   AdjLsa* adjLsa = m_nlsr.getLsdb().findAdjLsa(lsaKey);
@@ -1178,8 +1139,10 @@
     NLSR_LOG_TRACE("Verifying SeqNo for AdjLsa is same as requested.");
     if (adjLsa->getLsSeqNo() == seqNo) {
       std::string content = adjLsa->serialize();
-      putLsaData(interest,content);
-      // increment SENT_ADJ_LSA_DATA
+      m_segmentPublisher.publish(interest.getName(), interest.getName(),
+                                 ndn::encoding::makeStringBlock(ndn::tlv::Content, content),
+                                 m_lsaRefreshTime, m_nlsr.getSigningInfo());
+
       lsaIncrementSignal(Statistics::PacketType::SENT_ADJ_LSA_DATA);
     }
     else {
@@ -1205,7 +1168,6 @@
     NLSR_LOG_ERROR("Received Interest for a coordinate LSA when link-state routing is enabled");
   }
 
-  // increment RCV_COORD_LSA_INTEREST
   lsaIncrementSignal(Statistics::PacketType::RCV_COORD_LSA_INTEREST);
   NLSR_LOG_DEBUG("CoordinateLsa interest " << interest << " received");
   CoordinateLsa* corLsa = m_nlsr.getLsdb().findCoordinateLsa(lsaKey);
@@ -1213,8 +1175,10 @@
     NLSR_LOG_TRACE("Verifying SeqNo for CoordinateLsa is same as requested.");
     if (corLsa->getLsSeqNo() == seqNo) {
       std::string content = corLsa->serialize();
-      putLsaData(interest,content);
-      // increment SENT_COORD_LSA_DATA
+      m_segmentPublisher.publish(interest.getName(), interest.getName(),
+                                 ndn::encoding::makeStringBlock(ndn::tlv::Content, content),
+                                 m_lsaRefreshTime, m_nlsr.getSigningInfo());
+
       lsaIncrementSignal(Statistics::PacketType::SENT_COORD_LSA_DATA);
     }
     else {
@@ -1264,7 +1228,6 @@
       NLSR_LOG_WARN("Received unrecognized LSA Type: " << interestedLsType);
     }
 
-    // increment RCV_LSA_DATA
     lsaIncrementSignal(Statistics::PacketType::RCV_LSA_DATA);
   }
 }
@@ -1273,7 +1236,6 @@
 Lsdb::processContentNameLsa(const ndn::Name& lsaKey,
                             uint64_t lsSeqNo, std::string& dataContent)
 {
-  // increment RCV_NAME_LSA_DATA
   lsaIncrementSignal(Statistics::PacketType::RCV_NAME_LSA_DATA);
   if (isNameLsaNew(lsaKey, lsSeqNo)) {
     NameLsa nameLsa;
@@ -1290,7 +1252,6 @@
 Lsdb::processContentAdjacencyLsa(const ndn::Name& lsaKey,
                                  uint64_t lsSeqNo, std::string& dataContent)
 {
-  // increment RCV_ADJ_LSA_DATA
   lsaIncrementSignal(Statistics::PacketType::RCV_ADJ_LSA_DATA);
   if (isAdjLsaNew(lsaKey, lsSeqNo)) {
     AdjLsa adjLsa;
@@ -1307,7 +1268,6 @@
 Lsdb::processContentCoordinateLsa(const ndn::Name& lsaKey,
                                   uint64_t lsSeqNo, std::string& dataContent)
 {
-  // increment RCV_COORD_LSA_DATA
   lsaIncrementSignal(Statistics::PacketType::RCV_COORD_LSA_DATA);
   if (isCoordinateLsaNew(lsaKey, lsSeqNo)) {
     CoordinateLsa corLsa;
diff --git a/src/lsdb.hpp b/src/lsdb.hpp
index 2ebb952..183f3dc 100644
--- a/src/lsdb.hpp
+++ b/src/lsdb.hpp
@@ -35,6 +35,8 @@
 #include <ndn-cxx/util/time.hpp>
 #include <ndn-cxx/util/segment-fetcher.hpp>
 
+#include <PSync/segment-publisher.hpp>
+
 #include <utility>
 #include <boost/cstdint.hpp>
 
@@ -219,6 +221,12 @@
   expressInterest(const ndn::Name& interestName, uint32_t timeoutCount,
                   ndn::time::steady_clock::TimePoint deadline = DEFAULT_LSA_RETRIEVAL_DEADLINE);
 
+  /* \brief Process interest which can be either:
+   * 1) Discovery interest from segment fetcher:
+   *    /localhop/<network>/nlsr/LSA/<site>/<router>/<lsaType>/<seqNo>
+   * 2) Interest containing segment number:
+   *    /localhop/<network>/nlsr/LSA/<site>/<router>/<lsaType>/<seqNo>/<version>/<segmentNo>
+  */
   void
   processInterest(const ndn::Name& name, const ndn::Interest& interest);
 
@@ -311,9 +319,6 @@
 private:
 
   void
-  putLsaData(const ndn::Interest& interest, const std::string& content);
-
-  void
   processInterestForNameLsa(const ndn::Interest& interest,
                             const ndn::Name& lsaKey,
                             uint64_t seqNo);
@@ -417,6 +422,7 @@
   ndn::util::signal::ScopedConnection m_onNewLsaConnection;
 
   std::set<std::shared_ptr<ndn::util::SegmentFetcher>> m_fetchers;
+  psync::SegmentPublisher m_segmentPublisher;
 };
 
 } // namespace nlsr
diff --git a/src/publisher/segment-publisher.hpp b/src/publisher/segment-publisher.hpp
deleted file mode 100644
index d80c90e..0000000
--- a/src/publisher/segment-publisher.hpp
+++ /dev/null
@@ -1,141 +0,0 @@
-/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/**
- * Copyright (c) 2014-2018,  Regents of the University of California,
- *                           Arizona Board of Regents,
- *                           Colorado State University,
- *                           University Pierre & Marie Curie, Sorbonne University,
- *                           Washington University in St. Louis,
- *                           Beijing Institute of Technology,
- *                           The University of Memphis.
- *
- * This file is part of NFD (Named Data Networking Forwarding Daemon).
- * See AUTHORS.md for complete list of NFD authors and contributors.
- *
- * NFD is free software: you can redistribute it and/or modify it under the terms
- * of the GNU General Public License as published by the Free Software Foundation,
- * either version 3 of the License, or (at your option) any later version.
- *
- * NFD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
- * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
- * PURPOSE.  See the GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along with
- * NFD, e.g., in COPYING.md file.  If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef NLSR_PUBLISHER_SEGMENT_PUBLISHER_HPP
-#define NLSR_PUBLISHER_SEGMENT_PUBLISHER_HPP
-
-#include <ndn-cxx/encoding/encoding-buffer.hpp>
-#include <ndn-cxx/security/key-chain.hpp>
-
-namespace nlsr {
-
-/*! \brief provides a publisher of Status Dataset or other segmented octet stream
-    \sa https://redmine.named-data.net/projects/nfd/wiki/StatusDataset
- */
-template <class FaceBase>
-class SegmentPublisher : boost::noncopyable
-{
-public:
-  SegmentPublisher(FaceBase& face,
-                   ndn::KeyChain& keyChain,
-                   const ndn::security::SigningInfo& signingInfo,
-                   const ndn::time::milliseconds& freshnessPeriod = getDefaultFreshness())
-    : m_face(face)
-    , m_keyChain(keyChain)
-    , m_signingInfo(signingInfo)
-    , m_freshnessPeriod(freshnessPeriod)
-  {
-  }
-
-  virtual
-  ~SegmentPublisher()
-  {
-  }
-
-  /*! \brief Define the max segment size as half the max NDN packet size.
-   */
-  static size_t
-  getMaxSegmentSize()
-  {
-    static const size_t MAX_SEGMENT_SIZE = ndn::MAX_NDN_PACKET_SIZE >> 1;
-    return MAX_SEGMENT_SIZE;
-  }
-
-  static constexpr ndn::time::milliseconds
-  getDefaultFreshness()
-  {
-    return ndn::time::milliseconds(1000);
-  }
-
-  /*! \brief Publish data under the provided prefix
-   *
-   * Processes whatever is provided from SegmentPublisher::generate,
-   * by breaking it into segments of MAX_SEGMENT_SIZE and sending each
-   * one individually. The last segment is distinguished by having the
-   * final block ID set to a timestamp.
-   */
-  void
-  publish(const ndn::Name& prefix)
-  {
-    ndn::EncodingBuffer buffer;
-    generate(buffer);
-
-    const uint8_t* rawBuffer = buffer.buf();
-    const uint8_t* segmentBegin = rawBuffer;
-    const uint8_t* end = rawBuffer + buffer.size();
-
-    ndn::Name segmentPrefix(prefix);
-    segmentPrefix.appendVersion();
-
-    uint64_t segmentNo = 0;
-    do {
-      const uint8_t* segmentEnd = segmentBegin + getMaxSegmentSize();
-      if (segmentEnd > end) {
-        segmentEnd = end;
-      }
-
-      ndn::Name segmentName(segmentPrefix);
-      segmentName.appendSegment(segmentNo);
-
-      std::shared_ptr<ndn::Data> data = std::make_shared<ndn::Data>(segmentName);
-      data->setContent(segmentBegin, segmentEnd - segmentBegin);
-      data->setFreshnessPeriod(m_freshnessPeriod);
-
-      segmentBegin = segmentEnd;
-      if (segmentBegin >= end) {
-        data->setFinalBlock(segmentName[-1]);
-      }
-
-      publishSegment(data);
-      ++segmentNo;
-    } while (segmentBegin < end);
-  }
-
-protected:
-  /*! \brief In a derived class, write the octets into outBuffer.
-   */
-  virtual size_t
-  generate(ndn::EncodingBuffer& outBuffer) = 0;
-
-private:
-  /*! \brief Helper function to sign and put data on a Face.
-   */
-  void
-  publishSegment(std::shared_ptr<ndn::Data>& data)
-  {
-    m_keyChain.sign(*data, m_signingInfo);
-    m_face.put(*data);
-  }
-
-private:
-  FaceBase& m_face;
-  ndn::KeyChain& m_keyChain;
-  const ndn::security::SigningInfo& m_signingInfo;
-  const ndn::time::milliseconds m_freshnessPeriod;
-};
-
-} // namespace nlsr
-
-#endif // NLSR_PUBLISHER_SEGMENT_PUBLISHER_HPP
diff --git a/tests/publisher/test-segment-publisher.cpp b/tests/publisher/test-segment-publisher.cpp
deleted file mode 100644
index a70e57f..0000000
--- a/tests/publisher/test-segment-publisher.cpp
+++ /dev/null
@@ -1,173 +0,0 @@
-/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/**
- * Copyright (c) 2014-2018,  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 "publisher/segment-publisher.hpp"
-
-#include "../boost-test.hpp"
-#include "../test-common.hpp"
-
-#include <ndn-cxx/encoding/tlv.hpp>
-#include <ndn-cxx/util/dummy-client-face.hpp>
-
-#include <boost/mpl/int.hpp>
-#include <boost/mpl/vector.hpp>
-
-namespace nlsr {
-namespace tests {
-
-using namespace nlsr::test;
-
-template<int64_t N=10000>
-class TestSegmentPublisher : public SegmentPublisher<ndn::util::DummyClientFace>
-{
-public:
-  TestSegmentPublisher(ndn::util::DummyClientFace& face,
-                       ndn::KeyChain& keyChain,
-                       ndn::security::SigningInfo& signingInfo,
-                       const ndn::time::milliseconds freshnessPeriod)
-    : SegmentPublisher(face, keyChain, signingInfo, freshnessPeriod)
-    , m_totalPayloadLength(0)
-  {
-
-  }
-
-  virtual
-  ~TestSegmentPublisher()
-  {
-  }
-
-  uint16_t
-  getLimit() const
-  {
-    return N;
-  }
-
-  size_t
-  getTotalPayloadLength() const
-  {
-    return m_totalPayloadLength;
-  }
-
-protected:
-
-  virtual size_t
-  generate(ndn::EncodingBuffer& outBuffer)
-  {
-    size_t totalLength = 0;
-    for (int64_t i = 0; i < N; i++) {
-        totalLength += prependNonNegativeIntegerBlock(outBuffer, ndn::tlv::Content, i);
-    }
-
-    m_totalPayloadLength += totalLength;
-    return totalLength;
-  }
-
-protected:
-  size_t m_totalPayloadLength;
-};
-
-template<int64_t N>
-class SegmentPublisherFixture : public BaseFixture
-{
-public:
-  SegmentPublisherFixture()
-    : m_face(std::make_shared<ndn::util::DummyClientFace>(m_ioService, m_keyChain))
-    , m_expectedFreshnessPeriod(ndn::time::milliseconds(111))
-    , m_publisher(*m_face, m_keyChain, m_signingInfo, m_expectedFreshnessPeriod)
-    , m_publishingPrefix("/localhost/nfd/SegmentPublisherFixture")
-  {
-  }
-
-  void
-  validate(const ndn::Data& data)
-  {
-    BOOST_CHECK_EQUAL(data.getFreshnessPeriod(), m_expectedFreshnessPeriod);
-
-    ndn::Block payload = data.getContent();
-
-    m_buffer.appendByteArray(payload.value(), payload.value_size());
-
-    // uint64_t segmentNo = data.getName()[-1].toSegment();
-    if (data.getFinalBlock().value_or(ndn::name::Component("")) != data.getName()[-1]) {
-      return;
-    }
-
-    // wrap data in a single Content TLV for easy parsing
-    m_buffer.prependVarNumber(m_buffer.size());
-    m_buffer.prependVarNumber(ndn::tlv::Content);
-
-    BOOST_TEST_CHECKPOINT("creating parser");
-    ndn::Block parser(m_buffer.buf(), m_buffer.size());
-    BOOST_TEST_CHECKPOINT("parsing aggregated response");
-    parser.parse();
-
-    BOOST_REQUIRE_EQUAL(parser.elements_size(), m_publisher.getLimit());
-
-    uint64_t expectedNo = m_publisher.getLimit() - 1;
-    for (ndn::Block::element_const_iterator i = parser.elements_begin();
-         i != parser.elements_end();
-         ++i)
-      {
-        uint64_t number = readNonNegativeInteger(*i);
-        BOOST_REQUIRE_EQUAL(number, expectedNo);
-        --expectedNo;
-      }
-  }
-
-protected:
-  std::shared_ptr<ndn::util::DummyClientFace> m_face;
-  const ndn::time::milliseconds m_expectedFreshnessPeriod;
-  TestSegmentPublisher<N> m_publisher;
-  ndn::EncodingBuffer m_buffer;
-  ndn::security::SigningInfo m_signingInfo;
-  const ndn::Name m_publishingPrefix;
-};
-
-using boost::mpl::int_;
-typedef boost::mpl::vector<int_<10000>, int_<100>, int_<10>, int_<0> > DatasetSizes;
-
-BOOST_AUTO_TEST_SUITE(PublisherTestSegmentPublisher)
-
-BOOST_FIXTURE_TEST_CASE_TEMPLATE(Generate, T, DatasetSizes, SegmentPublisherFixture<T::value>)
-{
-  this->m_publisher.publish(this->m_publishingPrefix);
-  this->m_face->processEvents();
-
-  size_t nSegments = this->m_publisher.getTotalPayloadLength() /
-                     this->m_publisher.getMaxSegmentSize();
-  if (this->m_publisher.getTotalPayloadLength() % this->m_publisher.getMaxSegmentSize() != 0 ||
-      nSegments == 0)
-    ++nSegments;
-
-  BOOST_CHECK_EQUAL(this->m_face->sentData.size(), nSegments);
-  for (const ndn::Data& data : this->m_face->sentData) {
-    this->validate(data);
-  }
-}
-
-BOOST_AUTO_TEST_SUITE_END()
-
-} // namespace tests
-} // namespace nlsr
diff --git a/tests/test-lsdb.cpp b/tests/test-lsdb.cpp
index 8a36113..2f9fefc 100644
--- a/tests/test-lsdb.cpp
+++ b/tests/test-lsdb.cpp
@@ -41,7 +41,7 @@
 {
 public:
   LsdbFixture()
-    : face(m_ioService, m_keyChain)
+    : face(m_ioService, m_keyChain, {true, true})
     , nlsr(m_ioService, m_scheduler, face, m_keyChain)
     , lsdb(nlsr.getLsdb())
     , conf(nlsr.getConfParameter())
@@ -172,6 +172,48 @@
   BOOST_CHECK_EQUAL(interests.size(), 0);
 }
 
+BOOST_AUTO_TEST_CASE(LsdbSegmentedData)
+{
+  // Add a lot of NameLSAs to exceed max packet size
+  ndn::Name lsaKey("/ndn/site/%C1.Router/this-router/NAME");
+
+  NameLsa* nameLsa = lsdb.findNameLsa(lsaKey);
+  uint64_t seqNo = nameLsa->getLsSeqNo();
+
+  ndn::Name prefix("/ndn/edu/memphis/netlab/research/nlsr/test/prefix/");
+
+  int nPrefixes = 0;
+  while (nameLsa->serialize().size() < ndn::MAX_NDN_PACKET_SIZE) {
+    nameLsa->addName(ndn::Name(prefix).appendNumber(++nPrefixes));
+  }
+  lsdb.installNameLsa(*nameLsa);
+
+  // Create another Lsdb and expressInterest
+  ndn::util::DummyClientFace face2(m_ioService, m_keyChain, {true, true});
+  face.linkTo(face2);
+  Nlsr nlsr2(m_ioService, m_scheduler, face2, m_keyChain);
+  std::string config = R"CONF(
+              trust-anchor
+                {
+                  type any
+                }
+            )CONF";
+  nlsr2.getValidator().load(config, "config-file-from-string");
+
+  Lsdb& lsdb2(nlsr2.getLsdb());
+
+  advanceClocks(ndn::time::milliseconds(1), 10);
+
+  ndn::Name interestName("/localhop/ndn/nlsr/LSA/site/%C1.Router/this-router/NAME");
+  interestName.appendNumber(seqNo);
+  // 0 == timeout count
+  lsdb2.expressInterest(interestName, 0);
+
+  advanceClocks(ndn::time::milliseconds(1), 10);
+
+  BOOST_CHECK_EQUAL(lsdb.getNameLsdb().front().getNpl(), lsdb2.getNameLsdb().front().getNpl());
+}
+
 BOOST_AUTO_TEST_CASE(SegmentLsaData)
 {
   ndn::Name lsaKey("/ndn/site/%C1.Router/this-router/NAME");
@@ -189,29 +231,21 @@
 
   std::string expectedDataContent = lsa->serialize();
 
-  ndn::Name interestName("/ndn/NLSR/LSA/site/%C1.Router/this-router/NAME/");
+  ndn::Name interestName("/localhop/ndn/nlsr/LSA/site/%C1.Router/this-router/NAME/");
   interestName.appendNumber(seqNo);
 
-  ndn::Interest interest(interestName);
-  lsdb.processInterest(ndn::Name(), interest);
-  advanceClocks(ndn::time::milliseconds(1), 10);
-  face.sentData.clear();
+  ndn::util::DummyClientFace face2(m_ioService, m_keyChain, {true, true});
+  face.linkTo(face2);
 
-  lsdb.processInterest(ndn::Name(), interest);
+  auto fetcher = ndn::util::SegmentFetcher::start(face2, ndn::Interest(interestName),
+                                                  ndn::security::v2::getAcceptAllValidator());
+  fetcher->onComplete.connect([&expectedDataContent] (ndn::ConstBufferPtr bufferPtr) {
+                                ndn::Block block(bufferPtr);
+                                BOOST_CHECK_EQUAL(expectedDataContent, readString(block));
+                              });
 
-  advanceClocks(ndn::time::milliseconds(1), 10);
-
-  std::string recvDataContent;
-  for (const ndn::Data& data : face.sentData)
-  {
-    const ndn::Block& nameBlock = data.getContent();
-    std::string nameBlockContent(reinterpret_cast<char const*>(nameBlock.value()),
-                                 nameBlock.value_size());
-
-    recvDataContent += nameBlockContent;
-  }
-
-  BOOST_CHECK_EQUAL(expectedDataContent, recvDataContent);
+  advanceClocks(ndn::time::milliseconds(1), 100);
+  fetcher->stop();
 }
 
 BOOST_AUTO_TEST_CASE(ReceiveSegmentedLsaData)
@@ -228,12 +262,11 @@
     lsa.addName(ndn::Name(prefix).appendNumber(nPrefixes));
   }
 
-  ndn::Name interestName("/ndn/NLSR/LSA/cs/%C1.Router/router1/NAME/");
+  ndn::Name interestName("/localhop/ndn/nlsr/LSA/cs/%C1.Router/router1/NAME/");
   interestName.appendNumber(seqNo);
 
-  const ndn::ConstBufferPtr bufferPtr = std::make_shared<ndn::Buffer>(lsa.serialize().c_str(),
-                                                                 lsa.serialize().size());
-  lsdb.afterFetchLsa(bufferPtr, interestName);
+  ndn::Block block = ndn::encoding::makeStringBlock(ndn::tlv::Content, lsa.serialize());
+  lsdb.afterFetchLsa(block.getBuffer(), interestName);
 
   NameLsa* foundLsa = lsdb.findNameLsa(lsa.getKey());
   BOOST_REQUIRE(foundLsa != nullptr);
diff --git a/tests/test-statistics.cpp b/tests/test-statistics.cpp
index 51797e5..3e46c80 100644
--- a/tests/test-statistics.cpp
+++ b/tests/test-statistics.cpp
@@ -196,7 +196,7 @@
  */
 BOOST_AUTO_TEST_CASE(LsdbSendLsaInterest)
 {
-  const std::string interestPrefix("/ndn/NLSR/LSA/site/%C1.Router/router/");
+  const std::string interestPrefix("/localhop/ndn/nlsr/LSA/site/%C1.Router/router/");
   uint32_t seqNo = 1;
 
   // Adjacency LSA
@@ -240,7 +240,7 @@
 
   lsdb.installAdjLsa(*adjLsa);
 
-  const std::string interestPrefix("/ndn/NLSR/LSA/site/%C1.Router/this-router/");
+  const std::string interestPrefix("/localhop/ndn/nlsr/LSA/site/%C1.Router/this-router/");
 
   // Receive Adjacency LSA Interest
   receiveInterestAndCheckSentStats(interestPrefix,
@@ -302,37 +302,37 @@
   ndn::time::system_clock::TimePoint MAX_TIME = ndn::time::system_clock::TimePoint::max();
 
   // adjacency lsa
-  ndn::Name adjInterest("/ndn/NLSR/LSA/cs/%C1.Router/router1/ADJACENCY/");
+  ndn::Name adjInterest("/localhop/ndn/nlsr/LSA/cs/%C1.Router/router1/ADJACENCY/");
   adjInterest.appendNumber(seqNo);
   AdjLsa aLsa(routerName, seqNo, MAX_TIME, 1, nlsr.getAdjacencyList());
   lsdb.installAdjLsa(aLsa);
 
-  const ndn::ConstBufferPtr aBuffer = std::make_shared<ndn::Buffer>(aLsa.serialize().c_str(),
-                                                                    aLsa.serialize().size());
-  lsdb.afterFetchLsa(aBuffer, adjInterest);
+  ndn::Block block = ndn::encoding::makeStringBlock(ndn::tlv::Content, aLsa.serialize());
+
+  lsdb.afterFetchLsa(block.getBuffer(), adjInterest);
   BOOST_CHECK_EQUAL(collector.getStatistics().get(Statistics::PacketType::RCV_ADJ_LSA_DATA), 1);
 
   // coordinate lsa
-  ndn::Name coordInterest("/ndn/NLSR/LSA/cs/%C1.Router/router1/COORDINATE/");
+  ndn::Name coordInterest("/localhop/ndn/nlsr/LSA/cs/%C1.Router/router1/COORDINATE/");
   coordInterest.appendNumber(seqNo);
   std::vector<double> angles = {20.0, 30.0};
   CoordinateLsa cLsa(routerName, seqNo, MAX_TIME, 2.5, angles);
   lsdb.installCoordinateLsa(cLsa);
 
-  const ndn::ConstBufferPtr cBuffer = std::make_shared<ndn::Buffer>(cLsa.serialize().c_str(),
-                                                                   cLsa.serialize().size());
-  lsdb.afterFetchLsa(cBuffer, coordInterest);
+  block = ndn::encoding::makeStringBlock(ndn::tlv::Content, cLsa.serialize());
+
+  lsdb.afterFetchLsa(block.getBuffer(), coordInterest);
   BOOST_CHECK_EQUAL(collector.getStatistics().get(Statistics::PacketType::RCV_COORD_LSA_DATA), 1);
 
   // name lsa
-  ndn::Name interestName("/ndn/NLSR/LSA/cs/%C1.Router/router1/NAME/");
+  ndn::Name interestName("/localhop/ndn/nlsr/LSA/cs/%C1.Router/router1/NAME/");
   interestName.appendNumber(seqNo);
   NameLsa nLsa(routerName, seqNo, MAX_TIME, nlsr.getNamePrefixList());
   lsdb.installNameLsa(nLsa);
 
-  const ndn::ConstBufferPtr nBuffer = std::make_shared<ndn::Buffer>(nLsa.serialize().c_str(),
-                                                                   nLsa.serialize().size());
-  lsdb.afterFetchLsa(nBuffer, interestName);
+  block = ndn::encoding::makeStringBlock(ndn::tlv::Content, nLsa.serialize());
+
+  lsdb.afterFetchLsa(block.getBuffer(), interestName);
   BOOST_CHECK_EQUAL(collector.getStatistics().get(Statistics::PacketType::RCV_NAME_LSA_DATA), 1);
 
   // 3 lsa data types should be received
