model: Implementing two more events for forwarding strategy: DidAddFibEntry and WillRemoveFibEntry
Currently, only DidAddFibEntry method is used and only in PerFibLimits
strategy. Change logic in global routing helper: set per FIB limits only if
forwarding strategy has created a corresponding Limit object.
diff --git a/model/fw/ndn-forwarding-strategy.cc b/model/fw/ndn-forwarding-strategy.cc
index b3e7940..4bab0a1 100644
--- a/model/fw/ndn-forwarding-strategy.cc
+++ b/model/fw/ndn-forwarding-strategy.cc
@@ -564,5 +564,18 @@
// do nothing here
}
+void
+ForwardingStrategy::DidAddFibEntry (Ptr<fib::Entry> fibEntry)
+{
+ // do nothing here
+}
+
+void
+ForwardingStrategy::WillRemoveFibEntry (Ptr<fib::Entry> fibEntry)
+{
+ // do nothing here
+}
+
+
} // namespace ndn
} // namespace ns3
diff --git a/model/fw/ndn-forwarding-strategy.h b/model/fw/ndn-forwarding-strategy.h
index d3b5c37..b838565 100644
--- a/model/fw/ndn-forwarding-strategy.h
+++ b/model/fw/ndn-forwarding-strategy.h
@@ -36,6 +36,7 @@
namespace pit { class Entry; }
class FibFaceMetric;
class Fib;
+namespace fib { class Entry; }
class ContentStore;
/**
@@ -109,6 +110,20 @@
*/
virtual void
RemoveFace (Ptr<Face> face);
+
+ /**
+ * @brief Event fired every time a FIB entry is added to FIB
+ * @param fibEntry FIB entry that was added
+ */
+ virtual void
+ DidAddFibEntry (Ptr<fib::Entry> fibEntry);
+
+ /**
+ * @brief Fired just before FIB entry will be removed from FIB
+ * @param fibEntry FIB entry that will be removed
+ */
+ virtual void
+ WillRemoveFibEntry (Ptr<fib::Entry> fibEntry);
protected:
/**
diff --git a/model/fw/per-fib-limits.h b/model/fw/per-fib-limits.h
index 3632a87..47f9ee6 100644
--- a/model/fw/per-fib-limits.h
+++ b/model/fw/per-fib-limits.h
@@ -80,6 +80,19 @@
exit (1);
}
}
+
+ /// \copydoc ForwardingStrategy::DidAddFibEntry
+ virtual void
+ DidAddFibEntry (Ptr<fib::Entry> fibEntry)
+ {
+ ObjectFactory factory;
+ factory.SetTypeId (fibEntry->m_faces.begin ()->m_face->GetObject<Limits> ()->GetInstanceTypeId ());
+
+ Ptr<Limits> limits = factory.template Create<Limits> ();
+ fibEntry->AggregateObject (limits);
+
+ super::DidAddFibEntry (fibEntry);
+ }
protected:
/// \copydoc ForwardingStrategy::CanSendOutInterest
diff --git a/model/fw/per-out-face-limits.h b/model/fw/per-out-face-limits.h
index 534768b..2c4a935 100644
--- a/model/fw/per-out-face-limits.h
+++ b/model/fw/per-out-face-limits.h
@@ -133,10 +133,10 @@
template<class Parent>
bool
PerOutFaceLimits<Parent>::CanSendOutInterest (Ptr<Face> inFace,
- Ptr<Face> outFace,
- Ptr<const InterestHeader> header,
- Ptr<const Packet> origPacket,
- Ptr<pit::Entry> pitEntry)
+ Ptr<Face> outFace,
+ Ptr<const InterestHeader> header,
+ Ptr<const Packet> origPacket,
+ Ptr<pit::Entry> pitEntry)
{
NS_LOG_FUNCTION (this << pitEntry->GetPrefix ());