diff --git a/docs/conf.py b/docs/conf.py
index 8fbda38..89dc2a0 100644
--- a/docs/conf.py
+++ b/docs/conf.py
@@ -249,8 +249,6 @@
         u'NDN auto-configuration client configuration file', None, 5),
     ('manpages/nfdc', 'nfdc',
         u'NFD utility to manipulate the forwarding table (FIB)', None, 1),
-    ('manpages/ndn-tlv-peek', 'ndn-tlv-peek', u'NFD consumer', None, 1),
-    ('manpages/ndn-tlv-poke', 'ndn-tlv-poke', u'NFD producer', None, 1),
     ('manpages/nfd-autoreg', 'nfd-autoreg', u'NFD Auto-registration Server', None, 1),
     ('manpages/nfd-status-http-server', 'nfd-status-http-server',
         u'NFD status HTTP server', None, 1),
diff --git a/docs/manpages.rst b/docs/manpages.rst
index d3d97a5..7207f34 100644
--- a/docs/manpages.rst
+++ b/docs/manpages.rst
@@ -14,6 +14,4 @@
    manpages/ndn-autoconfig-server
    misc/local-prefix-discovery
    manpages/nfd-autoreg
-   manpages/ndn-tlv-peek
-   manpages/ndn-tlv-poke
    :maxdepth: 1
