Slight API change. Now there is only one CcnxAppHelper that can create all CcnxApps
diff --git a/model/ccnx-face.cc b/model/ccnx-face.cc
index 18b2015..95c0b7f 100644
--- a/model/ccnx-face.cc
+++ b/model/ccnx-face.cc
@@ -27,6 +27,7 @@
#include "ns3/assert.h"
#include "ns3/uinteger.h"
#include "ns3/double.h"
+#include "ns3/simulator.h"
#include <boost/ref.hpp>
@@ -72,6 +73,7 @@
, m_protocolHandler (MakeNullCallback<void,const Ptr<CcnxFace>&,const Ptr<const Packet>&> ())
, m_ifup (false)
, m_id ((uint32_t)-1)
+ , m_lastLeakTime (0)
{
NS_LOG_FUNCTION (this);
@@ -109,6 +111,8 @@
if (!IsUp ())
return false;
+
+ LeakBucket ();
if (m_bucketMax > 0)
{
@@ -155,10 +159,21 @@
}
void
-CcnxFace::LeakBucket (const Time &interval)
+CcnxFace::LeakBucket ()
{
+ if (m_lastLeakTime.IsZero ())
+ {
+ m_lastLeakTime = Simulator::Now ();
+ return;
+ }
+
+ Time interval = Simulator::Now () - m_lastLeakTime;
const double leak = m_bucketLeak * interval.ToDouble (Time::S);
- m_bucket = std::max (0.0, m_bucket - leak);
+ if (leak >= 1.0)
+ {
+ m_bucket = std::max (0.0, m_bucket - leak);
+ m_lastLeakTime = Simulator::Now ();
+ }
// NS_LOG_DEBUG ("max: " << m_bucketMax << ", Current bucket: " << m_bucket << ", leak size: " << leak << ", interval: " << interval << ", " << m_bucketLeak);
}
@@ -177,12 +192,6 @@
m_bucketLeak = leak;
}
-void
-CcnxFace::LeakBucketByOnePacket ()
-{
- m_bucket = std::max (0.0, m_bucket-1.0);
-}
-
// void
// CcnxFace::SetMetric (uint16_t metric)
// {
@@ -202,6 +211,7 @@
* NetDevice states, such as found in real implementations
* (where the device may be down but face state is still up).
*/
+
bool
CcnxFace::IsUp (void) const
{