src: Expiration time change for LSA and Fib entry

Changed lifetime of LSA and FIB Entry to ndn::time::system_clock::TimePoint
type expiration timepoint. And refreshing event is scheduled at that timepoint

Refs: #1594

Change-Id: Ib31fe7ca79e79174eb3a5a4956ed5334da093b1b
diff --git a/src/lsa.cpp b/src/lsa.cpp
index dbb6ee5..ddae871 100644
--- a/src/lsa.cpp
+++ b/src/lsa.cpp
@@ -29,13 +29,13 @@
 }
 
 NameLsa::NameLsa(const ndn::Name& origR, const string& lst, uint32_t lsn,
-                 uint32_t lt,
+                 const ndn::time::system_clock::TimePoint& lt,
                  NamePrefixList& npl)
 {
   m_origRouter = origR;
   m_lsType = lst;
   m_lsSeqNo = lsn;
-  m_lifeTime = lt;
+  m_expirationTimePoint = lt;
   std::list<ndn::Name>& nl = npl.getNameList();
   for (std::list<ndn::Name>::iterator it = nl.begin(); it != nl.end(); it++) {
     addName((*it));
@@ -48,7 +48,7 @@
   string nameLsaData;
   nameLsaData = m_origRouter.toUri() + "|" + "name" + "|"
                 + boost::lexical_cast<std::string>(m_lsSeqNo) + "|"
-                + boost::lexical_cast<std::string>(m_lifeTime);
+                + ndn::time::toIsoString(m_expirationTimePoint);
   nameLsaData += "|";
   nameLsaData += boost::lexical_cast<std::string>(m_npl.getSize());
   std::list<ndn::Name> nl = m_npl.getNameList();
@@ -74,7 +74,7 @@
   try {
     m_lsType = *tok_iter++;
     m_lsSeqNo = boost::lexical_cast<uint32_t>(*tok_iter++);
-    m_lifeTime = boost::lexical_cast<uint32_t>(*tok_iter++);
+    m_expirationTimePoint = ndn::time::fromIsoString(*tok_iter++);
     numName = boost::lexical_cast<uint32_t>(*tok_iter++);
   }
   catch (std::exception& e) {
@@ -94,7 +94,7 @@
   _LOG_DEBUG("  Origination Router: " << m_origRouter);
   _LOG_DEBUG("  Ls Type: " << m_lsType);
   _LOG_DEBUG("  Ls Seq No: " << m_lsSeqNo);
-  _LOG_DEBUG("  Ls Lifetime: " << m_lifeTime);
+  _LOG_DEBUG("  Ls Lifetime: " << m_expirationTimePoint);
   _LOG_DEBUG("  Names: ");
   int i = 1;
   std::list<ndn::Name> nl = m_npl.getNameList();
@@ -110,8 +110,8 @@
   os << "Name Lsa: " << endl;
   os << "  Origination Router: " << nLsa.getOrigRouter() << endl;
   os << "  Ls Type: " << nLsa.getLsType() << endl;
-  os << "  Ls Seq No: " << (unsigned int)nLsa.getLsSeqNo() << endl;
-  os << "  Ls Lifetime: " << (unsigned int)nLsa.getLifeTime() << endl;
+  os << "  Ls Seq No: " << nLsa.getLsSeqNo() << endl;
+  os << "  Ls Lifetime: " << nLsa.getExpirationTimePoint() << endl;
   os << "  Names: " << endl;
   int i = 1;
   std::list<ndn::Name> nl = nLsa.getNpl().getNameList();
@@ -126,13 +126,13 @@
 
 CoordinateLsa::CoordinateLsa(const ndn::Name& origR, const string lst,
                              uint32_t lsn,
-                             uint32_t lt
-                             , double r, double theta)
+                             const ndn::time::system_clock::TimePoint& lt,
+                             double r, double theta)
 {
   m_origRouter = origR;
   m_lsType = lst;
   m_lsSeqNo = lsn;
-  m_lifeTime = lt;
+  m_expirationTimePoint = lt;
   m_corRad = r;
   m_corTheta = theta;
 }
@@ -162,7 +162,7 @@
   corLsaData += "coordinate";
   corLsaData += "|";
   corLsaData += (boost::lexical_cast<std::string>(m_lsSeqNo) + "|");
-  corLsaData += (boost::lexical_cast<std::string>(m_lifeTime) + "|");
+  corLsaData += (ndn::time::toIsoString(m_expirationTimePoint) + "|");
   corLsaData += (boost::lexical_cast<std::string>(m_corRad) + "|");
   corLsaData += (boost::lexical_cast<std::string>(m_corTheta) + "|");
   return corLsaData;
@@ -182,7 +182,7 @@
   try {
     m_lsType   = *tok_iter++;
     m_lsSeqNo  = boost::lexical_cast<uint32_t>(*tok_iter++);
-    m_lifeTime = boost::lexical_cast<uint32_t>(*tok_iter++);
+    m_expirationTimePoint = ndn::time::fromIsoString(*tok_iter++);
     m_corRad   = boost::lexical_cast<double>(*tok_iter++);
     m_corTheta = boost::lexical_cast<double>(*tok_iter++);
   }
@@ -199,7 +199,7 @@
   _LOG_DEBUG("  Origination Router: " << m_origRouter);
   _LOG_DEBUG("  Ls Type: " << m_lsType);
   _LOG_DEBUG("  Ls Seq No: " << m_lsSeqNo);
-  _LOG_DEBUG("  Ls Lifetime: " << m_lifeTime);
+  _LOG_DEBUG("  Ls Lifetime: " << m_expirationTimePoint);
   _LOG_DEBUG("    Hyperbolic Radius: " << m_corRad);
   _LOG_DEBUG("    Hyperbolic Theta: " << m_corRad);
 }
@@ -210,8 +210,8 @@
   os << "Cor Lsa: " << endl;
   os << "  Origination Router: " << cLsa.getOrigRouter() << endl;
   os << "  Ls Type: " << cLsa.getLsType() << endl;
-  os << "  Ls Seq No: " << (unsigned int)cLsa.getLsSeqNo() << endl;
-  os << "  Ls Lifetime: " << (unsigned int)cLsa.getLifeTime() << endl;
+  os << "  Ls Seq No: " << cLsa.getLsSeqNo() << endl;
+  os << "  Ls Lifetime: " << cLsa.getExpirationTimePoint() << endl;
   os << "    Hyperbolic Radius: " << cLsa.getCorRadius() << endl;
   os << "    Hyperbolic Theta: " << cLsa.getCorTheta() << endl;
   return os;
@@ -219,13 +219,13 @@
 
 
 AdjLsa::AdjLsa(const ndn::Name& origR, const string& lst, uint32_t lsn,
-               uint32_t lt,
+               const ndn::time::system_clock::TimePoint& lt,
                uint32_t nl , AdjacencyList& adl)
 {
   m_origRouter = origR;
   m_lsType = lst;
   m_lsSeqNo = lsn;
-  m_lifeTime = lt;
+  m_expirationTimePoint = lt;
   m_noLink = nl;
   std::list<Adjacent> al = adl.getAdjList();
   for (std::list<Adjacent>::iterator it = al.begin(); it != al.end(); it++) {
@@ -256,7 +256,7 @@
   string adjLsaData;
   adjLsaData = m_origRouter.toUri() + "|" + "adjacency" + "|"
                + boost::lexical_cast<std::string>(m_lsSeqNo) + "|"
-               + boost::lexical_cast<std::string>(m_lifeTime);
+               + ndn::time::toIsoString(m_expirationTimePoint);
   adjLsaData += "|";
   adjLsaData += boost::lexical_cast<std::string>(m_adl.getSize());
   std::list<Adjacent> al = m_adl.getAdjList();
@@ -286,7 +286,7 @@
   try {
     m_lsType   = *tok_iter++;
     m_lsSeqNo  = boost::lexical_cast<uint32_t>(*tok_iter++);
-    m_lifeTime = boost::lexical_cast<uint32_t>(*tok_iter++);
+    m_expirationTimePoint = ndn::time::fromIsoString(*tok_iter++);
     numLink    = boost::lexical_cast<uint32_t>(*tok_iter++);
   }
   catch (std::exception& e) {
@@ -332,7 +332,7 @@
   _LOG_DEBUG("  Origination Router: " << m_origRouter);
   _LOG_DEBUG("  Ls Type: " << m_lsType);
   _LOG_DEBUG("  Ls Seq No: " << m_lsSeqNo);
-  _LOG_DEBUG("  Ls Lifetime: " << m_lifeTime);
+  _LOG_DEBUG("  Ls Lifetime: " << m_expirationTimePoint);
   _LOG_DEBUG("  Adjacents: ");
   int i = 1;
   std::list<Adjacent> al = m_adl.getAdjList();
@@ -351,9 +351,9 @@
   os << "Adj Lsa: " << endl;
   os << "  Origination Router: " << aLsa.getOrigRouter() << endl;
   os << "  Ls Type: " << aLsa.getLsType() << endl;
-  os << "  Ls Seq No: " << (unsigned int)aLsa.getLsSeqNo() << endl;
-  os << "  Ls Lifetime: " << (unsigned int)aLsa.getLifeTime() << endl;
-  os << "  No Link: " << (unsigned int)aLsa.getNoLink() << endl;
+  os << "  Ls Seq No: " << aLsa.getLsSeqNo() << endl;
+  os << "  Ls Lifetime: " << aLsa.getExpirationTimePoint() << endl;
+  os << "  No Link: " << aLsa.getNoLink() << endl;
   os << "  Adjacents: " << endl;
   int i = 1;
   std::list<Adjacent> al = aLsa.getAdl().getAdjList();
diff --git a/src/lsa.hpp b/src/lsa.hpp
index bc43772..03fc7b6 100644
--- a/src/lsa.hpp
+++ b/src/lsa.hpp
@@ -3,6 +3,8 @@
 
 #include <boost/cstdint.hpp>
 #include <ndn-cxx/util/scheduler.hpp>
+#include <ndn-cxx/util/time.hpp>
+
 #include "adjacent.hpp"
 #include "name-prefix-list.hpp"
 #include "adjacency-list.hpp"
@@ -15,7 +17,7 @@
   Lsa()
     : m_origRouter()
     , m_lsSeqNo()
-    , m_lifeTime()
+    , m_expirationTimePoint()
     , m_expiringEventId()
   {
   }
@@ -57,16 +59,16 @@
     m_origRouter = org;
   }
 
-  uint32_t
-  getLifeTime() const
+  const ndn::time::system_clock::TimePoint&
+  getExpirationTimePoint() const
   {
-    return m_lifeTime;
+    return m_expirationTimePoint;
   }
 
   void
-  setLifeTime(uint32_t lt)
+  setExpirationTimePoint(const ndn::time::system_clock::TimePoint& lt)
   {
-    m_lifeTime = lt;
+    m_expirationTimePoint = lt;
   }
 
   void
@@ -85,7 +87,7 @@
   ndn::Name m_origRouter;
   std::string m_lsType;
   uint32_t m_lsSeqNo;
-  uint32_t m_lifeTime;
+  ndn::time::system_clock::TimePoint m_expirationTimePoint;
   ndn::EventId m_expiringEventId;
 };
 
@@ -100,7 +102,7 @@
   }
 
   NameLsa(const ndn::Name& origR, const std::string& lst, uint32_t lsn,
-          uint32_t lt,
+          const ndn::time::system_clock::TimePoint& lt,
           NamePrefixList& npl);
 
   NamePrefixList&
@@ -152,7 +154,8 @@
   }
 
   AdjLsa(const ndn::Name& origR, const std::string& lst, uint32_t lsn,
-         uint32_t lt, uint32_t nl , AdjacencyList& adl);
+         const ndn::time::system_clock::TimePoint& lt,
+         uint32_t nl , AdjacencyList& adl);
 
   AdjacencyList&
   getAdl()
