diff --git a/daemon/face/ndnlp-parse.cpp b/daemon/face/ndnlp-parse.cpp
new file mode 100644
index 0000000..1162f0e
--- /dev/null
+++ b/daemon/face/ndnlp-parse.cpp
@@ -0,0 +1,68 @@
+/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
+/**
+ * Copyright (C) 2014 Named Data Networking Project
+ * See COPYING for copyright and distribution information.
+ */
+
+#include "ndnlp-parse.hpp"
+
+namespace nfd {
+namespace ndnlp {
+
+void
+NdnlpData::wireDecode(const Block& wire)
+{
+  if (wire.type() != tlv::NdnlpData) {
+    throw ParseError("top element is not NdnlpData");
+  }
+  wire.parse();
+  const Block::element_container& elements = wire.elements();
+  if (elements.size() < 2) {
+    throw ParseError("NdnlpData element has incorrect number of children");
+  }
+  
+  const Block& sequenceElement = elements.front();
+  if (sequenceElement.type() != tlv::NdnlpSequence) {
+    throw ParseError("NdnlpSequence element is missing");
+  }
+  if (sequenceElement.value_size() != sizeof(uint64_t)) {
+    throw ParseError("NdnlpSequence element has incorrect length");
+  }
+  m_seq = be64toh(*reinterpret_cast<const uint64_t*>(&*sequenceElement.value_begin()));
+  
+  const Block& payloadElement = elements.back();
+  if (payloadElement.type() != tlv::NdnlpPayload) {
+    throw ParseError("NdnlpPayload element is missing");
+  }
+  m_payload = payloadElement;
+
+  if (elements.size() == 2) { // single wire packet
+    m_fragIndex = 0;
+    m_fragCount = 1;
+    return;
+  }
+  if (elements.size() != 4) {
+    throw ParseError("NdnlpData element has incorrect number of children");
+  }
+  
+  const Block& fragIndexElement = elements.at(1);
+  if (fragIndexElement.type() != tlv::NdnlpFragIndex) {
+    throw ParseError("NdnlpFragIndex element is missing");
+  }
+  if (fragIndexElement.value_size() != sizeof(uint16_t)) {
+    throw ParseError("NdnlpFragIndex element has incorrect length");
+  }
+  m_fragIndex = be16toh(*reinterpret_cast<const uint16_t*>(&*fragIndexElement.value_begin()));
+  
+  const Block& fragCountElement = elements.at(2);
+  if (fragCountElement.type() != tlv::NdnlpFragCount) {
+    throw ParseError("NdnlpFragCount element is missing");
+  }
+  if (fragCountElement.value_size() != sizeof(uint16_t)) {
+    throw ParseError("NdnlpFragCount element has incorrect length");
+  }
+  m_fragCount = be16toh(*reinterpret_cast<const uint16_t*>(&*fragCountElement.value_begin()));
+}
+
+} // namespace ndnlp
+} // namespace nfd
diff --git a/daemon/face/ndnlp-parse.hpp b/daemon/face/ndnlp-parse.hpp
new file mode 100644
index 0000000..2790569
--- /dev/null
+++ b/daemon/face/ndnlp-parse.hpp
@@ -0,0 +1,52 @@
+/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
+/**
+ * Copyright (C) 2014 Named Data Networking Project
+ * See COPYING for copyright and distribution information.
+ */
+
+#ifndef NFD_FACE_NDNLP_PARSE_HPP
+#define NFD_FACE_NDNLP_PARSE_HPP
+
+#include "common.hpp"
+#include "ndnlp-tlv.hpp"
+
+namespace nfd {
+namespace ndnlp {
+
+struct ParseError : public std::runtime_error
+{
+  ParseError(const std::string& what)
+    : std::runtime_error(what)
+  {
+  }
+};
+
+/** \brief represents a NdnlpData packet
+ *  
+ *  NdnlpData ::= NDNLP-DATA-TYPE TLV-LENGTH
+ *                  NdnlpSequence
+ *                  NdnlpFragIndex?
+ *                  NdnlpFragCount?
+ *                  NdnlpPayload
+ */
+class NdnlpData
+{
+public:
+  /** \brief parse a NdnlpData packet
+   *  
+   *  \exception ParseError packet is malformated
+   */
+  void
+  wireDecode(const Block& wire);
+  
+public:
+  uint64_t m_seq;
+  uint16_t m_fragIndex;
+  uint16_t m_fragCount;
+  Block m_payload;
+};
+
+} // namespace ndnlp
+} // namespace nfd
+
+#endif // NFD_FACE_NDNLP_PARSE_HPP
diff --git a/daemon/face/ndnlp-partial-message-store.cpp b/daemon/face/ndnlp-partial-message-store.cpp
new file mode 100644
index 0000000..22b493b
--- /dev/null
+++ b/daemon/face/ndnlp-partial-message-store.cpp
@@ -0,0 +1,119 @@
+/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
+/**
+ * Copyright (C) 2014 Named Data Networking Project
+ * See COPYING for copyright and distribution information.
+ */
+
+#include "ndnlp-partial-message-store.hpp"
+
+namespace nfd {
+namespace ndnlp {
+
+PartialMessage::PartialMessage()
+  : m_fragCount(0)
+  , m_received(0)
+  , m_totalLength(0)
+{
+}
+
+bool
+PartialMessage::add(uint16_t fragIndex, uint16_t fragCount, const Block& payload)
+{
+  if (m_received == 0) { // first packet
+    m_fragCount = fragCount;
+    m_payloads.resize(fragCount);
+  }
+  
+  if (m_fragCount != fragCount || fragIndex >= m_fragCount) {
+    return false;
+  }
+  
+  if (!m_payloads[fragIndex].empty()) { // duplicate
+    return false;
+  }
+  
+  m_payloads[fragIndex] = payload;
+  ++m_received;
+  m_totalLength += payload.value_size();
+}
+
+bool
+PartialMessage::isComplete() const
+{
+  return m_received == m_fragCount;
+}
+
+Block
+PartialMessage::reassemble()
+{
+  BOOST_ASSERT(this->isComplete());
+  
+  ndn::BufferPtr buffer = make_shared<ndn::Buffer>(m_totalLength);
+  uint8_t* buf = buffer->get();
+  for (std::vector<Block>::const_iterator it = m_payloads.begin();
+       it != m_payloads.end(); ++it) {
+    const Block& payload = *it;
+    memcpy(buf, payload.value(), payload.value_size());
+    buf += payload.value_size();
+  }
+  
+  return Block(buffer);
+}
+
+PartialMessageStore::PartialMessageStore(Scheduler& scheduler, time::Duration idleDuration)
+  : m_scheduler(scheduler)
+  , m_idleDuration(idleDuration)
+{
+}
+
+PartialMessageStore::~PartialMessageStore()
+{
+}
+
+void
+PartialMessageStore::receiveNdnlpData(const Block& pkt)
+{
+  NdnlpData parsed;
+  parsed.wireDecode(pkt);
+  if (parsed.m_fragCount == 1) { // single fragment
+    this->onReceive(parsed.m_payload.blockFromValue());
+    return;
+  }
+  
+  uint64_t messageIdentifier = parsed.m_seq - parsed.m_fragIndex;
+  shared_ptr<PartialMessage> pm = m_partialMessages[messageIdentifier];
+  if (!static_cast<bool>(pm)) {
+    m_partialMessages[messageIdentifier] = pm = make_shared<PartialMessage>();
+  }
+  this->scheduleCleanup(messageIdentifier, pm);
+  
+  pm->add(parsed.m_fragIndex, parsed.m_fragCount, parsed.m_payload);
+  if (pm->isComplete()) {
+    this->onReceive(pm->reassemble());
+    this->cleanup(messageIdentifier);
+  }
+}
+
+void
+PartialMessageStore::scheduleCleanup(uint64_t messageIdentifier,
+                                     shared_ptr<PartialMessage> partialMessage)
+{
+  partialMessage->m_expiry = m_scheduler.scheduleEvent(m_idleDuration,
+    bind(&PartialMessageStore::cleanup, this, messageIdentifier));
+}
+
+void
+PartialMessageStore::cleanup(uint64_t messageIdentifier)
+{
+  std::map<uint64_t, shared_ptr<PartialMessage> >::iterator it =
+    m_partialMessages.find(messageIdentifier);
+  if (it == m_partialMessages.end()) {
+    return;
+  }
+  
+  m_scheduler.cancelEvent(it->second->m_expiry);
+  m_partialMessages.erase(it);
+}
+
+} // namespace ndnlp
+} // namespace nfd
diff --git a/daemon/face/ndnlp-partial-message-store.hpp b/daemon/face/ndnlp-partial-message-store.hpp
new file mode 100644
index 0000000..954b79a
--- /dev/null
+++ b/daemon/face/ndnlp-partial-message-store.hpp
@@ -0,0 +1,89 @@
+/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
+/**
+ * Copyright (C) 2014 Named Data Networking Project
+ * See COPYING for copyright and distribution information.
+ */
+
+#ifndef NFD_FACE_NDNLP_PARTIAL_MESSAGE_STORE_HPP
+#define NFD_FACE_NDNLP_PARTIAL_MESSAGE_STORE_HPP
+
+#include "ndnlp-parse.hpp"
+#include "core/event-emitter.hpp"
+#include "core/scheduler.hpp"
+
+namespace nfd {
+namespace ndnlp {
+
+/** \brief represents a partially received message
+ */
+class PartialMessage : noncopyable
+{
+public:
+  PartialMessage();
+  
+  bool
+  add(uint16_t fragIndex, uint16_t fragCount, const Block& payload);
+  
+  bool
+  isComplete() const;
+  
+  /** \brief reassemble network layer packet
+   *  
+   *  isComplete() must be true before calling this method
+   *  
+   *  \exception ndn::Block::Error packet is malformated
+   *  \return network layer packet
+   */
+  Block
+  reassemble();
+  
+public:
+  EventId m_expiry;
+  
+private:
+  size_t m_fragCount;
+  size_t m_received;
+  std::vector<Block> m_payloads;
+  size_t m_totalLength;
+};
+
+/** \brief provides reassembly feature at receiver
+ */
+class PartialMessageStore : noncopyable
+{
+public:
+  PartialMessageStore(Scheduler& scheduler,
+    time::Duration idleDuration = time::milliseconds(100));
+  
+  virtual
+  ~PartialMessageStore();
+  
+  /** \brief receive a NdnlpData packet
+   *  
+   *  \exception ParseError NDNLP packet is malformated
+   *  \exception ndn::Block::Error network layer packet is malformated
+   */
+  void
+  receiveNdnlpData(const Block& pkt);
+  
+  /// fires when network layer packet is received
+  EventEmitter<Block> onReceive;
+  
+private:
+  void
+  scheduleCleanup(uint64_t messageIdentifier, shared_ptr<PartialMessage> partialMessage);
+  
+  void
+  cleanup(uint64_t messageIdentifier);
+  
+private:
+  std::map<uint64_t, shared_ptr<PartialMessage> > m_partialMessages;
+
+  Scheduler& m_scheduler;
+  time::Duration m_idleDuration;
+};
+
+} // namespace ndnlp
+} // namespace nfd
+
+#endif // NFD_FACE_NDNLP_PARTIAL_MESSAGE_STORE_HPP
diff --git a/tests/face/ndnlp.cpp b/tests/face/ndnlp.cpp
index f3b8ab6..1160cf3 100644
--- a/tests/face/ndnlp.cpp
+++ b/tests/face/ndnlp.cpp
@@ -6,6 +6,7 @@
 
 #include "face/ndnlp-sequence-generator.hpp"
 #include "face/ndnlp-slicer.hpp"
