From a1ad6046723a9b7bad4760f7fae8bb9139c678cb Mon Sep 17 00:00:00 2001 From: Ashlesh Gawande Date: Mon, 7 Oct 2019 15:56:11 -0500 Subject: [PATCH] src: schedule sync interest on NoRoute NACK refs #5012 Change-Id: I671b507c66e1957aae976c859e81591c93dc4d94 --- src/logic.cpp | 14 +++++++++++++- src/logic.hpp | 12 ++++++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/src/logic.cpp b/src/logic.cpp index 12b6feb..a8cd68e 100644 --- a/src/logic.cpp +++ b/src/logic.cpp @@ -368,6 +368,18 @@ Logic::onResetData(const Interest& interest, const Data& data) // This should not happened, drop the received data. } +void +Logic::onSyncNack(const Interest& interest, const ndn::lp::Nack& nack) +{ + _LOG_DEBUG_ID(">> Logic::onSyncNack"); + if (nack.getReason() == ndn::lp::NackReason::NO_ROUTE) { + auto after = ndn::time::milliseconds(m_reexpressionJitter(m_rng)); + _LOG_DEBUG_ID("Schedule sync interest after: " << after); + m_scheduler.schedule(after, [this] { sendSyncInterest(); }); + } + _LOG_DEBUG_ID("<< Logic::onSyncNack"); +} + void Logic::onSyncTimeout(const Interest& interest) { @@ -627,7 +639,7 @@ Logic::sendSyncInterest() m_pendingSyncInterest = m_face.expressInterest(interest, bind(&Logic::onSyncData, this, _1, _2), - bind(&Logic::onSyncTimeout, this, _1), // Nack + bind(&Logic::onSyncNack, this, _1, _2), bind(&Logic::onSyncTimeout, this, _1)); _LOG_DEBUG_ID("Send interest: " << interest.getName()); diff --git a/src/logic.hpp b/src/logic.hpp index 408e164..b363e9d 100644 --- a/src/logic.hpp +++ b/src/logic.hpp @@ -291,6 +291,18 @@ private: void onResetData(const Interest& interest, const Data& data); + /** + * @brief Callback to handle Sync Interest Nack + * + * This method checks whether the Nack is of type NoRoute + * and schedules a sync interest in m_reexpressionJitter + * + * @param interest The sync interest for which the Nack happened + * @param nack The incoming Nack + */ + void + onSyncNack(const Interest& interest, const ndn::lp::Nack& nack); + /** * @brief Callback to handle Sync Interest timeout. *