Changing SyncLogic to use native NS-3 random variable
This way behavior of the simulation is defined by NS-3's random
generator parameters. It is possible to set up different seed in
command line using --RngRun=<integer> parameter.
diff --git a/model/sync-logic.cc b/model/sync-logic.cc
index ad22b61..403138a 100644
--- a/model/sync-logic.cc
+++ b/model/sync-logic.cc
@@ -48,8 +48,12 @@
, m_onUpdate (onUpdate)
, m_onRemove (onRemove)
, m_ccnxHandle(new CcnxWrapper())
+#ifndef NS3_MODULE
, m_randomGenerator (static_cast<unsigned int> (std::time (0)))
, m_rangeUniformRandom (m_randomGenerator, uniform_int<> (20,80))
+#else
+ , m_rangeUniformRandom (20,80)
+#endif
{
#ifdef _STANDALONE
#ifdef _DEBUG
@@ -187,6 +191,7 @@
// }
m_syncInterestTable.remove (interestName);
+ _LOG_DEBUG (">> D" << interestName);
m_ccnxHandle->publishData (interestName,
lexical_cast<string> (*stateDiff),
m_syncResponseFreshness);
@@ -201,7 +206,16 @@
if (!timedProcessing)
{
- m_scheduler.schedule (TIME_MILLISECONDS (m_rangeUniformRandom ()) /*from 20 to 100ms*/,
+ uint32_t waitDelay =
+#ifndef NS3_MODULE
+ m_rangeUniformRandom ()
+#else
+ 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);
diff --git a/model/sync-logic.h b/model/sync-logic.h
index 64d551b..9734fad 100644
--- a/model/sync-logic.h
+++ b/model/sync-logic.h
@@ -45,6 +45,7 @@
#ifdef NS3_MODULE
#include <ns3/application.h>
+#include <ns3/random-variable.h>
#endif
namespace Sync {
@@ -143,8 +144,12 @@
Scheduler m_scheduler;
+#ifndef NS3_MODULE
boost::mt19937 m_randomGenerator;
boost::variate_generator<boost::mt19937&, boost::uniform_int<> > m_rangeUniformRandom;
+#else
+ ns3::UniformVariable m_rangeUniformRandom;
+#endif
static const int m_syncResponseFreshness = 2;