diff --git a/src/repo-command-response.hpp b/src/repo-command-response.hpp
new file mode 100644
index 0000000..0eb4f1d
--- /dev/null
+++ b/src/repo-command-response.hpp
@@ -0,0 +1,397 @@
+/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
+/**
+ * Copyright (c) 2014,  Regents of the University of California.
+ *
+ * This file is part of NDN repo-ng (Next generation of NDN repository).
+ * See AUTHORS.md for complete list of repo-ng authors and contributors.
+ *
+ * repo-ng 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.
+ *
+ * repo-ng 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
+ * repo-ng, e.g., in COPYING.md file.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef REPO_REPO_COMMAND_RESPONSE_HPP
+#define REPO_REPO_COMMAND_RESPONSE_HPP
+
+#include <ndn-cxx/encoding/block.hpp>
+#include <ndn-cxx/encoding/encoding-buffer.hpp>
+#include <ndn-cxx/encoding/tlv-nfd.hpp>
+#include "repo-tlv.hpp"
+
+namespace repo {
+
+using ndn::Block;
+using ndn::EncodingImpl;
+using ndn::EncodingEstimator;
+using ndn::EncodingBuffer;
+
+/**
+* @brief Class defining abstraction of Response for NDN Repo Protocol
+* @sa link http://redmine.named-data.net/projects/repo-ng/wiki/Repo_Protocol_Specification#Repo-Command-Response
+*/
+class RepoCommandResponse
+{
+public:
+  class Error : public ndn::Tlv::Error
+  {
+  public:
+    explicit
+    Error(const std::string& what)
+      : ndn::Tlv::Error(what)
+    {
+    }
+  };
+
+  RepoCommandResponse()
+    : m_hasStartBlockId(false)
+    , m_hasEndBlockId(false)
+    , m_hasProcessId(false)
+    , m_hasInsertNum(false)
+    , m_hasDeleteNum(false)
+    , m_hasStatusCode(false)
+  {
+  }
+
+  explicit
+  RepoCommandResponse(const Block& block)
+  {
+    wireDecode(block);
+  }
+
+  uint64_t
+  getStartBlockId() const
+  {
+    return m_startBlockId;
+  }
+
+  RepoCommandResponse&
+  setStartBlockId(uint64_t startBlockId)
+  {
+    m_startBlockId  = startBlockId;
+    m_hasStartBlockId = true;
+    m_wire.reset();
+    return *this;
+  }
+
+  bool
+  hasStartBlockId() const
+  {
+    return m_hasStartBlockId;
+  }
+
+  uint64_t
+  getEndBlockId() const
+  {
+    assert(hasEndBlockId());
+    return m_endBlockId;
+  }
+
+  RepoCommandResponse&
+  setEndBlockId(uint64_t endBlockId)
+  {
+    m_endBlockId  = endBlockId;
+    m_hasEndBlockId = true;
+    m_wire.reset();
+    return *this;
+  }
+
+  bool
+  hasEndBlockId() const
+  {
+    return m_hasEndBlockId;
+  }
+
+
+  uint64_t
+  getProcessId() const
+  {
+    return m_processId;
+  }
+
+  RepoCommandResponse&
+  setProcessId(uint64_t processId)
+  {
+    m_processId  = processId;
+    m_hasProcessId = true;
+    m_wire.reset();
+    return *this;
+  }
+
+  bool
+  hasProcessId() const
+  {
+    return m_hasProcessId;
+  }
+
+  uint64_t
+  getStatusCode() const
+  {
+    return m_statusCode;
+  }
+
+  RepoCommandResponse&
+  setStatusCode(uint64_t statusCode)
+  {
+    m_statusCode  = statusCode;
+    m_hasStatusCode = true;
+    m_wire.reset();
+    return *this;
+  }
+
+  bool
+  hasStatusCode() const
+  {
+    return m_hasStatusCode;
+  }
+
+  uint64_t
+  getInsertNum() const
+  {
+    return m_insertNum;
+  }
+
+  RepoCommandResponse&
+  setInsertNum(uint64_t insertNum)
+  {
+    m_insertNum = insertNum;
+    m_hasInsertNum = true;
+    m_wire.reset();
+    return *this;
+  }
+
+  bool
+  hasInsertNum() const
+  {
+    return m_hasInsertNum;
+  }
+
+  uint64_t
+  getDeleteNum() const
+  {
+    return m_deleteNum;
+  }
+
+  RepoCommandResponse&
+  setDeleteNum(uint64_t deleteNum)
+  {
+    m_deleteNum = deleteNum;
+    m_hasDeleteNum = true;
+    m_wire.reset();
+    return *this;
+  }
+
+  bool
+  hasDeleteNum() const
+  {
+    return m_hasDeleteNum;
+  }
+
+  template<bool T>
+  size_t
+  wireEncode(EncodingImpl<T>& block) const;
+
+  const Block&
+  wireEncode() const;
+
+  void
+  wireDecode(const Block& wire);
+
+private:
+  uint64_t m_statusCode;
+  uint64_t m_startBlockId;
+  uint64_t m_endBlockId;
+  uint64_t m_processId;
+  uint64_t m_insertNum;
+  uint64_t m_deleteNum;
+
+  bool m_hasStartBlockId;
+  bool m_hasEndBlockId;
+  bool m_hasProcessId;
+  bool m_hasInsertNum;
+  bool m_hasDeleteNum;
+  bool m_hasStatusCode;
+
+  mutable Block m_wire;
+};
+
+template<bool T>
+inline size_t
+RepoCommandResponse::wireEncode(EncodingImpl<T>& encoder) const
+{
+  size_t totalLength = 0;
+  size_t variableLength = 0;
+
+  if (m_hasDeleteNum) {
+    variableLength = encoder.prependNonNegativeInteger(m_deleteNum);
+    totalLength += variableLength;
+    totalLength += encoder.prependVarNumber(variableLength);
+    totalLength += encoder.prependVarNumber(tlv::DeleteNum);
+  }
+
+  if (m_hasInsertNum) {
+    variableLength = encoder.prependNonNegativeInteger(m_insertNum);
+    totalLength += variableLength;
+    totalLength += encoder.prependVarNumber(variableLength);
+    totalLength += encoder.prependVarNumber(tlv::InsertNum);
+  }
+
+  if (m_hasEndBlockId) {
+    variableLength = encoder.prependNonNegativeInteger(m_endBlockId);
+    totalLength += variableLength;
+    totalLength += encoder.prependVarNumber(variableLength);
+    totalLength += encoder.prependVarNumber(tlv::EndBlockId);
+  }
+
+  if (m_hasStartBlockId) {
+    variableLength = encoder.prependNonNegativeInteger(m_startBlockId);
+    totalLength += variableLength;
+    totalLength += encoder.prependVarNumber(variableLength);
+    totalLength += encoder.prependVarNumber(repo::tlv::StartBlockId);
+  }
+
+  if (m_hasStatusCode) {
+    variableLength = encoder.prependNonNegativeInteger(m_statusCode);
+    totalLength += variableLength;
+    totalLength += encoder.prependVarNumber(variableLength);
+    totalLength += encoder.prependVarNumber(tlv::StatusCode);
+  } else {
+    throw Error("required field StatusCode is missing");
+  }
+
+  if (m_hasProcessId) {
+    variableLength = encoder.prependNonNegativeInteger(m_processId);
+    totalLength += variableLength;
+    totalLength += encoder.prependVarNumber(variableLength);
+    totalLength += encoder.prependVarNumber(tlv::ProcessId);
+  }
+
+  totalLength += encoder.prependVarNumber(totalLength);
+  totalLength += encoder.prependVarNumber(tlv::RepoCommandResponse);
+  return totalLength;
+}
+
+inline const Block&
+RepoCommandResponse::wireEncode() const
+{
+  if (m_wire.hasWire())
+    return m_wire;
+
+  EncodingEstimator estimator;
+  size_t estimatedSize = wireEncode(estimator);
+
+  EncodingBuffer buffer(estimatedSize, 0);
+  wireEncode(buffer);
+
+  m_wire = buffer.block();
+  return m_wire;
+}
+
+inline void
+RepoCommandResponse::wireDecode(const Block& wire)
+{
+  m_hasStartBlockId = false;
+  m_hasEndBlockId = false;
+  m_hasProcessId = false;
+  m_hasStatusCode = false;
+  m_hasInsertNum = false;
+  m_hasDeleteNum = false;
+
+  m_wire = wire;
+
+  m_wire.parse();
+
+  Block::element_const_iterator val;
+
+  if (m_wire.type() != tlv::RepoCommandResponse)
+    throw Error("RepoCommandResponse malformed");
+
+  // StartBlockId
+  val = m_wire.find(tlv::StartBlockId);
+  if (val != m_wire.elements_end())
+  {
+    m_hasStartBlockId = true;
+    m_startBlockId = readNonNegativeInteger(*val);
+  }
+
+  // EndBlockId
+  val = m_wire.find(tlv::EndBlockId);
+  if (val != m_wire.elements_end())
+  {
+    m_hasEndBlockId = true;
+    m_endBlockId = readNonNegativeInteger(*val);
+  }
+
+  // ProcessId
+  val = m_wire.find(tlv::ProcessId);
+  if (val != m_wire.elements_end())
+  {
+    m_hasProcessId = true;
+    m_processId = readNonNegativeInteger(*val);
+  }
+
+  // StatusCode
+  val = m_wire.find(tlv::StatusCode);
+  if (val != m_wire.elements_end())
+  {
+    m_hasStatusCode = true;
+    m_statusCode = readNonNegativeInteger(*val);
+
+  } else {
+    throw Error("required field StatusCode is missing");
+  }
+
+  // InsertNum
+  val = m_wire.find(tlv::InsertNum);
+  if (val != m_wire.elements_end())
+  {
+    m_hasInsertNum = true;
+    m_insertNum = readNonNegativeInteger(*val);
+  }
+
+  // DeleteNum
+  val = m_wire.find(tlv::DeleteNum);
+  if (val != m_wire.elements_end())
+  {
+    m_hasDeleteNum = true;
+    m_deleteNum = readNonNegativeInteger(*val);
+  }
+}
+
+inline std::ostream&
+operator<<(std::ostream& os, const RepoCommandResponse& repoCommandResponse)
+{
+  os << "RepoCommandResponse(";
+
+  if (repoCommandResponse.hasProcessId()) {
+    os << " ProcessId: " << repoCommandResponse.getProcessId();
+  }
+  if (repoCommandResponse.hasStatusCode()) {
+    os << " StatusCode: " << repoCommandResponse.getStatusCode();
+  }
+  if (repoCommandResponse.hasStartBlockId()) {
+    os << " StartBlockId: " << repoCommandResponse.getStartBlockId();
+  }
+  if (repoCommandResponse.hasEndBlockId()) {
+    os << " EndBlockId: " << repoCommandResponse.getEndBlockId();
+  }
+  if (repoCommandResponse.hasInsertNum()) {
+    os << " InsertNum: " << repoCommandResponse.getInsertNum();
+  }
+  if (repoCommandResponse.hasDeleteNum()) {
+    os << " DeleteNum: " << repoCommandResponse.getDeleteNum();
+
+  }
+  os << " )";
+  return os;
+}
+
+} // namespace repo
+
+#endif // REPO_REPO_COMMAND_RESPONSE_HPP
