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 
113 protected: // actions
115  VIRTUAL_WITH_TESTS void
116  sendInterest(shared_ptr<pit::Entry> pitEntry,
117  shared_ptr<Face> outFace,
118  bool wantNewNonce = false);
119 
125  VIRTUAL_WITH_TESTS void
126  rejectPendingInterest(shared_ptr<pit::Entry> pitEntry);
127 
128 protected: // accessors
130  getMeasurements();
131 
132  shared_ptr<Face>
133  getFace(FaceId id);
134 
135  const FaceTable&
136  getFaceTable();
137 
138 protected: // accessors
141 
142 private:
143  Name m_name;
144 
149  Forwarder& m_forwarder;
150 
151  MeasurementsAccessor m_measurements;
152 };
153 
154 inline const Name&
156 {
157  return m_name;
158 }
159 
160 inline void
161 Strategy::sendInterest(shared_ptr<pit::Entry> pitEntry,
162  shared_ptr<Face> outFace,
163  bool wantNewNonce)
164 {
165  m_forwarder.onOutgoingInterest(pitEntry, *outFace, wantNewNonce);
166 }
167 
168 inline void
169 Strategy::rejectPendingInterest(shared_ptr<pit::Entry> pitEntry)
170 {
171  m_forwarder.onInterestReject(pitEntry);
172 }
173 
174 inline MeasurementsAccessor&
176 {
177  return m_measurements;
178 }
179 
180 inline shared_ptr<Face>
182 {
183  return m_forwarder.getFace(id);
184 }
185 
186 inline const FaceTable&
188 {
189  return m_forwarder.getFaceTable();
190 }
191 
192 } // namespace fw
193 } // namespace nfd
194 
195 #endif // NFD_DAEMON_FW_STRATEGY_HPP
FaceTable & getFaceTable()
Definition: forwarder.hpp:248
const Name & getName() const
a Name that represent the Strategy program
Definition: strategy.hpp:155
signal::Signal< FaceTable, shared_ptr< Face > > & afterAddFace
Definition: strategy.hpp:139
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 an Interest packet
Definition: interest.hpp:45
provides a lightweight signal / event system
represents a face
Definition: face.hpp:57
shared_ptr< Face > getFace(FaceId id)
Definition: strategy.hpp:181
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:175
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:38
#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:187
Strategy(Forwarder &forwarder, const Name &name)
construct a strategy instance
Definition: strategy.cpp:35
identifies a face
Name abstraction to represent an absolute name.
Definition: name.hpp:46
shared_ptr< Face > getFace(FaceId id) const
get existing Face
Definition: forwarder.hpp:254
void rejectPendingInterest(shared_ptr< pit::Entry > pitEntry)
decide that a pending Interest cannot be forwarded
Definition: strategy.hpp:169
represents a forwarding strategy
Definition: strategy.hpp:38
signal::Signal< FaceTable, shared_ptr< Face > > & beforeRemoveFace
Definition: strategy.hpp:140
void sendInterest(shared_ptr< pit::Entry > pitEntry, shared_ptr< Face > outFace, bool wantNewNonce=false)
send Interest to outFace
Definition: strategy.hpp:161
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
represents a Data packet
Definition: data.hpp:39