One more checkpoint. Now the code seems to work in a basic scenario
diff --git a/helper/ndn-stack-helper.cc b/helper/ndn-stack-helper.cc
index cfa6f3e..72bec65 100644
--- a/helper/ndn-stack-helper.cc
+++ b/helper/ndn-stack-helper.cc
@@ -267,8 +267,9 @@
NS_LOG_INFO("DataRate for this link is " << dataRate.Get());
double maxInterestPackets = 1.0 * dataRate.Get ().GetBitRate () / 8.0 / (m_avgContentObjectSize + m_avgInterestSize);
- NS_LOG_INFO ("Max packets per second: " << maxInterestPackets);
- NS_LOG_INFO ("Max burst: " << m_avgRtt.ToDouble (Time::S) * maxInterestPackets);
+ // NS_LOG_INFO ("Max packets per second: " << maxInterestPackets);
+ // NS_LOG_INFO ("Max burst: " << m_avgRtt.ToDouble (Time::S) * maxInterestPackets);
+ NS_LOG_INFO ("MaxLimit: " << (int)(m_avgRtt.ToDouble (Time::S) * maxInterestPackets));
// Set max to BDP
face->GetLimits ().SetMaxLimit (m_avgRtt.ToDouble (Time::S) * maxInterestPackets);
diff --git a/model/fw/best-route.cc b/model/fw/best-route.cc
index 604318f..076234f 100644
--- a/model/fw/best-route.cc
+++ b/model/fw/best-route.cc
@@ -62,7 +62,7 @@
Ptr<const Packet> origPacket,
Ptr<pit::Entry> pitEntry)
{
- NS_LOG_FUNCTION (this);
+ NS_LOG_FUNCTION (this << header->GetName ());
// Try to work out with just green faces
bool greenOk = super::DoPropagateInterest (inFace, header, origPacket, pitEntry);
diff --git a/model/fw/per-fib-limits.cc b/model/fw/per-fib-limits.cc
index d79a8fc..d56d48c 100644
--- a/model/fw/per-fib-limits.cc
+++ b/model/fw/per-fib-limits.cc
@@ -63,7 +63,6 @@
PerFibLimits::DoDispose ()
{
super::DoDispose ();
- // m_decayLimitsEvent.Cancel ();
}
void
@@ -99,21 +98,9 @@
// just suppress without any other action
return false;
}
-
- // if (pitEntry->GetFibEntry ()->GetLimits ().IsBelowLimit ())
- // {
- // if (outFace->GetLimits ().IsBelowLimit ())
- // {
- // pitEntry->AddOutgoing (outFace);
- // return true;
- // }
- // else
- // {
- // NS_LOG_DEBUG ("Face limit. Reverting back per-prefix allowance");
- // pitEntry->GetFibEntry ()->GetLimits ().RemoveOutstanding ();
- // }
- // }
+ NS_LOG_DEBUG ("Limit: " << outFace->GetLimits ().m_curMaxLimit << ", outstanding: " << outFace->GetLimits ().m_outstanding);
+
if (outFace->GetLimits ().IsBelowLimit ())
{
pitEntry->AddOutgoing (outFace);
@@ -122,15 +109,14 @@
Ptr<Packet> packetToSend = origPacket->Copy ();
outFace->Send (packetToSend);
- DidSendOutInterest (outFace, header, origPacket, pitEntry);
-
+ DidSendOutInterest (outFace, header, origPacket, pitEntry);
return true;
}
else
{
- NS_LOG_DEBUG ("Face limit");
+ NS_LOG_DEBUG ("Face limit for " << header->GetName ());
}
-
+
bool enqueued = m_pitQueues[outFace].Enqueue (inFace, pitEntry);
if (enqueued)
{
@@ -157,7 +143,6 @@
}
ProcessFromQueue ();
- // pitEntry->GetFibEntry ()->GetLimits ().RemoveOutstanding ();
}
@@ -178,29 +163,38 @@
}
ProcessFromQueue ();
-
- // pitEntry->GetFibEntry ()->GetLimits ().RemoveOutstanding ();
}
void
PerFibLimits::ProcessFromQueue ()
{
+ NS_LOG_FUNCTION (this);
+
for (PitQueueMap::iterator queue = m_pitQueues.begin ();
queue != m_pitQueues.end ();
queue++)
{
Ptr<Face> outFace = queue->first;
+
+ NS_LOG_DEBUG ("Processing " << *outFace);
while (!queue->second.IsEmpty () && outFace->GetLimits ().IsBelowLimit ())
{
// now we have enqueued packet and have slot available. Send out delayed packet
Ptr<pit::Entry> pitEntry = queue->second.Pop ();
+
+ // wrong, but for experimental purposes
+ // pitEntry->UpdateLifetime (pitEntry->GetInterest ()->GetInterestLifetime ());
+
+ NS_ASSERT_MSG (pitEntry != 0, "There *have to* be an entry in queue");
+
pitEntry->AddOutgoing (outFace);
Ptr<Packet> packetToSend = Create<Packet> ();
packetToSend->AddHeader (*pitEntry->GetInterest ());
-
+
+ NS_LOG_DEBUG ("Delayed sending for " << pitEntry->GetPrefix ());
outFace->Send (packetToSend);
DidSendOutInterest (outFace, pitEntry->GetInterest (), packetToSend, pitEntry);
}
@@ -217,19 +211,6 @@
// // ??
// }
-// void
-// PerFibLimits::DecayLimits ()
-// {
-// for (Ptr<fib::Entry> entry = m_fib->Begin ();
-// entry != m_fib->End ();
-// entry = m_fib->Next (entry))
-// {
-// entry->GetLimits ().DecayCurrentLimit ();
-// }
-
-// m_decayLimitsEvent = Simulator::Schedule (Seconds (1.0), &PerFibLimits::DecayLimits, this);
-// }
-
} // namespace fw
} // namespace ndn
diff --git a/utils/ndn-limits.cc b/utils/ndn-limits.cc
index a14abb2..d53e370 100644
--- a/utils/ndn-limits.cc
+++ b/utils/ndn-limits.cc
@@ -140,7 +140,7 @@
{
if (!IsEnabled ()) return true;
- if (m_curMaxLimit - m_outstanding > 1.0)
+ if (m_curMaxLimit - m_outstanding >= 1.0)
{
// static UniformVariable acceptanceProbability (0, m_curMaxLimit);
// double value = acceptanceProbability.GetValue ();
diff --git a/utils/ndn-pit-queue.cc b/utils/ndn-pit-queue.cc
index b287308..f8feb72 100644
--- a/utils/ndn-pit-queue.cc
+++ b/utils/ndn-pit-queue.cc
@@ -22,18 +22,21 @@
#include "ns3/ndn-face.h"
#include "ns3/ndn-pit-entry.h"
+#include "ns3/log.h"
#include "ns3/assert.h"
using namespace std;
using namespace boost;
+NS_LOG_COMPONENT_DEFINE ("ndn.PitQueue");
+
namespace ns3 {
namespace ndn {
PitQueue::PitQueue ()
- : m_maxQueueSize (10)
- , m_lastQueue (m_queues.begin ())
+ : m_maxQueueSize (20)
+ , m_lastQueue (m_queues.end ())
{
}
@@ -58,6 +61,7 @@
if (queue == m_queues.end ())
{
pair<PerInFaceQueue::iterator, bool> itemPair = m_queues.insert (make_pair (inFace, boost::make_shared<Queue> ()));
+ m_lastQueue = m_queues.end (); // for some reason end() iterator is invalidated when new item is inserted
NS_ASSERT (itemPair.second == true);
queue = itemPair.first;
@@ -90,7 +94,9 @@
}
if (queue == m_queues.end ())
- queue = m_queues.begin (); // circle to the beginning
+ {
+ queue = m_queues.begin (); // circle to the beginning
+ }
while (queue != m_queues.end () && queue->second->size () == 0) // advance iterator
{
@@ -157,7 +163,7 @@
bool
PitQueue::IsEmpty () const
{
- bool isEmpty = (m_queues.size () == 0);
+ bool isEmpty = true;
for (PerInFaceQueue::const_iterator queue = m_queues.begin ();
queue != m_queues.end ();