represents a forwarding strategy More...
#include <strategy.hpp>
Public Member Functions | |
Strategy (Forwarder &forwarder, const Name &name) | |
construct a strategy instance More... | |
virtual | ~Strategy () |
const Name & | getName () const |
virtual void | afterReceiveInterest (const Face &inFace, const Interest &interest, const shared_ptr< pit::Entry > &pitEntry)=0 |
trigger after Interest is received More... | |
virtual void | beforeSatisfyInterest (const shared_ptr< pit::Entry > &pitEntry, const Face &inFace, const Data &data) |
trigger before PIT entry is satisfied More... | |
virtual void | beforeExpirePendingInterest (const shared_ptr< pit::Entry > &pitEntry) |
trigger before PIT entry expires More... | |
virtual void | afterReceiveNack (const Face &inFace, const lp::Nack &nack, const shared_ptr< pit::Entry > &pitEntry) |
trigger after Nack is received More... | |
Protected Member Functions | |
void | sendInterest (const shared_ptr< pit::Entry > &pitEntry, Face &outFace, const Interest &interest) |
send Interest to outFace More... | |
DEPRECATED (void sendInterest(const shared_ptr< pit::Entry > &pitEntry, Face &outFace, bool wantNewNonce=false)) | |
send Interest to outFace More... | |
void | rejectPendingInterest (const shared_ptr< pit::Entry > &pitEntry) |
decide that a pending Interest cannot be forwarded More... | |
void | sendNack (const shared_ptr< pit::Entry > &pitEntry, const Face &outFace, const lp::NackHeader &header) |
send Nack to outFace More... | |
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 More... | |
const fib::Entry & | lookupFib (const pit::Entry &pitEntry) const |
performs a FIB lookup, considering Link object if present More... | |
MeasurementsAccessor & | getMeasurements () |
Face * | getFace (FaceId id) const |
const FaceTable & | getFaceTable () const |
Protected Attributes | |
signal::Signal< FaceTable, Face & > & | afterAddFace |
signal::Signal< FaceTable, Face & > & | beforeRemoveFace |
represents a forwarding strategy
Definition at line 38 of file strategy.hpp.
construct a strategy instance
forwarder | a reference to the Forwarder, used to enable actions and accessors. Strategy subclasses should pass this reference, and should not keep a reference themselves. |
name | the strategy Name. It's recommended to include a version number as the last component. |
Definition at line 37 of file strategy.cpp.
References ~Strategy().
|
virtualdefault |
Referenced by Strategy().
|
inline |
Definition at line 56 of file strategy.hpp.
References afterReceiveInterest(), afterReceiveNack(), beforeExpirePendingInterest(), beforeSatisfyInterest(), and VIRTUAL_WITH_TESTS.
Referenced by nfd::strategy_choice::clearStrategyInfo(), nfd::strategy_choice::StrategyChoice::findEffectiveStrategy(), nfd::strategy_choice::StrategyChoice::get(), nfd::strategy_choice::Entry::getStrategyName(), and nfd::strategy_choice::StrategyChoice::insert().
|
pure virtual |
trigger after Interest is received
The Interest:
The strategy should decide whether and where to forward this Interest.
Implemented in nfd::fw::BestRouteStrategy2, nfd::fw::AccessStrategy, nfd::fw::asf::AsfStrategy, nfd::fw::BestRouteStrategy, nfd::fw::ClientControlStrategy, nfd::fw::NccStrategy, and nfd::fw::MulticastStrategy.
Referenced by getName(), and nfd::Forwarder::startProcessNack().
|
virtual |
trigger before PIT entry is satisfied
This trigger is invoked when an incoming Data satisfies the PIT entry. It can be invoked even if the PIT entry has already been satisfied.
In this base class this method does nothing.
Reimplemented in nfd::fw::AccessStrategy, nfd::fw::asf::AsfStrategy, and nfd::fw::NccStrategy.
Definition at line 49 of file strategy.cpp.
References nfd::face::Face::getId(), ndn::Data::getName(), and NFD_LOG_DEBUG.
Referenced by getName(), and nfd::Forwarder::startProcessNack().
|
virtual |
trigger before PIT entry expires
PIT entry expires when InterestLifetime has elapsed for all InRecords, and it is not satisfied by an incoming Data.
This trigger is not invoked for PIT entry already satisfied.
In this base class this method does nothing.
Definition at line 57 of file strategy.cpp.
References NFD_LOG_DEBUG.
Referenced by getName(), and nfd::Forwarder::startProcessNack().
|
virtual |
trigger after Nack is received
This trigger is invoked when an incoming Nack is received in response to an forwarded Interest. The Nack has been confirmed to be a response to the last Interest forwarded to that upstream, i.e. the PIT out-record exists and has a matching Nonce. The NackHeader has been recorded in the PIT out-record.
In this base class this method does nothing.
Reimplemented in nfd::fw::BestRouteStrategy2, and nfd::fw::asf::AsfStrategy.
Definition at line 63 of file strategy.cpp.
References nfd::pit::FaceRecord::getFace(), nfd::getGlobalRng(), nfd::face::Face::getId(), nfd::pit::FaceRecord::getLastRenewed(), NFD_LOG_DEBUG, sendInterest(), ndn::Interest::setNonce(), and nfd::fw::violatesScope().
Referenced by getName(), and nfd::Forwarder::startProcessNack().
|
inlineprotected |
send Interest to outFace
pitEntry | PIT entry |
outFace | face through which to send out the Interest |
interest | the Interest packet |
Definition at line 137 of file strategy.hpp.
References DEPRECATED(), and VIRTUAL_WITH_TESTS.
Referenced by nfd::fw::MulticastStrategy::afterReceiveInterest(), nfd::fw::NccStrategy::afterReceiveInterest(), nfd::fw::BestRouteStrategy::afterReceiveInterest(), nfd::fw::AccessStrategy::afterReceiveInterest(), nfd::fw::BestRouteStrategy2::afterReceiveInterest(), nfd::fw::asf::AsfStrategy::afterReceiveNack(), afterReceiveNack(), and nfd::fw::NccStrategy::doPropagate().
|
protected |
send Interest to outFace
pitEntry | PIT entry |
outFace | face through which to send out the Interest |
wantNewNonce | if true, a new Nonce will be generated, rather than reusing a Nonce from one of the PIT in-records |
Referenced by sendInterest().
|
inlineprotected |
decide that a pending Interest cannot be forwarded
pitEntry | PIT entry |
This shall not be called if the pending Interest has been forwarded earlier, and does not need to be resent now.
Definition at line 162 of file strategy.hpp.
References VIRTUAL_WITH_TESTS.
Referenced by nfd::fw::MulticastStrategy::afterReceiveInterest(), nfd::fw::NccStrategy::afterReceiveInterest(), nfd::fw::asf::AsfStrategy::afterReceiveInterest(), nfd::fw::BestRouteStrategy::afterReceiveInterest(), nfd::fw::AccessStrategy::afterReceiveInterest(), and nfd::fw::BestRouteStrategy2::afterReceiveInterest().
|
inlineprotected |
send Nack to outFace
pitEntry | PIT entry |
outFace | face through which to send out the Nack |
header | Nack header |
The outFace must have a PIT in-record, otherwise this method has no effect.
Definition at line 175 of file strategy.hpp.
References lookupFib(), and sendNacks().
Referenced by nfd::fw::BestRouteStrategy2::afterReceiveInterest(), nfd::fw::BestRouteStrategy2::afterReceiveNack(), nfd::fw::asf::getValueForSorting(), and sendNacks().
|
protected |
send Nack to every face that has an in-record, except those in exceptFaces
pitEntry | PIT entry |
header | NACK header |
exceptFaces | list of faces that should be excluded from sending Nacks |
Definition at line 107 of file strategy.cpp.
References nfd::pit::FaceRecord::getFace(), and sendNack().
Referenced by nfd::fw::BestRouteStrategy2::afterReceiveNack(), and sendNack().
|
protected |
performs a FIB lookup, considering Link object if present
Definition at line 129 of file strategy.cpp.
References nfd::fib::Fib::findLongestPrefixMatch(), ndn::Link::getDelegations(), nfd::Forwarder::getFib(), nfd::pit::Entry::getInterest(), ndn::Interest::getLink(), nfd::Forwarder::getNetworkRegionTable(), nfd::fib::Entry::getPrefix(), ndn::Interest::getSelectedDelegation(), ndn::Interest::hasLink(), nfd::fib::Entry::hasNextHops(), ndn::Interest::hasSelectedDelegation(), nfd::pit::Entry::in_begin(), nfd::pit::Entry::in_end(), nfd::NetworkRegionTable::isInProducerRegion(), NFD_LOG_TRACE, and ndn::Name::size().
Referenced by nfd::fw::MulticastStrategy::afterReceiveInterest(), nfd::fw::NccStrategy::afterReceiveInterest(), nfd::fw::asf::AsfStrategy::afterReceiveInterest(), nfd::fw::BestRouteStrategy::afterReceiveInterest(), nfd::fw::AccessStrategy::afterReceiveInterest(), nfd::fw::BestRouteStrategy2::afterReceiveInterest(), nfd::fw::NccStrategy::doPropagate(), and sendNack().
|
inlineprotected |
Definition at line 199 of file strategy.hpp.
Referenced by nfd::fw::NccStrategy::beforeSatisfyInterest(), nfd::fw::AccessStrategy::beforeSatisfyInterest(), nfd::fw::NccStrategy::getMeasurementsEntryInfo(), and nfd::fw::NccStrategy::timeoutOnBestFace().
|
inlineprotected |
Definition at line 205 of file strategy.hpp.
References nfd::Forwarder::getFace().
Referenced by nfd::fw::AccessStrategy::afterReceiveInterest(), and nfd::fw::NccStrategy::doPropagate().
|
inlineprotected |
Definition at line 211 of file strategy.hpp.
References nfd::Forwarder::getFaceTable().
|
protected |
Definition at line 217 of file strategy.hpp.
|
protected |
Definition at line 218 of file strategy.hpp.