diff --git a/src/util/concepts.hpp b/src/util/concepts.hpp
new file mode 100644
index 0000000..dee15d3
--- /dev/null
+++ b/src/util/concepts.hpp
@@ -0,0 +1,54 @@
+/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
+/**
+ * Copyright (c) 2013-2014 Regents of the University of California.
+ *
+ * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
+ *
+ * ndn-cxx library is free software: you can redistribute it and/or modify it under the
+ * terms of the GNU Lesser General Public License as published by the Free Software
+ * Foundation, either version 3 of the License, or (at your option) any later version.
+ *
+ * ndn-cxx library 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 Lesser General Public License for more details.
+ *
+ * You should have received copies of the GNU General Public License and GNU Lesser
+ * General Public License along with ndn-cxx, e.g., in COPYING.md file.  If not, see
+ * <http://www.gnu.org/licenses/>.
+ *
+ * See AUTHORS.md for complete list of ndn-cxx authors and contributors.
+ */
+
+#ifndef NDN_UTIL_CONCEPTS_HPP
+#define NDN_UTIL_CONCEPTS_HPP
+
+#include <boost/concept/usage.hpp>
+
+namespace ndn {
+
+template<class X>
+class WireEncodable
+{
+public:
+  BOOST_CONCEPT_USAGE(WireEncodable)
+  {
+    X j;
+    j.wireEncode();
+  }
+};
+
+template<class X>
+class WireDecodable
+{
+public:
+  BOOST_CONCEPT_USAGE(WireDecodable)
+  {
+    Block block;
+    X j(block);
+    j.wireDecode(block);
+  }
+};
+
+} // namespace ndn
+
+#endif // NDN_UTIL_CONCEPTS_HPP
diff --git a/src/util/notification-stream.hpp b/src/util/notification-stream.hpp
new file mode 100644
index 0000000..991a885
--- /dev/null
+++ b/src/util/notification-stream.hpp
@@ -0,0 +1,112 @@
+/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
+/**
+ * Copyright (c) 2013-2014 Regents of the University of California.
+ *
+ * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
+ *
+ * ndn-cxx library is free software: you can redistribute it and/or modify it under the
+ * terms of the GNU Lesser General Public License as published by the Free Software
+ * Foundation, either version 3 of the License, or (at your option) any later version.
+ *
+ * ndn-cxx library 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 Lesser General Public License for more details.
+ *
+ * You should have received copies of the GNU General Public License and GNU Lesser
+ * General Public License along with ndn-cxx, e.g., in COPYING.md file.  If not, see
+ * <http://www.gnu.org/licenses/>.
+ *
+ * See AUTHORS.md for complete list of ndn-cxx authors and contributors.
+ */
+
+/**
+ * Original copyright notice from NFD:
+ *
+ * Copyright (c) 2014,  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 NDN_UTIL_NOTIFICATION_STREAM_HPP
+#define NDN_UTIL_NOTIFICATION_STREAM_HPP
+
+#include "../name.hpp"
+#include "../face.hpp"
+#include "../security/key-chain.hpp"
+
+#include "concepts.hpp"
+
+namespace ndn {
+
+class Face;
+class KeyChain;
+
+namespace util {
+
+/** \brief provides a publisher of Notification Stream
+ *  \sa http://redmine.named-data.net/projects/nfd/wiki/Notification
+ */
+template<typename Notification>
+class NotificationStream : noncopyable
+{
+public:
+  BOOST_CONCEPT_ASSERT((WireEncodable<Notification>));
+
+  NotificationStream(Face& face, const Name& prefix, KeyChain& keyChain)
+    : m_face(face)
+    , m_prefix(prefix)
+    , m_keyChain(keyChain)
+    , m_sequenceNo(0)
+  {
+  }
+
+  virtual
+  ~NotificationStream()
+  {
+  }
+
+  void
+  postNotification(const Notification& notification)
+  {
+    Name dataName = m_prefix;
+    dataName.appendSequenceNumber(m_sequenceNo);
+
+    shared_ptr<Data> data = make_shared<Data>(dataName);
+    data->setContent(notification.wireEncode());
+    data->setFreshnessPeriod(time::seconds(1));
+
+    m_keyChain.sign(*data);
+    m_face.put(*data);
+
+    ++m_sequenceNo;
+  }
+
+private:
+  Face& m_face;
+  const Name m_prefix;
+  KeyChain& m_keyChain;
+  uint64_t m_sequenceNo;
+};
+
+} // namespace util
+} // namespace ndn
+
+#endif // NDN_UTIL_NOTIFICATION_STREAM_HPP
diff --git a/src/util/notification-subscriber.hpp b/src/util/notification-subscriber.hpp
new file mode 100644
index 0000000..32d9d6a
--- /dev/null
+++ b/src/util/notification-subscriber.hpp
@@ -0,0 +1,245 @@
+/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
+/**
+ * Copyright (c) 2013-2014 Regents of the University of California.
+ *
+ * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
+ *
+ * ndn-cxx library is free software: you can redistribute it and/or modify it under the
+ * terms of the GNU Lesser General Public License as published by the Free Software
+ * Foundation, either version 3 of the License, or (at your option) any later version.
+ *
+ * ndn-cxx library 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 Lesser General Public License for more details.
+ *
+ * You should have received copies of the GNU General Public License and GNU Lesser
+ * General Public License along with ndn-cxx, e.g., in COPYING.md file.  If not, see
+ * <http://www.gnu.org/licenses/>.
+ *
+ * See AUTHORS.md for complete list of ndn-cxx authors and contributors.
+ */
+
+/**
+ * Original copyright notice from NFD:
+ *
+ * Copyright (c) 2014,  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 NDN_UTIL_NOTIFICATION_SUBSCRIBER_HPP
+#define NDN_UTIL_NOTIFICATION_SUBSCRIBER_HPP
+
+#include "event-emitter.hpp"
+#include "../face.hpp"
+#include "concepts.hpp"
+#include <boost/concept_check.hpp>
+
+namespace ndn {
+namespace util {
+
+/** \brief provides a subscriber of Notification Stream
+ *  \sa http://redmine.named-data.net/projects/nfd/wiki/Notification
+ *  \tparam Notification type of Notification item, appears in payload of Data packets
+ */
+template<typename Notification>
+class NotificationSubscriber : noncopyable
+{
+public:
+  BOOST_CONCEPT_ASSERT((boost::DefaultConstructible<Notification>));
+  BOOST_CONCEPT_ASSERT((WireDecodable<Notification>));
+
+  /** \brief construct a NotificationSubscriber
+   *  \note The subscriber is not started after construction.
+   *        User should add one or more handlers to onNotification, and invoke .start().
+   */
+  NotificationSubscriber(Face& face, const Name& prefix,
+                         const time::milliseconds& interestLifetime = time::milliseconds(60000))
+    : m_face(face)
+    , m_prefix(prefix)
+    , m_isRunning(false)
+    , m_lastSequenceNo(std::numeric_limits<uint64_t>::max())
+    , m_lastInterestId(0)
+    , m_interestLifetime(interestLifetime)
+  {
+  }
+
+  virtual
+  ~NotificationSubscriber()
+  {
+  }
+
+  /** \return InterestLifetime of Interests to retrieve notifications
+   *  \details This must be greater than FreshnessPeriod of Notification Data packets,
+   *           to ensure correct operation of this subscriber implementation.
+   */
+  time::milliseconds
+  getInterestLifetime() const
+  {
+    return m_interestLifetime;
+  }
+
+  bool
+  isRunning() const
+  {
+    return m_isRunning;
+  }
+
+  /** \brief start or resume receiving notifications
+   *  \note onNotification must have at least one listener,
+   *        otherwise this operation has no effect.
+   */
+  void
+  start()
+  {
+    if (m_isRunning) // already running
+      return;
+    m_isRunning = true;
+
+    this->sendInitialInterest();
+  }
+
+  /** \brief stop receiving notifications
+   */
+  void
+  stop()
+  {
+    if (!m_isRunning) // not running
+      return;
+    m_isRunning = false;
+
+    if (m_lastInterestId != 0)
+      m_face.removePendingInterest(m_lastInterestId);
+    m_lastInterestId = 0;
+  }
+
+public: // subscriptions
+  /** \brief fires when a Notification is received
+   *  \note Removing all handlers will cause the subscriber to stop.
+   */
+  EventEmitter<Notification> onNotification;
+
+  /** \brief fires when no Notification is received within .getInterestLifetime period
+   */
+  EventEmitter<> onTimeout;
+
+  /** \brief fires when a Data packet in the Notification Stream cannot be decoded as Notification
+   */
+  EventEmitter<Data> onDecodeError;
+
+private:
+  void
+  sendInitialInterest()
+  {
+    if (this->shouldStop())
+      return;
+
+    shared_ptr<Interest> interest = make_shared<Interest>(m_prefix);
+    interest->setMustBeFresh(true);
+    interest->setChildSelector(1);
+    interest->setInterestLifetime(getInterestLifetime());
+
+    m_lastInterestId = m_face.expressInterest(*interest,
+                         bind(&NotificationSubscriber<Notification>::afterReceiveData, this, _2),
+                         bind(&NotificationSubscriber<Notification>::afterTimeout, this));
+  }
+
+  void
+  sendNextInterest()
+  {
+    if (this->shouldStop())
+      return;
+
+    BOOST_ASSERT(m_lastSequenceNo !=
+                 std::numeric_limits<uint64_t>::max());// overflow or missing initial reply
+
+    Name nextName = m_prefix;
+    nextName.appendSequenceNumber(m_lastSequenceNo + 1);
+
+    shared_ptr<Interest> interest = make_shared<Interest>(nextName);
+    interest->setInterestLifetime(getInterestLifetime());
+
+    m_lastInterestId = m_face.expressInterest(*interest,
+                         bind(&NotificationSubscriber<Notification>::afterReceiveData, this, _2),
+                         bind(&NotificationSubscriber<Notification>::afterTimeout, this));
+  }
+
+  /** \brief Check if the subscriber is or should be stopped.
+   *  \return true if the subscriber is stopped.
+   */
+  bool
+  shouldStop()
+  {
+    if (!m_isRunning)
+      return true;
+    if (onNotification.isEmpty()) {
+      this->stop();
+      return true;
+    }
+    return false;
+  }
+
+  void
+  afterReceiveData(const Data& data)
+  {
+    if (this->shouldStop())
+      return;
+
+    Notification notification;
+    try {
+      m_lastSequenceNo = data.getName().get(-1).toSequenceNumber();
+      notification.wireDecode(data.getContent().blockFromValue());
+    }
+    catch (tlv::Error&) {
+      this->onDecodeError(data);
+      this->sendInitialInterest();
+      return;
+    }
+
+    this->onNotification(notification);
+
+    this->sendNextInterest();
+  }
+
+  void
+  afterTimeout()
+  {
+    if (this->shouldStop())
+      return;
+
+    this->onTimeout();
+
+    this->sendInitialInterest();
+  }
+
+private:
+  Face& m_face;
+  Name m_prefix;
+  bool m_isRunning;
+  uint64_t m_lastSequenceNo;
+  const PendingInterestId* m_lastInterestId;
+  time::milliseconds m_interestLifetime;
+};
+
+} // namespace util
+} // namespace ndn
+
+#endif // NDN_UTIL_NOTIFICATION_SUBSCRIBER_HPP
