diff --git a/rib/service.cpp b/rib/service.cpp
new file mode 100644
index 0000000..3b3798f
--- /dev/null
+++ b/rib/service.cpp
@@ -0,0 +1,152 @@
+/* -*- 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 "service.hpp"
+
+#include "rib-manager.hpp"
+#include "core/config-file.hpp"
+#include "core/logger-factory.hpp"
+#include "core/global-io.hpp"
+
+#include <boost/property_tree/info_parser.hpp>
+
+#include <ndn-cxx/transport/unix-transport.hpp>
+#include <ndn-cxx/transport/tcp-transport.hpp>
+
+namespace nfd {
+namespace rib {
+
+static const std::string INTERNAL_CONFIG = "internal://nfd.conf";
+
+Service::Service(const std::string& configFile, ndn::KeyChain& keyChain)
+  : m_configFile(configFile)
+  , m_keyChain(keyChain)
+{
+}
+
+Service::Service(const ConfigSection& config, ndn::KeyChain& keyChain)
+  : m_configSection(config)
+  , m_keyChain(keyChain)
+{
+}
+
+Service::~Service()
+{
+  // It is necessary to explicitly define the destructor, because some member variables
+  // (e.g., unique_ptr<RibManager>) are forward-declared, but implicitly declared destructor
+  // requires complete types for all members when instantiated.
+}
+
+void
+Service::initialize()
+{
+  m_face.reset(new ndn::Face(getLocalNfdTransport(), getGlobalIoService(), m_keyChain));
+  m_dispatcher.reset(new ndn::mgmt::Dispatcher(*m_face, m_keyChain));
+
+  initializeLogging();
+
+  m_ribManager.reset(new RibManager(*m_dispatcher, *m_face, m_keyChain));
+
+  ConfigFile config([] (const std::string& filename, const std::string& sectionName,
+                        const ConfigSection& section, bool isDryRun) {
+      // Ignore "log" and sections belonging to NFD,
+      // but raise an error if we're missing a handler for a "rib" section.
+      if (sectionName != "rib" || sectionName == "log") {
+        // do nothing
+      }
+      else {
+        // missing "rib" section handler
+        ConfigFile::throwErrorOnUnknownSection(filename, sectionName, section, isDryRun);
+      }
+    });
+  m_ribManager->setConfigFile(config);
+
+  // parse config file
+  if (!m_configFile.empty()) {
+    config.parse(m_configFile, true);
+    config.parse(m_configFile, false);
+  }
+  else {
+    config.parse(m_configSection, true, INTERNAL_CONFIG);
+    config.parse(m_configSection, false, INTERNAL_CONFIG);
+  }
+
+  m_ribManager->registerWithNfd();
+  m_ribManager->enableLocalControlHeader();
+}
+
+void
+Service::initializeLogging()
+{
+  ConfigFile config(&ConfigFile::ignoreUnknownSection);
+  LoggerFactory::getInstance().setConfigFile(config);
+
+  if (!m_configFile.empty()) {
+    config.parse(m_configFile, true);
+    config.parse(m_configFile, false);
+  }
+  else {
+    config.parse(m_configSection, true, INTERNAL_CONFIG);
+    config.parse(m_configSection, false, INTERNAL_CONFIG);
+  }
+}
+
+shared_ptr<ndn::Transport>
+Service::getLocalNfdTransport()
+{
+  ConfigSection config;
+
+  if (!m_configFile.empty()) {
+    // Any format errors should have been caught already
+    // If error is thrown at this point, it is development error
+    boost::property_tree::read_info(m_configFile, config);
+  }
+  else
+    config = m_configSection;
+
+  if (config.get_child_optional("face_system.unix")) {
+    // unix socket enabled
+
+    auto&& socketPath = config.get<std::string>("face_system.unix.path", "/var/run/nfd.sock");
+    // default socketPath should be the same as in FaceManager::processSectionUnix
+
+    return make_shared<ndn::UnixTransport>(socketPath);
+  }
+  else if (config.get_child_optional("face_system.tcp") &&
+           config.get<std::string>("face_system.tcp.listen", "yes") == "yes") {
+    // tcp is enabled
+
+    auto&& port = config.get<std::string>("face_system.tcp.port", "6363");
+    // default port should be the same as in FaceManager::processSectionTcp
+
+    return make_shared<ndn::TcpTransport>("localhost", port);
+  }
+  else {
+    BOOST_THROW_EXCEPTION(Error("No transport is available to communicate with NFD"));
+  }
+}
+
+} // namespace rib
+} // namespace nfd