@@ -213,8 +216,8 @@
   }
 
   CoordinateLsa(const ndn::Name& origR, const std::string lst, uint32_t lsn,
-                uint32_t lt
-                , double r, double theta);
+                const ndn::time::system_clock::TimePoint& lt,
+                double r, double theta);
 
   const ndn::Name
   getKey() const;
diff --git a/src/lsdb.cpp b/src/lsdb.cpp
index f99482d..9a2afab 100644
--- a/src/lsdb.cpp
+++ b/src/lsdb.cpp
@@ -32,7 +32,7 @@
   NameLsa nameLsa(m_nlsr.getConfParameter().getRouterPrefix(),
                   "name",
                   m_nlsr.getSequencingManager().getNameLsaSeq() + 1,
-                  m_nlsr.getConfParameter().getRouterDeadInterval(),
+                  getLsaExpirationTimePoint(),
                   m_nlsr.getNamePrefixList());
   m_nlsr.getSequencingManager().increaseNameLsaSeq();
   return installNameLsa(nameLsa);
@@ -66,9 +66,10 @@
 }
 
 ndn::EventId
-Lsdb::scheduleNameLsaExpiration(const ndn::Name& key, int seqNo, int expTime)
+Lsdb::scheduleNameLsaExpiration(const ndn::Name& key, int seqNo,
+                                const ndn::time::seconds& expTime)
 {
-  return m_nlsr.getScheduler().scheduleEvent(ndn::time::seconds(expTime),
+  return m_nlsr.getScheduler().scheduleEvent(expTime,
                                              ndn::bind(&Lsdb::exprireOrRefreshNameLsa,
                                                        this, key, seqNo));
 }
@@ -76,7 +77,7 @@
 bool
 Lsdb::installNameLsa(NameLsa& nlsa)
 {
-  int timeToExpire = m_lsaRefreshTime;
+  ndn::time::seconds timeToExpire = ndn::time::seconds(m_lsaRefreshTime);
   NameLsa* chkNameLsa = findNameLsa(nlsa.getKey());
   if (chkNameLsa == 0) {
     addNameLsa(nlsa);
@@ -96,7 +97,9 @@
       }
     }
     if (nlsa.getOrigRouter() != m_nlsr.getConfParameter().getRouterPrefix()) {
-      timeToExpire = nlsa.getLifeTime();
+      ndn::time::system_clock::Duration duration = nlsa.getExpirationTimePoint() -
+                                                   ndn::time::system_clock::now();
+      timeToExpire = ndn::time::duration_cast<ndn::time::seconds>(duration);
     }
     nlsa.setExpiringEventId(scheduleNameLsaExpiration(nlsa.getKey(),
                                                       nlsa.getLsSeqNo(),
@@ -108,7 +111,7 @@
       _LOG_DEBUG("Old Name LSA ");
       chkNameLsa->writeLog();
       chkNameLsa->setLsSeqNo(nlsa.getLsSeqNo());
-      chkNameLsa->setLifeTime(nlsa.getLifeTime());
+      chkNameLsa->setExpirationTimePoint(nlsa.getExpirationTimePoint());
       chkNameLsa->getNpl().sort();
       nlsa.getNpl().sort();
       std::list<ndn::Name> nameToAdd;
@@ -142,7 +145,9 @@
         }
       }
       if (nlsa.getOrigRouter() != m_nlsr.getConfParameter().getRouterPrefix()) {
-        timeToExpire = nlsa.getLifeTime();
+        ndn::time::system_clock::Duration duration = nlsa.getExpirationTimePoint() -
+                                                     ndn::time::system_clock::now();
+        timeToExpire = ndn::time::duration_cast<ndn::time::seconds>(duration);
       }
       cancelScheduleLsaExpiringEvent(chkNameLsa->getExpiringEventId());
       chkNameLsa->setExpiringEventId(scheduleNameLsaExpiration(nlsa.getKey(),
@@ -232,7 +237,7 @@
   CoordinateLsa corLsa(m_nlsr.getConfParameter().getRouterPrefix(),
                        "coordinate",
                        m_nlsr.getSequencingManager().getCorLsaSeq() + 1,
-                       m_nlsr.getConfParameter().getRouterDeadInterval(),
+                       getLsaExpirationTimePoint(),
                        m_nlsr.getConfParameter().getCorR(),
                        m_nlsr.getConfParameter().getCorTheta());
   m_nlsr.getSequencingManager().increaseCorLsaSeq();
@@ -269,9 +274,9 @@
 
 ndn::EventId
 Lsdb::scheduleCoordinateLsaExpiration(const ndn::Name& key, int seqNo,
-                                      int expTime)
+                                      const ndn::time::seconds& expTime)
 {
-  return m_nlsr.getScheduler().scheduleEvent(ndn::time::seconds(expTime),
+  return m_nlsr.getScheduler().scheduleEvent(expTime,
                                              ndn::bind(&Lsdb::exprireOrRefreshCoordinateLsa,
                                                        this, key, seqNo));
 }
@@ -279,7 +284,7 @@
 bool
 Lsdb::installCoordinateLsa(CoordinateLsa& clsa)
 {
-  int timeToExpire = m_lsaRefreshTime;
+  ndn::time::seconds timeToExpire = ndn::time::seconds(m_lsaRefreshTime);
   CoordinateLsa* chkCorLsa = findCoordinateLsa(clsa.getKey());
   if (chkCorLsa == 0) {
     _LOG_DEBUG("New Coordinate LSA. Adding to LSDB");
@@ -295,7 +300,9 @@
       m_nlsr.getRoutingTable().scheduleRoutingTableCalculation(m_nlsr);
     }
     if (clsa.getOrigRouter() != m_nlsr.getConfParameter().getRouterPrefix()) {
-      timeToExpire = clsa.getLifeTime();
+      ndn::time::system_clock::Duration duration = clsa.getExpirationTimePoint() -
+                                                   ndn::time::system_clock::now();
+      timeToExpire = ndn::time::duration_cast<ndn::time::seconds>(duration);
     }
     scheduleCoordinateLsaExpiration(clsa.getKey(),
                                     clsa.getLsSeqNo(), timeToExpire);
@@ -306,7 +313,7 @@
       _LOG_DEBUG("Old Coordinate LSA");
       chkCorLsa->writeLog();
       chkCorLsa->setLsSeqNo(clsa.getLsSeqNo());
-      chkCorLsa->setLifeTime(clsa.getLifeTime());
+      chkCorLsa->setExpirationTimePoint(clsa.getExpirationTimePoint());
       if (!chkCorLsa->isEqualContent(clsa)) {
         chkCorLsa->setCorRadius(clsa.getCorRadius());
         chkCorLsa->setCorTheta(clsa.getCorTheta());
@@ -315,7 +322,9 @@
         }
       }
       if (clsa.getOrigRouter() != m_nlsr.getConfParameter().getRouterPrefix()) {
-        timeToExpire = clsa.getLifeTime();
+        ndn::time::system_clock::Duration duration = clsa.getExpirationTimePoint() -
+                                                     ndn::time::system_clock::now();
+        timeToExpire = ndn::time::duration_cast<ndn::time::seconds>(duration);
       }
       cancelScheduleLsaExpiringEvent(chkCorLsa->getExpiringEventId());
       chkCorLsa->setExpiringEventId(scheduleCoordinateLsaExpiration(clsa.getKey(),
@@ -474,9 +483,10 @@
 
 
 ndn::EventId
-Lsdb::scheduleAdjLsaExpiration(const ndn::Name& key, int seqNo, int expTime)
+Lsdb::scheduleAdjLsaExpiration(const ndn::Name& key, int seqNo,
+                               const ndn::time::seconds& expTime)
 {
-  return m_nlsr.getScheduler().scheduleEvent(ndn::time::seconds(expTime),
+  return m_nlsr.getScheduler().scheduleEvent(expTime,
                                              ndn::bind(&Lsdb::exprireOrRefreshAdjLsa,
                                                        this, key, seqNo));
 }
@@ -484,7 +494,7 @@
 bool
 Lsdb::installAdjLsa(AdjLsa& alsa)
 {
-  int timeToExpire = m_lsaRefreshTime;
+  ndn::time::seconds timeToExpire = ndn::time::seconds(m_lsaRefreshTime);
   AdjLsa* chkAdjLsa = findAdjLsa(alsa.getKey());
   if (chkAdjLsa == 0) {
     _LOG_DEBUG("New Adj LSA. Adding to LSDB");
@@ -493,7 +503,9 @@
     alsa.addNptEntries(m_nlsr);
     m_nlsr.getRoutingTable().scheduleRoutingTableCalculation(m_nlsr);
     if (alsa.getOrigRouter() != m_nlsr.getConfParameter().getRouterPrefix()) {
-      timeToExpire = alsa.getLifeTime();
+      ndn::time::system_clock::Duration duration = alsa.getExpirationTimePoint() -
+                                                   ndn::time::system_clock::now();
+      timeToExpire = ndn::time::duration_cast<ndn::time::seconds>(duration);
     }
     scheduleAdjLsaExpiration(alsa.getKey(),
                              alsa.getLsSeqNo(), timeToExpire);
@@ -504,14 +516,16 @@
       _LOG_DEBUG("Old Adj LSA");
       chkAdjLsa->writeLog();
       chkAdjLsa->setLsSeqNo(alsa.getLsSeqNo());
-      chkAdjLsa->setLifeTime(alsa.getLifeTime());
+      chkAdjLsa->setExpirationTimePoint(alsa.getExpirationTimePoint());
       if (!chkAdjLsa->isEqualContent(alsa)) {
         chkAdjLsa->getAdl().reset();
         chkAdjLsa->getAdl().addAdjacents(alsa.getAdl());
         m_nlsr.getRoutingTable().scheduleRoutingTableCalculation(m_nlsr);
       }
       if (alsa.getOrigRouter() != m_nlsr.getConfParameter().getRouterPrefix()) {
-        timeToExpire = alsa.getLifeTime();
+        ndn::time::system_clock::Duration duration = alsa.getExpirationTimePoint() -
+                                                     ndn::time::system_clock::now();
+        timeToExpire = ndn::time::duration_cast<ndn::time::seconds>(duration);
       }
       cancelScheduleLsaExpiringEvent(chkAdjLsa->getExpiringEventId());
       chkAdjLsa->setExpiringEventId(scheduleAdjLsaExpiration(alsa.getKey(),
@@ -530,7 +544,7 @@
   AdjLsa adjLsa(m_nlsr.getConfParameter().getRouterPrefix(),
                 "adjacency",
                 m_nlsr.getSequencingManager().getAdjLsaSeq() + 1,
-                m_nlsr.getConfParameter().getRouterDeadInterval(),
+                getLsaExpirationTimePoint(),
                 m_nlsr.getAdjacencyList().getNumOfActiveNeighbor(),
                 m_nlsr.getAdjacencyList());
   m_nlsr.getSequencingManager().increaseAdjLsaSeq();
@@ -606,11 +620,12 @@
         _LOG_DEBUG("Own Name LSA, so refreshing name LSA");
         chkNameLsa->setLsSeqNo(chkNameLsa->getLsSeqNo() + 1);
         m_nlsr.getSequencingManager().setNameLsaSeq(chkNameLsa->getLsSeqNo());
+        chkNameLsa->setExpirationTimePoint(getLsaExpirationTimePoint());
         chkNameLsa->writeLog();
         // schedule refreshing event again
         chkNameLsa->setExpiringEventId(scheduleNameLsaExpiration(chkNameLsa->getKey(),
                                                                  chkNameLsa->getLsSeqNo(),
-                                                                 m_lsaRefreshTime));
+                                                                 ndn::time::seconds(m_lsaRefreshTime)));
         // publish routing update
         ndn::Name lsaPrefix = m_nlsr.getConfParameter().getLsaPrefix();
         lsaPrefix.append(m_nlsr.getConfParameter().getRouterPrefix());
@@ -643,10 +658,11 @@
         _LOG_DEBUG("Own Adj LSA, so refreshing Adj LSA");
         chkAdjLsa->setLsSeqNo(chkAdjLsa->getLsSeqNo() + 1);
         m_nlsr.getSequencingManager().setAdjLsaSeq(chkAdjLsa->getLsSeqNo());
+        chkAdjLsa->setExpirationTimePoint(getLsaExpirationTimePoint());
         // schedule refreshing event again
         chkAdjLsa->setExpiringEventId(scheduleAdjLsaExpiration(chkAdjLsa->getKey(),
                                                                chkAdjLsa->getLsSeqNo(),
-                                                               m_lsaRefreshTime));
+                                                               ndn::time::seconds(m_lsaRefreshTime)));
         // publish routing update
         ndn::Name lsaPrefix = m_nlsr.getConfParameter().getLsaPrefix();
         lsaPrefix.append(m_nlsr.getConfParameter().getRouterPrefix());
@@ -682,11 +698,12 @@
         _LOG_DEBUG("Own Cor LSA, so refreshing Cor LSA");
         chkCorLsa->setLsSeqNo(chkCorLsa->getLsSeqNo() + 1);
         m_nlsr.getSequencingManager().setCorLsaSeq(chkCorLsa->getLsSeqNo());
+        chkCorLsa->setExpirationTimePoint(getLsaExpirationTimePoint());
         // schedule refreshing event again
         chkCorLsa->setExpiringEventId(scheduleCoordinateLsaExpiration(
                                         chkCorLsa->getKey(),
                                         chkCorLsa->getLsSeqNo(),
-                                        m_lsaRefreshTime));
+                                        ndn::time::seconds(m_lsaRefreshTime)));
         // publish routing update
         ndn::Name lsaPrefix = m_nlsr.getConfParameter().getLsaPrefix();
         lsaPrefix.append(m_nlsr.getConfParameter().getRouterPrefix());
@@ -921,6 +938,14 @@
   _LOG_DEBUG("Interest timed out for  LSA(name): " << interestName);
 }
 
+ndn::time::system_clock::TimePoint
+Lsdb::getLsaExpirationTimePoint()
+{
+  ndn::time::system_clock::TimePoint expirationTimePoint = ndn::time::system_clock::now();
+  expirationTimePoint = expirationTimePoint +
+                        ndn::time::seconds(m_nlsr.getConfParameter().getRouterDeadInterval());
+  return expirationTimePoint;
+}
 
 void
 Lsdb::printAdjLsdb()
diff --git a/src/lsdb.hpp b/src/lsdb.hpp
index ff7450a..752b52b 100644
--- a/src/lsdb.hpp
+++ b/src/lsdb.hpp
@@ -4,6 +4,7 @@
 #include <utility>
 #include <boost/cstdint.hpp>
 #include <ndn-cxx/security/key-chain.hpp>
+#include <ndn-cxx/util/time.hpp>
 
 #include "lsa.hpp"
 
@@ -115,20 +116,22 @@
   doesAdjLsaExist(const ndn::Name& key);
 
   ndn::EventId
-  scheduleNameLsaExpiration(const ndn::Name& key, int seqNo, int expTime);
+  scheduleNameLsaExpiration(const ndn::Name& key, int seqNo,
+                            const ndn::time::seconds& expTime);
 
   void
   exprireOrRefreshNameLsa(const ndn::Name& lsaKey, uint64_t seqNo);
 
   ndn::EventId
-  scheduleAdjLsaExpiration(const ndn::Name& key, int seqNo, int expTime);
+  scheduleAdjLsaExpiration(const ndn::Name& key, int seqNo,
+                           const ndn::time::seconds& expTime);
 
   void
   exprireOrRefreshAdjLsa(const ndn::Name& lsaKey, uint64_t seqNo);
 
   ndn::EventId
   scheduleCoordinateLsaExpiration(const ndn::Name& key, int seqNo,
-                                  int expTime);
+                                  const ndn::time::seconds& expTime);
 
   void
   exprireOrRefreshCoordinateLsa(const ndn::Name& lsaKey,
@@ -174,6 +177,9 @@
   void
   processInterestTimedOut(const ndn::Interest& interest);
 
+  ndn::time::system_clock::TimePoint
+  getLsaExpirationTimePoint();
+
 private:
   void
   cancelScheduleLsaExpiringEvent(ndn::EventId eid);
diff --git a/src/route/fib-entry.cpp b/src/route/fib-entry.cpp
index ba2731f..f35bae7 100644
--- a/src/route/fib-entry.cpp
+++ b/src/route/fib-entry.cpp
@@ -37,6 +37,7 @@
 FibEntry::writeLog()
 {
   _LOG_DEBUG("Name Prefix: " << m_name);
+  _LOG_DEBUG("Time to Refresh: " << m_expirationTimePoint);
   _LOG_DEBUG("Seq No: " << m_seqNo);
   m_nexthopList.writeLog();
 }
@@ -45,7 +46,7 @@
 operator<<(ostream& os, FibEntry fe)
 {
   os << "Name Prefix: " << fe.getName() << endl;
-  os << "Time to Refresh: " << fe.getTimeToRefresh() << endl;
+  os << "Time to Refresh: " << fe.getExpirationTimePoint() << endl;
   os << fe.getNexthopList() << endl;
   return os;
 }
diff --git a/src/route/fib-entry.hpp b/src/route/fib-entry.hpp
index 14d3772..35da960 100644
--- a/src/route/fib-entry.hpp
+++ b/src/route/fib-entry.hpp
@@ -6,6 +6,7 @@
 #include <boost/cstdint.hpp>
 
 #include <ndn-cxx/util/scheduler.hpp>
+#include <ndn-cxx/util/time.hpp>
 
 #include "nexthop.hpp"
 #include "nexthop-list.hpp"
@@ -17,14 +18,14 @@
 public:
   FibEntry()
     : m_name()
-    , m_timeToRefresh(0)
+    , m_expirationTimePoint()
     , m_seqNo(0)
     , m_nexthopList()
   {
   }
 
   FibEntry(const ndn::Name& name)
-    : m_timeToRefresh(0)
+    : m_expirationTimePoint()
     , m_seqNo(0)
     , m_nexthopList()
   {
@@ -43,16 +44,16 @@
     return m_nexthopList;
   }
 
-  int32_t
-  getTimeToRefresh() const
+  const ndn::time::system_clock::TimePoint&
+  getExpirationTimePoint() const
   {
-    return m_timeToRefresh;
+    return m_expirationTimePoint;
   }
 
   void
-  setTimeToRefresh(int32_t ttr)
+  setExpirationTimePoint(const ndn::time::system_clock::TimePoint& ttr)
   {
-    m_timeToRefresh = ttr;
+    m_expirationTimePoint = ttr;
   }
 
   void
@@ -87,7 +88,7 @@
 
 private:
   ndn::Name m_name;
-  int32_t m_timeToRefresh;
+  ndn::time::system_clock::TimePoint m_expirationTimePoint;
   ndn::EventId m_expiringEventId;
   int32_t m_seqNo;
   NexthopList m_nexthopList;
diff --git a/src/route/fib.cpp b/src/route/fib.cpp
index 17269dc..633eaa8 100644
--- a/src/route/fib.cpp
+++ b/src/route/fib.cpp
@@ -32,13 +32,13 @@
 
 ndn::EventId
 Fib::scheduleEntryRefreshing(const ndn::Name& name, int32_t feSeqNum,
-                             int32_t refreshTime)
+                             const ndn::time::seconds& expTime)
 {
   std::cout << "Fib::scheduleEntryRefreshing Called" << std::endl;
   std::cout << "Name: " << name << " Seq Num: " << feSeqNum << std::endl;
   _LOG_DEBUG("Fib::scheduleEntryRefreshing Called");
   _LOG_DEBUG("Name: " << name << " Seq Num: " << feSeqNum);
-  return m_nlsr.getScheduler().scheduleEvent(ndn::time::seconds(refreshTime),
+  return m_nlsr.getScheduler().scheduleEvent(expTime,
                                              ndn::bind(&Fib::refreshEntry, this,
                                                        name, feSeqNum));
 }
@@ -67,7 +67,7 @@
       it->setSeqNo(feSeqNum + 1);
       it->setExpiringEventId(scheduleEntryRefreshing(it->getName() ,
                                                      it->getSeqNo(),
-                                                     m_refreshTime));
+                                                     ndn::time::seconds(m_refreshTime)));
     }
   }
 }
