diff --git a/src/util/scheduler.cpp b/src/util/scheduler.cpp
index 15200c9..9852fb2 100644
--- a/src/util/scheduler.cpp
+++ b/src/util/scheduler.cpp
@@ -22,141 +22,82 @@
 #include "scheduler.hpp"
 #include <boost/scope_exit.hpp>
 
+namespace ns3 {
+
+/// @cond include_hidden
+
+template<>
+struct EventMemberImplObjTraits<std::function<void()>> {
+  typedef std::function<void()> T;
+  static T&
+  GetReference(T& p)
+  {
+    return p;
+  }
+};
+
+/// @endcond
+
+} // namespace ns3
+
 namespace ndn {
 namespace util {
 namespace scheduler {
 
-class EventInfo : noncopyable
-{
-public:
-  EventInfo(time::nanoseconds after, const EventCallback& callback)
-    : expireTime(time::steady_clock::now() + after)
-    , isExpired(false)
-    , callback(callback)
-  {
-  }
-
-  time::nanoseconds
-  expiresFromNow() const
-  {
-    return std::max(expireTime - time::steady_clock::now(), time::nanoseconds::zero());
-  }
-
-public:
-  time::steady_clock::TimePoint expireTime;
-  bool isExpired;
-  EventCallback callback;
-  EventQueue::const_iterator queueIt;
-};
-
-bool
-EventId::operator!() const
-{
-  return m_info.expired() || m_info.lock()->isExpired;
-}
-
-bool
-EventId::operator==(const EventId& other) const
-{
-  return (!(*this) && !other) ||
-         !(m_info.owner_before(other.m_info) || other.m_info.owner_before(m_info));
-}
-
-std::ostream&
-operator<<(std::ostream& os, const EventId& eventId)
-{
-  return os << eventId.m_info.lock();
-}
-
-bool
-EventQueueCompare::operator()(const shared_ptr<EventInfo>& a, const shared_ptr<EventInfo>& b) const
-{
-  return a->expireTime < b->expireTime;
-}
-
 Scheduler::Scheduler(boost::asio::io_service& ioService)
-  : m_deadlineTimer(ioService)
-  , m_isEventExecuting(false)
+  : m_scheduledEvent(m_events.end())
 {
 }
 
+Scheduler::~Scheduler()
+{
+  cancelAllEvents();
+}
+
 EventId
-Scheduler::scheduleEvent(const time::nanoseconds& after, const EventCallback& callback)
+Scheduler::scheduleEvent(const time::nanoseconds& after, const Event& event)
 {
-  BOOST_ASSERT(callback != nullptr);
+  EventId eventId = std::make_shared<ns3::EventId>();
+  weak_ptr<ns3::EventId> eventWeak = eventId;
+  std::function<void()> eventWithCleanup = [this, event, eventWeak] () {
+    event();
+    shared_ptr<ns3::EventId> eventId = eventWeak.lock();
+    if (eventId != nullptr) {
+      this->m_events.erase(eventId); // remove the event from the set after it is executed
+    }
+  };
 
-  EventQueue::iterator i = m_queue.insert(make_shared<EventInfo>(after, callback));
-  (*i)->queueIt = i;
+  ns3::EventId id = ns3::Simulator::Schedule(ns3::NanoSeconds(after.count()),
+                                             &std::function<void()>::operator(), eventWithCleanup);
+  *eventId = std::move(id);
+  m_events.insert(eventId);
 
-  if (!m_isEventExecuting && i == m_queue.begin()) {
-    // the new event is the first one to expire
-    this->scheduleNext();
-  }
-
-  return EventId(*i);
+  return eventId;
 }
 
 void
 Scheduler::cancelEvent(const EventId& eventId)
 {
-  shared_ptr<EventInfo> info = eventId.m_info.lock();
-  if (info == nullptr || info->isExpired) {
-    return; // event already expired or cancelled
-  }
-
-  if (info->queueIt == m_queue.begin()) {
-    m_deadlineTimer.cancel();
-  }
-  m_queue.erase(info->queueIt);
-
-  if (!m_isEventExecuting) {
-    this->scheduleNext();
+  if (eventId != nullptr) {
+    ns3::Simulator::Remove(*eventId);
+    const_cast<EventId&>(eventId).reset();
+    m_events.erase(eventId);
   }
 }
 
 void
 Scheduler::cancelAllEvents()
 {
-  m_queue.clear();
-  m_deadlineTimer.cancel();
-}
-
-void
-Scheduler::scheduleNext()
-{
-  if (!m_queue.empty()) {
-    m_deadlineTimer.expires_from_now((*m_queue.begin())->expiresFromNow());
-    m_deadlineTimer.async_wait(bind(&Scheduler::executeEvent, this, _1));
-  }
-}
-
-void
-Scheduler::executeEvent(const boost::system::error_code& error)
-{
-  if (error) { // e.g., cancelled
-    return;
-  }
-
-  m_isEventExecuting = true;
-
-  BOOST_SCOPE_EXIT_ALL(this) {
-    m_isEventExecuting = false;
-    this->scheduleNext();
-  };
-
-  // process all expired events
-  time::steady_clock::TimePoint now = time::steady_clock::now();
-  while (!m_queue.empty()) {
-    EventQueue::iterator head = m_queue.begin();
-    shared_ptr<EventInfo> info = *head;
-    if (info->expireTime > now) {
-      break;
+  for (auto i = m_events.begin(); i != m_events.end(); ) {
+    auto next = i;
+    ++next; // ns3::Simulator::Remove can call cancelEvent
+    if ((*i) != nullptr) {
+      ns3::Simulator::Remove((**i));
+      const_cast<EventId&>(*i).reset();
     }
-
-    m_queue.erase(head);
-    info->isExpired = true;
-    info->callback();
+    i = next;
   }
+  m_events.clear();
 }
 
 } // namespace scheduler
diff --git a/src/util/scheduler.hpp b/src/util/scheduler.hpp
index cad5c09..2fbcf21 100644
--- a/src/util/scheduler.hpp
+++ b/src/util/scheduler.hpp
@@ -25,101 +25,18 @@
 #include "../common.hpp"
 #include "monotonic_deadline_timer.hpp"
 
+#include "ns3/simulator.h"
+
 #include <set>
 
 namespace ndn {
 namespace util {
 namespace scheduler {
 
-/**
- * \brief Function to be invoked when a scheduled event expires
+/** \class EventId
+ *  \brief Opaque type (shared_ptr) representing ID of a scheduled event
  */
-typedef function<void()> EventCallback;
-
-/**
- * \brief Stores internal information about a scheduled event
- */
-class EventInfo;
-
-/**
- * \brief Identifies a scheduled event
- */
-class EventId
-{
-public:
-  /**
-   * \brief Constructs an empty EventId
-   * \note EventId is implicitly convertible from nullptr.
-   */
-  EventId(std::nullptr_t = nullptr)
-  {
-  }
-
-  /**
-   * \retval true The event is valid.
-   * \retval false This EventId is empty, or the event is expired or cancelled.
-   */
-  explicit
-  operator bool() const
-  {
-    return !this->operator!();
-  }
-
-  /**
-   * \retval true This EventId is empty, or the event is expired or cancelled.
-   * \retval false The event is valid.
-   */
-  bool
-  operator!() const;
-
-  /**
-   * \return whether this and other refer to the same event, or are both empty/expired/cancelled
-   */
-  bool
-  operator==(const EventId& other) const;
-
-  bool
-  operator!=(const EventId& other) const
-  {
-    return !this->operator==(other);
-  }
-
-  /**
-   * \brief clear this EventId
-   * \note This does not cancel the event.
-   * \post !(*this)
-   */
-  void
-  reset()
-  {
-    m_info.reset();
-  }
-
-private:
-  explicit
-  EventId(const weak_ptr<EventInfo>& info)
-    : m_info(info)
-  {
-  }
-
-private:
-  weak_ptr<EventInfo> m_info;
-
-  friend class Scheduler;
-  friend std::ostream& operator<<(std::ostream& os, const EventId& eventId);
-};
-
-std::ostream&
-operator<<(std::ostream& os, const EventId& eventId);
-
-class EventQueueCompare
-{
-public:
-  bool
-  operator()(const shared_ptr<EventInfo>& a, const shared_ptr<EventInfo>& b) const;
-};
-
-typedef std::multiset<shared_ptr<EventInfo>, EventQueueCompare> EventQueue;
+typedef std::shared_ptr<ns3::EventId> EventId;
 
 /**
  * \brief Generic scheduler
@@ -130,17 +47,19 @@
   /**
    * \deprecated use EventCallback
    */
-  typedef EventCallback Event;
+  typedef function<void()> Event;
 
   explicit
   Scheduler(boost::asio::io_service& ioService);
 
+  ~Scheduler();
+
   /**
    * \brief Schedule a one-time event after the specified delay
    * \return EventId that can be used to cancel the scheduled event
    */
   EventId
-  scheduleEvent(const time::nanoseconds& after, const EventCallback& callback);
+  scheduleEvent(const time::nanoseconds& after, const Event& event);
 
   /**
    * \brief Cancel a scheduled event
@@ -155,25 +74,36 @@
   cancelAllEvents();
 
 private:
-  /**
-   * \brief Schedule the next event on the deadline timer
-   */
-  void
-  scheduleNext();
+  struct EventInfo
+  {
+    EventInfo(const time::nanoseconds& after, const Event& event);
 
-  /**
-   * \brief Execute expired events
-   * \note If an event callback throws, the exception is propagated to the thread running the
-   *       io_service. In case there are other expired events, they will be processed in the next
-   *       invocation of this method.
-   */
-  void
-  executeEvent(const boost::system::error_code& code);
+    EventInfo(const time::steady_clock::TimePoint& when, const EventInfo& previousEvent);
 
-private:
-  monotonic_deadline_timer m_deadlineTimer;
-  EventQueue m_queue;
-  bool m_isEventExecuting;
+    bool
+    operator <=(const EventInfo& other) const
+    {
+      return this->m_scheduledTime <= other.m_scheduledTime;
+    }
+
+    bool
+    operator <(const EventInfo& other) const
+    {
+      return this->m_scheduledTime < other.m_scheduledTime;
+    }
+
+    time::nanoseconds
+    expiresFromNow() const;
+
+    time::steady_clock::TimePoint m_scheduledTime;
+    Event m_event;
+    mutable EventId m_eventId;
+  };
+
+  typedef std::multiset<EventId> EventQueue;
+
+  EventQueue m_events;
+  EventQueue::iterator m_scheduledEvent;
 };
 
 } // namespace scheduler
