NS-3 based Named Data Networking (NDN) simulator
ndnSIM 2.0: 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 
54  const Name&
55  getName() const;
56 
57 public: // triggers
78  virtual void
79  afterReceiveInterest(const Face& inFace,
80  const Interest& interest,
81  shared_ptr<fib::Entry> fibEntry,
82  shared_ptr<pit::Entry> pitEntry) = 0;
83 
94  virtual void
95  beforeSatisfyInterest(shared_ptr<pit::Entry> pitEntry,
96  const Face& inFace, const Data& data);
97 
110  virtual void
111  beforeExpirePendingInterest(shared_ptr<pit::Entry> pitEntry);
112 
129  virtual void
130  afterReceiveNack(const Face& inFace, const lp::Nack& nack,
131  shared_ptr<fib::Entry> fibEntry, shared_ptr<pit::Entry> pitEntry);
132 
133 protected: // actions
140  VIRTUAL_WITH_TESTS void
141  sendInterest(shared_ptr<pit::Entry> pitEntry, shared_ptr<Face> outFace,
142  bool wantNewNonce = false);
143 
150  VIRTUAL_WITH_TESTS void
151  rejectPendingInterest(shared_ptr<pit::Entry> pitEntry);
152 
160  VIRTUAL_WITH_TESTS void
161  sendNack(shared_ptr<pit::Entry> pitEntry, const Face& outFace,
162  const lp::NackHeader& header);
163 
171  void
172  sendNacks(shared_ptr<pit::Entry> pitEntry, const lp::NackHeader& header,
173  std::initializer_list<const Face*> exceptFaces = std::initializer_list<const Face*>());
174 
175 protected: // accessors
177  getMeasurements();
178 
179  shared_ptr<Face>
180  getFace(FaceId id);
181 
182  const FaceTable&
183  getFaceTable();
184 
185 protected: // accessors
188 
189 private:
190  Name m_name;
191 
196  Forwarder& m_forwarder;
197 
198  MeasurementsAccessor m_measurements;
199 };
200 
201 inline const Name&
203 {
204  return m_name;
205 }
206 
207 inline void
208 Strategy::sendInterest(shared_ptr<pit::Entry> pitEntry,
209  shared_ptr<Face> outFace,
210  bool wantNewNonce)
211 {
212  m_forwarder.onOutgoingInterest(pitEntry, *outFace, wantNewNonce);
213 }
214 
215 inline void
216 Strategy::rejectPendingInterest(shared_ptr<pit::Entry> pitEntry)
217 {
218  m_forwarder.onInterestReject(pitEntry);
219 }
220 
221 inline void
222 Strategy::sendNack(shared_ptr<pit::Entry> pitEntry, const Face& outFace,
223  const lp::NackHeader& header)
224 {
225  m_forwarder.onOutgoingNack(pitEntry, outFace, header);
226 }
227 
228 inline MeasurementsAccessor&
230 {
231  return m_measurements;
232 }
233 
234 inline shared_ptr<Face>
236 {
237  return m_forwarder.getFace(id);
238 }
239 
240 inline const FaceTable&
242 {
243  return m_forwarder.getFaceTable();
244 }
245 
246 } // namespace fw
247 } // namespace nfd
248 
249 #endif // NFD_DAEMON_FW_STRATEGY_HPP
const Name & getName() const
a Name that represent the Strategy program
Definition: strategy.hpp:202
FaceTable & getFaceTable()
Definition: forwarder.hpp:277
signal::Signal< FaceTable, shared_ptr< Face > > & afterAddFace
Definition: strategy.hpp:186
virtual void beforeSatisfyInterest(shared_ptr< pit::Entry > pitEntry, const Face &inFace, const Data &data)
trigger before PIT entry is satisfied
Definition: strategy.cpp:50
main class of NFD
Definition: forwarder.hpp:55
represents an Interest packet
Definition: interest.hpp:45
provides a lightweight signal / event system
represents a Network Nack
Definition: nack.hpp:40
void sendNacks(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:72
shared_ptr< Face > getFace(FaceId id)
Definition: strategy.hpp:235
virtual void beforeExpirePendingInterest(shared_ptr< pit::Entry > pitEntry)
trigger before PIT entry expires
Definition: strategy.cpp:58
virtual ~Strategy()
Definition: strategy.cpp:45
MeasurementsAccessor & getMeasurements()
Definition: strategy.hpp:229
allows Strategy to access portion of Measurements table under its namespace
container of all Faces
Definition: face-table.hpp:38
Copyright (c) 2011-2015 Regents of the University of California.
Definition: ndn-common.hpp:40
#define VIRTUAL_WITH_TESTS
Copyright (c) 2014-2015, Regents of the University of California, Arizona Board of Regents...
Definition: common.hpp:37
const FaceTable & getFaceTable()
Definition: strategy.hpp:241
Strategy(Forwarder &forwarder, const Name &name)
construct a strategy instance
Definition: strategy.cpp:35
Name abstraction to represent an absolute name.
Definition: name.hpp:46
shared_ptr< Face > getFace(FaceId id) const
get existing Face
Definition: forwarder.hpp:283
void rejectPendingInterest(shared_ptr< pit::Entry > pitEntry)
decide that a pending Interest cannot be forwarded
Definition: strategy.hpp:216
represents a forwarding strategy
Definition: strategy.hpp:38
signal::Signal< FaceTable, shared_ptr< Face > > & beforeRemoveFace
Definition: strategy.hpp:187
void sendInterest(shared_ptr< pit::Entry > pitEntry, shared_ptr< Face > outFace, bool wantNewNonce=false)
send Interest to outFace
Definition: strategy.hpp:208
virtual void afterReceiveInterest(const Face &inFace, const Interest &interest, shared_ptr< fib::Entry > fibEntry, shared_ptr< pit::Entry > pitEntry)=0
trigger after Interest is received
void sendNack(shared_ptr< pit::Entry > pitEntry, const Face &outFace, const lp::NackHeader &header)
send Nack to outFace
Definition: strategy.hpp:222
virtual void afterReceiveNack(const Face &inFace, const lp::Nack &nack, shared_ptr< fib::Entry > fibEntry, shared_ptr< pit::Entry > pitEntry)
trigger after Nack is received
Definition: strategy.cpp:64
uint64_t FaceId
identifies a face
Definition: face.hpp:39
represents a Data packet
Definition: data.hpp:39
represents a Network NACK header
Definition: nack-header.hpp:52