Correcting NACK behavior (actually, reaction to NACKs)
diff --git a/model/ccnx-bestroute-strategy.cc b/model/ccnx-bestroute-strategy.cc
index a7a9801..20d1a81 100644
--- a/model/ccnx-bestroute-strategy.cc
+++ b/model/ccnx-bestroute-strategy.cc
@@ -66,6 +66,9 @@
if (bestMetric.m_status == CcnxFibFaceMetric::NDN_FIB_RED) // no point to send there
continue;
+ if (pitEntry.m_incoming.find (bestMetric.m_face) != pitEntry.m_incoming.end ())
+ continue; // don't forward to face that we received interest from
+
if (pitEntry.m_outgoing.find (bestMetric.m_face) != pitEntry.m_outgoing.end ()) // already forwarded before
continue;
diff --git a/model/ccnx-flooding-strategy.cc b/model/ccnx-flooding-strategy.cc
index 52231b4..147edba 100644
--- a/model/ccnx-flooding-strategy.cc
+++ b/model/ccnx-flooding-strategy.cc
@@ -63,11 +63,14 @@
if (metricFace.m_status == CcnxFibFaceMetric::NDN_FIB_RED) // all non-read faces are in front
break;
- if (metricFace.m_face == incomingFace) // same face as incoming, don't forward
- continue;
+ if (metricFace.m_face == incomingFace)
+ continue; // same face as incoming, don't forward
- if (pitEntry.m_outgoing.find (metricFace.m_face) != pitEntry.m_outgoing.end ()) // already forwarded before
- continue;
+ if (pitEntry.m_incoming.find (metricFace.m_face) != pitEntry.m_incoming.end ())
+ continue; // don't forward to face that we received interest from
+
+ if (pitEntry.m_outgoing.find (metricFace.m_face) != pitEntry.m_outgoing.end ())
+ continue; // already forwarded before
bool faceAvailable = metricFace.m_face->IsBelowLimit ();
if (!faceAvailable) // huh...
diff --git a/model/ccnx-l3-protocol.cc b/model/ccnx-l3-protocol.cc
index bba9ef9..718e684 100644
--- a/model/ccnx-l3-protocol.cc
+++ b/model/ccnx-l3-protocol.cc
@@ -308,7 +308,8 @@
"Outgoing entry should exist");
outFace->m_face->LeakBucketByOnePacket ();
- // outFace->m_waitingInVain = true; // don't think that this is necessary
+ m_pit->modify (m_pit->iterator_to (pitEntry),
+ ll::bind (&CcnxPitEntry::SetWaitingInVain, ll::_1, outFace));
// m_droppedInterestsTrace (header, DROP_CONGESTION, m_node->GetObject<Ccnx> (), incomingFace);
@@ -337,7 +338,8 @@
// ForwardingStrategy will try its best to forward packet to at least one interface.
// If no interests was propagated, then there is not other option for forwarding or
// ForwardingStrategy failed to find it.
- if (!propagated) GiveUpInterest (pitEntry, header);
+ if (!propagated && pitEntry.AreAllOutgoingInVain ())
+ GiveUpInterest (pitEntry, header);
}
// Processing Interests
diff --git a/model/ccnx-pit-entry-outgoing-face.cc b/model/ccnx-pit-entry-outgoing-face.cc
index c15df71..a0a8772 100644
--- a/model/ccnx-pit-entry-outgoing-face.cc
+++ b/model/ccnx-pit-entry-outgoing-face.cc
@@ -30,7 +30,7 @@
// , m_retxNum (0)
// , m_nonce (nonce)
// , m_outstanding (true)
- // , m_waitingInVain (false)
+ , m_waitingInVain (false)
{
}
diff --git a/model/ccnx-pit-entry-outgoing-face.h b/model/ccnx-pit-entry-outgoing-face.h
index de1dd4b..0fce545 100644
--- a/model/ccnx-pit-entry-outgoing-face.h
+++ b/model/ccnx-pit-entry-outgoing-face.h
@@ -41,7 +41,7 @@
// uint32_t m_retxNum; ///< \brief number of retransmission
// int m_nonce; ///< \brief nonce of the outgoing Interest
// bool m_outstanding; ///< \brief flag to indicate that this interest is currently pending
- // bool m_waitingInVain; ///< \brief when flag is set, we do not expect data for this interest, only a small hope that it will happen
+ bool m_waitingInVain; ///< \brief when flag is set, we do not expect data for this interest, only a small hope that it will happen
public:
CcnxPitEntryOutgoingFace (Ptr<CcnxFace> face);
diff --git a/model/ccnx-pit-entry.cc b/model/ccnx-pit-entry.cc
index 61b4fcc..2886ed6 100644
--- a/model/ccnx-pit-entry.cc
+++ b/model/ccnx-pit-entry.cc
@@ -23,6 +23,12 @@
#include "ccnx-fib.h"
#include "ns3/simulator.h"
+#include "ns3/log.h"
+
+#include <boost/lambda/lambda.hpp>
+namespace ll = boost::lambda;
+
+NS_LOG_COMPONENT_DEFINE ("CcnxPitEntry");
namespace ns3
{
@@ -83,4 +89,23 @@
m_outgoing.erase (outgoing);
}
-}
+void
+CcnxPitEntry::SetWaitingInVain (CcnxPitEntryOutgoingFaceContainer::type::iterator face)
+{
+ m_outgoing.modify (face,
+ (&ll::_1)->*&CcnxPitEntryOutgoingFace::m_waitingInVain = true);
+}
+
+bool
+CcnxPitEntry::AreAllOutgoingInVain () const
+{
+ bool inVain = true;
+ std::for_each (m_outgoing.begin (), m_outgoing.end (),
+ ll::var(inVain) &= (&ll::_1)->*&CcnxPitEntryOutgoingFace::m_waitingInVain);
+
+ NS_LOG_DEBUG ("inVain " << inVain);
+ return inVain;
+}
+
+
+}
diff --git a/model/ccnx-pit-entry.h b/model/ccnx-pit-entry.h
index bb42a6a..fd426f5 100644
--- a/model/ccnx-pit-entry.h
+++ b/model/ccnx-pit-entry.h
@@ -194,6 +194,18 @@
void
RemoveAllReferencesToFace (Ptr<CcnxFace> face);
+ /**
+ * @brief Flag outgoing face as hopeless
+ */
+ void
+ SetWaitingInVain (CcnxPitEntryOutgoingFaceContainer::type::iterator face);
+
+ /**
+ * @brief Check if all outgoing faces are NACKed
+ */
+ bool
+ AreAllOutgoingInVain () const;
+
protected:
private: