diff --git a/docs/INSTALL.rst b/docs/INSTALL.rst
index 2faba07..d3cef22 100644
--- a/docs/INSTALL.rst
+++ b/docs/INSTALL.rst
@@ -177,10 +177,6 @@
    configured properly (or ``<LIBPATH>/pkgconfig`` is a default path),
    ``pkgconfig --libs --clflags libndn-cxx`` will return all necessary
    compile and link flags for the library.
--  ``<BINPATH>/ndncatchunks3``: a simplified equivalent to ndncatchunks2
-   in NDNx package
--  ``<BINPATH>/ndnputchunks3``: a simplified equivalent to ndnputchunks2
-   in NDNx package
 -  ``<BINPATH>/ndnsec``: tool to manage NDN keys and certificates
 -  ``<BINPATH>/ndnsec-*``: convenience scripts for ``ndnsec`` tools
 
diff --git a/tools/ndncatchunks3.cpp b/tools/ndncatchunks3.cpp
deleted file mode 100644
index b9a41d2..0000000
--- a/tools/ndncatchunks3.cpp
+++ /dev/null
@@ -1,205 +0,0 @@
-/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/**
- * Copyright (c) 2013-2016 Regents of the University of California.
- *
- * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
- *
- * ndn-cxx library is free software: you can redistribute it and/or modify it under the
- * terms of the GNU Lesser General Public License as published by the Free Software
- * Foundation, either version 3 of the License, or (at your option) any later version.
- *
- * ndn-cxx library 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 Lesser General Public License for more details.
- *
- * You should have received copies of the GNU General Public License and GNU Lesser
- * General Public License along with ndn-cxx, e.g., in COPYING.md file.  If not, see
- * <http://www.gnu.org/licenses/>.
- *
- * See AUTHORS.md for complete list of ndn-cxx authors and contributors.
- *
- * @author Wentao Shang <http://irl.cs.ucla.edu/~wentao/>
- */
-
-#include "face.hpp"
-
-namespace ndn {
-
-class Consumer
-{
-public:
-  Consumer(const std::string& dataName,
-           size_t pipeSize, size_t nTotalSegments,
-           bool mustBeFresh = true)
-    : m_dataName(dataName)
-    , m_pipeSize(pipeSize)
-    , m_nTotalSegments(nTotalSegments)
-    , m_nextSegment(0)
-    , m_totalSize(0)
-    , m_isOutputEnabled(false)
-    , m_mustBeFresh(mustBeFresh)
-  {
-  }
-
-  inline void
-  enableOutput()
-  {
-    m_isOutputEnabled = true;
-  }
-
-  void
-  run();
-
-private:
-  void
-  onData(Data& data);
-
-  void
-  onTimeout(const Interest& interest);
-
-  Face m_face;
-  Name m_dataName;
-  size_t m_pipeSize;
-  size_t m_nTotalSegments;
-  size_t m_nextSegment;
-  size_t m_totalSize;
-  bool m_isOutputEnabled;  // set to false by default
-
-  bool m_mustBeFresh;
-};
-
-void
-Consumer::run()
-{
-  try
-    {
-      for (size_t i = 0; i < m_pipeSize; i++)
-        {
-          Interest interest(Name(m_dataName).appendSegment(m_nextSegment++));
-          interest.setInterestLifetime(time::milliseconds(4000));
-          interest.setMustBeFresh(m_mustBeFresh);
-
-          m_face.expressInterest(interest,
-                                 bind(&Consumer::onData, this, _2),
-                                 bind(&Consumer::onTimeout, this, _1));
-        }
-
-      // processEvents will block until the requested data received or timeout occurs
-      m_face.processEvents();
-    }
-  catch (std::exception& e)
-    {
-      std::cerr << "ERROR: " << e.what() << std::endl;
-    }
-}
-
-void
-Consumer::onData(Data& data)
-{
-  const Block& content = data.getContent();
-  const Name& name = data.getName();
-
-  if (m_isOutputEnabled)
-    {
-      std::cout.write(reinterpret_cast<const char*>(content.value()), content.value_size());
-    }
-
-  m_totalSize += content.value_size();
-
-  if (name[-1].toSegment() + 1 == m_nTotalSegments)
-    {
-      std::cerr << "Last segment received." << std::endl;
-      std::cerr << "Total # bytes of content received: " << m_totalSize << std::endl;
-    }
-  else
-    {
-      // Send interest for next segment
-      Interest interest(Name(m_dataName).appendSegment(m_nextSegment++));
-      interest.setInterestLifetime(time::milliseconds(4000));
-      interest.setMustBeFresh(m_mustBeFresh);
-
-      m_face.expressInterest(interest,
-                             bind(&Consumer::onData, this, _2),
-                             bind(&Consumer::onTimeout, this, _1));
-    }
-}
-
-
-void
-Consumer::onTimeout(const Interest& interest)
-{
-  //XXX: currently no retrans
-  std::cerr << "TIMEOUT: last interest sent for segment #" << (m_nextSegment - 1) << std::endl;
-}
-
-
-int
-usage(const std::string &filename)
-{
-  std::cerr << "Usage: \n    "
-            << filename << " [-p pipeSize] [-c nTotalSegmentsment] [-o] /ndn/name\n";
-  return 1;
-}
-
-
-int
-main(int argc, char** argv)
-{
-  std::string name;
-  int pipeSize = 1;
-  int nTotalSegments = std::numeric_limits<int>::max();
-  bool output = false;
-
-  int opt;
-  while ((opt = getopt(argc, argv, "op:c:")) != -1)
-    {
-      switch (opt)
-        {
-        case 'p':
-          pipeSize = atoi(optarg);
-          if (pipeSize <= 0)
-            pipeSize = 1;
-          std::cerr << "main(): set pipe size = " << pipeSize << std::endl;
-          break;
-        case 'c':
-          nTotalSegments = atoi(optarg);
-          if (nTotalSegments <= 0)
-            nTotalSegments = 1;
-          std::cerr << "main(): set total seg = " << nTotalSegments << std::endl;
-          break;
-        case 'o':
-          output = true;
-          break;
-        default:
-          return usage(argv[0]);
-        }
-    }
-
-  if (optind < argc)
-    {
-      name = argv[optind];
-    }
-
-  if (name.empty())
-    {
-      return usage(argv[0]);
-    }
-
-  Consumer consumer(name, pipeSize, nTotalSegments);
-
-  if (output)
-    consumer.enableOutput();
-
-  consumer.run();
-
-  return 0;
-}
-
-} // namespace ndn
-
-int
-main(int argc, char** argv)
-{
-  std::cerr << "ndncatchunks3 is deprecated. Use ndncatchunks program from ndn-tools repository.\n" << std::endl;
-  return ndn::main(argc, argv);
-}
diff --git a/tools/ndnputchunks3.cpp b/tools/ndnputchunks3.cpp
deleted file mode 100644
index a977322..0000000
--- a/tools/ndnputchunks3.cpp
+++ /dev/null
@@ -1,159 +0,0 @@
-/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/**
- * Copyright (c) 2013-2016 Regents of the University of California.
- *
- * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
- *
- * ndn-cxx library is free software: you can redistribute it and/or modify it under the
- * terms of the GNU Lesser General Public License as published by the Free Software
- * Foundation, either version 3 of the License, or (at your option) any later version.
- *
- * ndn-cxx library 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 Lesser General Public License for more details.
- *
- * You should have received copies of the GNU General Public License and GNU Lesser
- * General Public License along with ndn-cxx, e.g., in COPYING.md file.  If not, see
- * <http://www.gnu.org/licenses/>.
- *
- * See AUTHORS.md for complete list of ndn-cxx authors and contributors.
- *
- * @author Wentao Shang <http://irl.cs.ucla.edu/~wentao/>
- */
-
-#include "face.hpp"
-#include "security/key-chain.hpp"
-
-namespace ndn {
-
-const size_t MAX_SEG_SIZE = 4096;
-
-class Producer
-{
-public:
-  Producer(const char* name)
-    : m_name(name)
-    , m_isVerbose(false)
-  {
-    int segnum = 0;
-    char* buf = new char[MAX_SEG_SIZE];
-    do
-      {
-        std::cin.read(buf, MAX_SEG_SIZE);
-        ssize_t got = std::cin.gcount();
-
-        if (got > 0)
-          {
-            shared_ptr<Data> data =
-              make_shared<Data>(Name(m_name).appendSegment(segnum));
-
-            data->setFreshnessPeriod(time::milliseconds(10000)); // 10 sec
-            data->setContent(reinterpret_cast<const uint8_t*>(buf), got);
-
-            m_keychain.sign(*data);
-            m_store.push_back(data);
-            segnum++;
-          }
-      }
-    while (static_cast<bool>(std::cin));
-
-    if (m_isVerbose)
-      std::cerr << "Created " << segnum << " chunks for prefix [" << m_name << "]" << std::endl;
-  }
-
-  void
-  onInterest(const Interest& interest)
-  {
-    if (m_isVerbose)
-      std::cerr << "<< I: " << interest << std::endl;
-
-    size_t segnum = static_cast<size_t>(interest.getName().rbegin()->toSegment());
-
-    if (segnum < m_store.size())
-      {
-        m_face.put(*m_store[segnum]);
-      }
-  }
-
-  void
-  onRegisterFailed(const Name& prefix, const std::string& reason)
-  {
-    std::cerr << "ERROR: Failed to register prefix '"
-              << prefix << "' in local hub's daemon (" << reason << ")"
-              << std::endl;
-    m_face.shutdown();
-  }
-
-  void
-  run()
-  {
-    if (m_store.empty())
-      {
-        std::cerr << "Nothing to serve. Exiting." << std::endl;
-        return;
-      }
-
-    m_face.setInterestFilter(m_name,
-                             bind(&Producer::onInterest, this, _2),
-                             RegisterPrefixSuccessCallback(),
-                             bind(&Producer::onRegisterFailed, this, _1, _2));
-    m_face.processEvents();
-  }
-
-private:
-  Name m_name;
-  Face m_face;
-  KeyChain m_keychain;
-
-  std::vector< shared_ptr<Data> > m_store;
-
-  bool m_isVerbose;
-};
-
-int
-main(int argc, char** argv)
-{
-  if (argc < 2)
-    {
-      std::cerr << "Usage: ./ndnputchunks [data_prefix]\n";
-      return -1;
-    }
-
-  try
-    {
-      time::steady_clock::TimePoint startTime = time::steady_clock::now();
-
-      std::cerr << "Preparing the input..." << std::endl;
-      Producer producer(argv[1]);
-      std::cerr << "Ready... (took " << (time::steady_clock::now() - startTime) << std::endl;
-
-      while (true)
-        {
-          try
-            {
-              // this will exit when daemon dies... so try to connect again if possible
-              producer.run();
-            }
-          catch (std::exception& e)
-            {
-              std::cerr << "ERROR: " << e.what() << std::endl;
-              // and keep going
-              sleep(1);
-            }
-        }
-    }
-  catch (std::exception& e)
-    {
-      std::cerr << "ERROR: " << e.what() << std::endl;
-    }
-  return 0;
-}
-
-} // namespace ndn
-
-int
-main(int argc, char** argv)
-{
-  std::cerr << "ndnputchunks3 is deprecated. Use ndnputchunks program from ndn-tools repository.\n" << std::endl;
-  return ndn::main(argc, argv);
-}
