fw: Slightly modifying events for Interest forwarding.
Now we have explicit method to check whether Interest can be forwarded
or not. Unlike it was before, now this method allows clear chaining.
diff --git a/model/fw/ndn-forwarding-strategy.cc b/model/fw/ndn-forwarding-strategy.cc
index b04d48e..14db750 100644
--- a/model/fw/ndn-forwarding-strategy.cc
+++ b/model/fw/ndn-forwarding-strategy.cc
@@ -467,7 +467,7 @@
}
bool
-ForwardingStrategy::TrySendOutInterest (Ptr<Face> inFace,
+ForwardingStrategy::CanSendOutInterest (Ptr<Face> inFace,
Ptr<Face> outFace,
Ptr<const InterestHeader> header,
Ptr<const Packet> origPacket,
@@ -492,6 +492,22 @@
return false; // already forwarded before during this retransmission cycle
}
}
+
+ return true;
+}
+
+
+bool
+ForwardingStrategy::TrySendOutInterest (Ptr<Face> inFace,
+ Ptr<Face> outFace,
+ Ptr<const InterestHeader> header,
+ Ptr<const Packet> origPacket,
+ Ptr<pit::Entry> pitEntry)
+{
+ if (!CanSendOutInterest (inFace, outFace, header, origPacket, pitEntry))
+ {
+ return false;
+ }
pitEntry->AddOutgoing (outFace);
@@ -514,7 +530,7 @@
}
void
-ForwardingStrategy::DidSendOutData (Ptr<Face> inFace,
+ForwardingStrategy::DidSendOutData (Ptr<Face> outFace,
Ptr<const ContentObjectHeader> header,
Ptr<const Packet> payload,
Ptr<const Packet> origPacket,
diff --git a/model/fw/ndn-forwarding-strategy.h b/model/fw/ndn-forwarding-strategy.h
index fbf2295..fa42502 100644
--- a/model/fw/ndn-forwarding-strategy.h
+++ b/model/fw/ndn-forwarding-strategy.h
@@ -216,18 +216,49 @@
Ptr<const Packet> origPacket,
Ptr<pit::Entry> pitEntry);
+ /**
+ * @brief Method that implements logic to distinguish between new and retransmitted interest
+ *
+ * This method is called only when DetectRetransmissions attribute is set true (by default).
+ *
+ * Currently, the retransmission detection logic relies on the fact that list of incoming faces
+ * already has inFace (i.e., a similar interest is received on the same face more than once).
+ *
+ * @param inFace incoming face
+ * @param header deserialized Interest header
+ * @param origPacket original packet
+ * @param pitEntry an existing PIT entry, corresponding to the duplicated Interest
+ * @return true if Interest should be considered as retransmitted
+ */
virtual bool
DetectRetransmittedInterest (Ptr<Face> inFace,
Ptr<const InterestHeader> header,
Ptr<const Packet> origPacket,
Ptr<pit::Entry> pitEntry);
- // When Interest is satisfied from the cache, incoming face is 0
+ /**
+ * @brief Even fired just before Interest will be satisfied
+ *
+ * Note that when Interest is satisfied from the cache, incoming face will be 0
+ *
+ * @param inFace incoming face
+ * @param pitEntry an existing PIT entry, corresponding to the duplicated Interest
+ */
virtual void
WillSatisfyPendingInterest (Ptr<Face> inFace,
Ptr<pit::Entry> pitEntry);
- // for data received both from network and cache
+ /**
+ * @brief Actual procedure to satisfy Interest
+ *
+ * Note that when Interest is satisfied from the cache, incoming face will be 0
+ *
+ * @param inFace incoming face
+ * @param header deserialized ContentObject header
+ * @param payload ContentObject payload
+ * @param origPacket original packet
+ * @param pitEntry an existing PIT entry, corresponding to the duplicated Interest
+ */
virtual void
SatisfyPendingInterest (Ptr<Face> inFace, // 0 allowed (from cache)
Ptr<const ContentObjectHeader> header,
@@ -235,19 +266,52 @@
Ptr<const Packet> origPacket,
Ptr<pit::Entry> pitEntry);
+ /**
+ * @brief Event which is fired just after data was send out on the face
+ *
+ * @param outFace outgoing face
+ * @param header deserialized ContentObject header
+ * @param payload ContentObject payload
+ * @param origPacket original packet
+ * @param pitEntry an existing PIT entry, corresponding to the duplicated Interest
+ */
virtual void
- DidSendOutData (Ptr<Face> inFace,
+ DidSendOutData (Ptr<Face> outFace,
Ptr<const ContentObjectHeader> header,
Ptr<const Packet> payload,
Ptr<const Packet> origPacket,
Ptr<pit::Entry> pitEntry);
-
+
+ /**
+ * @brief Event which is fired every time an unsolicited DATA packet (no active PIT entry) is received
+ *
+ * The current implementation allows ignoring unsolicited DATA (by default), or cache it by setting
+ * attribute CacheUnsolicitedData true
+ *
+ * @param inFace incoming face
+ * @param header deserialized ContentObject header
+ * @param payload ContentObject payload
+ * @param origPacket original packet
+ */
virtual void
DidReceiveUnsolicitedData (Ptr<Face> inFace,
Ptr<const ContentObjectHeader> header,
Ptr<const Packet> payload,
Ptr<const Packet> origPacket);
-
+
+ /**
+ * @brief Method implementing logic to suppress (collapse) similar Interests
+ *
+ * In the base class implementation this method checks list of incoming/outgoing faces of the PIT entry
+ * (for new Intersets, both lists are empty before this call)
+ *
+ * For more details, refer to the source code.
+ *
+ * @param inFace incoming face
+ * @param header deserialized ContentObject header
+ * @param payload ContentObject payload
+ * @param origPacket original packet
+ */
virtual bool
ShouldSuppressIncomingInterest (Ptr<Face> inFace,
Ptr<const InterestHeader> header,
@@ -255,9 +319,40 @@
Ptr<pit::Entry> pitEntry);
/**
- * @brief Event fired before actually sending out an interest
+ * @brief Method to check whether Interest can be send out on the particular face or not
*
- * If event returns false, then there is some kind of a problem (e.g., per-face limit reached)
+ * In the base class, this method perfoms two checks:
+ * 1. If inFace is equal to outFace (when equal, Interest forwarding is prohibited)
+ * 2. Whether Interest should be suppressed (list of outgoing faces include outFace),
+ * considering (if enabled) retransmission logic
+ *
+ * @param inFace incoming face of the Interest
+ * @param outFace proposed outgoing face of the Interest
+ * @param header parsed Interest header
+ * @param origPacket original Interest packet
+ * @param pitEntry reference to PIT entry (reference to corresponding FIB entry inside)
+ *
+ * @see DetectRetransmittedInterest
+ */
+ virtual bool
+ CanSendOutInterest (Ptr<Face> inFace,
+ Ptr<Face> outFace,
+ Ptr<const InterestHeader> header,
+ Ptr<const Packet> origPacket,
+ Ptr<pit::Entry> pitEntry);
+
+ /**
+ * @brief Method implementing actual interest forwarding, taking into account CanSendOutInterest decision
+ *
+ * If event returns false, then there is some kind of a problem exists
+ *
+ * @param inFace incoming face of the Interest
+ * @param outFace proposed outgoing face of the Interest
+ * @param header parsed Interest header
+ * @param origPacket original Interest packet
+ * @param pitEntry reference to PIT entry (reference to corresponding FIB entry inside)
+ *
+ * @see CanSendOutInterest
*/
virtual bool
TrySendOutInterest (Ptr<Face> inFace,
@@ -267,7 +362,12 @@
Ptr<pit::Entry> pitEntry);
/**
- * @brief Event fired just after sending out an interest
+ * @brief Event fired just after forwarding the Interest
+ *
+ * @param outFace outgoing face of the Interest
+ * @param header parsed Interest header
+ * @param origPacket original Interest packet
+ * @param pitEntry reference to PIT entry (reference to corresponding FIB entry inside)
*/
virtual void
DidSendOutInterest (Ptr<Face> outFace,
diff --git a/model/fw/simple-limits.h b/model/fw/simple-limits.h
index dd597c0..ce639e3 100644
--- a/model/fw/simple-limits.h
+++ b/model/fw/simple-limits.h
@@ -23,6 +23,7 @@
#define NDNSIM_SIMPLE_LIMITS_H
#include "ns3/event-id.h"
+#include "ns3/log.h"
#include "ns3/ndn-pit.h"
#include "ns3/ndn-pit-entry.h"
#include "ns3/simulator.h"
@@ -72,7 +73,7 @@
protected:
virtual bool
- TrySendOutInterest (Ptr<Face> inFace,
+ CanSendOutInterest (Ptr<Face> inFace,
Ptr<Face> outFace,
Ptr<const InterestHeader> header,
Ptr<const Packet> origPacket,
@@ -84,9 +85,14 @@
private:
std::string m_limitType;
+
+ static LogComponent g_log;
};
template<class Parent>
+LogComponent SimpleLimits<Parent>::g_log = LogComponent ("ndn.SimpleLimits");
+
+template<class Parent>
TypeId
SimpleLimits<Parent>::GetTypeId (void)
{
@@ -105,50 +111,36 @@
template<class Parent>
bool
-SimpleLimits<Parent>::TrySendOutInterest (Ptr<Face> inFace,
- Ptr<Face> outFace,
- Ptr<const InterestHeader> header,
- Ptr<const Packet> origPacket,
- Ptr<pit::Entry> pitEntry)
+SimpleLimits<Parent>::CanSendOutInterest (Ptr<Face> inFace,
+ Ptr<Face> outFace,
+ Ptr<const InterestHeader> header,
+ Ptr<const Packet> origPacket,
+ Ptr<pit::Entry> pitEntry)
{
- // NS_LOG_FUNCTION (this << pitEntry->GetPrefix ());
- // totally override all (if any) parent processing
-
- pit::Entry::out_iterator outgoing =
- pitEntry->GetOutgoing ().find (outFace);
+ NS_LOG_FUNCTION (this << pitEntry->GetPrefix ());
- if (outgoing != pitEntry->GetOutgoing ().end ())
+ if (!super::CanSendOutInterest (inFace, outFace, header, origPacket, pitEntry))
{
- // just suppress without any other action
return false;
}
-
+
Ptr<Limits> faceLimits = outFace->template GetObject<Limits> ();
if (faceLimits->IsBelowLimit ())
{
faceLimits->BorrowLimit ();
- pitEntry->AddOutgoing (outFace);
-
- //transmission
- Ptr<Packet> packetToSend = origPacket->Copy ();
- outFace->Send (packetToSend);
-
- this->DidSendOutInterest (outFace, header, origPacket, pitEntry);
return true;
}
else
{
- // NS_LOG_DEBUG ("Face limit for " << header->GetName ());
+ return false;
}
-
- return false;
}
template<class Parent>
void
SimpleLimits<Parent>::WillEraseTimedOutPendingInterest (Ptr<pit::Entry> pitEntry)
{
- // NS_LOG_FUNCTION (this << pitEntry->GetPrefix ());
+ NS_LOG_FUNCTION (this << pitEntry->GetPrefix ());
for (pit::Entry::out_container::iterator face = pitEntry->GetOutgoing ().begin ();
face != pitEntry->GetOutgoing ().end ();
@@ -167,7 +159,7 @@
SimpleLimits<Parent>::WillSatisfyPendingInterest (Ptr<Face> inFace,
Ptr<pit::Entry> pitEntry)
{
- // NS_LOG_FUNCTION (this << pitEntry->GetPrefix ());
+ NS_LOG_FUNCTION (this << pitEntry->GetPrefix ());
for (pit::Entry::out_container::iterator face = pitEntry->GetOutgoing ().begin ();
face != pitEntry->GetOutgoing ().end ();