utils: Enable use of the simulation time in NFD

Conversion of ndnSIM time to system_clock::time_point, steady_clock::time_point, so that NFD use the simulation time.
diff --git a/helper/ndn-stack-helper.cpp b/helper/ndn-stack-helper.cpp
index bd2413e..5d3dcd2 100644
--- a/helper/ndn-stack-helper.cpp
+++ b/helper/ndn-stack-helper.cpp
@@ -61,6 +61,8 @@
   : m_limitsEnabled(false)
   , m_needSetDefaultRoutes(false)
 {
+  setCustomNdnCxxClocks();
+
   m_ndnFactory.SetTypeId("ns3::ndn::L3Protocol");
   m_strategyFactory.SetTypeId("ns3::ndn::fw::Flooding");
   m_contentStoreFactory.SetTypeId("ns3::ndn::cs::Lru");
@@ -85,6 +87,13 @@
 }
 
 void
+StackHelper::setCustomNdnCxxClocks()
+{
+  ::ndn::time::setCustomClocks(make_shared<ns3::ndn::time::CustomSteadyClock>(),
+                               make_shared<ns3::ndn::time::CustomSystemClock>());
+}
+
+void
 StackHelper::SetStackAttributes(const std::string& attr1, const std::string& value1,
                                 const std::string& attr2, const std::string& value2,
                                 const std::string& attr3, const std::string& value3,
diff --git a/helper/ndn-stack-helper.hpp b/helper/ndn-stack-helper.hpp
index afc43dc..b6b4266 100644
--- a/helper/ndn-stack-helper.hpp
+++ b/helper/ndn-stack-helper.hpp
@@ -303,6 +303,10 @@
   PointToPointNetDeviceCallback(Ptr<Node> node, Ptr<L3Protocol> ndn,
                                 Ptr<NetDevice> netDevice) const;
 
+public:
+  void
+  setCustomNdnCxxClocks();
+
 private:
   StackHelper(const StackHelper&);
   StackHelper&
diff --git a/model/ndn-common.hpp b/model/ndn-common.hpp
index 8b1a692..7769cef 100644
--- a/model/ndn-common.hpp
+++ b/model/ndn-common.hpp
@@ -43,7 +43,9 @@
 
 ATTRIBUTE_HELPER_HEADER(Name);
 
-namespace time = ::ndn::time;
+namespace time {
+using namespace ::ndn::time;
+}
 
 using ::ndn::Exclude;
 
diff --git a/utils/ndn-time.cpp b/utils/ndn-time.cpp
new file mode 100644
index 0000000..075b1a9
--- /dev/null
+++ b/utils/ndn-time.cpp
@@ -0,0 +1,71 @@
+/* -*-  Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
+/*
+ * Copyright (c) 2012-2014 University of California, Los Angeles
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation;
+ *
+ * This program 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 this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+
+#include "ndn-time.hpp"
+
+#include "ns3/simulator.h"
+
+namespace ns3 {
+namespace ndn {
+namespace time {
+
+system_clock::time_point
+CustomSystemClock::getNow() const
+{
+  boost::chrono::nanoseconds ns(Simulator::Now().GetNanoSeconds());
+  return system_clock::time_point(ns);
+}
+
+std::string
+CustomSystemClock::getSince() const
+{
+  return " since start of simulation";
+}
+
+boost::posix_time::time_duration
+CustomSystemClock::toPosixDuration(const system_clock::duration& duration) const
+{
+  BOOST_ASSERT_MSG(false, "Must not be called");
+  return boost::posix_time::microseconds(1);
+}
+
+////////////////////////////////////
+
+steady_clock::time_point
+CustomSteadyClock::getNow() const
+{
+  boost::chrono::nanoseconds ns(Simulator::Now().GetNanoSeconds());
+  return steady_clock::time_point(ns);
+}
+
+std::string
+CustomSteadyClock::getSince() const
+{
+  return " since start of simulation";
+}
+
+boost::posix_time::time_duration
+CustomSteadyClock::toPosixDuration(const steady_clock::duration& duration) const
+{
+  BOOST_ASSERT_MSG(false, "Must not be called");
+  return boost::posix_time::microseconds(1);
+}
+
+} // namespace time
+} // namespace ndn
+} // namespace ns3
diff --git a/utils/ndn-time.hpp b/utils/ndn-time.hpp
new file mode 100644
index 0000000..aa40cbd
--- /dev/null
+++ b/utils/ndn-time.hpp
@@ -0,0 +1,58 @@
+/* -*-  Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
+/*
+ * Copyright (c) 2012-2014 University of California, Los Angeles
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation;
+ *
+ * This program 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 this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+
+#ifndef NDNSIM_UTILS_TIME_HPP
+#define NDNSIM_UTILS_TIME_HPP
+
+#include "ns3/ndnSIM/model/ndn-common.hpp"
+
+#include <ndn-cxx/util/time-custom-clock.hpp>
+
+namespace ns3 {
+namespace ndn {
+namespace time {
+
+class CustomSystemClock : public CustomClock<system_clock> {
+public:
+  system_clock::time_point
+  getNow() const;
+
+  std::string
+  getSince() const;
+
+  boost::posix_time::time_duration
+  toPosixDuration(const system_clock::duration& duration) const;
+};
+
+class CustomSteadyClock : public CustomClock<steady_clock> {
+public:
+  steady_clock::time_point
+  getNow() const;
+
+  std::string
+  getSince() const;
+
+  boost::posix_time::time_duration
+  toPosixDuration(const steady_clock::duration& duration) const;
+};
+
+} // namespace time
+} // namespace ndn
+} // namespace ns3
+
+#endif // NDNSIM_UTILS_TIME_HPP