NS-3 based Named Data Networking (NDN) simulator
ndnSIM 2.0: 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
 a Name that represent the Strategy program More...
 
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 More...
 
virtual void beforeSatisfyInterest (shared_ptr< pit::Entry > pitEntry, const Face &inFace, const Data &data)
 trigger before PIT entry is satisfied More...
 
virtual void beforeExpirePendingInterest (shared_ptr< pit::Entry > pitEntry)
 trigger before PIT entry expires More...
 
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 More...
 

Protected Member Functions

void sendInterest (shared_ptr< pit::Entry > pitEntry, shared_ptr< Face > outFace, bool wantNewNonce=false)
 send Interest to outFace More...
 
void rejectPendingInterest (shared_ptr< pit::Entry > pitEntry)
 decide that a pending Interest cannot be forwarded More...
 
void sendNack (shared_ptr< pit::Entry > pitEntry, const Face &outFace, const lp::NackHeader &header)
 send Nack to outFace More...
 
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 More...
 
MeasurementsAccessorgetMeasurements ()
 
shared_ptr< Face > getFace (FaceId id)
 
const FaceTablegetFaceTable ()
 

Protected Attributes

signal::Signal< FaceTable, shared_ptr< Face > > & afterAddFace
 
signal::Signal< FaceTable, shared_ptr< 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 35 of file strategy.cpp.

§ ~Strategy()

nfd::fw::Strategy::~Strategy ( )
virtual

Definition at line 45 of file strategy.cpp.

Member Function Documentation

§ getName()

const Name & nfd::fw::Strategy::getName ( ) const
inline

a Name that represent the Strategy program

Definition at line 202 of file strategy.hpp.

Referenced by nfd::clearStrategyInfo(), nfd::strategy_choice::Entry::getStrategyName(), and nfd::StrategyChoice::insert().

§ afterReceiveInterest()

virtual void nfd::fw::Strategy::afterReceiveInterest ( const Face &  inFace,
const Interest interest,
shared_ptr< fib::Entry fibEntry,
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
Note
The strategy is permitted to store a weak reference to fibEntry. Do not store a shared reference, because FIB entry may be deleted at any moment. fibEntry is passed by value to allow obtaining a weak reference from it.
The strategy is permitted to store a shared reference to pitEntry. pitEntry is passed by value to reflect this fact.

Implemented in nfd::fw::AccessStrategy, nfd::fw::BestRouteStrategy2, nfd::fw::BestRouteStrategy, nfd::fw::ClientControlStrategy, nfd::fw::NccStrategy, nfd::fw::BroadcastStrategy, and nfd::fw::MulticastStrategy.

Referenced by nfd::Forwarder::startProcessNack().

§ beforeSatisfyInterest()

void nfd::fw::Strategy::beforeSatisfyInterest ( 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.

Note
The strategy is permitted to store a shared reference to pitEntry. pitEntry is passed by value to reflect this fact.

Reimplemented in nfd::fw::AccessStrategy, and nfd::fw::NccStrategy.

Definition at line 50 of file strategy.cpp.

References ndn::Data::getName(), and NFD_LOG_DEBUG.

Referenced by nfd::Forwarder::startProcessNack().

§ beforeExpirePendingInterest()

void nfd::fw::Strategy::beforeExpirePendingInterest ( 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.

Note
The strategy is permitted to store a shared reference to pitEntry. pitEntry is passed by value to reflect this fact.

Definition at line 58 of file strategy.cpp.

References NFD_LOG_DEBUG.

Referenced by nfd::Forwarder::startProcessNack().

§ afterReceiveNack()

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

Note
The strategy is permitted to store a weak reference to fibEntry. Do not store a shared reference, because PIT entry may be deleted at any moment. fibEntry is passed by value to allow obtaining a weak reference from it.
The strategy is permitted to store a shared reference to pitEntry. pitEntry is passed by value to reflect this fact.

Reimplemented in nfd::fw::BestRouteStrategy2.

Definition at line 64 of file strategy.cpp.

References NFD_LOG_DEBUG.

Referenced by nfd::Forwarder::startProcessNack().

§ sendInterest()

void nfd::fw::Strategy::sendInterest ( shared_ptr< pit::Entry pitEntry,
shared_ptr< Face >  outFace,
bool  wantNewNonce = false 
)
inlineprotected

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

Definition at line 208 of file strategy.hpp.

Referenced by nfd::fw::MulticastStrategy::afterReceiveInterest(), nfd::fw::NccStrategy::afterReceiveInterest(), nfd::fw::ClientControlStrategy::afterReceiveInterest(), nfd::fw::BestRouteStrategy::afterReceiveInterest(), nfd::fw::BestRouteStrategy2::afterReceiveInterest(), nfd::fw::AccessStrategy::afterReceiveInterest(), and nfd::fw::NccStrategy::doPropagate().

§ rejectPendingInterest()

void nfd::fw::Strategy::rejectPendingInterest ( 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 216 of file strategy.hpp.

Referenced by nfd::fw::MulticastStrategy::afterReceiveInterest(), nfd::fw::NccStrategy::afterReceiveInterest(), nfd::fw::ClientControlStrategy::afterReceiveInterest(), nfd::fw::BestRouteStrategy::afterReceiveInterest(), and nfd::fw::BestRouteStrategy2::afterReceiveInterest().

§ sendNack()

void nfd::fw::Strategy::sendNack ( 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 222 of file strategy.hpp.

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

§ sendNacks()

void nfd::fw::Strategy::sendNacks ( 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 72 of file strategy.cpp.

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

Referenced by nfd::fw::BestRouteStrategy2::afterReceiveNack().

§ getMeasurements()

§ getFace()

shared_ptr< Face > nfd::fw::Strategy::getFace ( FaceId  id)
inlineprotected

§ getFaceTable()

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

Definition at line 241 of file strategy.hpp.

References nfd::Forwarder::getFaceTable().

Member Data Documentation

§ afterAddFace

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

Definition at line 186 of file strategy.hpp.

§ beforeRemoveFace

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

Definition at line 187 of file strategy.hpp.


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