NS-3 based Named Data Networking (NDN) simulator
ndnSIM 2.3: NDN, CCN, CCNx, content centric networks
API Documentation
nfd::fw::Strategy Class Referenceabstract

represents a forwarding strategy More...

#include <strategy.hpp>

Inheritance diagram for nfd::fw::Strategy:
Collaboration diagram for nfd::fw::Strategy:

Public Member Functions

 Strategy (Forwarder &forwarder, const Name &name)
 construct a strategy instance More...
 
virtual ~Strategy ()
 
const NamegetName () 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::EntrylookupFib (const pit::Entry &pitEntry) const
 performs a FIB lookup, considering Link object if present More...
 
MeasurementsAccessorgetMeasurements ()
 
FacegetFace (FaceId id) const
 
const FaceTablegetFaceTable () const
 

Protected Attributes

signal::Signal< FaceTable, Face & > & afterAddFace
 
signal::Signal< FaceTable, Face & > & beforeRemoveFace
 

Detailed Description

represents a forwarding strategy

Definition at line 38 of file strategy.hpp.

Constructor & Destructor Documentation

◆ Strategy()

nfd::fw::Strategy::Strategy ( Forwarder forwarder,
const Name name 
)

construct a strategy instance

Parameters
forwardera reference to the Forwarder, used to enable actions and accessors. Strategy subclasses should pass this reference, and should not keep a reference themselves.
namethe strategy Name. It's recommended to include a version number as the last component.

Definition at line 37 of file strategy.cpp.

References ~Strategy().

◆ ~Strategy()

nfd::fw::Strategy::~Strategy ( )
virtualdefault

Referenced by Strategy().

Member Function Documentation

◆ getName()

◆ afterReceiveInterest()

virtual void nfd::fw::Strategy::afterReceiveInterest ( const Face inFace,
const Interest interest,
const shared_ptr< pit::Entry > &  pitEntry 
)
pure virtual

trigger after Interest is received

The Interest:

  • does not violate Scope
  • is not looped
  • cannot be satisfied by ContentStore
  • is under a namespace managed by this strategy

The strategy should decide whether and where to forward this Interest.

  • If the strategy decides to forward this Interest, invoke this->sendInterest one or more times, either now or shortly after
  • If strategy concludes that this Interest cannot be forwarded, invoke this->rejectPendingInterest so that PIT entry will be deleted shortly
Warning
The strategy must not retain shared_ptr<pit::Entry>, otherwise undefined behavior may occur. However, the strategy is allowed to store weak_ptr<pit::Entry>.

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().

◆ beforeSatisfyInterest()

void nfd::fw::Strategy::beforeSatisfyInterest ( const shared_ptr< pit::Entry > &  pitEntry,
const Face inFace,
const Data data 
)
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.

Warning
The strategy must not retain shared_ptr<pit::Entry>, otherwise undefined behavior may occur. However, the strategy is allowed to store weak_ptr<pit::Entry>.

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().

◆ beforeExpirePendingInterest()

void nfd::fw::Strategy::beforeExpirePendingInterest ( const shared_ptr< pit::Entry > &  pitEntry)
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.

Warning
The strategy must not retain shared_ptr<pit::Entry>, otherwise undefined behavior may occur. However, the strategy is allowed to store weak_ptr<pit::Entry>, although this isn't useful here because PIT entry would be deleted shortly after.

Definition at line 57 of file strategy.cpp.

References NFD_LOG_DEBUG.

Referenced by getName(), and nfd::Forwarder::startProcessNack().

◆ afterReceiveNack()

void nfd::fw::Strategy::afterReceiveNack ( const Face inFace,
const lp::Nack nack,
const shared_ptr< pit::Entry > &  pitEntry 
)
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.

Warning
The strategy must not retain shared_ptr<pit::Entry>, otherwise undefined behavior may occur. However, the strategy is allowed to store weak_ptr<pit::Entry>.

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().

◆ sendInterest()

void nfd::fw::Strategy::sendInterest ( const shared_ptr< pit::Entry > &  pitEntry,
Face outFace,
const Interest interest 
)
inlineprotected

◆ DEPRECATED()

nfd::fw::Strategy::DEPRECATED ( void   sendInterestconst shared_ptr< pit::Entry > &pitEntry, Face &outFace, bool wantNewNonce=false)
protected

send Interest to outFace

Parameters
pitEntryPIT entry
outFaceface through which to send out the Interest
wantNewNonceif true, a new Nonce will be generated, rather than reusing a Nonce from one of the PIT in-records
Deprecated:
use sendInterest(pitEntry, outFace, interest) instead

Referenced by sendInterest().

◆ rejectPendingInterest()

void nfd::fw::Strategy::rejectPendingInterest ( const shared_ptr< pit::Entry > &  pitEntry)
inlineprotected

decide that a pending Interest cannot be forwarded

Parameters
pitEntryPIT 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().

◆ sendNack()

void nfd::fw::Strategy::sendNack ( const shared_ptr< pit::Entry > &  pitEntry,
const Face outFace,
const lp::NackHeader header 
)
inlineprotected

send Nack to outFace

Parameters
pitEntryPIT entry
outFaceface through which to send out the Nack
headerNack 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().

◆ sendNacks()

void nfd::fw::Strategy::sendNacks ( const shared_ptr< pit::Entry > &  pitEntry,
const lp::NackHeader header,
std::initializer_list< const Face *>  exceptFaces = std::initializer_list<const Face*>() 
)
protected

send Nack to every face that has an in-record, except those in exceptFaces

Parameters
pitEntryPIT entry
headerNACK header
exceptFaceslist of faces that should be excluded from sending Nacks
Note
This is not an action, but a helper that invokes the sendNack action.

Definition at line 107 of file strategy.cpp.

References nfd::pit::FaceRecord::getFace(), and sendNack().

Referenced by nfd::fw::BestRouteStrategy2::afterReceiveNack(), and sendNack().

◆ lookupFib()

◆ getMeasurements()

◆ getFace()

Face* nfd::fw::Strategy::getFace ( FaceId  id) const
inlineprotected

◆ getFaceTable()

const FaceTable& nfd::fw::Strategy::getFaceTable ( ) const
inlineprotected

Definition at line 211 of file strategy.hpp.

References nfd::Forwarder::getFaceTable().

Member Data Documentation

◆ afterAddFace

signal::Signal<FaceTable, Face&>& nfd::fw::Strategy::afterAddFace
protected

Definition at line 217 of file strategy.hpp.

◆ beforeRemoveFace

signal::Signal<FaceTable, Face&>& nfd::fw::Strategy::beforeRemoveFace
protected

Definition at line 218 of file strategy.hpp.


The documentation for this class was generated from the following files: