Many corrections
diff --git a/ccnx/sync-scheduler.h b/ccnx/sync-scheduler.h
index c7ebe09..155c6ba 100644
--- a/ccnx/sync-scheduler.h
+++ b/ccnx/sync-scheduler.h
@@ -29,7 +29,10 @@
#include "sync-logic-event-container.h"
#define TIME_SECONDS(number) boost::posix_time::seconds (number)
+#define TIME_MILLISECONDS(number) boost::posix_time::milliseconds(number)
+#define TIME_NOW boost::get_system_time ()
typedef boost::posix_time::time_duration TimeDuration;
+typedef boost::system_time TimeAbsolute;
namespace Sync {
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;
diff --git a/ns3/sync-ccnx-wrapper.cc b/ns3/sync-ccnx-wrapper.cc
index b61f034..dc768f6 100644
--- a/ns3/sync-ccnx-wrapper.cc
+++ b/ns3/sync-ccnx-wrapper.cc
@@ -110,7 +110,7 @@
CcnxInterestHeader interestHeader;
interestHeader.SetNonce (m_rand.GetValue ());
interestHeader.SetName (name);
- interestHeader.SetInterestLifetime (Seconds (10000.0)); // really long-lived interests
+ interestHeader.SetInterestLifetime (Seconds (10.0)); // really long-lived interests
Ptr<Packet> packet = Create<Packet> ();
packet->AddPacketTag (CreateObject<TypeTag> (TypeTag::INTEREST));
diff --git a/ns3/sync-scheduler.h b/ns3/sync-scheduler.h
index f10dc70..a98f8c1 100644
--- a/ns3/sync-scheduler.h
+++ b/ns3/sync-scheduler.h
@@ -25,6 +25,7 @@
#include <ns3/nstime.h>
#include <ns3/event-id.h>
+#include <ns3/simulator.h>
#include <list>
#include <map>
@@ -32,7 +33,9 @@
#define TIME_SECONDS(number) ns3::Seconds(number)
#define TIME_MILLISECONDS(number) ns3::MilliSeconds(number)
+#define TIME_NOW ns3::Simulator::Now ()
typedef ns3::Time TimeDuration;
+typedef ns3::Time TimeAbsolute;
namespace Sync {