ForwardingStrategy removes PIT if interest wasn't propagated. Updated
Limits interface (adding config options). Small randomization for decay
frequency in PerFibLimits strategy.
diff --git a/utils/ndn-limits.cc b/utils/ndn-limits.cc
index 967c773..a14abb2 100644
--- a/utils/ndn-limits.cc
+++ b/utils/ndn-limits.cc
@@ -22,6 +22,7 @@
#include "ns3/log.h"
#include "ns3/simulator.h"
+#include "ns3/random-variable.h"
NS_LOG_COMPONENT_DEFINE ("ndn.Limits");
@@ -38,6 +39,30 @@
.SetParent <Object> ()
.AddConstructor <Limits> ()
+ .AddAttribute ("ExpDecayTau", "Parameter 'tau' for the exponential delay of the current maximum limit variable",
+ TimeValue (Seconds (100.0)),
+ MakeTimeAccessor (&Limits::m_exponentialDecayTau),
+ MakeTimeChecker ()
+ )
+
+ .AddAttribute ("NonDecreasePeriod", "Only one decrease is allowed per one NonDecreasePeriod",
+ TimeValue (Seconds (0.1)),
+ MakeTimeAccessor (&Limits::m_nonDecreasePeriod),
+ MakeTimeChecker ()
+ )
+
+ .AddAttribute ("AdditiveIncrease", "Parameter for additive increase",
+ DoubleValue (1.0),
+ MakeDoubleAccessor (&Limits::m_additiveIncrease),
+ MakeDoubleChecker<double> ()
+ )
+
+ .AddAttribute ("MultiplicativeDecrease", "Parameter for multiplicative decrease",
+ DoubleValue (0.5),
+ MakeDoubleAccessor (&Limits::m_multiplicativeDecrease),
+ MakeDoubleChecker<double> ()
+ )
+
.AddTraceSource ("CurMaxLimit",
"Current maximum limit",
MakeTraceSourceAccessor (&Limits::m_curMaxLimit))
@@ -56,21 +81,25 @@
m_curMaxLimit = max;
}
+uint32_t
+Limits::GetMaxLimit () const
+{
+ return m_maxLimit;
+}
void
Limits::DecayCurrentLimit ()
{
- if (m_maxLimit == 0) return;
+ if (!IsEnabled ()) return;
if (!m_lastDecay.IsZero ())
{
- const double tau = 100.0; // seconds
double timeDiff = (Simulator::Now () - m_lastDecay).ToDouble (Time::S);
NS_LOG_DEBUG ("m_maxLimit - (m_maxLimit - m_curMaxLimit) * exp (-timeDiff / tau)");
- NS_LOG_DEBUG (m_maxLimit << " - " << " ( " << m_maxLimit << " - " << (double)m_curMaxLimit << " ) " << " * " << " exp (- " << timeDiff << " / " << tau << " ) ");
+ NS_LOG_DEBUG (m_maxLimit << " - " << " ( " << m_maxLimit << " - " << (double)m_curMaxLimit << " ) " << " * " << " exp (- " << timeDiff << " / " << m_exponentialDecayTau.ToDouble (Time::S) << " ) ");
- m_curMaxLimit = m_maxLimit - (m_maxLimit - m_curMaxLimit) * exp (-timeDiff / tau);
+ m_curMaxLimit = m_maxLimit - (m_maxLimit - m_curMaxLimit) * exp (-timeDiff / m_exponentialDecayTau.ToDouble (Time::S));
}
m_lastDecay = Simulator::Now ();
@@ -79,39 +108,54 @@
void
Limits::IncreaseLimit ()
{
- if (m_maxLimit == 0) return;
+ if (!IsEnabled ()) return;
// Additive increase
m_curMaxLimit = std::min (1.0 * m_maxLimit,
- (double)m_curMaxLimit + 1.0 / (double)m_curMaxLimit);
+ (double)m_curMaxLimit + m_additiveIncrease / (double)m_curMaxLimit);
}
void
Limits::DecreaseLimit ()
{
- if (m_maxLimit == 0) return;
+ if (!IsEnabled ()) return;
+
+// m_curMaxLimit = std::max (0.0,
+// (double)m_curMaxLimit - m_multiplicativeDecrease / (double)m_curMaxLimit);
+// }
- const double maxDecreaseFrequency = 10.0;
-
- if (!m_lastDecrease.IsZero () && Simulator::Now () - m_lastDecrease < Seconds (1 / maxDecreaseFrequency))
- return;
-
- // Multiplicative decrease... almost
- m_curMaxLimit = 0.5 * m_curMaxLimit;
+ if (m_lastDecrease.IsZero () ||
+ (!m_lastDecrease.IsZero () && Simulator::Now () - m_lastDecrease > m_nonDecreasePeriod)) // allow
+ {
+ // Multiplicative decrease... almost
+ m_curMaxLimit = m_multiplicativeDecrease * m_curMaxLimit;
- m_lastDecrease = Simulator::Now ();
+ m_lastDecrease = Simulator::Now ();
+ }
}
bool
Limits::IsBelowLimit ()
{
- if (m_maxLimit == 0) return true;
+ if (!IsEnabled ()) return true;
if (m_curMaxLimit - m_outstanding > 1.0)
{
- m_outstanding += 1;
- return true;
+ // static UniformVariable acceptanceProbability (0, m_curMaxLimit);
+ // double value = acceptanceProbability.GetValue ();
+ double value = m_outstanding+ 1;
+
+ if (m_outstanding < value)
+ {
+ m_outstanding += 1.0;
+ return true;
+ }
+ else
+ return false;
+
+ // m_outstanding += 1;
+ // return true;
}
else
return false;
@@ -120,7 +164,7 @@
void
Limits::RemoveOutstanding ()
{
- if (m_maxLimit == 0) return; //limits are disabled
+ if (!IsEnabled ()) return; //limits are disabled
NS_LOG_DEBUG (m_outstanding);
NS_ASSERT_MSG (m_outstanding >= 1, "Should not be possible, unless we decreasing this number twice somewhere");
diff --git a/utils/ndn-limits.h b/utils/ndn-limits.h
index b8ca50d..034c979 100644
--- a/utils/ndn-limits.h
+++ b/utils/ndn-limits.h
@@ -51,25 +51,40 @@
{ }
/**
- * Set per-prefix limit
+ * @brief Set limit for the number of outstanding interests
*/
void
SetMaxLimit (uint32_t max);
/**
- * Decay current limit (exponential decaying)
+ * @brief Get limit for the number of outstanding interests
+ */
+ uint32_t
+ GetMaxLimit () const;
+
+ /**
+ * @brief Check whether limits are enabled or not
+ */
+ inline bool
+ IsEnabled () const;
+
+ /**
+ * @brief Decay current limit (exponential decaying)
+ *
+ * If needed, this method should be called externally periodically (doesn't matter how often, decaying amount will remain the same).
+ * Decaying is most likely needed for per-prefix limits, but definitely not needed for per-face limits.
*/
void
DecayCurrentLimit ();
/**
- * Increase current limit (additive increase)
+ * @brief Increase current limit (additive increase)
*/
void
IncreaseLimit ();
/**
- * Decrease current limit (multiplicative decrease)
+ * @brief Decrease current limit (multiplicative decrease)
*/
void
DecreaseLimit ();
@@ -79,13 +94,13 @@
////////////////////////////////////////////////////////////////////////////
/**
- * Check if new interest can be send out, if yes, number of outstanding will be increased
+ * @brief Check if new interest can be send out, if yes, number of outstanding will be increased
*/
bool
IsBelowLimit ();
/**
- * Remove outstanding interests
+ * @brief Remove outstanding interests
*/
void
RemoveOutstanding ();
@@ -96,10 +111,22 @@
TracedValue< double > m_curMaxLimit;
TracedValue< uint32_t > m_outstanding;
+ Time m_exponentialDecayTau;
+ Time m_nonDecreasePeriod;
+ double m_additiveIncrease;
+ double m_multiplicativeDecrease;
+
Time m_lastDecrease;
Time m_lastDecay;
};
+inline bool
+Limits::IsEnabled () const
+{
+ return m_maxLimit != 0;
+}
+
+
} // namespace ndn
} // namespace ns3