@@ -128,9 +128,12 @@
                        std::ceil(nhit->getRouteCost()), m_refreshTime);
       }
       newEntry.getNexthopList().sort();
-      newEntry.setTimeToRefresh(m_refreshTime);
+      ndn::time::system_clock::TimePoint expirationTimePoint = ndn::time::system_clock::now();
+      expirationTimePoint = expirationTimePoint + ndn::time::seconds(m_refreshTime);
+      newEntry.setExpirationTimePoint(expirationTimePoint);
       newEntry.setSeqNo(1);
-      newEntry.setExpiringEventId(scheduleEntryRefreshing(name , 1, m_refreshTime));
+      newEntry.setExpiringEventId(scheduleEntryRefreshing(name , 1,
+                                                          ndn::time::seconds(m_refreshTime)));
       m_table.push_back(newEntry);
     }
   }
@@ -156,14 +159,17 @@
                          std::ceil(nhit->getRouteCost()), m_refreshTime);
         }
       }
-      it->setTimeToRefresh(m_refreshTime);
+      ndn::time::system_clock::TimePoint expirationTimePoint = ndn::time::system_clock::now();
+      expirationTimePoint = expirationTimePoint + ndn::time::seconds(m_refreshTime);
+      it->setExpirationTimePoint(expirationTimePoint);
       std::cout << "Cancellling Scheduled event" << std::endl;
       std::cout << "Name: " << name << "Seq num: " << it->getSeqNo() << std::endl;
       _LOG_DEBUG("Cancelling Scheduled event. Name: " << name);
       cancelScheduledExpiringEvent(it->getExpiringEventId());
       it->setSeqNo(it->getSeqNo() + 1);
       (*it).setExpiringEventId(scheduleEntryRefreshing(it->getName() ,
-                                                       it->getSeqNo(), m_refreshTime));
+                                                       it->getSeqNo(),
+                                                       ndn::time::seconds(m_refreshTime)));
     }
     else {
       remove(name);
diff --git a/src/route/fib.hpp b/src/route/fib.hpp
index d144e1f..02aa400 100644
--- a/src/route/fib.hpp
+++ b/src/route/fib.hpp
@@ -5,6 +5,7 @@
 #include <boost/cstdint.hpp>
 
 #include <ndn-cxx/management/nfd-controller.hpp>
+#include <ndn-cxx/util/time.hpp>
 #include "face-map.hpp"
 #include "fib-entry.hpp"
 
@@ -56,7 +57,7 @@
 
   ndn::EventId
   scheduleEntryRefreshing(const ndn::Name& name, int32_t feSeqNum,
-                          int32_t refreshTime);
+                          const ndn::time::seconds& expTime);
 
   void
   cancelScheduledExpiringEvent(ndn::EventId eid);