diff --git a/core/segment-publisher.hpp b/core/segment-publisher.hpp
deleted file mode 100644
index d79586d..0000000
--- a/core/segment-publisher.hpp
+++ /dev/null
@@ -1,132 +0,0 @@
-/* -*- 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/>.
- */
-
-#ifndef NFD_CORE_SEGMENT_PUBLISHER_HPP
-#define NFD_CORE_SEGMENT_PUBLISHER_HPP
-
-#include "common.hpp"
-
-#include <ndn-cxx/encoding/encoding-buffer.hpp>
-#include <ndn-cxx/security/key-chain.hpp>
-
-namespace nfd {
-
-/** \brief provides a publisher of Status Dataset or other segmented octet stream
- *  \sa http://redmine.named-data.net/projects/nfd/wiki/StatusDataset
- */
-template <class FaceBase>
-class SegmentPublisher : noncopyable
-{
-public:
-  SegmentPublisher(FaceBase& face,
-                   const Name& prefix,
-                   ndn::KeyChain& keyChain,
-                   const time::milliseconds& freshnessPeriod = getDefaultFreshness())
-    : m_face(face)
-    , m_prefix(prefix)
-    , m_keyChain(keyChain)
-    , m_freshnessPeriod(freshnessPeriod)
-  {
-  }
-
-  virtual
-  ~SegmentPublisher()
-  {
-  }
-
-  static size_t
-  getMaxSegmentSize()
-  {
-    static const size_t MAX_SEGMENT_SIZE = ndn::MAX_NDN_PACKET_SIZE >> 1;
-    return MAX_SEGMENT_SIZE;
-  }
-
-  static constexpr time::milliseconds
-  getDefaultFreshness()
-  {
-    return time::milliseconds(1000);
-  }
-
-  void
-  publish()
-  {
-    ndn::EncodingBuffer buffer;
-    generate(buffer);
-
-    const uint8_t* rawBuffer = buffer.buf();
-    const uint8_t* segmentBegin = rawBuffer;
-    const uint8_t* end = rawBuffer + buffer.size();
-
-    Name segmentPrefix(m_prefix);
-    segmentPrefix.appendVersion();
-
-    uint64_t segmentNo = 0;
-    do {
-      const uint8_t* segmentEnd = segmentBegin + getMaxSegmentSize();
-      if (segmentEnd > end) {
-        segmentEnd = end;
-      }
-
-      Name segmentName(segmentPrefix);
-      segmentName.appendSegment(segmentNo);
-
-      shared_ptr<Data> data = make_shared<Data>(segmentName);
-      data->setContent(segmentBegin, segmentEnd - segmentBegin);
-      data->setFreshnessPeriod(m_freshnessPeriod);
-
-      segmentBegin = segmentEnd;
-      if (segmentBegin >= end) {
-        data->setFinalBlockId(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:
-  void
-  publishSegment(shared_ptr<Data>& data)
-  {
-    m_keyChain.sign(*data);
-    m_face.put(*data);
-  }
-
-private:
-  FaceBase& m_face;
-  const Name m_prefix;
-  ndn::KeyChain& m_keyChain;
-  const time::milliseconds m_freshnessPeriod;
-};
-
-} // namespace nfd
-
-#endif // NFD_CORE_SEGMENT_PUBLISHER_HPP
diff --git a/tests/core/segment-publisher.t.cpp b/tests/core/segment-publisher.t.cpp
deleted file mode 100644
index 4223d19..0000000
--- a/tests/core/segment-publisher.t.cpp
+++ /dev/null
@@ -1,165 +0,0 @@
-/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/**
- * Copyright (c) 2014-2016,  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 "core/segment-publisher.hpp"
-#include <ndn-cxx/encoding/tlv.hpp>
-
-#include "tests/test-common.hpp"
-#include "tests/identity-management-fixture.hpp"
-#include <ndn-cxx/util/dummy-client-face.hpp>
-
-namespace nfd {
-namespace tests {
-
-NFD_LOG_INIT("SegmentPublisherTest");
-
-template<int64_t N=10000>
-class SegmentPublisherTester : public SegmentPublisher<ndn::util::DummyClientFace>
-{
-public:
-  SegmentPublisherTester(ndn::util::DummyClientFace& face,
-                         const Name& prefix,
-                         ndn::KeyChain& keyChain,
-                         const time::milliseconds freshnessPeriod)
-    : SegmentPublisher(face, prefix, keyChain, freshnessPeriod)
-    , m_totalPayloadLength(0)
-  {
-
-  }
-
-  virtual
-  ~SegmentPublisherTester() = default;
-
-  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, tlv::Content, i);
-    }
-    m_totalPayloadLength += totalLength;
-    return totalLength;
-  }
-
-protected:
-  size_t m_totalPayloadLength;
-};
-
-template<int64_t N>
-class SegmentPublisherFixture : public IdentityManagementFixture
-{
-public:
-  SegmentPublisherFixture()
-    : m_face(m_keyChain)
-    , m_expectedFreshnessPeriod(time::milliseconds(111))
-    , m_publisher(m_face, "/localhost/nfd/SegmentPublisherFixture",
-                  m_keyChain, m_expectedFreshnessPeriod)
-  {
-  }
-
-  void
-  validate(const Data& data)
-  {
-    BOOST_CHECK_EQUAL(data.getFreshnessPeriod(), m_expectedFreshnessPeriod);
-
-    Block payload = data.getContent();
-    NFD_LOG_DEBUG("payload size (w/o Content TLV): " << payload.value_size());
-
-    m_buffer.appendByteArray(payload.value(), payload.value_size());
-
-    uint64_t segmentNo = data.getName()[-1].toSegment();
-    if (data.getFinalBlockId() != data.getName()[-1]) {
-      return;
-    }
-
-    NFD_LOG_DEBUG("got final block: #" << segmentNo);
-
-    // wrap data in a single Content TLV for easy parsing
-    m_buffer.prependVarNumber(m_buffer.size());
-    m_buffer.prependVarNumber(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;
-    std::for_each(parser.elements_begin(), parser.elements_end(),
-      [&expectedNo] (const Block& element) {
-        uint64_t number = readNonNegativeInteger(element);
-        BOOST_REQUIRE_EQUAL(number, expectedNo);
-        --expectedNo;
-      });
-  }
-
-protected:
-  ndn::util::DummyClientFace m_face;
-  const time::milliseconds m_expectedFreshnessPeriod;
-  SegmentPublisherTester<N> m_publisher;
-  ndn::EncodingBuffer m_buffer;
-  ndn::KeyChain m_keyChain;
-};
-
-using boost::mpl::int_;
-typedef boost::mpl::vector<int_<10000>, int_<100>, int_<10>, int_<0>> DatasetSizes;
-
-BOOST_AUTO_TEST_SUITE(TestSegmentPublisher)
-
-BOOST_FIXTURE_TEST_CASE_TEMPLATE(Generate, T, DatasetSizes, SegmentPublisherFixture<T::value>)
-{
-  this->m_publisher.publish();
-  this->m_face.processEvents();
-
-  size_t nSegments =
-    this->m_publisher.getTotalPayloadLength() / this->m_publisher.getMaxSegmentSize() +
-    (this->m_publisher.getTotalPayloadLength() % this->m_publisher.getMaxSegmentSize() != 0 ||
-     this->m_publisher.getTotalPayloadLength() == 0);
-
-  BOOST_CHECK_EQUAL(this->m_face.sentData.size(), nSegments);
-  for (const Data& data : this->m_face.sentData) {
-    this->validate(data);
-  }
-}
-
-BOOST_AUTO_TEST_SUITE_END()
-
-} // namespace tests
-} // namespace nfd
