Small corrections and python bindings rescan
diff --git a/model/forwarding-strategy/green-yellow-red.cc b/model/forwarding-strategy/green-yellow-red.cc
index f945bbe..e3d4322 100644
--- a/model/forwarding-strategy/green-yellow-red.cc
+++ b/model/forwarding-strategy/green-yellow-red.cc
@@ -58,7 +58,7 @@
{
static TypeId tid = TypeId ("ns3::ndnSIM::GreenYellowRed")
.SetGroupName ("Ccnx")
- .SetParent<CcnxForwardingStrategy> ()
+ .SetParent<Nacks> ()
;
return tid;
@@ -126,5 +126,19 @@
super::WillSatisfyPendingInterest (incomingFace, pitEntry);
}
+void
+GreenYellowRed::DidReceiveValidNack (const Ptr<CcnxFace> &incomingFace,
+ uint32_t nackCode,
+ Ptr<CcnxPitEntry> pitEntry)
+{
+ super::DidReceiveValidNack (incomingFace, nackCode, pitEntry);
+
+ if (nackCode != CcnxInterestHeader::NACK_LOOP)
+ {
+ pitEntry->GetFibEntry ()->UpdateStatus (incomingFace, CcnxFibFaceMetric::NDN_FIB_YELLOW);
+ }
+}
+
+
} // namespace ndnSIM
} // namespace ns3
diff --git a/model/forwarding-strategy/green-yellow-red.h b/model/forwarding-strategy/green-yellow-red.h
index 71f4955..383f3f4 100644
--- a/model/forwarding-strategy/green-yellow-red.h
+++ b/model/forwarding-strategy/green-yellow-red.h
@@ -21,7 +21,7 @@
#ifndef NDNSIM_GREEN_YELLOW_RED_H
#define NDNSIM_GREEN_YELLOW_RED_H
-#include "ccnx-forwarding-strategy.h"
+#include "nacks.h"
namespace ns3 {
namespace ndnSIM {
@@ -30,7 +30,7 @@
* \ingroup ccnx
*/
class GreenYellowRed :
- public CcnxForwardingStrategy
+ public Nacks
{
public:
static TypeId GetTypeId (void);
@@ -45,9 +45,13 @@
Ptr<CcnxInterestHeader> &header,
const Ptr<const Packet> &packet,
Ptr<CcnxPitEntry> pitEntry);
+ virtual void
+ DidReceiveValidNack (const Ptr<CcnxFace> &incomingFace,
+ uint32_t nackCode,
+ Ptr<CcnxPitEntry> pitEntry);
private:
- typedef CcnxForwardingStrategy super;
+ typedef Nacks super;
};
} // namespace ndnSIM
diff --git a/model/forwarding-strategy/nacks.cc b/model/forwarding-strategy/nacks.cc
index 925788c..b0a193e 100644
--- a/model/forwarding-strategy/nacks.cc
+++ b/model/forwarding-strategy/nacks.cc
@@ -83,11 +83,50 @@
}
void
-Nacks::OnNack (const Ptr<CcnxFace> &face,
+Nacks::OnNack (const Ptr<CcnxFace> &incomingFace,
Ptr<CcnxInterestHeader> &header,
- const Ptr<const Packet> &p)
+ const Ptr<const Packet> &packet)
{
- NS_ASSERT (false);
+ NS_ASSERT (m_nacksEnabled);
+
+ // NS_LOG_FUNCTION (incomingFace << header << packet);
+ m_inNacks (header, incomingFace);
+
+ Ptr<CcnxPitEntry> pitEntry = m_pit->Lookup (*header);
+ if (pitEntry == 0)
+ {
+ // somebody is doing something bad
+ m_dropNacks (header, incomingFace);
+ return;
+ }
+
+ // This was done in error. Never, never do anything, except normal leakage. This way we ensure that we will not have losses,
+ // at least when there is only one client
+ //
+ // incomingFace->LeakBucketByOnePacket ();
+
+ pitEntry->SetWaitingInVain (incomingFace);
+
+ DidReceiveValidNack (incomingFace, header->GetNack (), pitEntry);
+
+ if (!pitEntry->AreAllOutgoingInVain ()) // not all ougtoing are in vain
+ {
+ NS_LOG_DEBUG ("Not all outgoing are in vain");
+ // suppress
+ // Don't do anything, we are still expecting data from some other face
+ m_dropNacks (header, incomingFace);
+ return;
+ }
+
+ Ptr<Packet> nonNackInterest = Create<Packet> ();
+ header->SetNack (CcnxInterestHeader::NORMAL_INTEREST);
+ nonNackInterest->AddHeader (*header);
+
+ bool propagated = DoPropagateInterest (incomingFace, header, nonNackInterest, pitEntry);
+ if (!propagated)
+ {
+ DidExhaustForwardingOptions (incomingFace, header, nonNackInterest, pitEntry);
+ }
}
void
@@ -143,6 +182,20 @@
}
}
+void
+Nacks::DidReceiveValidNack (const Ptr<CcnxFace> &incomingFace,
+ uint32_t nackCode,
+ Ptr<CcnxPitEntry> pitEntry)
+{
+ // If NACK is NACK_GIVEUP_PIT, then neighbor gave up trying to and removed it's PIT entry.
+ // So, if we had an incoming entry to this neighbor, then we can remove it now
+ if (nackCode == CcnxInterestHeader::NACK_GIVEUP_PIT)
+ {
+ pitEntry->RemoveIncoming (incomingFace);
+ }
+
+ pitEntry->GetFibEntry ()->UpdateStatus (incomingFace, CcnxFibFaceMetric::NDN_FIB_YELLOW);
+}
} // namespace ndnSIM
} // namespace ns3
diff --git a/model/forwarding-strategy/nacks.h b/model/forwarding-strategy/nacks.h
index fbcec9f..81e478c 100644
--- a/model/forwarding-strategy/nacks.h
+++ b/model/forwarding-strategy/nacks.h
@@ -70,10 +70,10 @@
Ptr<CcnxInterestHeader> &header,
const Ptr<const Packet> &p);
- // virtual void
- // OnDataDelayed (Ptr<const CcnxContentObjectHeader> header,
- // Ptr<const Packet> payload,
- // const Ptr<const Packet> &packet);
+ virtual void
+ DidReceiveValidNack (const Ptr<CcnxFace> &incomingFace,
+ uint32_t nackCode,
+ Ptr<CcnxPitEntry> pitEntry);
protected:
bool m_nacksEnabled;
diff --git a/model/pit/ccnx-pit-entry.cc b/model/pit/ccnx-pit-entry.cc
index 081b155..aca735a 100644
--- a/model/pit/ccnx-pit-entry.cc
+++ b/model/pit/ccnx-pit-entry.cc
@@ -111,15 +111,29 @@
m_outgoing.erase (outgoing);
}
-void
-CcnxPitEntry::SetWaitingInVain (CcnxPitEntry::out_iterator face)
-{
- NS_LOG_DEBUG (boost::cref (*face->m_face));
+// void
+// CcnxPitEntry::SetWaitingInVain (CcnxPitEntry::out_iterator face)
+// {
+// NS_LOG_DEBUG (boost::cref (*face->m_face));
- m_outgoing.modify (face,
+// m_outgoing.modify (face,
+// (&ll::_1)->*&CcnxPitEntryOutgoingFace::m_waitingInVain = true);
+// }
+
+void
+CcnxPitEntry::SetWaitingInVain (Ptr<CcnxFace> face)
+{
+ // NS_LOG_DEBUG (boost::cref (*face->m_face));
+
+ out_iterator item = m_outgoing.find (face);
+ if (item == m_outgoing.end ())
+ return;
+
+ m_outgoing.modify (item,
(&ll::_1)->*&CcnxPitEntryOutgoingFace::m_waitingInVain = true);
}
+
bool
CcnxPitEntry::AreAllOutgoingInVain () const
{
diff --git a/model/pit/ccnx-pit-entry.h b/model/pit/ccnx-pit-entry.h
index 37de28e..4cbae2e 100644
--- a/model/pit/ccnx-pit-entry.h
+++ b/model/pit/ccnx-pit-entry.h
@@ -205,8 +205,10 @@
/**
* @brief Flag outgoing face as hopeless
*/
+ // virtual void
+ // SetWaitingInVain (out_iterator face);
virtual void
- SetWaitingInVain (out_iterator face);
+ SetWaitingInVain (Ptr<CcnxFace> face);
/**
* @brief Check if all outgoing faces are NACKed