+#include "face/ndnlp-partial-message-store.hpp"
 
 #include <boost/test/unit_test.hpp>
 
@@ -76,7 +77,7 @@
 }
 
 // slice a Block to four NDNLP packets
-BOOST_AUTO_TEST_CASE(SliceData4)
+BOOST_AUTO_TEST_CASE(Slice4)
 {
   uint8_t blockValue[5050];
   memset(blockValue, 0xcc, sizeof(blockValue));
@@ -132,6 +133,85 @@
   BOOST_CHECK_EQUAL(totalPayloadSize, block.size());
 }
 
+class ReassembleFixture
+{
+protected:
+  ReassembleFixture()
+    : m_slicer(1500)
+    , m_scheduler(m_io)
+    , m_partialMessageStore(m_scheduler)
+  {
+    m_partialMessageStore.onReceive += bind(&std::vector<Block>::push_back,
+                                            &m_received, _1);
+  }
+
+  Block
+  makeBlock(size_t valueLength)
+  {
+    uint8_t blockValue[valueLength];
+    memset(blockValue, 0xcc, sizeof(blockValue));
+    return ndn::dataBlock(0x01, blockValue, sizeof(blockValue));
+  }
+  
+protected:
+  boost::asio::io_service m_io;
+  Scheduler m_scheduler;
+  
+  ndnlp::Slicer m_slicer;
+  ndnlp::PartialMessageStore m_partialMessageStore;
+
+  // received network layer packets
+  std::vector<Block> m_received;
+};
+
+// reassemble one NDNLP packets into one Block
+BOOST_FIXTURE_TEST_CASE(Reassemble1, ReassembleFixture)
+{
+  Block block = makeBlock(60);
+  ndnlp::PacketArray pa = m_slicer.slice(block);
+  BOOST_REQUIRE_EQUAL(pa->size(), 1);
+  
+  BOOST_CHECK_EQUAL(m_received.size(), 0);
+  m_partialMessageStore.receiveNdnlpData(pa->at(0));
+  
+  BOOST_REQUIRE_EQUAL(m_received.size(), 1);
+  BOOST_CHECK_EQUAL_COLLECTIONS(m_received.at(0).begin(), m_received.at(0).end(),
+                                block.begin(),            block.end());
+}
+
+// reassemble four and two NDNLP packets into two Blocks
+BOOST_FIXTURE_TEST_CASE(Reassemble4and2, ReassembleFixture)
+{
+  Block block = makeBlock(5050);
+  ndnlp::PacketArray pa = m_slicer.slice(block);
+  BOOST_REQUIRE_EQUAL(pa->size(), 4);
+  
+  Block block2 = makeBlock(2000);
+  ndnlp::PacketArray pa2 = m_slicer.slice(block2);
+  BOOST_REQUIRE_EQUAL(pa2->size(), 2);
+  
+  BOOST_CHECK_EQUAL(m_received.size(), 0);
+  m_partialMessageStore.receiveNdnlpData(pa->at(0));
+  BOOST_CHECK_EQUAL(m_received.size(), 0);
+  m_partialMessageStore.receiveNdnlpData(pa->at(1));
+  BOOST_CHECK_EQUAL(m_received.size(), 0);
+  m_partialMessageStore.receiveNdnlpData(pa2->at(1));
+  BOOST_CHECK_EQUAL(m_received.size(), 0);
+  m_partialMessageStore.receiveNdnlpData(pa->at(1));
+  BOOST_CHECK_EQUAL(m_received.size(), 0);
+  m_partialMessageStore.receiveNdnlpData(pa2->at(0));
+  BOOST_CHECK_EQUAL(m_received.size(), 1);
+  m_partialMessageStore.receiveNdnlpData(pa->at(3));
+  BOOST_CHECK_EQUAL(m_received.size(), 1);
+  m_partialMessageStore.receiveNdnlpData(pa->at(2));
+  
+  BOOST_REQUIRE_EQUAL(m_received.size(), 2);
+  BOOST_CHECK_EQUAL_COLLECTIONS(m_received.at(1).begin(), m_received.at(1).end(),
+                                block.begin(),            block.end());
+  BOOST_CHECK_EQUAL_COLLECTIONS(m_received.at(0).begin(), m_received.at(0).end(),
+                                block2.begin(),           block2.end());
+}
+
 BOOST_AUTO_TEST_SUITE_END()
 
 } // namespace nfd
