NS-3 based Named Data Networking (NDN) simulator
ndnSIM 2.5: NDN, CCN, CCNx, content centric networks
API Documentation
nfd::RibManager Class Reference

Implements the RIB Management of NFD Management Protocol. More...

#include <rib-manager.hpp>

Inheritance diagram for nfd::RibManager:
Collaboration diagram for nfd::RibManager:

Public Types

enum  SlAnnounceResult {
  SlAnnounceResult::OK, SlAnnounceResult::ERROR, SlAnnounceResult::VALIDATION_FAILURE, SlAnnounceResult::EXPIRED,
  SlAnnounceResult::NOT_FOUND
}
 
using SlAnnounceCallback = std::function< void(SlAnnounceResult res)>
 
using SlFindAnnCallback = std::function< void(optional< ndn::PrefixAnnouncement >)>
 

Public Member Functions

 RibManager (rib::Rib &rib, ndn::Face &face, ndn::KeyChain &keyChain, ndn::nfd::Controller &nfdController, Dispatcher &dispatcher)
 
void applyLocalhostConfig (const ConfigSection &section, const std::string &filename)
 Apply localhost_security configuration. More...
 
void enableLocalhop (const ConfigSection &section, const std::string &filename)
 Apply localhop_security configuration and allow accepting commands on /localhop/nfd/rib prefix. More...
 
void disableLocalhop ()
 Disallow accepting commands on /localhop/nfd/rib prefix. More...
 
void applyPaConfig (const ConfigSection &section, const std::string &filename)
 Apply prefix_announcement_validation configuration. More...
 
void registerWithNfd ()
 Start accepting commands and dataset requests. More...
 
void enableLocalFields ()
 Enable NDNLP IncomingFaceId field in order to support self-registration commands. More...
 
void slAnnounce (const ndn::PrefixAnnouncement &pa, uint64_t faceId, time::milliseconds maxLifetime, const SlAnnounceCallback &cb)
 Insert a route by prefix announcement from self-learning strategy. More...
 
void slRenew (const Name &name, uint64_t faceId, time::milliseconds maxLifetime, const SlAnnounceCallback &cb)
 Renew a route created by prefix announcement from self-learning strategy. More...
 
void slFindAnn (const Name &name, const SlFindAnnCallback &cb) const
 Retrieve an outgoing prefix announcement for self-learning strategy. More...
 
- Public Member Functions inherited from nfd::ManagerBase
virtual ~ManagerBase ()
 
const std::string & getModule () const
 

Static Public Attributes

static const Name LOCALHOP_TOP_PREFIX = "/localhop/nfd"
 

Additional Inherited Members

- Protected Types inherited from nfd::ManagerBase
using ControlCommandHandler = std::function< void(const ControlCommand &command, const Name &prefix, const Interest &interest, const ControlParameters &parameters, const ndn::mgmt::CommandContinuation done)>
 
- Protected Member Functions inherited from nfd::ManagerBase
 ManagerBase (const std::string &module, Dispatcher &dispatcher)
 
 ManagerBase (const std::string &module, Dispatcher &dispatcher, CommandAuthenticator &authenticator)
 
template<typename Command >
void registerCommandHandler (const std::string &verb, const ControlCommandHandler &handler)
 
void registerStatusDatasetHandler (const std::string &verb, const ndn::mgmt::StatusDatasetHandler &handler)
 
ndn::mgmt::PostNotification registerNotificationStream (const std::string &verb)
 
void extractRequester (const Interest &interest, ndn::mgmt::AcceptContinuation accept)
 Extracts the requester from a ControlCommand request. More...
 

Detailed Description

Implements the RIB Management of NFD Management Protocol.

See also
https://redmine.named-data.net/projects/nfd/wiki/RibMgmt

Definition at line 49 of file rib-manager.hpp.

Member Typedef Documentation

◆ SlAnnounceCallback

using nfd::RibManager::SlAnnounceCallback = std::function<void(SlAnnounceResult res)>

Definition at line 101 of file rib-manager.hpp.

◆ SlFindAnnCallback

using nfd::RibManager::SlFindAnnCallback = std::function<void(optional<ndn::PrefixAnnouncement>)>

Definition at line 102 of file rib-manager.hpp.

Member Enumeration Documentation

◆ SlAnnounceResult

Enumerator
OK 

RIB and FIB have been updated.

ERROR 

unspecified error

VALIDATION_FAILURE 

the announcement cannot be verified against the trust schema

EXPIRED 

the announcement has expired

NOT_FOUND 

route does not exist (slRenew only)

Definition at line 93 of file rib-manager.hpp.

Constructor & Destructor Documentation

◆ RibManager()

nfd::RibManager::RibManager ( rib::Rib rib,
ndn::Face face,
ndn::KeyChain keyChain,
ndn::nfd::Controller nfdController,
Dispatcher dispatcher 
)

Definition at line 51 of file rib-manager.cpp.

References nfd::ManagerBase::registerStatusDatasetHandler().

Member Function Documentation

◆ applyLocalhostConfig()

void nfd::RibManager::applyLocalhostConfig ( const ConfigSection section,
const std::string &  filename 
)

