Checkpoint
diff --git a/model/sync-logic.cc b/model/sync-logic.cc
index bd4456f..0e8d0b7 100644
--- a/model/sync-logic.cc
+++ b/model/sync-logic.cc
@@ -20,6 +20,9 @@
* Alexander Afanasyev <alexander.afanasyev@ucla.edu>
*/
+#include <ns3/ccnx-pit.h>
+#include <ns3/ccnx.h>
+
#include "sync-logic.h"
#include "sync-diff-leaf.h"
#include "sync-full-leaf.h"
@@ -64,11 +67,11 @@
, m_ccnxHandle(new CcnxWrapper())
#ifndef NS3_MODULE
, m_randomGenerator (static_cast<unsigned int> (std::time (0)))
- , m_rangeUniformRandom (m_randomGenerator, uniform_int<> (200,300))
+ , m_rangeUniformRandom (m_randomGenerator, uniform_int<> (500,1000))
, m_reexpressionJitter (m_randomGenerator, uniform_int<> (0,100))
#else
, m_rangeUniformRandom (200,300)
- , m_reexpressionJitter (0, 100)
+ , m_reexpressionJitter (0,200)
#endif
{
#ifdef _STANDALONE
@@ -81,8 +84,6 @@
#endif
#endif
#endif
-
- _LOG_DEBUG ("syncPrefix");
#ifndef NS3_MODULE
// In NS3 module these functions are moved to StartApplication method
@@ -177,18 +178,24 @@
{
_LOG_TRACE ("processSyncInterest (): Digest is zero, adding /state to PIT");
m_syncInterestTable.insert (interestName + "/state");
+ // _LOG_TRACE (*GetNode ()->GetObject<ns3::Ccnx> ()->GetPit ());
}
else
{
_LOG_TRACE ("processSyncInterest (): Same state. Adding to PIT");
m_syncInterestTable.insert (interestName);
+ // _LOG_TRACE (*GetNode ()->GetObject<ns3::Ccnx> ()->GetPit ());
}
-
- // !!! important change !!!
- m_scheduler.cancel (REEXPRESSING_INTEREST);
- m_scheduler.schedule (TIME_SECONDS_WITH_JITTER (m_syncInterestReexpress),
- bind (&SyncLogic::sendSyncInterest, this),
- REEXPRESSING_INTEREST);
+
+ if (m_outstandingInterest == interestName)
+ {
+ _LOG_DEBUG ("Cancelling interest reexpressing 1");
+ // !!! important change !!!
+ m_scheduler.cancel (REEXPRESSING_INTEREST);
+ m_scheduler.schedule (TIME_SECONDS_WITH_JITTER (m_syncInterestReexpress),
+ bind (&SyncLogic::sendSyncInterest, this),
+ REEXPRESSING_INTEREST);
+ }
return;
}
@@ -233,7 +240,7 @@
}
else
{
- m_recentUnknownDigests.insert (DigestTime (digest, TIME_NOW + TIME_SECONDS (m_unknownDigestStoreTime)));
+ // m_recentUnknownDigests.insert (DigestTime (digest, TIME_NOW + TIME_SECONDS (m_unknownDigestStoreTime)));
uint32_t waitDelay = GET_RANDOM (m_rangeUniformRandom);
_LOG_DEBUG ("Digest is not in the log. Schedule processing after small delay: " << waitDelay << "ms");
@@ -244,22 +251,24 @@
// just in case, re-express our interest (e.g., probably something bad happened)
- m_scheduler.cancel (REEXPRESSING_INTEREST);
- m_scheduler.schedule (TIME_SECONDS_WITH_JITTER (0),
- bind (&SyncLogic::sendSyncInterest, this),
- REEXPRESSING_INTEREST);
+ // m_scheduler.cancel (REEXPRESSING_INTEREST);
+ // m_scheduler.schedule (TIME_SECONDS_WITH_JITTER (0),
+ // bind (&SyncLogic::sendSyncInterest, this),
+ // REEXPRESSING_INTEREST);
}
}
else
{
- _LOG_TRACE (">> D " << interestName << "/state" << " (timed processing)");
+ _LOG_TRACE (" (timed processing)");
+ // _LOG_TRACE (">> D " << interestName << "/state" << " (timed processing)");
- m_syncInterestTable.remove (interestName + "/state");
- m_ccnxHandle->publishData (interestName + "/state",
- lexical_cast<string> (m_state),
- m_syncResponseFreshness);
+ // m_syncInterestTable.remove (interestName + "/state");
+ // m_ccnxHandle->publishData (interestName + "/state",
+ // lexical_cast<string> (m_state),
+ // m_syncResponseFreshness);
- if (m_outstandingInterest == interestName)
+ // exit (1);
+ // if (m_outstandingInterest == interestName)
{
m_scheduler.cancel (REEXPRESSING_INTEREST);
m_scheduler.schedule (TIME_SECONDS_WITH_JITTER (0),
diff --git a/ns3/sync-ccnx-wrapper.cc b/ns3/sync-ccnx-wrapper.cc
index b61f034..5260dfc 100644
--- a/ns3/sync-ccnx-wrapper.cc
+++ b/ns3/sync-ccnx-wrapper.cc
@@ -108,7 +108,9 @@
is >> *name;
CcnxInterestHeader interestHeader;
- interestHeader.SetNonce (m_rand.GetValue ());
+ uint32_t nonce = m_rand.GetValue ();
+ _LOG_DEBUG ("Nonce: " << nonce);
+ interestHeader.SetNonce (nonce);
interestHeader.SetName (name);
interestHeader.SetInterestLifetime (Seconds (10000.0)); // really long-lived interests
diff --git a/ns3/sync-log.h b/ns3/sync-log.h
index 6dbc930..9da0dc8 100644
--- a/ns3/sync-log.h
+++ b/ns3/sync-log.h
@@ -27,6 +27,8 @@
#include <ns3/log.h>
+#ifdef _DEBUG
+
#define INIT_LOGGER(name) NS_LOG_COMPONENT_DEFINE(name);
#define _LOG_INFO(x) NS_LOG_INFO(x)
@@ -41,6 +43,17 @@
#else
+#define INIT_LOGGER(name)
+#define _LOG_INFO(x)
+#define _LOG_DEBUG(x)
+#define _LOG_TRACE(x)
+#define _LOG_FUNCTION(x)
+#define _LOG_FUNCTION_NOARGS
+
+#endif
+
+#else
+
#ifdef HAVE_LOG4CXX
#include <log4cxx/logger.h>
diff --git a/ns3/sync-scheduler.cc b/ns3/sync-scheduler.cc
index 95e4bf8..025eb3e 100644
--- a/ns3/sync-scheduler.cc
+++ b/ns3/sync-scheduler.cc
@@ -50,7 +50,7 @@
void
Scheduler::schedule (const TimeDuration &reltime, Event event, uint32_t label)
{
- NS_LOG_DEBUG ("Schedule event for " << (Simulator::Now () +reltime).ToDouble (Time::S) << "s for label " << label);
+ _LOG_DEBUG ("Schedule event for " << (Simulator::Now () +reltime).ToDouble (Time::S) << "s for label " << label);
list< EventId > &eventsForLabel = m_labeledEvents [label];
list< EventId >::iterator i = eventsForLabel.begin ();
@@ -75,7 +75,7 @@
Scheduler::cancel (uint32_t label)
{
list< EventId > &eventsForLabel = m_labeledEvents [label];
- NS_LOG_DEBUG ("Canceling events for label " << label << " (" << eventsForLabel.size () << " events)");
+ _LOG_DEBUG ("Canceling events for label " << label << " (" << eventsForLabel.size () << " events)");
for (list< EventId >::iterator i = eventsForLabel.begin ();
i != eventsForLabel.end ();