src: Lsa interest retransmission in case of timeout

Refs: #1634

Change-Id: Iceeb6921bcc360de50714d227e8f12c4d0514115
diff --git a/src/communication/sync-logic-handler.cpp b/src/communication/sync-logic-handler.cpp
index f4a42a2..05f3e87 100644
--- a/src/communication/sync-logic-handler.cpp
+++ b/src/communication/sync-logic-handler.cpp
@@ -83,7 +83,8 @@
         interestName.append("name");
         interestName.appendNumber(sm.getNameLsaSeq());
         pnlsr.getLsdb().expressInterest(interestName,
-                                        pnlsr.getConfParameter().getInterestResendTime());
+                                        pnlsr.getConfParameter().getInterestResendTime(),
+                                        0);
       }
       if (pnlsr.getLsdb().isAdjLsaNew(rName.append("adjacency"),
                                       sm.getAdjLsaSeq())) {
@@ -94,7 +95,8 @@
         interestName.append("adjacency");
         interestName.appendNumber(sm.getAdjLsaSeq());
         pnlsr.getLsdb().expressInterest(interestName,
-                                        pnlsr.getConfParameter().getInterestResendTime());
+                                        pnlsr.getConfParameter().getInterestResendTime(),
+                                        0);
       }
       if (pnlsr.getLsdb().isCoordinateLsaNew(rName.append("coordinate"),
                                              sm.getCorLsaSeq())) {
@@ -105,7 +107,8 @@
         interestName.append("coordinate");
         interestName.appendNumber(sm.getCorLsaSeq());
         pnlsr.getLsdb().expressInterest(interestName,
-                                        pnlsr.getConfParameter().getInterestResendTime());
+                                        pnlsr.getConfParameter().getInterestResendTime(),
+                                        0);
       }
     }
     catch (std::exception& e) {
diff --git a/src/lsdb.cpp b/src/lsdb.cpp
index 9a2afab..c970472 100644
--- a/src/lsdb.cpp
+++ b/src/lsdb.cpp
@@ -724,7 +724,8 @@
 
 
 void
-Lsdb::expressInterest(const ndn::Name& interestName, uint32_t interestLifeTime)
+Lsdb::expressInterest(const ndn::Name& interestName, uint32_t interestLifeTime,
+                      uint32_t timeoutCount)
 {
   std::cout << "Expressing Interest :" << interestName << std::endl;
   _LOG_DEBUG("Expressing Interest for LSA(name): " << interestName);
@@ -735,7 +736,7 @@
                                        ndn::bind(&Lsdb::processContent,
                                                  this, _1, _2),
                                        ndn::bind(&Lsdb::processInterestTimedOut,
-                                                 this, _1));
+                                                 this, _1, timeoutCount));
 }
 
 void
@@ -931,11 +932,17 @@
 }
 
 void
-Lsdb::processInterestTimedOut(const ndn::Interest& interest)
+Lsdb::processInterestTimedOut(const ndn::Interest& interest, uint32_t timeoutCount)
 {
   const ndn::Name& interestName(interest.getName());
-  cout << "Interest timed out for LSA(name): " << interestName << endl;
   _LOG_DEBUG("Interest timed out for  LSA(name): " << interestName);
+  if ((timeoutCount + 1) <= m_nlsr.getConfParameter().getInterestRetryNumber()) {
+    _LOG_DEBUG("Interest timeoutCount: " << (timeoutCount + 1));
+    _LOG_DEBUG("Need to express interest again for LSA(name): " << interestName);
+    expressInterest(interestName,
+                    m_nlsr.getConfParameter().getInterestResendTime(),
+                    timeoutCount + 1);
+  }
 }
 
 ndn::time::system_clock::TimePoint
diff --git a/src/lsdb.hpp b/src/lsdb.hpp
index 752b52b..ef98138 100644
--- a/src/lsdb.hpp
+++ b/src/lsdb.hpp
@@ -138,7 +138,8 @@
                                 uint64_t seqNo);
 public:
   void
-  expressInterest(const ndn::Name& interestName, uint32_t interestLifeTime);
+  expressInterest(const ndn::Name& interestName, uint32_t interestLifeTime,
+                  uint32_t timeoutCount);
 
   void
   processInterest(const ndn::Name& name, const ndn::Interest& interest);
@@ -175,7 +176,7 @@
                               uint32_t lsSeqNo, std::string& dataContent);
 
   void
-  processInterestTimedOut(const ndn::Interest& interest);
+  processInterestTimedOut(const ndn::Interest& interest, uint32_t timeoutCount);
 
   ndn::time::system_clock::TimePoint
   getLsaExpirationTimePoint();