Apply localhost_security configuration.

Definition at line 73 of file rib-manager.cpp.

References ndn::security::ValidatorConfig::load().

◆ enableLocalhop()

void nfd::RibManager::enableLocalhop ( const ConfigSection section,
const std::string &  filename 
)

Apply localhop_security configuration and allow accepting commands on /localhop/nfd/rib prefix.

Definition at line 79 of file rib-manager.cpp.

References ndn::security::ValidatorConfig::load().

◆ disableLocalhop()

void nfd::RibManager::disableLocalhop ( )

Disallow accepting commands on /localhop/nfd/rib prefix.

Definition at line 86 of file rib-manager.cpp.

◆ applyPaConfig()

void nfd::RibManager::applyPaConfig ( const ConfigSection section,
const std::string &  filename 
)

Apply prefix_announcement_validation configuration.

Definition at line 92 of file rib-manager.cpp.

References ndn::security::ValidatorConfig::load().

◆ registerWithNfd()

void nfd::RibManager::registerWithNfd ( )

◆ enableLocalFields()

void nfd::RibManager::enableLocalFields ( )

Enable NDNLP IncomingFaceId field in order to support self-registration commands.

Definition at line 114 of file rib-manager.cpp.

References ndn::nfd::BIT_LOCAL_FIELDS_ENABLED, ndn::tlv::nfd::ControlParameters, NDN_THROW, NFD_LOG_DEBUG, ndn::nfd::Controller::start(), and ndn::to_string().

◆ slAnnounce()

void nfd::RibManager::slAnnounce ( const ndn::PrefixAnnouncement pa,
uint64_t  faceId,
time::milliseconds  maxLifetime,
const SlAnnounceCallback cb 
)

Insert a route by prefix announcement from self-learning strategy.

Parameters
paA prefix announcement. It must contain the Data.
faceIdFace on which the announcement arrives.
maxLifetimeMaximum route lifetime as imposed by self-learning strategy.
cbCallback to receive the operation result.

If pa passes validation and is unexpired, inserts or replaces a route for the announced name and faceId whose lifetime is set to the earlier of now+maxLifetime or prefix announcement expiration time, updates FIB, and invokes cb with SlAnnounceResult::OK. In case pa expires when validation completes, invokes cb with SlAnnounceResult::EXPIRED. If pa cannot be verified by the trust schema given in rib.localhop_security config key, or the relevant config has not been loaded via enableLocalHop, invokes cb with SlAnnounceResult::VALIDATION_FAILURE.

Self-learning strategy invokes this method after receiving a Data carrying a prefix announcement.

Definition at line 357 of file rib-manager.cpp.

References ndn::PrefixAnnouncement::getData(), and ndn::security::v2::Validator::validate().

◆ slRenew()

void nfd::RibManager::slRenew ( const Name name,
uint64_t  faceId,
time::milliseconds  maxLifetime,
const SlAnnounceCallback cb 
)

Renew a route created by prefix announcement from self-learning strategy.

Parameters
nameData name, for finding RIB entry by longest-prefix-match.
faceIdNexthop face.
maxLifetimeMaximum route lifetime as imposed by self-learning strategy.
cbCallback to receive the operation result.

If the specified route exists, prolongs its lifetime to the earlier of now+maxLifetime or prefix announcement expiration time, and invokes cb with SlAnnounceResult::OK. If the prefix announcement has expired, invokes cb with SlAnnounceResult::EXPIRED. If the route is not found, invokes cb with SlAnnounceResult::NOT_FOUND.

Self-learning strategy invokes this method after an Interest forwarded via a learned route is satisfied.

Bug:
In current implementation, if an slAnnounce operation is in progress to create a Route or replace a prefix announcement, slRenew could fail because Route does not exist in existing RIB, or overwrite the new prefix announcement with an old one.

Definition at line 382 of file rib-manager.cpp.

References nfd::rib::Route::annExpires, nfd::rib::Route::announcement, nfd::rib::Route::expires, nfd::rib::Route::faceId, NFD_LOG_DEBUG, NFD_LOG_INFO, ndn::time::steady_clock::now(), nonstd::optional_lite::nullopt, nfd::rib::Route::origin, and ndn::nfd::ROUTE_ORIGIN_PREFIXANN.

◆ slFindAnn()

void nfd::RibManager::slFindAnn ( const Name name,
const SlFindAnnCallback cb 
) const

Retrieve an outgoing prefix announcement for self-learning strategy.

Parameters
nameData name.
cbCallback to receive a prefix announcement that announces a prefix of name, or nullopt if no RIB entry is found by longest-prefix-match of name.

Self-learning strategy invokes this method before sending a Data in reply to a discovery Interest, so as to attach a prefix announcement onto that Data.

Bug:
In current implementation, if an slAnnounce operation is in progress, slFindAnn does not wait for that operation to complete and its result reflects the prior RIB state.

Definition at line 407 of file rib-manager.cpp.

References nonstd::optional_lite::nullopt.

Member Data Documentation

◆ LOCALHOP_TOP_PREFIX

const Name nfd::RibManager::LOCALHOP_TOP_PREFIX = "/localhop/nfd"
static

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