Many corrections
diff --git a/model/sync-diff-state-container.h b/model/sync-diff-state-container.h
index 6e98aa4..2aa6d2c 100644
--- a/model/sync-diff-state-container.h
+++ b/model/sync-diff-state-container.h
@@ -33,7 +33,7 @@
#include <boost/multi_index/hashed_index.hpp>
#include <boost/multi_index/sequenced_index.hpp>
// #include <boost/multi_index/random_access_index.hpp>
-// #include <boost/multi_index/member.hpp>
+#include <boost/multi_index/member.hpp>
#include <boost/multi_index/mem_fun.hpp>
namespace mi = boost::multi_index;
@@ -63,6 +63,7 @@
/// @cond include_hidden
struct sequenced { };
+struct timed { };
/// @endcond
/**
@@ -87,6 +88,37 @@
{
};
+struct DigestTime
+{
+ DigestTime (DigestConstPtr digest, const TimeAbsolute &time)
+ : m_digest (digest)
+ , m_time (time)
+ {
+ }
+
+ DigestConstPtr m_digest;
+ TimeAbsolute m_time;
+};
+
+struct UnknownDigestContainer : public mi::multi_index_container<
+ DigestTime,
+ mi::indexed_by<
+ mi::hashed_unique<
+ mi::tag<hashed>,
+ mi::member<DigestTime, DigestConstPtr, &DigestTime::m_digest>,
+ DigestPtrHash,
+ DigestPtrEqual
+ >
+ ,
+ mi::ordered_non_unique<
+ mi::tag<timed>,
+ mi::member<DigestTime, TimeAbsolute, &DigestTime::m_time>
+ >
+ >
+ >
+{
+};
+
} // Sync
#endif // SYNC_DIFF_STATE_CONTAINER_H
diff --git a/model/sync-logic.cc b/model/sync-logic.cc
index 6e3a55c..5a0f443 100644
--- a/model/sync-logic.cc
+++ b/model/sync-logic.cc
@@ -209,19 +209,28 @@
if (!timedProcessing)
{
- uint32_t waitDelay =
+ UnknownDigestContainer::index<hashed>::type::iterator previousUnknownDigest = m_recentUnknownDigests.get<hashed> ().find (digest);
+ if (previousUnknownDigest != m_recentUnknownDigests.get<hashed> ().end ())
+ {
+ _LOG_DEBUG ("Digest is not in the log, but we have already seen it. (Don't do anything)");
+ }
+ else
+ {
+ m_recentUnknownDigests.insert (DigestTime (digest, TIME_NOW + TIME_SECONDS (m_unknownDigestStoreTime)));
+
+ uint32_t waitDelay =
#ifndef NS3_MODULE
- m_rangeUniformRandom ()
+ m_rangeUniformRandom ()
#else
- m_rangeUniformRandom.GetValue ()
+ m_rangeUniformRandom.GetValue ()
#endif
- ;
+ ;
- _LOG_DEBUG ("Digest is not in the log. Schedule processing after small delay: " << waitDelay << "ms");
- m_scheduler.schedule (TIME_MILLISECONDS (waitDelay) /*from 20 to 100ms*/,
- bind (&SyncLogic::processSyncInterest, this, digest, interestName, true),
- DELAYED_INTEREST_PROCESSING);
-
+ _LOG_DEBUG ("Digest is not in the log. Schedule processing after small delay: " << waitDelay << "ms");
+ m_scheduler.schedule (TIME_MILLISECONDS (waitDelay) /*from 20 to 100ms*/,
+ bind (&SyncLogic::processSyncInterest, this, digest, interestName, true),
+ DELAYED_INTEREST_PROCESSING);
+ }
}
else
{
diff --git a/model/sync-logic.h b/model/sync-logic.h
index 3ddf45f..12b9f54 100644
--- a/model/sync-logic.h
+++ b/model/sync-logic.h
@@ -132,6 +132,7 @@
private:
FullState m_state;
DiffStateContainer m_log;
+ UnknownDigestContainer m_recentUnknownDigests;
boost::recursive_mutex m_stateMutex;
std::string m_outstandingInterest;
@@ -150,10 +151,12 @@
#else
ns3::UniformVariable m_rangeUniformRandom;
#endif
-
+
+ static const int m_unknownDigestStoreTime = 10; // seconds
#ifdef NS3_MODULE
- static const int m_syncResponseFreshness = 100; //
- static const int m_syncInterestReexpress = 10000; // make sure it doesn't happen
+ static const int m_syncResponseFreshness = 100; // milliseconds
+ static const int m_syncInterestReexpress = 10; // seconds
+ // don't forget to adjust value in SyncCcnxWrapper
#else
static const int m_syncResponseFreshness = 2000;
static const int m_syncInterestReexpress = 4;