Finalizing interest limits. Now everything seem to work.
To work correctly, a lot of parameters have to be adjusted, including average
contentObject size, averageRTT, queues on nodes.
diff --git a/helper/ccnx-stack-helper.cc b/helper/ccnx-stack-helper.cc
index 234a64c..d9f9d6b 100644
--- a/helper/ccnx-stack-helper.cc
+++ b/helper/ccnx-stack-helper.cc
@@ -141,9 +141,13 @@
}
void
-CcnxStackHelper::EnableLimits (bool enable/* = true*/)
+CcnxStackHelper::EnableLimits (bool enable/* = true*/, Time avgRtt/*=Seconds(0.1)*/, uint32_t avgContentObject/*=1100*/, uint32_t avgInterest/*=40*/)
{
+ NS_LOG_INFO ("EnableLimits: " << enable);
m_limitsEnabled = enable;
+ m_avgContentObjectSize = avgContentObject;
+ m_avgInterestSize = avgInterest;
+ m_avgRtt = avgRtt;
}
Ptr<CcnxFaceContainer>
@@ -198,9 +202,13 @@
if (m_limitsEnabled)
{
+ NS_LOG_INFO ("Limits are enabled");
Ptr<PointToPointNetDevice> p2p = DynamicCast<PointToPointNetDevice> (device);
if (p2p == 0)
- continue; // only PointToPointNetDevice supports limits
+ {
+ NS_LOG_INFO ("Non p2p interface");
+ continue; // only PointToPointNetDevice supports limits
+ }
// Setup bucket filtering
// Assume that we know average data packet size, and this size is equal default size
@@ -209,11 +217,13 @@
DataRateValue dataRate; device->GetAttribute ("DataRate", dataRate);
NS_LOG_INFO("DataRate for this link is " << dataRate.Get());
- face->SetBucketMax
- (0.1 * dataRate.Get().GetBitRate () / (NDN_DEFAULT_DATA_SIZE + sizeof (CcnxInterestHeader)));
-
- face->SetBucketLeak
- (0.97 * dataRate.Get().GetBitRate () / (NDN_DEFAULT_DATA_SIZE + sizeof (CcnxInterestHeader)));
+
+ double maxInterestPackets = 1.0 * dataRate.Get ().GetBitRate () / 8.0 / m_avgContentObjectSize;
+ NS_LOG_INFO ("BucketMax: " << maxInterestPackets);
+
+ // Set bucket max to BDP
+ face->SetBucketMax (m_avgRtt.ToDouble (Time::S) * maxInterestPackets); // number of interests allowed
+ face->SetBucketLeak (maxInterestPackets);
}
face->SetUp ();
diff --git a/helper/ccnx-stack-helper.h b/helper/ccnx-stack-helper.h
index af45c2b..ee166fc 100644
--- a/helper/ccnx-stack-helper.h
+++ b/helper/ccnx-stack-helper.h
@@ -30,6 +30,7 @@
#include "ns3/ccnx-forwarding-helper.h"
#include "ns3/ccnx.h"
#include "ns3/ccnx-interest-header.h"
+#include "ns3/nstime.h"
namespace ns3 {
@@ -85,9 +86,14 @@
/**
* @brief Enable Interest limits (disabled by default)
+ *
+ * @param enable Enable or disable limits
+ * @param avgRtt Average RTT
+ * @param avgContentObject Average size of contentObject packets (including all headers)
+ * @param avgInterest Average size of interest packets (including all headers)
*/
void
- EnableLimits (bool enable = true);
+ EnableLimits (bool enable = true, Time avgRtt=Seconds(0.1), uint32_t avgContentObject=1100, uint32_t avgInterest=40);
/**
* \brief Install CCNx stack on the node
@@ -198,6 +204,9 @@
private:
ObjectFactory m_strategyFactory;
bool m_limitsEnabled;
+ Time m_avgRtt;
+ uint32_t m_avgContentObjectSize;
+ uint32_t m_avgInterestSize;
// /**
// * @brief Enable pcap output the indicated Ccnx and interface pair.