fw+doc: Renaming and extending limit extenstion
SimpleLimits now called PerOutFaceLimits. Also, there is now
PerFibLimits that is inherited from PerOutFaceLimits and implements
additional check.
Also, this commit includes a couple of tricks to improve documentation
of templated classes (PerOutFaceLimits and PerFibLimits). Not ideal, but
much better than before.
diff --git a/docs/Doxyfile b/docs/Doxyfile
index e04011a..8ca2128 100644
--- a/docs/Doxyfile
+++ b/docs/Doxyfile
@@ -309,13 +309,13 @@
# If the EXTRACT_STATIC tag is set to YES all static members of a file
# will be included in the documentation.
-EXTRACT_STATIC = NO
+EXTRACT_STATIC = YES
# If the EXTRACT_LOCAL_CLASSES tag is set to YES classes (and structs)
# defined locally in source files will be included in the documentation.
# If set to NO only classes defined in header files are included.
-EXTRACT_LOCAL_CLASSES = NO
+EXTRACT_LOCAL_CLASSES = YES
# This flag is only useful for Objective-C code. When set to YES local
# methods, which are defined in the implementation section but not in
@@ -517,7 +517,7 @@
# The QUIET tag can be used to turn on/off the messages that are generated
# by doxygen. Possible values are YES and NO. If left blank NO is used.
-QUIET = YES
+QUIET = NO
# The WARNINGS tag can be used to turn on/off the warning messages that are
# generated by doxygen. Possible values are YES and NO. If left blank
@@ -536,7 +536,7 @@
# parameters in a documented function, or documenting parameters that
# don't exist or using markup commands wrongly.
-WARN_IF_DOC_ERROR = NO
+WARN_IF_DOC_ERROR = YES
# This WARN_NO_PARAMDOC option can be abled to get warnings for
# functions that are documented, but have no documentation for their parameters
diff --git a/model/cs/ndn-content-store.h b/model/cs/ndn-content-store.h
index 047fd81..19ff996 100644
--- a/model/cs/ndn-content-store.h
+++ b/model/cs/ndn-content-store.h
@@ -147,7 +147,7 @@
virtual bool
Add (Ptr<const ContentObjectHeader> header, Ptr<const Packet> packet) = 0;
- // /**
+ // /*
// * \brief Add a new content to the content store.
// *
// * \param header Interest header for which an entry should be removed
diff --git a/model/fw/best-route.cc b/model/fw/best-route.cc
index 076234f..046d7a2 100644
--- a/model/fw/best-route.cc
+++ b/model/fw/best-route.cc
@@ -33,14 +33,21 @@
#include <boost/lambda/bind.hpp>
namespace ll = boost::lambda;
-NS_LOG_COMPONENT_DEFINE ("ndn.fw.BestRoute");
-
namespace ns3 {
namespace ndn {
namespace fw {
NS_OBJECT_ENSURE_REGISTERED (BestRoute);
-
+
+LogComponent BestRoute::g_log = LogComponent (BestRoute::GetLogName ().c_str ());
+
+std::string
+BestRoute::GetLogName ()
+{
+ return super::GetLogName ()+".BestRoute";
+}
+
+
TypeId
BestRoute::GetTypeId (void)
{
diff --git a/model/fw/best-route.h b/model/fw/best-route.h
index 3f4fef7..6e17b99 100644
--- a/model/fw/best-route.h
+++ b/model/fw/best-route.h
@@ -24,6 +24,7 @@
#define NDNSIM_BEST_ROUTE_H
#include "green-yellow-red.h"
+#include "ns3/log.h"
namespace ns3 {
namespace ndn {
@@ -44,6 +45,12 @@
GetTypeId ();
/**
+ * @brief Helper function to retrieve logging name for the forwarding strategy
+ */
+ static std::string
+ GetLogName ();
+
+ /**
* @brief Default constructor
*/
BestRoute ();
@@ -54,6 +61,8 @@
Ptr<const InterestHeader> header,
Ptr<const Packet> origPacket,
Ptr<pit::Entry> pitEntry);
+protected:
+ static LogComponent g_log;
};
} // namespace fw
diff --git a/model/fw/flooding.cc b/model/fw/flooding.cc
index 6d021ec..b4e94a8 100644
--- a/model/fw/flooding.cc
+++ b/model/fw/flooding.cc
@@ -36,14 +36,20 @@
#include <boost/lambda/bind.hpp>
namespace ll = boost::lambda;
-NS_LOG_COMPONENT_DEFINE ("ndn.fw.Flooding");
-
namespace ns3 {
namespace ndn {
namespace fw {
NS_OBJECT_ENSURE_REGISTERED (Flooding);
-
+
+LogComponent Flooding::g_log = LogComponent (Flooding::GetLogName ().c_str ());
+
+std::string
+Flooding::GetLogName ()
+{
+ return super::GetLogName ()+".Flooding";
+}
+
TypeId Flooding::GetTypeId ()
{
static TypeId tid = TypeId ("ns3::ndn::fw::Flooding")
diff --git a/model/fw/flooding.h b/model/fw/flooding.h
index d730113..c4f6205 100644
--- a/model/fw/flooding.h
+++ b/model/fw/flooding.h
@@ -23,6 +23,7 @@
#define NDNSIM_FLOODING_H
#include "nacks.h"
+#include "ns3/log.h"
namespace ns3 {
namespace ndn {
@@ -37,9 +38,19 @@
class Flooding :
public Nacks
{
-public:
- static TypeId GetTypeId ();
+private:
+ typedef Nacks super;
+public:
+ static TypeId
+ GetTypeId ();
+
+ /**
+ * @brief Helper function to retrieve logging name for the forwarding strategy
+ */
+ static std::string
+ GetLogName ();
+
/**
* @brief Default constructor
*/
@@ -53,8 +64,8 @@
Ptr<const Packet> origPacket,
Ptr<pit::Entry> pitEntry);
-private:
- typedef Nacks super;
+protected:
+ static LogComponent g_log;
};
} // namespace fw
diff --git a/model/fw/green-yellow-red.h b/model/fw/green-yellow-red.h
index 363d0cb..371f7fd 100644
--- a/model/fw/green-yellow-red.h
+++ b/model/fw/green-yellow-red.h
@@ -34,7 +34,8 @@
public Nacks
{
public:
- static TypeId GetTypeId (void);
+ static TypeId
+ GetTypeId (void);
protected:
virtual void
diff --git a/model/fw/nacks.h b/model/fw/nacks.h
index ef14f19..421897b 100644
--- a/model/fw/nacks.h
+++ b/model/fw/nacks.h
@@ -35,11 +35,11 @@
{
private:
typedef ForwardingStrategy super;
-
+
public:
static TypeId
GetTypeId ();
-
+
// from super
virtual void
OnInterest (Ptr<Face> face,
diff --git a/model/fw/ndn-forwarding-strategy.cc b/model/fw/ndn-forwarding-strategy.cc
index 14db750..770613b 100644
--- a/model/fw/ndn-forwarding-strategy.cc
+++ b/model/fw/ndn-forwarding-strategy.cc
@@ -44,13 +44,19 @@
#include <boost/tuple/tuple.hpp>
namespace ll = boost::lambda;
-NS_LOG_COMPONENT_DEFINE ("ndn.ForwardingStrategy");
-
namespace ns3 {
namespace ndn {
NS_OBJECT_ENSURE_REGISTERED (ForwardingStrategy);
+NS_LOG_COMPONENT_DEFINE (ForwardingStrategy::GetLogName ().c_str ());
+
+std::string
+ForwardingStrategy::GetLogName ()
+{
+ return "ndn.fw";
+}
+
TypeId ForwardingStrategy::GetTypeId (void)
{
static TypeId tid = TypeId ("ns3::ndn::ForwardingStrategy")
diff --git a/model/fw/ndn-forwarding-strategy.h b/model/fw/ndn-forwarding-strategy.h
index fa42502..cd0d041 100644
--- a/model/fw/ndn-forwarding-strategy.h
+++ b/model/fw/ndn-forwarding-strategy.h
@@ -49,6 +49,11 @@
static TypeId GetTypeId (void);
/**
+ * @brief Helper function to retrieve logging name for the forwarding strategy
+ */
+ static std::string GetLogName ();
+
+ /**
* @brief Default constructor
*/
ForwardingStrategy ();
diff --git a/model/fw/per-fib-limits.cc b/model/fw/per-fib-limits.cc
new file mode 100644
index 0000000..3b60cf5
--- /dev/null
+++ b/model/fw/per-fib-limits.cc
@@ -0,0 +1,68 @@
+/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
+/*
+ * Copyright (c) 2012 University of California, Los Angeles
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation;
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ * Author: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
+ */
+
+#include "per-fib-limits.h"
+#include "per-out-face-limits.h"
+
+#include "ns3/ndn-l3-protocol.h"
+#include "ns3/ndn-interest-header.h"
+#include "ns3/ndn-content-object-header.h"
+
+#include "best-route.h"
+#include "flooding.h"
+#include "smart-flooding.h"
+
+namespace ns3 {
+namespace ndn {
+namespace fw {
+
+template class PerFibLimits< PerOutFaceLimits<BestRoute> >;
+typedef PerFibLimits< PerOutFaceLimits<BestRoute> > PerFibLimitsPerOutFaceLimitsBestRoute;
+NS_OBJECT_ENSURE_REGISTERED (PerFibLimitsPerOutFaceLimitsBestRoute);
+
+template class PerFibLimits< PerOutFaceLimits<Flooding> >;
+typedef PerFibLimits< PerOutFaceLimits<Flooding> > PerFibLimitsPerOutFaceLimitsFlooding;
+NS_OBJECT_ENSURE_REGISTERED (PerFibLimitsPerOutFaceLimitsFlooding);
+
+template class PerFibLimits< PerOutFaceLimits<SmartFlooding> >;
+typedef PerFibLimits< PerOutFaceLimits<SmartFlooding> > PerFibLimitsPerOutFaceLimitsSmartFlooding;
+NS_OBJECT_ENSURE_REGISTERED (PerFibLimitsPerOutFaceLimitsSmartFlooding);
+
+#ifdef DOXYGEN
+// /**
+// * \brief Strategy implementing per-fib-per-out-face limits on top of BestRoute strategy
+// */
+class BestRoute::PerOutFaceLimits::PerFibLimits : public ::ns3::ndn::fw::PerFibLimits< ::ns3::ndn::fw::PerOutFaceLimits<BestRoute> > { };
+
+/**
+ * \brief Strategy implementing per-fib-per-out-face limits on top of Flooding strategy
+ */
+class Flooding::PerOutFaceLimits::PerFibLimits : public ::ns3::ndn::fw::PerFibLimits< ::ns3::ndn::fw::PerOutFaceLimits<Flooding> > { };
+
+/**
+ * \brief Strategy implementing per-fib-per-out-face limits on top of SmartFlooding strategy
+ */
+class SmartFlooding::PerOutFaceLimits::PerFibLimits : public ::ns3::ndn::fw::PerFibLimits< ::ns3::ndn::fw::PerOutFaceLimits<SmartFlooding> > { };
+
+#endif
+
+} // namespace fw
+} // namespace ndn
+} // namespace ns3
diff --git a/model/fw/simple-limits.h b/model/fw/per-fib-limits.h
similarity index 60%
copy from model/fw/simple-limits.h
copy to model/fw/per-fib-limits.h
index ce639e3..3632a87 100644
--- a/model/fw/simple-limits.h
+++ b/model/fw/per-fib-limits.h
@@ -1,6 +1,6 @@
/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2011 University of California, Los Angeles
+ * Copyright (c) 2012 University of California, Los Angeles
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
@@ -19,8 +19,8 @@
*/
-#ifndef NDNSIM_SIMPLE_LIMITS_H
-#define NDNSIM_SIMPLE_LIMITS_H
+#ifndef NDNSIM_PER_FIB_LIMITS_H
+#define NDNSIM_PER_FIB_LIMITS_H
#include "ns3/event-id.h"
#include "ns3/log.h"
@@ -42,7 +42,7 @@
* \brief Strategy implementing per-FIB entry limits
*/
template<class Parent>
-class SimpleLimits :
+class PerFibLimits :
public Parent
{
private:
@@ -53,25 +53,36 @@
GetTypeId ();
/**
+ * @brief Helper function to retrieve logging name for the forwarding strategy
+ */
+ static std::string
+ GetLogName ();
+
+ /**
* @brief Default constructor
*/
- SimpleLimits ()
+ PerFibLimits ()
{ }
+ /// \copydoc ForwardingStrategy::WillEraseTimedOutPendingInterest
virtual void
WillEraseTimedOutPendingInterest (Ptr<pit::Entry> pitEntry);
+ /// \copydoc ForwardingStrategy::AddFace
virtual void
AddFace (Ptr<Face> face)
{
- ObjectFactory factory (m_limitType);
- Ptr<Limits> limits = factory.template Create<Limits> ();
- face->AggregateObject (limits);
-
super::AddFace (face);
+
+ if (face->GetObject<Limits> () == 0)
+ {
+ NS_FATAL_ERROR ("At least per-face limits should be enabled");
+ exit (1);
+ }
}
protected:
+ /// \copydoc ForwardingStrategy::CanSendOutInterest
virtual bool
CanSendOutInterest (Ptr<Face> inFace,
Ptr<Face> outFace,
@@ -79,39 +90,43 @@
Ptr<const Packet> origPacket,
Ptr<pit::Entry> pitEntry);
+ /// \copydoc ForwardingStrategy::WillSatisfyPendingInterest
virtual void
WillSatisfyPendingInterest (Ptr<Face> inFace,
Ptr<pit::Entry> pitEntry);
+protected:
+ static LogComponent g_log; ///< @brief Logging variable
+
private:
std::string m_limitType;
-
- static LogComponent g_log;
};
template<class Parent>
-LogComponent SimpleLimits<Parent>::g_log = LogComponent ("ndn.SimpleLimits");
+LogComponent PerFibLimits<Parent>::g_log = LogComponent (PerFibLimits<Parent>::GetLogName ().c_str ());
+
+template<class Parent>
+std::string
+PerFibLimits<Parent>::GetLogName ()
+{
+ return super::GetLogName ()+".PerFibLimits";
+}
template<class Parent>
TypeId
-SimpleLimits<Parent>::GetTypeId (void)
+PerFibLimits<Parent>::GetTypeId (void)
{
- static TypeId tid = TypeId ((super::GetTypeId ().GetName ()+"::SimpleLimits").c_str ())
+ static TypeId tid = TypeId ((super::GetTypeId ().GetName ()+"::PerFibLimits").c_str ())
.SetGroupName ("Ndn")
.template SetParent <super> ()
- .template AddConstructor <SimpleLimits> ()
-
- .template AddAttribute ("Limit", "Limit type to be used (e.g., ns3::ndn::Limits::Window or ns3::ndn::Limits::Rate)",
- StringValue ("ns3::ndn::Limits::Window"),
- MakeStringAccessor (&SimpleLimits<Parent>::m_limitType),
- MakeStringChecker ())
+ .template AddConstructor <PerFibLimits> ()
;
return tid;
}
template<class Parent>
bool
-SimpleLimits<Parent>::CanSendOutInterest (Ptr<Face> inFace,
+PerFibLimits<Parent>::CanSendOutInterest (Ptr<Face> inFace,
Ptr<Face> outFace,
Ptr<const InterestHeader> header,
Ptr<const Packet> origPacket,
@@ -119,36 +134,29 @@
{
NS_LOG_FUNCTION (this << pitEntry->GetPrefix ());
- if (!super::CanSendOutInterest (inFace, outFace, header, origPacket, pitEntry))
+ Ptr<Limits> fibLimits = pitEntry->GetFibEntry ()->template GetObject<Limits> ();
+ // no checks for the limit here. the check should be somewhere elese
+
+ if (fibLimits->IsBelowLimit ())
{
- return false;
+ if (super::CanSendOutInterest (inFace, outFace, header, origPacket, pitEntry))
+ {
+ fibLimits->BorrowLimit ();
+ return true;
+ }
}
- Ptr<Limits> faceLimits = outFace->template GetObject<Limits> ();
- if (faceLimits->IsBelowLimit ())
- {
- faceLimits->BorrowLimit ();
- return true;
- }
- else
- {
- return false;
- }
+ return false;
}
template<class Parent>
void
-SimpleLimits<Parent>::WillEraseTimedOutPendingInterest (Ptr<pit::Entry> pitEntry)
+PerFibLimits<Parent>::WillEraseTimedOutPendingInterest (Ptr<pit::Entry> pitEntry)
{
NS_LOG_FUNCTION (this << pitEntry->GetPrefix ());
- for (pit::Entry::out_container::iterator face = pitEntry->GetOutgoing ().begin ();
- face != pitEntry->GetOutgoing ().end ();
- face ++)
- {
- Ptr<Limits> faceLimits = face->m_face->GetObject<Limits> ();
- faceLimits->ReturnLimit ();
- }
+ Ptr<Limits> fibLimits = pitEntry->GetFibEntry ()->template GetObject<Limits> ();
+ fibLimits->ReturnLimit ();
super::WillEraseTimedOutPendingInterest (pitEntry);
}
@@ -156,18 +164,13 @@
template<class Parent>
void
-SimpleLimits<Parent>::WillSatisfyPendingInterest (Ptr<Face> inFace,
+PerFibLimits<Parent>::WillSatisfyPendingInterest (Ptr<Face> inFace,
Ptr<pit::Entry> pitEntry)
{
NS_LOG_FUNCTION (this << pitEntry->GetPrefix ());
- for (pit::Entry::out_container::iterator face = pitEntry->GetOutgoing ().begin ();
- face != pitEntry->GetOutgoing ().end ();
- face ++)
- {
- Ptr<Limits> faceLimits = face->m_face->GetObject<Limits> ();
- faceLimits->ReturnLimit ();
- }
+ Ptr<Limits> fibLimits = pitEntry->GetFibEntry ()->template GetObject<Limits> ();
+ fibLimits->ReturnLimit ();
super::WillSatisfyPendingInterest (inFace, pitEntry);
}
@@ -176,4 +179,4 @@
} // namespace ndn
} // namespace ns3
-#endif // NDNSIM_SIMPLE_LIMITS_H
+#endif // NDNSIM_PER_FIB_LIMITS_H
diff --git a/model/fw/per-out-face-limits.cc b/model/fw/per-out-face-limits.cc
new file mode 100644
index 0000000..5591739
--- /dev/null
+++ b/model/fw/per-out-face-limits.cc
@@ -0,0 +1,67 @@
+/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
+/*
+ * Copyright (c) 2011 University of California, Los Angeles
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation;
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ * Author: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
+ */
+
+#include "per-out-face-limits.h"
+
+#include "ns3/ndn-l3-protocol.h"
+#include "ns3/ndn-interest-header.h"
+#include "ns3/ndn-content-object-header.h"
+
+#include "best-route.h"
+#include "flooding.h"
+#include "smart-flooding.h"
+
+namespace ns3 {
+namespace ndn {
+namespace fw {
+
+template class PerOutFaceLimits<BestRoute>;
+typedef PerOutFaceLimits<BestRoute> PerOutFaceLimitsBestRoute;
+NS_OBJECT_ENSURE_REGISTERED (PerOutFaceLimitsBestRoute);
+
+template class PerOutFaceLimits<Flooding>;
+typedef PerOutFaceLimits<Flooding> PerOutFaceLimitsFlooding;
+NS_OBJECT_ENSURE_REGISTERED (PerOutFaceLimitsFlooding);
+
+template class PerOutFaceLimits<SmartFlooding>;
+typedef PerOutFaceLimits<SmartFlooding> PerOutFaceLimitsSmartFlooding;
+NS_OBJECT_ENSURE_REGISTERED (PerOutFaceLimitsSmartFlooding);
+
+#ifdef DOXYGEN
+// /**
+// * \brief Strategy implementing per-out-face limits on top of BestRoute strategy
+// */
+class BestRoute::PerOutFaceLimits : public ::ns3::ndn::fw::PerOutFaceLimits<BestRoute> { };
+
+/**
+ * \brief Strategy implementing per-out-face limits on top of Flooding strategy
+ */
+class Flooding::PerOutFaceLimits : public ::ns3::ndn::fw::PerOutFaceLimits<Flooding> { };
+
+/**
+ * \brief Strategy implementing per-out-face limits on top of SmartFlooding strategy
+ */
+class SmartFlooding::PerOutFaceLimits : public ::ns3::ndn::fw::PerOutFaceLimits<SmartFlooding> { };
+#endif
+
+} // namespace fw
+} // namespace ndn
+} // namespace ns3
+
diff --git a/model/fw/simple-limits.h b/model/fw/per-out-face-limits.h
similarity index 71%
rename from model/fw/simple-limits.h
rename to model/fw/per-out-face-limits.h
index ce639e3..534768b 100644
--- a/model/fw/simple-limits.h
+++ b/model/fw/per-out-face-limits.h
@@ -19,8 +19,8 @@
*/
-#ifndef NDNSIM_SIMPLE_LIMITS_H
-#define NDNSIM_SIMPLE_LIMITS_H
+#ifndef NDNSIM_PER_OUT_FACE_LIMITS_H
+#define NDNSIM_PER_OUT_FACE_LIMITS_H
#include "ns3/event-id.h"
#include "ns3/log.h"
@@ -39,28 +39,39 @@
/**
* \ingroup ndn
- * \brief Strategy implementing per-FIB entry limits
+ * \brief Strategy implementing per-outgoing face limits
*/
template<class Parent>
-class SimpleLimits :
+class PerOutFaceLimits :
public Parent
{
private:
typedef Parent super;
public:
+ /**
+ * @brief Get TypeId of the class
+ */
static TypeId
GetTypeId ();
/**
+ * @brief Helper function to retrieve logging name for the forwarding strategy
+ */
+ static std::string
+ GetLogName ();
+
+ /**
* @brief Default constructor
*/
- SimpleLimits ()
+ PerOutFaceLimits ()
{ }
-
+
+ /// \copydoc ForwardingStrategy::WillEraseTimedOutPendingInterest
virtual void
WillEraseTimedOutPendingInterest (Ptr<pit::Entry> pitEntry);
+ /// \copydoc ForwardingStrategy::AddFace
virtual void
AddFace (Ptr<Face> face)
{
@@ -72,6 +83,7 @@
}
protected:
+ /// \copydoc ForwardingStrategy::CanSendOutInterest
virtual bool
CanSendOutInterest (Ptr<Face> inFace,
Ptr<Face> outFace,
@@ -79,31 +91,40 @@
Ptr<const Packet> origPacket,
Ptr<pit::Entry> pitEntry);
+ /// \copydoc ForwardingStrategy::WillSatisfyPendingInterest
virtual void
WillSatisfyPendingInterest (Ptr<Face> inFace,
Ptr<pit::Entry> pitEntry);
+protected:
+ static LogComponent g_log; ///< @brief Logging variable
+
private:
std::string m_limitType;
-
- static LogComponent g_log;
};
template<class Parent>
-LogComponent SimpleLimits<Parent>::g_log = LogComponent ("ndn.SimpleLimits");
+LogComponent PerOutFaceLimits<Parent>::g_log = LogComponent (PerOutFaceLimits<Parent>::GetLogName ().c_str ());
+
+template<class Parent>
+std::string
+PerOutFaceLimits<Parent>::GetLogName ()
+{
+ return super::GetLogName ()+".PerOutFaceLimits";
+}
template<class Parent>
TypeId
-SimpleLimits<Parent>::GetTypeId (void)
+PerOutFaceLimits<Parent>::GetTypeId (void)
{
- static TypeId tid = TypeId ((super::GetTypeId ().GetName ()+"::SimpleLimits").c_str ())
+ static TypeId tid = TypeId ((super::GetTypeId ().GetName ()+"::PerOutFaceLimits").c_str ())
.SetGroupName ("Ndn")
.template SetParent <super> ()
- .template AddConstructor <SimpleLimits> ()
+ .template AddConstructor <PerOutFaceLimits> ()
.template AddAttribute ("Limit", "Limit type to be used (e.g., ns3::ndn::Limits::Window or ns3::ndn::Limits::Rate)",
StringValue ("ns3::ndn::Limits::Window"),
- MakeStringAccessor (&SimpleLimits<Parent>::m_limitType),
+ MakeStringAccessor (&PerOutFaceLimits<Parent>::m_limitType),
MakeStringChecker ())
;
return tid;
@@ -111,34 +132,30 @@
template<class Parent>
bool
-SimpleLimits<Parent>::CanSendOutInterest (Ptr<Face> inFace,
+PerOutFaceLimits<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 ());
-
- if (!super::CanSendOutInterest (inFace, outFace, header, origPacket, pitEntry))
- {
- return false;
- }
Ptr<Limits> faceLimits = outFace->template GetObject<Limits> ();
if (faceLimits->IsBelowLimit ())
{
- faceLimits->BorrowLimit ();
- return true;
+ if (super::CanSendOutInterest (inFace, outFace, header, origPacket, pitEntry))
+ {
+ faceLimits->BorrowLimit ();
+ return true;
+ }
}
- else
- {
- return false;
- }
+
+ return false;
}
template<class Parent>
void
-SimpleLimits<Parent>::WillEraseTimedOutPendingInterest (Ptr<pit::Entry> pitEntry)
+PerOutFaceLimits<Parent>::WillEraseTimedOutPendingInterest (Ptr<pit::Entry> pitEntry)
{
NS_LOG_FUNCTION (this << pitEntry->GetPrefix ());
@@ -156,7 +173,7 @@
template<class Parent>
void
-SimpleLimits<Parent>::WillSatisfyPendingInterest (Ptr<Face> inFace,
+PerOutFaceLimits<Parent>::WillSatisfyPendingInterest (Ptr<Face> inFace,
Ptr<pit::Entry> pitEntry)
{
NS_LOG_FUNCTION (this << pitEntry->GetPrefix ());
@@ -176,4 +193,4 @@
} // namespace ndn
} // namespace ns3
-#endif // NDNSIM_SIMPLE_LIMITS_H
+#endif // NDNSIM_PER_OUT_FACE_LIMITS_H
diff --git a/model/fw/simple-limits.cc b/model/fw/simple-limits.cc
deleted file mode 100644
index 7880194..0000000
--- a/model/fw/simple-limits.cc
+++ /dev/null
@@ -1,57 +0,0 @@
-/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
-/*
- * Copyright (c) 2011 University of California, Los Angeles
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation;
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- *
- * Author: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
- */
-
-#include "simple-limits.h"
-
-#include "ns3/ndn-l3-protocol.h"
-#include "ns3/ndn-interest-header.h"
-#include "ns3/ndn-content-object-header.h"
-
-#include "best-route.h"
-#include "flooding.h"
-#include "smart-flooding.h"
-
-namespace ns3 {
-namespace ndn {
-namespace fw {
-
-template class SimpleLimits<BestRoute>;
-typedef SimpleLimits<BestRoute> SimpleLimitsBestRoute;
-NS_OBJECT_ENSURE_REGISTERED (SimpleLimitsBestRoute);
-
-template class SimpleLimits<Flooding>;
-typedef SimpleLimits<Flooding> SimpleLimitsFlooding;
-NS_OBJECT_ENSURE_REGISTERED (SimpleLimitsFlooding);
-
-template class SimpleLimits<SmartFlooding>;
-typedef SimpleLimits<SmartFlooding> SimpleLimitsSmartFlooding;
-NS_OBJECT_ENSURE_REGISTERED (SimpleLimitsSmartFlooding);
-
-#ifdef DOXYGEN
-
-class SimpleLimitsBestRoute : public SimpleLimits<BestRoute> { };
-class SimpleLimitsFlooding : public SimpleLimits<Flooding> { };
-class SimpleLimitsSmartFlooding : public SimpleLimits<SmartFlooding> { };
-
-#endif
-
-} // namespace fw
-} // namespace ndn
-} // namespace ns3
diff --git a/model/fw/smart-flooding.cc b/model/fw/smart-flooding.cc
index e74b612..8a1d367 100644
--- a/model/fw/smart-flooding.cc
+++ b/model/fw/smart-flooding.cc
@@ -35,14 +35,20 @@
#include <boost/lambda/bind.hpp>
namespace ll = boost::lambda;
-NS_LOG_COMPONENT_DEFINE ("ndn.fw.SmartFlooding");
-
namespace ns3 {
namespace ndn {
namespace fw {
NS_OBJECT_ENSURE_REGISTERED (SmartFlooding);
-
+
+LogComponent SmartFlooding::g_log = LogComponent (SmartFlooding::GetLogName ().c_str ());
+
+std::string
+SmartFlooding::GetLogName ()
+{
+ return super::GetLogName ()+".SmartFlooding";
+}
+
TypeId
SmartFlooding::GetTypeId (void)
{
diff --git a/model/fw/smart-flooding.h b/model/fw/smart-flooding.h
index d30031b..f66d1e8 100644
--- a/model/fw/smart-flooding.h
+++ b/model/fw/smart-flooding.h
@@ -22,6 +22,7 @@
#define NDNSIM_SMART_FLOODING_H
#include "green-yellow-red.h"
+#include "ns3/log.h"
namespace ns3 {
namespace ndn {
@@ -33,8 +34,18 @@
class SmartFlooding :
public GreenYellowRed
{
+private:
+ typedef GreenYellowRed super;
+
public:
- static TypeId GetTypeId ();
+ static TypeId
+ GetTypeId ();
+
+ /**
+ * @brief Helper function to retrieve logging name for the forwarding strategy
+ */
+ static std::string
+ GetLogName ();
/**
* @brief Default constructor
@@ -48,8 +59,8 @@
Ptr<const Packet> origPacket,
Ptr<pit::Entry> pitEntry);
-private:
- typedef GreenYellowRed super;
+protected:
+ static LogComponent g_log;
};
} // namespace fw
diff --git a/model/ndn-face.h b/model/ndn-face.h
index 78c65a7..acb1c90 100644
--- a/model/ndn-face.h
+++ b/model/ndn-face.h
@@ -111,7 +111,7 @@
////////////////////////////////////////////////////////////////////
/**
- * \Brief Assign routing/forwarding metric with face
+ * \brief Assign routing/forwarding metric with face
*
* \param metric configured routing metric (cost) of this face
*/
diff --git a/model/pit/ndn-pit-entry-incoming-face.h b/model/pit/ndn-pit-entry-incoming-face.h
index cd75643..fb3987e 100644
--- a/model/pit/ndn-pit-entry-incoming-face.h
+++ b/model/pit/ndn-pit-entry-incoming-face.h
@@ -52,7 +52,7 @@
*/
IncomingFace ();
/**
- * @brie Copy operator
+ * @brief Copy operator
*/
IncomingFace &
operator = (const IncomingFace &other);
diff --git a/model/pit/ndn-pit-entry-outgoing-face.h b/model/pit/ndn-pit-entry-outgoing-face.h
index 63c6378..20dfdaf 100644
--- a/model/pit/ndn-pit-entry-outgoing-face.h
+++ b/model/pit/ndn-pit-entry-outgoing-face.h
@@ -56,7 +56,7 @@
OutgoingFace ();
/**
- * @brie Copy operator
+ * @brief Copy operator
*/
OutgoingFace &
operator = (const OutgoingFace &other);