Self-learning forwarding strategy. More...
#include <daemon/fw/self-learning-strategy.hpp>
Classes | |
class | InRecordInfo |
StrategyInfo on pit::InRecord. More... | |
class | OutRecordInfo |
StrategyInfo on pit::OutRecord. More... | |
Public Member Functions | |
SelfLearningStrategy (Forwarder &forwarder, const Name &name=getStrategyName()) | |
virtual void | afterContentStoreHit (const Data &data, const FaceEndpoint &ingress, const shared_ptr< pit::Entry > &pitEntry) |
Trigger after a matching Data is found in the Content Store. More... | |
virtual void | afterNewNextHop (const fib::NextHop &nextHop, const shared_ptr< pit::Entry > &pitEntry) |
Trigger after a new nexthop is added. More... | |
void | afterReceiveData (const Data &data, const FaceEndpoint &ingress, const shared_ptr< pit::Entry > &pitEntry) override |
Trigger after Data is received. More... | |
void | afterReceiveInterest (const Interest &interest, const FaceEndpoint &ingress, const shared_ptr< pit::Entry > &pitEntry) override |
Trigger after an Interest is received. More... | |
void | afterReceiveNack (const lp::Nack &nack, const FaceEndpoint &ingress, const shared_ptr< pit::Entry > &pitEntry) override |
Trigger after a Nack is received. More... | |
virtual void | beforeSatisfyInterest (const Data &data, const FaceEndpoint &ingress, const shared_ptr< pit::Entry > &pitEntry) |
Trigger before a PIT entry is satisfied. More... | |
const Name & | getInstanceName () const noexcept |
Returns the strategy's instance name. More... | |
virtual void | onDroppedInterest (const Interest &interest, Face &egress) |
Trigger after an Interest is dropped (e.g., for exceeding allowed retransmissions). More... | |
virtual void | onInterestLoop (const Interest &interest, const FaceEndpoint &ingress) |
Trigger after an Interest loop is detected. More... | |
Static Public Member Functions | |
static bool | areSameType (const Name &instanceNameA, const Name &instanceNameB) |
Returns whether two names will instantiate the same strategy type. More... | |
static bool | canCreate (const Name &instanceName) |
Returns whether a strategy instance can be created from instanceName . More... | |
static unique_ptr< Strategy > | create (const Name &instanceName, Forwarder &forwarder) |
Returns a strategy instance created from instanceName . More... | |
static const Name & | getStrategyName () |
static std::set< Name > | listRegistered () |
Returns all registered versioned strategy names. More... | |
template<typename S > | |
static void | registerType (const Name &strategyName=S::getStrategyName()) |
Register a strategy type. More... | |
Protected Member Functions | |
Face * | getFace (FaceId id) const noexcept |
const FaceTable & | getFaceTable () const noexcept |
MeasurementsAccessor & | getMeasurements () noexcept |
const fib::Entry & | lookupFib (const pit::Entry &pitEntry) const |
Performs a FIB lookup, considering Link object if present. More... | |
void | rejectPendingInterest (const shared_ptr< pit::Entry > &pitEntry) |
Schedule the PIT entry for immediate deletion. More... | |
bool | sendData (const Data &data, Face &egress, const shared_ptr< pit::Entry > &pitEntry) |
Send a Data packet. More... | |
void | sendDataToAll (const Data &data, const shared_ptr< pit::Entry > &pitEntry, const Face &inFace) |
Send a Data packet to all matched and qualified faces. More... | |
pit::OutRecord * | sendInterest (const Interest &interest, Face &egress, const shared_ptr< pit::Entry > &pitEntry) |
Send an Interest packet. More... | |
bool | sendNack (const lp::Nack &nack, Face &egress) |
Send a Nack packet without going through the outgoing Nack pipeline. More... | |
bool | sendNack (const lp::NackHeader &header, Face &egress, const shared_ptr< pit::Entry > &pitEntry) |
Send a Nack packet. More... | |
void | sendNacks (const lp::NackHeader &header, const shared_ptr< pit::Entry > &pitEntry, std::initializer_list< const Face * > exceptFaces={}) |
Send Nack to every face that has an in-record, except those in exceptFaces . More... | |
void | setExpiryTimer (const shared_ptr< pit::Entry > &pitEntry, time::milliseconds duration) |
Schedule the PIT entry to be erased after duration . More... | |
void | setInstanceName (const Name &name) noexcept |
Set strategy instance name. More... | |
Static Protected Member Functions | |
static Name | makeInstanceName (const Name &input, const Name &strategyName) |
Construct a strategy instance name. More... | |
static ParsedInstanceName | parseInstanceName (const Name &input) |
Parse a strategy instance name. More... | |
static StrategyParameters | parseParameters (const PartialName ¶ms) |
Parse strategy parameters encoded in a strategy instance name. More... | |
Protected Attributes | |
signal::Signal< FaceTable, Face > & | afterAddFace |
signal::Signal< FaceTable, Face > & | beforeRemoveFace |
Self-learning forwarding strategy.
This strategy first broadcasts Interest to learn a single path towards data, then unicasts subsequent Interests along the learned path.
Definition at line 43 of file self-learning-strategy.hpp.
|
explicit |
Definition at line 47 of file self-learning-strategy.cpp.
|
virtualinherited |
Trigger after a matching Data is found in the Content Store.
In the base class, this method sends data
to ingress
.
pitEntry
shared_ptr after this function returns, otherwise undefined behavior may occur. However, the strategy is allowed to construct and keep a weak_ptr to pitEntry
. Definition at line 187 of file strategy.cpp.
|
virtualinherited |
Trigger after a new nexthop is added.
The strategy should decide whether to send the buffered Interests to the new nexthop.
In the base class, this method does nothing.
Reimplemented in nfd::fw::MulticastStrategy.
Definition at line 229 of file strategy.cpp.
|
overridevirtual |
Trigger after Data is received.
This trigger is invoked when an incoming Data satisfies exactly one PIT entry, and gives the strategy full control over Data forwarding.
When this trigger is invoked:
Inside this function:
In the base class, this method invokes beforeSatisfyInterest() and then returns the Data to all downstream faces via sendDataToAll().
pitEntry
shared_ptr after this function returns, otherwise undefined behavior may occur. However, the strategy is allowed to construct and keep a weak_ptr to pitEntry
. Reimplemented from nfd::fw::Strategy.
Definition at line 103 of file self-learning-strategy.cpp.
|
overridevirtual |
Trigger after an Interest is received.
The Interest:
The PIT entry is set to expire after InterestLifetime has elapsed at each downstream.
The strategy should decide whether and where to forward this Interest.
pitEntry
shared_ptr after this function returns, otherwise undefined behavior may occur. However, the strategy is allowed to construct and keep a weak_ptr to pitEntry
. Implements nfd::fw::Strategy.
Definition at line 69 of file self-learning-strategy.cpp.
|
overridevirtual |
Trigger after a 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.
If the PIT entry is not yet satisfied, its expiry timer remains unchanged. Otherwise, the PIT entry will normally expire immediately after this function returns.
If the strategy wishes to collect responses from additional upstream nodes, it should invoke setExpiryTimer() within this function to prolong the PIT entry lifetime. If a Nack arrives from another upstream during the extended PIT entry lifetime, this trigger will be invoked again. At that time, the strategy must invoke setExpiryTimer() again to continue collecting more responses.
In the base class, this method does nothing.
pitEntry
shared_ptr after this function returns, otherwise undefined behavior may occur. However, the strategy is allowed to construct and keep a weak_ptr to pitEntry
. Reimplemented from nfd::fw::Strategy.
Definition at line 133 of file self-learning-strategy.cpp.
|
staticinherited |
Returns whether two names will instantiate the same strategy type.
Definition at line 108 of file strategy.cpp.
|
virtualinherited |
Trigger before a PIT entry is satisfied.
This trigger is invoked when an incoming Data satisfies more than one PIT entry. The strategy can collect measurements information, but cannot manipulate Data forwarding. When an incoming Data satisfies only one PIT entry, afterReceiveData() is invoked instead and given full control over Data forwarding. If a strategy does not override afterReceiveData(), the default implementation invokes beforeSatisfyInterest().
Normally, PIT entries are erased after receiving the first matching Data. If the strategy wishes to collect responses from additional upstream nodes, it should invoke setExpiryTimer() within this function to prolong the PIT entry lifetime. If a Data arrives from another upstream during the extended PIT entry lifetime, this trigger will be invoked again. At that time, the strategy must invoke setExpiryTimer() again to continue collecting more responses.
In the base class, this method does nothing.
pitEntry
shared_ptr after this function returns, otherwise undefined behavior may occur. However, the strategy is allowed to construct and keep a weak_ptr to pitEntry
. Reimplemented in nfd::fw::asf::AsfStrategy, and nfd::fw::AccessStrategy.
Definition at line 197 of file strategy.cpp.
|
staticinherited |
Returns whether a strategy instance can be created from instanceName
.
instanceName | strategy instance name, may contain version and parameters |
Definition at line 86 of file strategy.cpp.
|
staticinherited |
Returns a strategy instance created from instanceName
.
nullptr | if canCreate(instanceName) == false |
std::invalid_argument | strategy type constructor does not accept the specified version or parameters |
Definition at line 92 of file strategy.cpp.
|
inlineprotectednoexceptinherited |
Definition at line 405 of file strategy.hpp.
|
inlineprotectednoexceptinherited |
Definition at line 411 of file strategy.hpp.
|
inlinenoexceptinherited |
Returns the strategy's instance name.
The instance name is assigned during instantiation. It contains a version component and may have extra parameter components.
Definition at line 126 of file strategy.hpp.
|
inlineprotectednoexceptinherited |
Definition at line 399 of file strategy.hpp.
|
static |
Definition at line 62 of file self-learning-strategy.cpp.
|
staticinherited |
Returns all registered versioned strategy names.
Definition at line 114 of file strategy.cpp.
|
protectedinherited |
Performs a FIB lookup, considering Link object if present.
Definition at line 313 of file strategy.cpp.
|
staticprotectedinherited |
Construct a strategy instance name.
input | strategy instance name, may contain version and parameters |
strategyName | strategy name with version but without parameters; typically this should be getStrategyName() |
If input
contains a version component, return input
unchanged. Otherwise, return input
plus the version component taken from strategyName
. This allows a strategy instance to be constructed with an unversioned name, but its final instance name should contain the version.
Definition at line 134 of file strategy.cpp.
|
virtualinherited |
Trigger after an Interest is dropped (e.g., for exceeding allowed retransmissions).
In the base class, this method does nothing.
Definition at line 223 of file strategy.cpp.
|
virtualinherited |
Trigger after an Interest loop is detected.
The Interest:
In the base class, this method sends a Nack with reason DUPLICATE to ingress
.
Reimplemented in nfd::fw::MulticastStrategy.
Definition at line 177 of file strategy.cpp.
|
staticprotectedinherited |
Parse a strategy instance name.
input | strategy instance name, may contain version and parameters |
std::invalid_argument | input format is unacceptable |
Definition at line 123 of file strategy.cpp.
|
staticprotectedinherited |
Parse strategy parameters encoded in a strategy instance name.
params | encoded parameters, typically obtained from a call to parseInstanceName() |
std::invalid_argument | the encoding format is invalid or unsupported by this implementation |
Definition at line 144 of file strategy.cpp.
|
inlinestaticinherited |
Register a strategy type.
S | subclass of Strategy |
strategyName | strategy program name, must contain version |
Definition at line 57 of file strategy.hpp.
|
inlineprotectedinherited |
Schedule the PIT entry for immediate deletion.
This helper function sets the PIT entry expiry time to zero. The strategy should invoke this function when it concludes that the Interest cannot be forwarded and it does not want to wait for responses from existing upstream nodes.
Definition at line 335 of file strategy.hpp.
|
protectedinherited |
Send a Data packet.
data | the Data packet |
egress | face through which to send out the Data |
pitEntry | the PIT entry |
Definition at line 247 of file strategy.cpp.
|
protectedinherited |
Send a Data packet to all matched and qualified faces.
A matched face qualifies if it is ad-hoc OR it is NOT inFace
.
data | the Data packet |
pitEntry | the PIT entry |
inFace | face on which the Data arrived |
Definition at line 269 of file strategy.cpp.
|
protectedinherited |
Send an Interest packet.
interest | the Interest packet |
egress | face through which to send out the Interest |
pitEntry | the PIT entry |
Definition at line 236 of file strategy.cpp.
|
inlineprotectedinherited |
Send a Nack packet without going through the outgoing Nack pipeline.
nack | the Nack packet |
egress | face through which to send out the Nack |
Definition at line 364 of file strategy.hpp.
|
inlineprotectedinherited |
Send a Nack packet.
The egress face must have a PIT in-record, otherwise this method has no effect.
header | the Nack header |
egress | face through which to send out the Nack |
pitEntry | the PIT entry |
Definition at line 351 of file strategy.hpp.
|
protectedinherited |
Send Nack to every face that has an in-record, except those in exceptFaces
.
header | the Nack header |
pitEntry | the PIT entry |
exceptFaces | list of faces that should be excluded from sending Nacks |
Definition at line 291 of file strategy.cpp.
|
inlineprotectedinherited |
Schedule the PIT entry to be erased after duration
.
Definition at line 386 of file strategy.hpp.
|
inlineprotectednoexceptinherited |
Set strategy instance name.
Definition at line 448 of file strategy.hpp.
Definition at line 473 of file strategy.hpp.
Definition at line 474 of file strategy.hpp.