diff --git a/tools/nfdc/available-commands.cpp b/tools/nfdc/available-commands.cpp
index 0d4847f..272c13d 100644
--- a/tools/nfdc/available-commands.cpp
+++ b/tools/nfdc/available-commands.cpp
@@ -1,5 +1,5 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/**
+/*
  * Copyright (c) 2014-2017,  Regents of the University of California,
  *                           Arizona Board of Regents,
  *                           Colorado State University,
@@ -26,8 +26,6 @@
 #include "available-commands.hpp"
 #include "face-module.hpp"
 #include "help.hpp"
-#include "legacy-nfdc.hpp"
-#include "legacy-status.hpp"
 #include "rib-module.hpp"
 #include "status.hpp"
 #include "strategy-choice-module.hpp"
@@ -44,35 +42,6 @@
   FaceModule::registerCommands(parser);
   RibModule::registerCommands(parser);
   StrategyChoiceModule::registerCommands(parser);
-
-  registerLegacyStatusCommand(parser);
-
-  struct LegacyNfdcCommandDefinition
-  {
-    std::string subcommand;
-    std::string title;
-    std::string replacementCommand; ///< replacement for deprecated legacy subcommand
-  };
-  const std::vector<LegacyNfdcCommandDefinition> legacyNfdcSubcommands{
-    {"register", "register a prefix", "route add"},
-    {"unregister", "unregister a prefix", "route remove"},
-    {"create", "create a face", "face create"},
-    {"destroy", "destroy a face", "face destroy"},
-    {"set-strategy", "set strategy choice on namespace", "strategy set"},
-    {"unset-strategy", "unset strategy choice on namespace", "strategy unset"},
-    {"add-nexthop", "add FIB nexthop", "route add"},
-    {"remove-nexthop", "remove FIB nexthop", "route remove"}
-  };
-  for (const LegacyNfdcCommandDefinition& lncd : legacyNfdcSubcommands) {
-    CommandDefinition def(lncd.subcommand, "");
-    def.setTitle(lncd.title);
-    def.addArg("args", ArgValueType::ANY, Required::NO, Positional::YES);
-    auto modes = AVAILABLE_IN_ONE_SHOT | AVAILABLE_IN_HELP;
-    if (!lncd.replacementCommand.empty()) {
-      modes = modes & ~AVAILABLE_IN_HELP;
-    }
-    parser.addCommand(def, bind(&legacyNfdcMain, _1, lncd.replacementCommand), modes);
-  }
 }
 
 } // namespace nfdc
diff --git a/tools/nfdc/command-parser.cpp b/tools/nfdc/command-parser.cpp
index b4c4558..74c5202 100644
--- a/tools/nfdc/command-parser.cpp
+++ b/tools/nfdc/command-parser.cpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/**
- * Copyright (c) 2014-2016,  Regents of the University of California,
+/*
+ * Copyright (c) 2014-2017,  Regents of the University of California,
  *                           Arizona Board of Regents,
  *                           Colorado State University,
  *                           University Pierre & Marie Curie, Sorbonne University,
@@ -120,7 +120,7 @@
       i = m_commands.find({noun, "list"});
     }
     else {
-      // help, exit, quit, legacy nfdc commands
+      // help, exit, quit commands
       i = m_commands.find({noun, ""});
     }
     nameLen = std::min<size_t>(1, tokens.size());
diff --git a/tools/nfdc/face-id-fetcher.cpp b/tools/nfdc/face-id-fetcher.cpp
deleted file mode 100644
index f0bf841..0000000
--- a/tools/nfdc/face-id-fetcher.cpp
+++ /dev/null
@@ -1,203 +0,0 @@
-/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/*
- * Copyright (c) 2014-2017,  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 "face-id-fetcher.hpp"
-
-#include <boost/lexical_cast.hpp>
-#include <boost/regex.hpp>
-
-#include <ndn-cxx/mgmt/nfd/face-query-filter.hpp>
-#include <ndn-cxx/mgmt/nfd/face-status.hpp>
-#include <ndn-cxx/security/validator-null.hpp>
-#include <ndn-cxx/util/segment-fetcher.hpp>
-
-namespace nfd {
-namespace tools {
-namespace nfdc {
-
-FaceIdFetcher::FaceIdFetcher(ndn::Face& face,
-                             ndn::nfd::Controller& controller,
-                             bool allowCreate,
-                             const SuccessCallback& onSucceed,
-                             const FailureCallback& onFail)
-  : m_face(face)
-  , m_controller(controller)
-  , m_allowCreate(allowCreate)
-  , m_onSucceed(onSucceed)
-  , m_onFail(onFail)
-{
-}
-
-void
-FaceIdFetcher::start(ndn::Face& face,
-                     ndn::nfd::Controller& controller,
-                     const std::string& input,
-                     bool allowCreate,
-                     const SuccessCallback& onSucceed,
-                     const FailureCallback& onFail)
-{
-  // 1. Try parse input as FaceId, if input is FaceId, succeed with parsed FaceId
-  // 2. Try parse input as FaceUri, if input is not FaceUri, fail
-  // 3. Canonize faceUri
-  // 4. If canonization fails, fail
-  // 5. Query for face
-  // 6. If query succeeds and finds a face, succeed with found FaceId
-  // 7. Create face
-  // 8. If face creation succeeds, succeed with created FaceId
-  // 9. Fail
-
-  boost::regex e("^[a-z0-9]+\\:.*");
-  if (!boost::regex_match(input, e)) {
-    try {
-      uint32_t faceId = boost::lexical_cast<uint32_t>(input);
-      onSucceed(faceId);
-      return;
-    }
-    catch (const boost::bad_lexical_cast&) {
-      onFail("No valid faceId or faceUri is provided");
-      return;
-    }
-  }
-  else {
-    FaceUri faceUri;
-    if (!faceUri.parse(input)) {
-      onFail("FaceUri parse failed");
-      return;
-    }
-
-    auto fetcher = new FaceIdFetcher(std::ref(face), std::ref(controller),
-                                     allowCreate, onSucceed, onFail);
-    fetcher->startGetFaceId(faceUri);
-  }
-}
-
-void
-FaceIdFetcher::startGetFaceId(const FaceUri& faceUri)
-{
-  faceUri.canonize(bind(&FaceIdFetcher::onCanonizeSuccess, this, _1),
-                   bind(&FaceIdFetcher::onCanonizeFailure, this, _1),
-                   m_face.getIoService(), time::seconds(4));
-}
-
-void
-FaceIdFetcher::onCanonizeSuccess(const FaceUri& canonicalUri)
-{
-  ndn::Name queryName("/localhost/nfd/faces/query");
-  ndn::nfd::FaceQueryFilter queryFilter;
-  queryFilter.setRemoteUri(canonicalUri.toString());
-  queryName.append(queryFilter.wireEncode());
-
-  ndn::Interest interestPacket(queryName);
-  interestPacket.setMustBeFresh(true);
-  interestPacket.setInterestLifetime(time::milliseconds(4000));
-  auto interest = std::make_shared<ndn::Interest>(interestPacket);
-
-  ndn::util::SegmentFetcher::fetch(
-    m_face, *interest, ndn::security::v2::getAcceptAllValidator(),
-    bind(&FaceIdFetcher::onQuerySuccess, this, _1, canonicalUri),
-    bind(&FaceIdFetcher::onQueryFailure, this, _1, canonicalUri));
-}
-
-void
-FaceIdFetcher::onCanonizeFailure(const std::string& reason)
-{
-  fail("Canonize faceUri failed : " + reason);
-}
-
-void
-FaceIdFetcher::onQuerySuccess(const ndn::ConstBufferPtr& data,
-                              const FaceUri& canonicalUri)
-{
-  size_t offset = 0;
-  bool isOk = false;
-  ndn::Block block;
-  std::tie(isOk, block) = ndn::Block::fromBuffer(data, offset);
-
-  if (!isOk) {
-    if (m_allowCreate) {
-      startFaceCreate(canonicalUri);
-    }
-    else {
-      fail("Fail to find faceId");
-    }
-  }
-  else {
-    try {
-      ndn::nfd::FaceStatus status(block);
-      succeed(status.getFaceId());
-    }
-    catch (const ndn::tlv::Error& e) {
-      std::string errorMessage(e.what());
-      fail("ERROR: " + errorMessage);
-    }
-  }
-}
-
-void
-FaceIdFetcher::onQueryFailure(uint32_t errorCode,
-                              const FaceUri& canonicalUri)
-{
-  std::stringstream ss;
-  ss << "Cannot fetch data (code " << errorCode << ")";
-  fail(ss.str());
-}
-
-void
-FaceIdFetcher::onFaceCreateError(const ndn::nfd::ControlResponse& response,
-                                 const std::string& message)
-{
-  std::stringstream ss;
-  ss << message << " : " << response.getText() << " (code " << response.getCode() << ")";
-  fail(ss.str());
-}
-
-void
-FaceIdFetcher::startFaceCreate(const FaceUri& canonicalUri)
-{
-  ndn::nfd::ControlParameters parameters;
-  parameters.setUri(canonicalUri.toString());
-
-  m_controller.start<ndn::nfd::FaceCreateCommand>(parameters,
-    [this] (const ndn::nfd::ControlParameters& result) { succeed(result.getFaceId()); },
-    bind(&FaceIdFetcher::onFaceCreateError, this, _1, "Face creation failed"));
-}
-
-void
-FaceIdFetcher::succeed(uint32_t faceId)
-{
-  m_onSucceed(faceId);
-  delete this;
-}
-
-void
-FaceIdFetcher::fail(const std::string& reason)
-{
-  m_onFail(reason);
-  delete this;
-}
-
-} // namespace nfdc
-} // namespace tools
-} // namespace nfd
diff --git a/tools/nfdc/face-id-fetcher.hpp b/tools/nfdc/face-id-fetcher.hpp
deleted file mode 100644
index 5e45b7b..0000000
--- a/tools/nfdc/face-id-fetcher.hpp
+++ /dev/null
@@ -1,108 +0,0 @@
-/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/*
- * Copyright (c) 2014-2017,  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_TOOLS_NFDC_FACE_ID_FETCHER_HPP
-#define NFD_TOOLS_NFDC_FACE_ID_FETCHER_HPP
-
-#include "core/common.hpp"
-#include <ndn-cxx/face.hpp>
-#include <ndn-cxx/mgmt/nfd/controller.hpp>
-
-namespace nfd {
-namespace tools {
-namespace nfdc {
-
-class FaceIdFetcher
-{
-public:
-  typedef std::function<void(uint32_t)> SuccessCallback;
-  typedef std::function<void(const std::string&)> FailureCallback;
-
-  /** \brief obtain FaceId from input
-   *  \param face Reference to the Face that should be used to fetch data
-   *  \param controller Reference to the controller that should be used to sign the Interest
-   *  \param input User input, either FaceId or FaceUri
-   *  \param allowCreate Whether creating face is allowed
-   *  \param onSucceed Callback to be fired when faceId is obtained
-   *  \param onFail Callback to be fired when an error occurs
-   */
-  static void
-  start(ndn::Face& face,
-        ndn::nfd::Controller& controller,
-        const std::string& input,
-        bool allowCreate,
-        const SuccessCallback& onSucceed,
-        const FailureCallback& onFail);
-
-private:
-  FaceIdFetcher(ndn::Face& face,
-                ndn::nfd::Controller& controller,
-                bool allowCreate,
-                const SuccessCallback& onSucceed,
-                const FailureCallback& onFail);
-
-  void
-  onQuerySuccess(const ndn::ConstBufferPtr& data,
-                 const FaceUri& canonicalUri);
-
-  void
-  onQueryFailure(uint32_t errorCode,
-                 const FaceUri& canonicalUri);
-
-  void
-  onCanonizeSuccess(const FaceUri& canonicalUri);
-
-  void
-  onCanonizeFailure(const std::string& reason);
-
-  void
-  startGetFaceId(const FaceUri& faceUri);
-
-  void
-  startFaceCreate(const FaceUri& canonicalUri);
-
-  void
-  onFaceCreateError(const ndn::nfd::ControlResponse& response,
-                    const std::string& message);
-
-  void
-  succeed(uint32_t faceId);
-
-  void
-  fail(const std::string& reason);
-
-private:
-  ndn::Face& m_face;
-  ndn::nfd::Controller& m_controller;
-  bool m_allowCreate;
-  SuccessCallback m_onSucceed;
-  FailureCallback m_onFail;
-};
-
-} // namespace nfdc
-} // namespace tools
-} // namespace nfd
-
-#endif // NFD_TOOLS_NFDC_FACE_ID_FETCHER_HPP
diff --git a/tools/nfdc/legacy-nfdc.cpp b/tools/nfdc/legacy-nfdc.cpp
deleted file mode 100644
index e0e6bcd..0000000
--- a/tools/nfdc/legacy-nfdc.cpp
+++ /dev/null
@@ -1,405 +0,0 @@
-/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/**
- * Copyright (c) 2014-2017,  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 "legacy-nfdc.hpp"
-#include "face-id-fetcher.hpp"
-
-#include <boost/program_options.hpp>
-#include <boost/regex.hpp>
-
-namespace nfd {
-namespace tools {
-namespace nfdc {
-
-using ndn::nfd::ControlParameters;
-
-const time::milliseconds LegacyNfdc::DEFAULT_EXPIRATION_PERIOD = time::milliseconds::max();
-const uint64_t LegacyNfdc::DEFAULT_COST = 0;
-
-LegacyNfdc::LegacyNfdc(Face& face, KeyChain& keyChain)
-  : m_flags(ndn::nfd::ROUTE_FLAG_CHILD_INHERIT)
-  , m_cost(DEFAULT_COST)
-  , m_origin(ndn::nfd::ROUTE_ORIGIN_STATIC)
-  , m_expires(DEFAULT_EXPIRATION_PERIOD)
-  , m_facePersistency(ndn::nfd::FACE_PERSISTENCY_PERSISTENT)
-  , m_face(face)
-  , m_controller(face, keyChain)
-{
-}
-
-bool
-LegacyNfdc::dispatch(const std::string& command)
-{
-  if (command == "add-nexthop") {
-    if (m_commandLineArguments.size() != 2)
-      return false;
-    fibAddNextHop();
-  }
-  else if (command == "remove-nexthop") {
-    if (m_commandLineArguments.size() != 2)
-      return false;
-    fibRemoveNextHop();
-  }
-  else if (command == "register") {
-    if (m_commandLineArguments.size() != 2)
-      return false;
-    ribRegisterPrefix();
-  }
-  else if (command == "unregister") {
-    if (m_commandLineArguments.size() != 2)
-      return false;
-    ribUnregisterPrefix();
-  }
-  else if (command == "create") {
-    if (m_commandLineArguments.size() != 1)
-      return false;
-    faceCreate();
-  }
-  else if (command == "destroy") {
-    if (m_commandLineArguments.size() != 1)
-      return false;
-    faceDestroy();
-  }
-  else if (command == "set-strategy") {
-    if (m_commandLineArguments.size() != 2)
-      return false;
-    strategyChoiceSet();
-  }
-  else if (command == "unset-strategy") {
-    if (m_commandLineArguments.size() != 1)
-      return false;
-    strategyChoiceUnset();
-  }
-  else
-    return false;
-
-  return true;
-}
-
-void
-LegacyNfdc::fibAddNextHop()
-{
-  m_name = m_commandLineArguments[0];
-  const std::string& faceName = m_commandLineArguments[1];
-
-  FaceIdFetcher::start(m_face, m_controller, faceName, true,
-    [this] (const uint32_t faceId) {
-      ControlParameters parameters;
-      parameters
-        .setName(m_name)
-        .setCost(m_cost)
-        .setFaceId(faceId);
-
-      m_controller.start<ndn::nfd::FibAddNextHopCommand>(parameters,
-        bind(&LegacyNfdc::onSuccess, this, _1, "Nexthop insertion succeeded"),
-        bind(&LegacyNfdc::onError, this, _1, "Nexthop insertion failed"));
-    },
-    bind(&LegacyNfdc::onObtainFaceIdFailure, this, _1));
-}
-
-void
-LegacyNfdc::fibRemoveNextHop()
-{
-  m_name = m_commandLineArguments[0];
-  const std::string& faceName = m_commandLineArguments[1];
-
-  FaceIdFetcher::start(m_face, m_controller, faceName, false,
-    [this] (const uint32_t faceId) {
-      ControlParameters parameters;
-      parameters
-        .setName(m_name)
-        .setFaceId(faceId);
-
-      m_controller.start<ndn::nfd::FibRemoveNextHopCommand>(parameters,
-        bind(&LegacyNfdc::onSuccess, this, _1, "Nexthop removal succeeded"),
-        bind(&LegacyNfdc::onError, this, _1, "Nexthop removal failed"));
-    },
-    bind(&LegacyNfdc::onObtainFaceIdFailure, this, _1));
-}
-
-void
-LegacyNfdc::ribRegisterPrefix()
-{
-  m_name = m_commandLineArguments[0];
-  const std::string& faceName = m_commandLineArguments[1];
-
-  FaceIdFetcher::start(m_face, m_controller, faceName, true,
-    [this] (const uint32_t faceId) {
-      ControlParameters parameters;
-      parameters
-        .setName(m_name)
-        .setCost(m_cost)
-        .setFlags(m_flags)
-        .setOrigin(m_origin)
-        .setFaceId(faceId);
-
-      if (m_expires != DEFAULT_EXPIRATION_PERIOD)
-        parameters.setExpirationPeriod(m_expires);
-
-      m_controller.start<ndn::nfd::RibRegisterCommand>(parameters,
-        bind(&LegacyNfdc::onSuccess, this, _1, "Successful in name registration"),
-        bind(&LegacyNfdc::onError, this, _1, "Failed in name registration"));
-    },
-    bind(&LegacyNfdc::onObtainFaceIdFailure, this, _1));
-}
-
-void
-LegacyNfdc::ribUnregisterPrefix()
-{
-  m_name = m_commandLineArguments[0];
-  const std::string& faceName = m_commandLineArguments[1];
-
-  FaceIdFetcher::start(m_face, m_controller, faceName, false,
-    [this] (const uint32_t faceId) {
-      ControlParameters parameters;
-      parameters
-        .setName(m_name)
-        .setFaceId(faceId)
-        .setOrigin(m_origin);
-
-      m_controller.start<ndn::nfd::RibUnregisterCommand>(parameters,
-        bind(&LegacyNfdc::onSuccess, this, _1, "Successful in unregistering name"),
-        bind(&LegacyNfdc::onError, this, _1, "Failed in unregistering name"));
-    },
-    bind(&LegacyNfdc::onObtainFaceIdFailure, this, _1));
-}
-
-void
-LegacyNfdc::onCanonizeFailure(const std::string& reason)
-{
-  BOOST_THROW_EXCEPTION(Error(reason));
-}
-
-void
-LegacyNfdc::onObtainFaceIdFailure(const std::string& message)
-{
-  BOOST_THROW_EXCEPTION(Error(message));
-}
-
-void
-LegacyNfdc::faceCreate()
-{
-  boost::regex e("^[a-z0-9]+\\:.*");
-  if (!boost::regex_match(m_commandLineArguments[0], e))
-    BOOST_THROW_EXCEPTION(Error("invalid uri format"));
-
-  FaceUri faceUri;
-  faceUri.parse(m_commandLineArguments[0]);
-
-  faceUri.canonize(bind(&LegacyNfdc::startFaceCreate, this, _1),
-                   bind(&LegacyNfdc::onCanonizeFailure, this, _1),
-                   m_face.getIoService(), time::seconds(4));
-}
-
-void
-LegacyNfdc::startFaceCreate(const FaceUri& canonicalUri)
-{
-  ControlParameters parameters;
-  parameters.setUri(canonicalUri.toString());
-  parameters.setFacePersistency(m_facePersistency);
-
-  m_controller.start<ndn::nfd::FaceCreateCommand>(parameters,
-    bind(&LegacyNfdc::onSuccess, this, _1, "Face creation succeeded"),
-    bind(&LegacyNfdc::onError, this, _1, "Face creation failed"));
-}
-
-void
-LegacyNfdc::faceDestroy()
-{
-  ControlParameters parameters;
-  const std::string& faceName = m_commandLineArguments[0];
-
-  FaceIdFetcher::start(m_face, m_controller, faceName, false,
-    [this] (const uint32_t faceId) {
-      ControlParameters faceParameters;
-      faceParameters.setFaceId(faceId);
-
-      m_controller.start<ndn::nfd::FaceDestroyCommand>(faceParameters,
-        bind(&LegacyNfdc::onSuccess, this, _1, "Face destroy succeeded"),
-        bind(&LegacyNfdc::onError, this, _1, "Face destroy failed"));
-    },
-    bind(&LegacyNfdc::onObtainFaceIdFailure, this, _1));
-}
-
-void
-LegacyNfdc::strategyChoiceSet()
-{
-  const std::string& name = m_commandLineArguments[0];
-  const std::string& strategy = m_commandLineArguments[1];
-
-  ControlParameters parameters;
-  parameters
-    .setName(name)
-    .setStrategy(strategy);
-
-  m_controller.start<ndn::nfd::StrategyChoiceSetCommand>(parameters,
-    bind(&LegacyNfdc::onSuccess, this, _1, "Successfully set strategy choice"),
-    bind(&LegacyNfdc::onError, this, _1, "Failed to set strategy choice"));
-}
-
-void
-LegacyNfdc::strategyChoiceUnset()
-{
-  const std::string& name = m_commandLineArguments[0];
-
-  ControlParameters parameters;
-  parameters.setName(name);
-
-  m_controller.start<ndn::nfd::StrategyChoiceUnsetCommand>(parameters,
-    bind(&LegacyNfdc::onSuccess, this, _1, "Successfully unset strategy choice"),
-    bind(&LegacyNfdc::onError, this, _1, "Failed to unset strategy choice"));
-}
-
-void
-LegacyNfdc::onSuccess(const ControlParameters& commandSuccessResult, const std::string& message)
-{
-  std::cout << message << ": " << commandSuccessResult << std::endl;
-}
-
-void
-LegacyNfdc::onError(const ndn::nfd::ControlResponse& response, const std::string& message)
-{
-  std::ostringstream os;
-  os << message << ": " << response.getText() << " (code: " << response.getCode() << ")";
-  BOOST_THROW_EXCEPTION(Error(os.str()));
-}
-
-void
-legacyNfdcUsage()
-{
-  std::cout << "Usage:\n"
-    "nfdc [-h] [-V] COMMAND [<Command Options>]\n"
-    "       -h print usage and exit\n"
-    "       -V print version and exit\n"
-    "\n"
-    "   COMMAND can be one of the following:\n"
-    "       register [-I] [-C] [-c cost] [-e expiration time] [-o origin] name <faceId | faceUri>\n"
-    "           register name to the given faceId or faceUri\n"
-    "           -I: unset CHILD_INHERIT flag\n"
-    "           -C: set CAPTURE flag\n"
-    "           -c: specify cost (default 0)\n"
-    "           -e: specify expiration time in ms\n"
-    "               (by default the entry remains in FIB for the lifetime of the associated face)\n"
-    "           -o: specify origin\n"
-    "               0 for Local producer applications, 128 for NLSR, 255(default) for static routes\n"
-    "       unregister [-o origin] name <faceId | faceUri>\n"
-    "           unregister name from the given faceId\n"
-    "       create [-P] <faceUri> \n"
-    "           Create a face in one of the following formats:\n"
-    "           UDP unicast:    udp[4|6]://<remote-IP-or-host>[:<remote-port>]\n"
-    "           TCP:            tcp[4|6]://<remote-IP-or-host>[:<remote-port>] \n"
-    "           -P: create permanent (instead of persistent) face\n"
-    "       destroy <faceId | faceUri> \n"
-    "           Destroy a face\n"
-    "       set-strategy <name> <strategy> \n"
-    "           Set the strategy for a namespace \n"
-    "       unset-strategy <name> \n"
-    "           Unset the strategy for a namespace \n"
-    "       add-nexthop [-c <cost>] <name> <faceId | faceUri>\n"
-    "           Add a nexthop to a FIB entry\n"
-    "           -c: specify cost (default 0)\n"
-    "       remove-nexthop <name> <faceId | faceUri> \n"
-    "           Remove a nexthop from a FIB entry\n"
-    << std::endl;
-}
-
-void
-legacyNfdcMain(ExecuteContext& ctx, const std::string& replacementCommand)
-{
-  if (!replacementCommand.empty()) {
-    std::cerr << "'nfdc " << ctx.noun << "' command is deprecated. "
-              << "Use 'nfdc " << replacementCommand << "' instead.\n";
-  }
-
-  LegacyNfdc p(ctx.face, ctx.keyChain);
-
-  const std::string& subcommand = ctx.noun;
-  auto args = ctx.args.get<std::vector<std::string>>("args");
-  bool wantUnsetChildInherit = false;
-  bool wantCapture = false;
-  bool wantPermanentFace = false;
-  int64_t expires = -1;
-  std::underlying_type<ndn::nfd::RouteOrigin>::type origin = ndn::nfd::ROUTE_ORIGIN_STATIC;
-
-  namespace po = boost::program_options;
-  po::options_description options;
-  options.add_options()
-    (",I", po::bool_switch(&wantUnsetChildInherit))
-    (",C", po::bool_switch(&wantCapture))
-    (",c", po::value<uint64_t>(&p.m_cost))
-    (",e", po::value<int64_t>(&expires))
-    (",o", po::value<std::underlying_type<ndn::nfd::RouteOrigin>::type>(&origin))
-    (",P", po::bool_switch(&wantPermanentFace));
-  po::variables_map vm;
-  std::vector<std::string> unparsed;
-  try {
-    po::parsed_options parsed = po::command_line_parser(args).options(options).allow_unregistered().run();
-    unparsed = po::collect_unrecognized(parsed.options, po::include_positional);
-    po::store(parsed, vm);
-    po::notify(vm);
-  }
-  catch (const po::error& e) {
-    std::cerr << e.what() << std::endl;
-    legacyNfdcUsage();
-    ctx.exitCode = 2;
-    return;
-  }
-
-  if (wantUnsetChildInherit) {
-    p.m_flags &= ~(ndn::nfd::ROUTE_FLAG_CHILD_INHERIT);
-  }
-  if (wantCapture) {
-    p.m_flags |= ndn::nfd::ROUTE_FLAG_CAPTURE;
-  }
-  if (expires >= 0) {
-    // accept negative values as no expiration
-    p.m_expires = time::milliseconds(expires);
-  }
-  p.m_origin = static_cast<ndn::nfd::RouteOrigin>(origin);
-  if (wantPermanentFace) {
-    p.m_facePersistency = ndn::nfd::FACE_PERSISTENCY_PERMANENT;
-  }
-
-  if (std::any_of(unparsed.begin(), unparsed.end(),
-      [] (const std::string& s) { return s.empty() || s[0] == '-'; })) {
-    // unrecognized -option
-    legacyNfdcUsage();
-    ctx.exitCode = 2;
-    return;
-  }
-  p.m_commandLineArguments = unparsed;
-
-  bool isOk = p.dispatch(subcommand);
-  if (!isOk) {
-    legacyNfdcUsage();
-    ctx.exitCode = 2;
-    return;
-  }
-  ctx.face.processEvents();
-}
-
-} // namespace nfdc
-} // namespace tools
-} // namespace nfd
diff --git a/tools/nfdc/legacy-nfdc.hpp b/tools/nfdc/legacy-nfdc.hpp
deleted file mode 100644
index 782c255..0000000
--- a/tools/nfdc/legacy-nfdc.hpp
+++ /dev/null
@@ -1,185 +0,0 @@
-/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/**
- * Copyright (c) 2014-2017,  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_TOOLS_NFDC_LEGACY_NFDC_HPP
-#define NFD_TOOLS_NFDC_LEGACY_NFDC_HPP
-
-#include "execute-command.hpp"
-
-#include <ndn-cxx/encoding/nfd-constants.hpp>
-#include <ndn-cxx/mgmt/nfd/controller.hpp>
-
-namespace nfd {
-namespace tools {
-namespace nfdc {
-
-class LegacyNfdc : noncopyable
-{
-public:
-  static const time::milliseconds DEFAULT_EXPIRATION_PERIOD;
-  static const uint64_t DEFAULT_COST;
-
-  class Error : public std::runtime_error
-  {
-  public:
-    explicit
-    Error(const std::string& what)
-      : std::runtime_error(what)
-    {
-    }
-  };
-
-  LegacyNfdc(Face& face, KeyChain& keyChain);
-
-  bool
-  dispatch(const std::string& cmd);
-
-  /**
-   * \brief Adds a nexthop to a FIB entry
-   *
-   * If the FIB entry does not exist, it is inserted automatically
-   *
-   * cmd format:
-   *  [-c cost]  name faceId|faceUri
-   *
-   */
-  void
-  fibAddNextHop();
-
-  /**
-   * \brief Removes a nexthop from an existing FIB entry
-   *
-   * If the last nexthop record in a FIB entry is removed, the FIB entry is also deleted
-   *
-   * cmd format:
-   *  name faceId
-   *
-   */
-  void
-  fibRemoveNextHop();
-
-  /**
-   * \brief Registers name to the given faceId or faceUri
-   *
-   * cmd format:
-   *  [-I] [-C] [-c cost] name faceId|faceUri
-   */
-  void
-  ribRegisterPrefix();
-
-  /**
-   * \brief Unregisters name from the given faceId/faceUri
-   *
-   * cmd format:
-   *  name faceId/faceUri
-   */
-  void
-  ribUnregisterPrefix();
-
-  /**
-   * \brief Creates new face
-   *
-   * This command allows creation of UDP unicast and TCP faces only
-   *
-   * cmd format:
-   *  uri
-   *
-   */
-  void
-  faceCreate();
-
-  /**
-   * \brief Destroys face
-   *
-   * cmd format:
-   *  faceId|faceUri
-   *
-   */
-  void
-  faceDestroy();
-
-  /**
-   * \brief Sets the strategy for a namespace
-   *
-   * cmd format:
-   *  name strategy
-   *
-   */
-  void
-  strategyChoiceSet();
-
-  /**
-   * \brief Unset the strategy for a namespace
-   *
-   * cmd format:
-   *  name strategy
-   *
-   */
-  void
-  strategyChoiceUnset();
-
-private:
-  void
-  onSuccess(const ndn::nfd::ControlParameters& commandSuccessResult,
-            const std::string& message);
-
-  void
-  onError(const ndn::nfd::ControlResponse& response, const std::string& message);
-
-  void
-  onCanonizeFailure(const std::string& reason);
-
-  void
-  startFaceCreate(const FaceUri& canonicalUri);
-
-  void
-  onObtainFaceIdFailure(const std::string& message);
-
-public:
-  std::vector<std::string> m_commandLineArguments; // positional arguments
-  uint64_t m_flags;
-  uint64_t m_cost;
-  uint64_t m_faceId;
-  ndn::nfd::RouteOrigin m_origin;
-  time::milliseconds m_expires;
-  std::string m_name;
-  ndn::nfd::FacePersistency m_facePersistency;
-
-private:
-  Face& m_face;
-  ndn::nfd::Controller m_controller;
-};
-
-void
-legacyNfdcUsage();
-
-void
-legacyNfdcMain(ExecuteContext& ctx, const std::string& replacementCommand);
-
-} // namespace nfdc
-} // namespace tools
-} // namespace nfd
-
-#endif // NFD_TOOLS_NFDC_LEGACY_NFDC_HPP
diff --git a/tools/nfdc/legacy-status.cpp b/tools/nfdc/legacy-status.cpp
deleted file mode 100644
index a61defd..0000000
--- a/tools/nfdc/legacy-status.cpp
+++ /dev/null
@@ -1,126 +0,0 @@
-/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/**
- * Copyright (c) 2014-2017,  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 "legacy-status.hpp"
-#include "core/version.hpp"
-
-#include <boost/program_options.hpp>
-
-namespace nfd {
-namespace tools {
-namespace nfdc {
-
-static void
-showUsage(std::ostream& os, const boost::program_options::options_description& cmdOptions)
-{
-  os << "Usage: nfd-status [options]\n\n"
-     << "Show NFD version and status information.\n\n"
-     << cmdOptions;
-}
-
-/** \brief parse legacy nfd-status command line, and show usage if necessary
- *  \return if first item is -1, caller should retrieve and display StatusReport;
- *          otherwise, caller should immediately exit with the specified exit code
- */
-static std::tuple<int, StatusReportOptions>
-parseCommandLine(ExecuteContext& ctx, const std::vector<std::string>& args)
-{
-  StatusReportOptions options;
-
-  namespace po = boost::program_options;
-  po::options_description cmdOptions("StatusReportOptions");
-  cmdOptions.add_options()
-    ("help,h", "print this help message")
-    ("version,V", "show program version")
-    ("general,v", po::bool_switch(&options.wantForwarderGeneral), "show general status")
-    ("channels,c", po::bool_switch(&options.wantChannels), "show channels")
-    ("faces,f", po::bool_switch(&options.wantFaces), "show faces")
-    ("fib,b", po::bool_switch(&options.wantFib), "show FIB entries")
-    ("rib,r", po::bool_switch(&options.wantRib), "show RIB routes")
-    ("sc,s", po::bool_switch(&options.wantStrategyChoice), "show strategy choice entries")
-    ("xml,x", "output as XML instead of text (implies -vcfbrs)");
-  po::variables_map vm;
-  try {
-    po::store(po::command_line_parser(args).options(cmdOptions).run(), vm);
-    po::notify(vm);
-  }
-  catch (const po::error& e) {
-    ctx.err << e.what() << "\n";
-    showUsage(ctx.err, cmdOptions);
-    return std::make_tuple(2, options);
-  }
-
-  if (vm.count("help") > 0) {
-    showUsage(ctx.out, cmdOptions);
-    return std::make_tuple(0, options);
-  }
-  if (vm.count("version") > 0) {
-    ctx.out << "nfd-status " << NFD_VERSION_BUILD_STRING << "\n";
-    return std::make_tuple(0, options);
-  }
-
-  if (vm.count("xml") > 0) {
-    options.output = ReportFormat::XML;
-  }
-  if (options.output == ReportFormat::XML ||
-      (!options.wantForwarderGeneral && !options.wantChannels && !options.wantFaces &&
-       !options.wantFib && !options.wantRib && !options.wantStrategyChoice)) {
-    options.wantForwarderGeneral = options.wantChannels = options.wantFaces =
-      options.wantFib = options.wantRib = options.wantStrategyChoice = true;
-  }
-
-  return std::make_tuple(-1, options);
-}
-
-/** \brief the 'legacy-nfd-status' command
- */
-static void
-legacyNfdStatus(ExecuteContext& ctx)
-{
-  auto args = ctx.args.get<std::vector<std::string>>("args");
-
-  int exitCode = -1;
-  StatusReportOptions options;
-  std::tie(exitCode, options) = parseCommandLine(ctx, args);
-  if (exitCode >= 0) {
-    ctx.exitCode = exitCode;
-    return;
-  }
-
-  reportStatus(ctx, options);
-}
-
-void
-registerLegacyStatusCommand(CommandParser& parser)
-{
-  CommandDefinition defLegacyNfdStatus("legacy-nfd-status", "");
-  defLegacyNfdStatus
-    .addArg("args", ArgValueType::ANY, Required::NO, Positional::YES);
-  parser.addCommand(defLegacyNfdStatus, &legacyNfdStatus, AVAILABLE_IN_ALL & ~AVAILABLE_IN_HELP);
-}
-
-} // namespace nfdc
-} // namespace tools
-} // namespace nfd
diff --git a/tools/nfdc/legacy-status.hpp b/tools/nfdc/legacy-status.hpp
deleted file mode 100644
index e200292..0000000
--- a/tools/nfdc/legacy-status.hpp
+++ /dev/null
@@ -1,44 +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/>.
- */
-
-#ifndef NFD_TOOLS_NFDC_LEGACY_STATUS_HPP
-#define NFD_TOOLS_NFDC_LEGACY_STATUS_HPP
-
-#include "status.hpp"
-
-namespace nfd {
-namespace tools {
-namespace nfdc {
-
-/** \brief registers 'legacy-nfd-status' command
- */
-void
-registerLegacyStatusCommand(CommandParser& parser);
-
-} // namespace nfdc
-} // namespace tools
-} // namespace nfd
-
-#endif // NFD_TOOLS_NFDC_LEGACY_STATUS_HPP