diff --git a/docs/manpages/ndn-tlv-peek.rst b/docs/manpages/ndn-tlv-peek.rst
deleted file mode 100644
index b2edd2d..0000000
--- a/docs/manpages/ndn-tlv-peek.rst
+++ /dev/null
@@ -1,62 +0,0 @@
-ndn-tlv-peek
-============
-
-Deprecated
-----------
-
-ndn-tlv-peek is deprecated and will be removed in a future release of NFD.
-Please use ``ndnpeek`` program from ndn-tools repository `<https://github.com/named-data/ndn-tools>`__.
-
-Usage
------
-
-::
-
-    ndn-tlv-peek [-h] [-f] [-r] [-m min] [-M max] [-l lifetime] [-p] [-w timeout] name
-
-Description
------------
-
-``ndn-tlv-peek`` is a simple consumer program that sends one Interest and expects one Data
-packet in response.  The full Data packet (in TLV format) is written to stdout.  The
-program terminates with return code 0 if Data arrives, and with return code 1 when timeout
-occurs.
-
-``name`` is interpreted as the Interest name.
-
-Options
--------
-
-``-h``
-  Print help and exit
-
-``-f``
-  If specified, set ``MustBeFresh`` selector in the Interest packet.
-
-``-r``
-  Set ``ChildSelector=1`` (the rightmost child) selector.
-
-``-m``
-  Set ``min`` as the ``MinSuffixComponents`` selector.
-
-``-M``
-  Set ``max`` as the ``MaxSuffixComponents`` selector.
-
-``-l``
-  Set ``lifetime`` (in milliseconds) as the ``InterestLifetime``.
-
-``-p``
-  If specified, print the received payload only, not the full packet.
-
-``-w``
-  Timeout after ``timeout`` milliseconds.
-
-
-Examples
---------
-
-Send Interest for ``ndn:/app1/video`` and print the received payload only
-
-::
-
-    ndn-tlv-peek -p ndn:/app1/video
diff --git a/docs/manpages/ndn-tlv-poke.rst b/docs/manpages/ndn-tlv-poke.rst
deleted file mode 100644
index f43117d..0000000
--- a/docs/manpages/ndn-tlv-poke.rst
+++ /dev/null
@@ -1,60 +0,0 @@
-ndn-tlv-poke
-============
-
-Deprecated
-----------
-
-ndn-tlv-poke is deprecated and will be removed in a future release of NFD.
-Please use ``ndnpoke`` program from ndn-tools repository `<https://github.com/named-data/ndn-tools>`__.
-
-Usage
------
-
-::
-
-    ndn-tlv-poke [-h] [-f] [-D] [-i identity] [-F] [-x freshness] [-w timeout] name
-
-Description
------------
-
-``ndn-tlv-poke`` is a simple producer program that reads payload from stdin and publishes it
-as a single NDN Data packet.  The Data packet is published either as a response to the
-incoming Interest for the given ``name``, or forcefully pushed to the local NDN
-forwarder's cache if ``-f`` flag is specified.
-
-The program terminates with return code 0 if Data is sent and with return code 1 when
-timeout occurs.
-
-Options
--------
-
-``-h``
-  Print usage and exit.
-
-``-f``
-  If specified, send Data without waiting for Interest.
-
-``-D``
-  If specified, use ``DigestSha256`` signature instead of default ``SignatureSha256WithRsa``.
-
-``-i``
-  Use ``identity`` to sign the created Data packet.
-
-``-F``
-  Set ``FinalBlockId`` to the last component of specified name.
-
-``-x``
-  Set ``FreshnessPeriod`` in milliseconds.
-
-``-w``
-  Wait at most ``timeout`` milliseconds for the incoming Interest.  If no Interest arrives
-  within the ``timeout``, the Data packet will not be published.
-
-
-Examples
---------
-
-Create Data packet with content ``hello`` with the name ``ndn:/app/video`` and wait at
-most 3 seconds for the incoming Interest for it::
-
-    echo "Hello" | build/bin/ndn-tlv-poke -w 3000 ndn:/app/video
diff --git a/tools/ndn-tlv-peek.cpp b/tools/ndn-tlv-peek.cpp
deleted file mode 100644
index ee37bbc..0000000
--- a/tools/ndn-tlv-peek.cpp
+++ /dev/null
@@ -1,280 +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/>.
- */
-
-#include "version.hpp"
-
-#include <boost/noncopyable.hpp>
-
-#include <ndn-cxx/face.hpp>
-
-namespace ndntlvpeek {
-
-class NdnTlvPeek : boost::noncopyable
-{
-public:
-  explicit
-  NdnTlvPeek(char* programName)
-    : m_programName(programName)
-    , m_mustBeFresh(false)
-    , m_isChildSelectorRightmost(false)
-    , m_minSuffixComponents(-1)
-    , m_maxSuffixComponents(-1)
-    , m_interestLifetime(-1)
-    , m_isPayloadOnlySet(false)
-    , m_timeout(-1)
-    , m_prefixName("")
-    , m_isDataReceived(false)
-  {
-  }
-
-  void
-  usage()
-  {
-    std::cout << "\n Usage:\n " << m_programName << " "
-      "[-f] [-r] [-m min] [-M max] [-l lifetime] [-p] [-w timeout] ndn:/name\n"
-      "   Get one data item matching the name prefix and write it to stdout\n"
-      "   [-f]          - set MustBeFresh\n"
-      "   [-r]          - set ChildSelector to select rightmost child\n"
-      "   [-m min]      - set MinSuffixComponents\n"
-      "   [-M max]      - set MaxSuffixComponents\n"
-      "   [-l lifetime] - set InterestLifetime in time::milliseconds\n"
-      "   [-p]          - print payload only, not full packet\n"
-      "   [-w timeout]  - set Timeout in time::milliseconds\n"
-      "   [-h]          - print help and exit\n"
-      "   [-V]          - print version and exit\n"
-      "\n";
-    exit(1);
-  }
-
-  void
-  setMustBeFresh()
-  {
-    m_mustBeFresh = true;
-  }
-
-  void
-  setRightmostChildSelector()
-  {
-    m_isChildSelectorRightmost = true;
-  }
-
-  void
-  setMinSuffixComponents(int minSuffixComponents)
-  {
-    if (minSuffixComponents < 0)
-      usage();
-    m_minSuffixComponents = minSuffixComponents;
-  }
-
-  void
-  setMaxSuffixComponents(int maxSuffixComponents)
-  {
-    if (maxSuffixComponents < 0)
-      usage();
-    m_maxSuffixComponents = maxSuffixComponents;
-  }
-
-  void
-  setInterestLifetime(int interestLifetime)
-  {
-    if (interestLifetime < 0)
-      usage();
-    m_interestLifetime = ndn::time::milliseconds(interestLifetime);
-  }
-
-  void
-  setPayloadOnly()
-  {
-    m_isPayloadOnlySet = true;
-  }
-
-  void
-  setTimeout(int timeout)
-  {
-    if (timeout < 0)
-      usage();
-    m_timeout = ndn::time::milliseconds(timeout);
-  }
-
-  void
-  setPrefixName(char* prefixName)
-  {
-    m_prefixName = prefixName;
-    if (m_prefixName.length() == 0)
-      usage();
-  }
-
-  ndn::time::milliseconds
-  getDefaultInterestLifetime()
-  {
-    return ndn::time::seconds(4);
-  }
-
-  ndn::Interest
-  createInterestPacket()
-  {
-    ndn::Name interestName(m_prefixName);
-    ndn::Interest interestPacket(interestName);
-    if (m_mustBeFresh)
-      interestPacket.setMustBeFresh(true);
-    if (m_isChildSelectorRightmost)
-      interestPacket.setChildSelector(1);
-    if (m_minSuffixComponents >= 0)
-      interestPacket.setMinSuffixComponents(m_minSuffixComponents);
-    if (m_maxSuffixComponents >= 0)
-      interestPacket.setMaxSuffixComponents(m_maxSuffixComponents);
-    if (m_interestLifetime < ndn::time::milliseconds::zero())
-      interestPacket.setInterestLifetime(getDefaultInterestLifetime());
-    else
-      interestPacket.setInterestLifetime(m_interestLifetime);
-    return interestPacket;
-  }
-
-  void
-  onData(const ndn::Interest& interest, ndn::Data& data)
-  {
-    m_isDataReceived = true;
-    if (m_isPayloadOnlySet)
-      {
-        const ndn::Block& block = data.getContent();
-        std::cout.write(reinterpret_cast<const char*>(block.value()), block.value_size());
-      }
-    else
-      {
-        const ndn::Block& block = data.wireEncode();
-        std::cout.write(reinterpret_cast<const char*>(block.wire()), block.size());
-      }
-  }
-
-  void
-  onTimeout(const ndn::Interest& interest)
-  {
-  }
-
-  void
-  run()
-  {
-    try
-      {
-        m_face.expressInterest(createInterestPacket(),
-                               bind(&NdnTlvPeek::onData, this, _1, _2),
-                               bind(&NdnTlvPeek::onTimeout, this, _1));
-        if (m_timeout < ndn::time::milliseconds::zero())
-          {
-            if (m_interestLifetime < ndn::time::milliseconds::zero())
-              m_face.processEvents(getDefaultInterestLifetime());
-            else
-              m_face.processEvents(m_interestLifetime);
-          }
-        else
-          m_face.processEvents(m_timeout);
-      }
-    catch (std::exception& e)
-      {
-        std::cerr << "ERROR: " << e.what() << "\n" << std::endl;
-        exit(1);
-      }
-  }
-
-  bool
-  isDataReceived() const
-  {
-    return m_isDataReceived;
-  }
-
-private:
-
-  std::string m_programName;
-  bool m_mustBeFresh;
-  bool m_isChildSelectorRightmost;
-  int m_minSuffixComponents;
-  int m_maxSuffixComponents;
-  ndn::time::milliseconds m_interestLifetime;
-  bool m_isPayloadOnlySet;
-  ndn::time::milliseconds m_timeout;
-  std::string m_prefixName;
-  bool m_isDataReceived;
-  ndn::Face m_face;
-};
-
-}
-
-int
-main(int argc, char* argv[])
-{
-  std::cerr << "ndn-tlv-peek is deprecated. Use ndnpeek program from ndn-tools repository.\n"
-               "See `man ndn-tlv-peek` for details." << std::endl;
-
-  ndntlvpeek::NdnTlvPeek ndnTlvPeek(argv[0]);
-  int option;
-  while ((option = getopt(argc, argv, "hfrm:M:l:pw:V")) != -1) {
-    switch (option) {
-    case 'h':
-      ndnTlvPeek.usage();
-      break;
-    case 'f':
-      ndnTlvPeek.setMustBeFresh();
-      break;
-    case 'r':
-      ndnTlvPeek.setRightmostChildSelector();
-      break;
-    case 'm':
-      ndnTlvPeek.setMinSuffixComponents(atoi(optarg));
-      break;
-    case 'M':
-      ndnTlvPeek.setMaxSuffixComponents(atoi(optarg));
-      break;
-    case 'l':
-      ndnTlvPeek.setInterestLifetime(atoi(optarg));
-      break;
-    case 'p':
-      ndnTlvPeek.setPayloadOnly();
-      break;
-    case 'w':
-      ndnTlvPeek.setTimeout(atoi(optarg));
-      break;
-    case 'V':
-      std::cout << NFD_VERSION_BUILD_STRING << std::endl;
-      return 0;
-    default:
-      ndnTlvPeek.usage();
-      break;
-    }
-  }
-
-  argc -= optind;
-  argv += optind;
-
-  if (argv[0] == 0)
-    ndnTlvPeek.usage();
-
-  ndnTlvPeek.setPrefixName(argv[0]);
-  ndnTlvPeek.run();
-
-  if (ndnTlvPeek.isDataReceived())
-    return 0;
-  else
-    return 1;
-}
diff --git a/tools/ndn-tlv-poke.cpp b/tools/ndn-tlv-poke.cpp
deleted file mode 100644
index da74c32..0000000
--- a/tools/ndn-tlv-poke.cpp
+++ /dev/null
@@ -1,278 +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/>.
- */
-
-#include "version.hpp"
-
-#include <boost/noncopyable.hpp>
-
-#include <ndn-cxx/face.hpp>
-#include <ndn-cxx/security/key-chain.hpp>
-
-namespace ndntlvpoke {
-
-class NdnTlvPoke : boost::noncopyable
-{
-public:
-  explicit
-  NdnTlvPoke(char* programName)
-    : m_programName(programName)
-    , m_isForceDataSet(false)
-    , m_isUseDigestSha256Set(false)
-    , m_isLastAsFinalBlockIdSet(false)
-    , m_freshnessPeriod(-1)
-    , m_timeout(-1)
-    , m_isDataSent(false)
-  {
-  }
-
-  void
-  usage()
-  {
-    std::cout << "\n Usage:\n " << m_programName << " "
-      "[-f] [-D] [-i identity] [-F] [-x freshness] [-w timeout] ndn:/name\n"
-      "   Reads payload from stdin and sends it to local NDN forwarder as a "
-      "single Data packet\n"
-      "   [-f]          - force, send Data without waiting for Interest\n"
-      "   [-D]          - use DigestSha256 signing method instead of "
-      "SignatureSha256WithRsa\n"
-      "   [-i identity] - set identity to be used for signing\n"
-      "   [-F]          - set FinalBlockId to the last component of Name\n"
-      "   [-x]          - set FreshnessPeriod in time::milliseconds\n"
-      "   [-w timeout]  - set Timeout in time::milliseconds\n"
-      "   [-h]          - print help and exit\n"
-      "   [-V]          - print version and exit\n"
-      "\n";
-    exit(1);
-  }
-
-  void
-  setForceData()
-  {
-    m_isForceDataSet = true;
-  }
-
-  void
-  setUseDigestSha256()
-  {
-    m_isUseDigestSha256Set = true;
-  }
-
-  void
-  setIdentityName(char* identityName)
-  {
-    m_identityName = ndn::make_shared<ndn::Name>(identityName);
-  }
-
-  void
-  setLastAsFinalBlockId()
-  {
-    m_isLastAsFinalBlockIdSet = true;
-  }
-
-  void
-  setFreshnessPeriod(int freshnessPeriod)
-  {
-    if (freshnessPeriod < 0)
-      usage();
-    m_freshnessPeriod = ndn::time::milliseconds(freshnessPeriod);
-  }
-
-  void
-  setTimeout(int timeout)
-  {
-    if (timeout < 0)
-      usage();
-    m_timeout = ndn::time::milliseconds(timeout);
-  }
-
-  void
-  setPrefixName(char* prefixName)
-  {
-    m_prefixName = ndn::Name(prefixName);
-  }
-
-  ndn::time::milliseconds
-  getDefaultTimeout()
-  {
-    return ndn::time::seconds(10);
-  }
-
-  ndn::Data
-  createDataPacket()
-  {
-    ndn::Data dataPacket(m_prefixName);
-    std::stringstream payloadStream;
-    payloadStream << std::cin.rdbuf();
-    std::string payload = payloadStream.str();
-    dataPacket.setContent(reinterpret_cast<const uint8_t*>(payload.c_str()), payload.length());
-    if (m_freshnessPeriod >= ndn::time::milliseconds::zero())
-      dataPacket.setFreshnessPeriod(m_freshnessPeriod);
-    if (m_isLastAsFinalBlockIdSet)
-      {
-        if (!m_prefixName.empty())
-          dataPacket.setFinalBlockId(m_prefixName.get(-1));
-        else
-          {
-            std::cerr << "Name Provided Has 0 Components" << std::endl;
-            exit(1);
-          }
-      }
-    if (m_isUseDigestSha256Set)
-      m_keyChain.signWithSha256(dataPacket);
-    else
-      {
-        if (!static_cast<bool>(m_identityName))
-          m_keyChain.sign(dataPacket);
-        else
-          m_keyChain.signByIdentity(dataPacket, *m_identityName);
-      }
-    return dataPacket;
-  }
-
-  void
-  onInterest(const ndn::Name& name,
-             const ndn::Interest& interest,
-             const ndn::Data& dataPacket)
-  {
-    m_face.put(dataPacket);
-    m_isDataSent = true;
-    m_face.shutdown();
-  }
-
-  void
-  onRegisterFailed(const ndn::Name& prefix, const std::string& reason)
-  {
-    std::cerr << "Prefix Registration Failure." << std::endl;
-    std::cerr << "Reason = " << reason << std::endl;
-  }
-
-  void
-  run()
-  {
-    try
-      {
-        ndn::Data dataPacket = createDataPacket();
-        if (m_isForceDataSet)
-          {
-            m_face.put(dataPacket);
-            m_isDataSent = true;
-          }
-        else
-          {
-            m_face.setInterestFilter(m_prefixName,
-                                     bind(&NdnTlvPoke::onInterest, this, _1, _2, dataPacket),
-                                     ndn::RegisterPrefixSuccessCallback(),
-                                     bind(&NdnTlvPoke::onRegisterFailed, this, _1, _2));
-          }
-        if (m_timeout < ndn::time::milliseconds::zero())
-          m_face.processEvents(getDefaultTimeout());
-        else
-          m_face.processEvents(m_timeout);
-      }
-    catch (std::exception& e)
-      {
-        std::cerr << "ERROR: " << e.what() << "\n" << std::endl;
-        exit(1);
-      }
-  }
-
-  bool
-  isDataSent() const
-  {
-    return m_isDataSent;
-  }
-
-private:
-
-  ndn::KeyChain m_keyChain;
-  std::string m_programName;
-  bool m_isForceDataSet;
-  bool m_isUseDigestSha256Set;
-  ndn::shared_ptr<ndn::Name> m_identityName;
-  bool m_isLastAsFinalBlockIdSet;
-  ndn::time::milliseconds m_freshnessPeriod;
-  ndn::time::milliseconds m_timeout;
-  ndn::Name m_prefixName;
-  bool m_isDataSent;
-  ndn::Face m_face;
-
-};
-
-}
-
-int
-main(int argc, char* argv[])
-{
-  std::cerr << "ndn-tlv-poke is deprecated. Use ndnpoke program from ndn-tools repository.\n"
-               "See `man ndn-tlv-poke` for details." << std::endl;
-
-  int option;
-  ndntlvpoke::NdnTlvPoke ndnTlvPoke(argv[0]);
-  while ((option = getopt(argc, argv, "hfDi:Fx:w:V")) != -1) {
-    switch (option) {
-    case 'h':
-      ndnTlvPoke.usage();
-      break;
-    case 'f':
-      ndnTlvPoke.setForceData();
-      break;
-    case 'D':
-      ndnTlvPoke.setUseDigestSha256();
-      break;
-    case 'i':
-      ndnTlvPoke.setIdentityName(optarg);
-      break;
-    case 'F':
-      ndnTlvPoke.setLastAsFinalBlockId();
-      break;
-    case 'x':
-      ndnTlvPoke.setFreshnessPeriod(atoi(optarg));
-      break;
-    case 'w':
-      ndnTlvPoke.setTimeout(atoi(optarg));
-      break;
-    case 'V':
-      std::cout << NFD_VERSION_BUILD_STRING << std::endl;
-      return 0;
-    default:
-      ndnTlvPoke.usage();
-      break;
-    }
-  }
-
-  argc -= optind;
-  argv += optind;
-
-  if (argv[0] == 0)
-    ndnTlvPoke.usage();
-
-  ndnTlvPoke.setPrefixName(argv[0]);
-  ndnTlvPoke.run();
-
-  if (ndnTlvPoke.isDataSent())
-    return 0;
-  else
-    return 1;
-}
