NS-3 based Named Data Networking (NDN) simulator
ndnSIM 2.3: NDN, CCN, CCNx, content centric networks
API Documentation
strategy.hpp
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
26 #ifndef NFD_DAEMON_FW_STRATEGY_HPP
27 #define NFD_DAEMON_FW_STRATEGY_HPP
28 
29 #include "forwarder.hpp"
30 #include "strategy-registry.hpp"
32 
33 namespace nfd {
34 namespace fw {
35 
38 class Strategy : public enable_shared_from_this<Strategy>, noncopyable
39 {
40 public:
48  Strategy(Forwarder& forwarder, const Name& name);
49 
50  virtual
51  ~Strategy();
52 
55  const Name&
56  getName() const
57  {
58  return m_name;
59  }
60 
61 public: // triggers
79  virtual void
80  afterReceiveInterest(const Face& inFace, const Interest& interest,
81  const shared_ptr<pit::Entry>& pitEntry) = 0;
82 
93  virtual void
94  beforeSatisfyInterest(const shared_ptr<pit::Entry>& pitEntry,
95  const Face& inFace, const Data& data);
96 
110  virtual void
111  beforeExpirePendingInterest(const shared_ptr<pit::Entry>& pitEntry);
112 
126  virtual void
127  afterReceiveNack(const Face& inFace, const lp::Nack& nack,
128  const shared_ptr<pit::Entry>& pitEntry);
129 
130 protected: // actions
136  VIRTUAL_WITH_TESTS void
137  sendInterest(const shared_ptr<pit::Entry>& pitEntry, Face& outFace,
138  const Interest& interest)
139  {
140  m_forwarder.onOutgoingInterest(pitEntry, outFace, interest);
141  }
142 
150  DEPRECATED(
151  void
152  sendInterest(const shared_ptr<pit::Entry>& pitEntry, Face& outFace,
153  bool wantNewNonce = false));
154 
161  VIRTUAL_WITH_TESTS void
162  rejectPendingInterest(const shared_ptr<pit::Entry>& pitEntry)
163  {
164  m_forwarder.onInterestReject(pitEntry);
165  }
166 
174  VIRTUAL_WITH_TESTS void
175  sendNack(const shared_ptr<pit::Entry>& pitEntry, const Face& outFace,
176  const lp::NackHeader& header)
177  {
178  m_forwarder.onOutgoingNack(pitEntry, outFace, header);
179  }
180 
188  void
189  sendNacks(const shared_ptr<pit::Entry>& pitEntry, const lp::NackHeader& header,
190  std::initializer_list<const Face*> exceptFaces = std::initializer_list<const Face*>());
191 
192 protected: // accessors
195  const fib::Entry&
196  lookupFib(const pit::Entry& pitEntry) const;
197 
200  {
201  return m_measurements;
202  }
203 
204  Face*
205  getFace(FaceId id) const
206  {
207  return m_forwarder.getFace(id);
208  }
209 
210  const FaceTable&
211  getFaceTable() const
212  {
213  return m_forwarder.getFaceTable();
214  }
215 
216 protected: // accessors
219 
220 private:
221  Name m_name;
222 
227  Forwarder& m_forwarder;
228 
229  MeasurementsAccessor m_measurements;
230 };
231 
232 } // namespace fw
233 } // namespace nfd
234 
235 #endif // NFD_DAEMON_FW_STRATEGY_HPP
signal::Signal< FaceTable, Face & > & afterAddFace
Definition: strategy.hpp:217
generalization of a network interface
Definition: face.hpp:67
represents a FIB entry
Definition: fib-entry.hpp:51
void sendNack(const shared_ptr< pit::Entry > &pitEntry, const Face &outFace, const lp::NackHeader &header)
send Nack to outFace
Definition: strategy.hpp:175
Face * getFace(FaceId id) const
Definition: strategy.hpp:205
#define VIRTUAL_WITH_TESTS
Copyright (c) 2014-2016, Regents of the University of California, Arizona Board of Regents...
Definition: common.hpp:38
virtual void beforeExpirePendingInterest(const shared_ptr< pit::Entry > &pitEntry)
trigger before PIT entry expires
Definition: strategy.cpp:57
main class of NFD
Definition: forwarder.hpp:54
represents an Interest packet
Definition: interest.hpp:42
const Name & getName() const
Definition: strategy.hpp:56
provides a lightweight signal / event system
represents a Network Nack
Definition: nack.hpp:40
virtual void afterReceiveNack(const Face &inFace, const lp::Nack &nack, const shared_ptr< pit::Entry > &pitEntry)
trigger after Nack is received
Definition: strategy.cpp:63
virtual ~Strategy()
FaceTable & getFaceTable()
Definition: forwarder.hpp:70
container of all faces
Definition: face-table.hpp:37
Copyright (c) 2011-2015 Regents of the University of California.
Definition: ndn-common.hpp:40
MeasurementsAccessor & getMeasurements()
Definition: strategy.hpp:199
an Interest table entry
Definition: pit-entry.hpp:57
void rejectPendingInterest(const shared_ptr< pit::Entry > &pitEntry)
decide that a pending Interest cannot be forwarded
Definition: strategy.hpp:162
virtual void beforeSatisfyInterest(const shared_ptr< pit::Entry > &pitEntry, const Face &inFace, const Data &data)
trigger before PIT entry is satisfied
Definition: strategy.cpp:49
Strategy(Forwarder &forwarder, const Name &name)
construct a strategy instance
Definition: strategy.cpp:37
DEPRECATED(void sendInterest(const shared_ptr< pit::Entry > &pitEntry, Face &outFace, bool wantNewNonce=false))
send Interest to outFace
Name abstraction to represent an absolute name.
Definition: name.hpp:46
signal::Signal< FaceTable, Face & > & beforeRemoveFace
Definition: strategy.hpp:218
represents a forwarding strategy
Definition: strategy.hpp:38
void sendNacks(const shared_ptr< pit::Entry > &pitEntry, const lp::NackHeader &header, std::initializer_list< const Face *> exceptFaces=std::initializer_list< const Face *>())
send Nack to every face that has an in-record, except those in exceptFaces
Definition: strategy.cpp:107
allows Strategy to access portion of Measurements table under its namespace
const fib::Entry & lookupFib(const pit::Entry &pitEntry) const
performs a FIB lookup, considering Link object if present
Definition: strategy.cpp:129
const FaceTable & getFaceTable() const
Definition: strategy.hpp:211
virtual void afterReceiveInterest(const Face &inFace, const Interest &interest, const shared_ptr< pit::Entry > &pitEntry)=0
trigger after Interest is received
uint64_t FaceId
identifies a face
Definition: face.hpp:39
represents a Data packet
Definition: data.hpp:37
represents a Network NACK header
Definition: nack-header.hpp:52
void sendInterest(const shared_ptr< pit::Entry > &pitEntry, Face &outFace, const Interest &interest)
send Interest to outFace
Definition: strategy.hpp:137
Face * getFace(FaceId id) const
get existing Face
Definition: forwarder.hpp:80