NS-3 based Named Data Networking (NDN) simulator
ndnSIM 2.0: NDN, CCN, CCNx, content centric networks
API Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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"
31 
32 namespace nfd {
33 namespace fw {
34 
37 class Strategy : public enable_shared_from_this<Strategy>, noncopyable
38 {
39 public:
47  Strategy(Forwarder& forwarder, const Name& name);
48 
49  virtual
50  ~Strategy();
51 
53  const Name&
54  getName() const;
55 
56 public: // triggers
77  virtual void
78  afterReceiveInterest(const Face& inFace,
79  const Interest& interest,
80  shared_ptr<fib::Entry> fibEntry,
81  shared_ptr<pit::Entry> pitEntry) = 0;
82 
93  virtual void
94  beforeSatisfyInterest(shared_ptr<pit::Entry> pitEntry,
95  const Face& inFace, const Data& data);
96 
109  virtual void
110  beforeExpirePendingInterest(shared_ptr<pit::Entry> pitEntry);
111 
112 protected: // actions
114  VIRTUAL_WITH_TESTS void
115  sendInterest(shared_ptr<pit::Entry> pitEntry,
116  shared_ptr<Face> outFace,
117  bool wantNewNonce = false);
118 
124  VIRTUAL_WITH_TESTS void
125  rejectPendingInterest(shared_ptr<pit::Entry> pitEntry);
126 
127 protected: // accessors
129  getMeasurements();
130 
131  shared_ptr<Face>
132  getFace(FaceId id);
133 
134  const FaceTable&
135  getFaceTable();
136 
137 protected: // accessors
138  signal::Signal<FaceTable, shared_ptr<Face>>& afterAddFace;
139  signal::Signal<FaceTable, shared_ptr<Face>>& beforeRemoveFace;
140 
141 private:
142  Name m_name;
143 
148  Forwarder& m_forwarder;
149 
150  MeasurementsAccessor m_measurements;
151 };
152 
153 inline const Name&
155 {
156  return m_name;
157 }
158 
159 inline void
160 Strategy::sendInterest(shared_ptr<pit::Entry> pitEntry,
161  shared_ptr<Face> outFace,
162  bool wantNewNonce)
163 {
164  m_forwarder.onOutgoingInterest(pitEntry, *outFace, wantNewNonce);
165 }
166 
167 inline void
168 Strategy::rejectPendingInterest(shared_ptr<pit::Entry> pitEntry)
169 {
170  m_forwarder.onInterestReject(pitEntry);
171 }
172 
173 inline MeasurementsAccessor&
175 {
176  return m_measurements;
177 }
178 
179 inline shared_ptr<Face>
181 {
182  return m_forwarder.getFace(id);
183 }
184 
185 inline const FaceTable&
187 {
188  return m_forwarder.getFaceTable();
189 }
190 
191 } // namespace fw
192 } // namespace nfd
193 
194 #endif // NFD_DAEMON_FW_STRATEGY_HPP
FaceTable & getFaceTable()
Definition: forwarder.hpp:237
const Name & getName() const
a Name that represent the Strategy program
Definition: strategy.hpp:154
signal::Signal< FaceTable, shared_ptr< Face > > & afterAddFace
Definition: strategy.hpp:138
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:54
represents a face
Definition: face.hpp:59
shared_ptr< Face > getFace(FaceId id)
Definition: strategy.hpp:180
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:174
allows Strategy to access portion of Measurements table under its namespace
container of all Faces
Definition: face-table.hpp:38
const FaceTable & getFaceTable()
Definition: strategy.hpp:186
Strategy(Forwarder &forwarder, const Name &name)
construct a strategy instance
Definition: strategy.cpp:35
identifies a face
shared_ptr< Face > getFace(FaceId id) const
get existing Face
Definition: forwarder.hpp:243
void rejectPendingInterest(shared_ptr< pit::Entry > pitEntry)
decide that a pending Interest cannot be forwarded
Definition: strategy.hpp:168
represents a forwarding strategy
Definition: strategy.hpp:37
signal::Signal< FaceTable, shared_ptr< Face > > & beforeRemoveFace
Definition: strategy.hpp:139
#define VIRTUAL_WITH_TESTS
Copyright (c) 2014, Regents of the University of California, Arizona Board of Regents, Colorado State University, University Pierre & Marie Curie, Sorbonne University, Washington University in St.
Definition: common.hpp:37
void sendInterest(shared_ptr< pit::Entry > pitEntry, shared_ptr< Face > outFace, bool wantNewNonce=false)
send Interest to outFace
Definition: strategy.hpp:160
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