NS-3 based Named Data Networking (NDN) simulator
ndnSIM 2.0: NDN, CCN, CCNx, content centric networks
API Documentation
ndn::Face Class Reference

Abstraction to communicate with local or remote NDN forwarder. More...

#include <face.hpp>

Inheritance diagram for ndn::Face:
Collaboration diagram for ndn::Face:

Classes

class  Error
 

Public Member Functions

 Face ()
 Create a new Face using the default transport (UnixTransport) More...
 
 Face (boost::asio::io_service &ioService)
 Create a new Face using the default transport (UnixTransport) More...
 
 ~Face ()
 
const PendingInterestId * expressInterest (const Interest &interest, const OnData &onData, const OnTimeout &onTimeout=OnTimeout())
 Express Interest. More...
 
const PendingInterestId * expressInterest (const Name &name, const Interest &tmpl, const OnData &onData, const OnTimeout &onTimeout=OnTimeout())
 Express Interest using name and Interest template. More...
 
void removePendingInterest (const PendingInterestId *pendingInterestId)
 Cancel previously expressed Interest. More...
 
size_t getNPendingInterests () const
 Get number of pending Interests. More...
 
const RegisteredPrefixId * setInterestFilter (const InterestFilter &interestFilter, const OnInterest &onInterest, const RegisterPrefixFailureCallback &onFailure, const security::SigningInfo &signingInfo=security::SigningInfo(), uint64_t flags=nfd::ROUTE_FLAG_CHILD_INHERIT)
 Set InterestFilter to dispatch incoming matching interest to onInterest callback and register the filtered prefix with the connected NDN forwarder. More...
 
const RegisteredPrefixId * setInterestFilter (const InterestFilter &interestFilter, const OnInterest &onInterest, const RegisterPrefixSuccessCallback &onSuccess, const RegisterPrefixFailureCallback &onFailure, const security::SigningInfo &signingInfo=security::SigningInfo(), uint64_t flags=nfd::ROUTE_FLAG_CHILD_INHERIT)
 Set InterestFilter to dispatch incoming matching interest to onInterest callback and register the filtered prefix with the connected NDN forwarder. More...
 
const InterestFilterId * setInterestFilter (const InterestFilter &interestFilter, const OnInterest &onInterest)
 Set InterestFilter to dispatch incoming matching interest to onInterest callback. More...
 
const RegisteredPrefixId * setInterestFilter (const InterestFilter &interestFilter, const OnInterest &onInterest, const RegisterPrefixSuccessCallback &onSuccess, const RegisterPrefixFailureCallback &onFailure, const IdentityCertificate &certificate, uint64_t flags=nfd::ROUTE_FLAG_CHILD_INHERIT)
 Set InterestFilter to dispatch incoming matching interest to onInterest callback and register the filtered prefix with the connected NDN forwarder. More...
 
const RegisteredPrefixId * setInterestFilter (const InterestFilter &interestFilter, const OnInterest &onInterest, const RegisterPrefixFailureCallback &onFailure, const IdentityCertificate &certificate, uint64_t flags=nfd::ROUTE_FLAG_CHILD_INHERIT)
 Set InterestFilter to dispatch incoming matching interest to onInterest callback and register the filtered prefix with the connected NDN forwarder. More...
 
const RegisteredPrefixId * setInterestFilter (const InterestFilter &interestFilter, const OnInterest &onInterest, const RegisterPrefixSuccessCallback &onSuccess, const RegisterPrefixFailureCallback &onFailure, const Name &identity, uint64_t flags=nfd::ROUTE_FLAG_CHILD_INHERIT)
 Set InterestFilter to dispatch incoming matching interest to onInterest callback and register the filtered prefix with the connected NDN forwarder. More...
 
const RegisteredPrefixId * setInterestFilter (const InterestFilter &interestFilter, const OnInterest &onInterest, const RegisterPrefixFailureCallback &onFailure, const Name &identity, uint64_t flags=nfd::ROUTE_FLAG_CHILD_INHERIT)
 Set InterestFilter to dispatch incoming matching interest to onInterest callback and register the filtered prefix with the connected NDN forwarder. More...
 
const RegisteredPrefixId * registerPrefix (const Name &prefix, const RegisterPrefixSuccessCallback &onSuccess, const RegisterPrefixFailureCallback &onFailure, const security::SigningInfo &signingInfo=security::SigningInfo(), uint64_t flags=nfd::ROUTE_FLAG_CHILD_INHERIT)
 Register prefix with the connected NDN forwarder. More...
 
const RegisteredPrefixId * registerPrefix (const Name &prefix, const RegisterPrefixSuccessCallback &onSuccess, const RegisterPrefixFailureCallback &onFailure, const IdentityCertificate &certificate, uint64_t flags=nfd::ROUTE_FLAG_CHILD_INHERIT)
 Register prefix with the connected NDN forwarder. More...
 
const RegisteredPrefixId * registerPrefix (const Name &prefix, const RegisterPrefixSuccessCallback &onSuccess, const RegisterPrefixFailureCallback &onFailure, const Name &identity, uint64_t flags=nfd::ROUTE_FLAG_CHILD_INHERIT)
 Register prefix with the connected NDN forwarder and call onInterest when a matching interest is received. More...
 
void unsetInterestFilter (const RegisteredPrefixId *registeredPrefixId)
 Remove the registered prefix entry with the registeredPrefixId. More...
 
void unsetInterestFilter (const InterestFilterId *interestFilterId)
 Remove previously set InterestFilter from library's FIB. More...
 
void unregisterPrefix (const RegisteredPrefixId *registeredPrefixId, const UnregisterPrefixSuccessCallback &onSuccess, const UnregisterPrefixFailureCallback &onFailure)
 Unregister prefix from RIB. More...
 
void put (const Data &data)
 Publish data packet. More...
 
void processEvents (const time::milliseconds &timeout=time::milliseconds::zero(), bool keepThread=false)
 Noop (kept for compatibility) More...
 
void shutdown ()
 Shutdown face operations. More...
 
boost::asio::io_service & getIoService ()
 Return nullptr (kept for compatibility) More...
 

Detailed Description

Abstraction to communicate with local or remote NDN forwarder.

Definition at line 100 of file face.hpp.

Constructor & Destructor Documentation

ndn::Face::Face ( )

Create a new Face using the default transport (UnixTransport)

Exceptions
ConfigFile::Erroron configuration file parse failure
Face::Erroron unsupported protocol

Definition at line 40 of file face.cpp.

ndn::Face::Face ( boost::asio::io_service &  ioService)
explicit

Create a new Face using the default transport (UnixTransport)

Usage examples:
Face face1;
Face face2(face1.getIoService());

// Now the following ensures that events on both faces are processed
face1.processEvents();
// or face1.getIoService().run();
or
boost::asio::io_service ioService;
Face face1(ioService);
Face face2(ioService);
...

ioService.run();
Parameters
ioServiceA reference to boost::io_service object that should control all IO operations.
Exceptions
ConfigFile::Erroron configuration file parse failure
Face::Erroron unsupported protocol

Definition at line 46 of file face.cpp.

References ns3::ndn::StackHelper::getKeyChain(), and ~Face().

ndn::Face::~Face ( )
default

Referenced by Face().

Member Function Documentation

const PendingInterestId * ndn::Face::expressInterest ( const Interest interest,
const OnData onData,
const OnTimeout onTimeout = OnTimeout() 
)

Express Interest.

Parameters
interestAn Interest to be expressed
onDataCallback to be called when a matching data packet is received
onTimeout(optional) A function object to call if the interest times out
Returns
The pending interest ID which can be used with removePendingInterest
Exceptions
Errorwhen Interest size exceeds maximum limit (MAX_NDN_PACKET_SIZE)

Definition at line 63 of file face.cpp.

References ndn::Interest::getName().

Referenced by ndn::Validator::afterCheckPolicy(), ndn::nfd::Controller::Controller(), nfd::rib::RibManager::enableLocalControlHeader(), expressInterest(), and ndn::Validator::onTimeout().

const PendingInterestId * ndn::Face::expressInterest ( const Name name,
const Interest tmpl,
const OnData onData,
const OnTimeout onTimeout = OnTimeout() 
)

Express Interest using name and Interest template.

Parameters
nameName of the Interest
tmplInterest template to fill parameters
onDataCallback to be called when a matching data packet is received
onTimeout(optional) A function object to call if the interest times out
Returns
Opaque pending interest ID which can be used with removePendingInterest
Exceptions
Errorwhen Interest size exceeds maximum limit (MAX_NDN_PACKET_SIZE)

Definition at line 76 of file face.cpp.

References expressInterest(), and ndn::tlv::Interest.

void ndn::Face::removePendingInterest ( const PendingInterestId *  pendingInterestId)

Cancel previously expressed Interest.

Parameters
pendingInterestIdThe ID returned from expressInterest.

Definition at line 106 of file face.cpp.

Referenced by ndn::util::NotificationSubscriber< FaceEventNotification >::stop().

size_t ndn::Face::getNPendingInterests ( ) const

Get number of pending Interests.

Definition at line 115 of file face.cpp.

const RegisteredPrefixId * ndn::Face::setInterestFilter ( const InterestFilter interestFilter,
const OnInterest onInterest,
const RegisterPrefixFailureCallback onFailure,
const security::SigningInfo signingInfo = security::SigningInfo(),
uint64_t  flags = nfd::ROUTE_FLAG_CHILD_INHERIT 
)

Set InterestFilter to dispatch incoming matching interest to onInterest callback and register the filtered prefix with the connected NDN forwarder.

This version of setInterestFilter combines setInterestFilter and registerPrefix operations and is intended to be used when only one filter for the same prefix needed to be set. When multiple names sharing the same prefix should be dispatched to different callbacks, use one registerPrefix call, followed (in onSuccess callback) by a series of setInterestFilter calls.

Parameters
interestFilterInterest filter (prefix part will be registered with the forwarder)
onInterestA callback to be called when a matching interest is received
onFailureA callback to be called when prefixRegister command fails
flags(optional) RIB flags
signingInfo(optional) Signing parameters. When omitted, a default parameters used in the signature will be used.
Returns
Opaque registered prefix ID which can be used with unsetInterestFilter or removeRegisteredPrefix

Definition at line 121 of file face.cpp.

Referenced by ndn::mgmt::Dispatcher::addTopPrefix(), setInterestFilter(), and nfd::rib::RibManager::~RibManager().

const RegisteredPrefixId * ndn::Face::setInterestFilter ( const InterestFilter interestFilter,
const OnInterest onInterest,
const RegisterPrefixSuccessCallback onSuccess,
const RegisterPrefixFailureCallback onFailure,
const security::SigningInfo signingInfo = security::SigningInfo(),
uint64_t  flags = nfd::ROUTE_FLAG_CHILD_INHERIT 
)

Set InterestFilter to dispatch incoming matching interest to onInterest callback and register the filtered prefix with the connected NDN forwarder.

This version of setInterestFilter combines setInterestFilter and registerPrefix operations and is intended to be used when only one filter for the same prefix needed to be set. When multiple names sharing the same prefix should be dispatched to different callbacks, use one registerPrefix call, followed (in onSuccess callback) by a series of setInterestFilter calls.

Parameters
interestFilterInterest filter (prefix part will be registered with the forwarder)
onInterestA callback to be called when a matching interest is received
onSuccessA callback to be called when prefixRegister command succeeds
onFailureA callback to be called when prefixRegister command fails
flags(optional) RIB flags
signingInfo(optional) Signing parameters. When omitted, a default parameters used in the signature will be used.
Returns
Opaque registered prefix ID which can be used with unsetInterestFilter or removeRegisteredPrefix

Definition at line 136 of file face.cpp.

References ndn::nfd::CommandOptions::setSigningInfo().

const InterestFilterId * ndn::Face::setInterestFilter ( const InterestFilter interestFilter,
const OnInterest onInterest 
)

Set InterestFilter to dispatch incoming matching interest to onInterest callback.

Parameters
interestFilterInterest
onInterestA callback to be called when a matching interest is received

This method modifies library's FIB only, and does not register the prefix with the forwarder. It will always succeed. To register prefix with the forwarder, use registerPrefix, or use the setInterestFilter overload taking two callbacks.

Returns
Opaque interest filter ID which can be used with unsetInterestFilter

Definition at line 155 of file face.cpp.

const RegisteredPrefixId * ndn::Face::setInterestFilter ( const InterestFilter interestFilter,
const OnInterest onInterest,
const RegisterPrefixSuccessCallback onSuccess,
const RegisterPrefixFailureCallback onFailure,
const IdentityCertificate certificate,
uint64_t  flags = nfd::ROUTE_FLAG_CHILD_INHERIT 
)

Set InterestFilter to dispatch incoming matching interest to onInterest callback and register the filtered prefix with the connected NDN forwarder.

Deprecated:
Use override with SigningInfo instead of this function

This version of setInterestFilter combines setInterestFilter and registerPrefix operations and is intended to be used when only one filter for the same prefix needed to be set. When multiple names sharing the same prefix should be dispatched to different callbacks, use one registerPrefix call, followed (in onSuccess callback) by a series of setInterestFilter calls.

Parameters
interestFilterInterest filter (prefix part will be registered with the forwarder)
onInterestA callback to be called when a matching interest is received
onSuccessA callback to be called when prefixRegister command succeeds
onFailureA callback to be called when prefixRegister command fails
flags(optional) RIB flags
certificate(optional) A certificate under which the prefix registration command is signed. When omitted, a default certificate of the default identity is used to sign the registration command
Returns
Opaque registered prefix ID which can be used with unsetInterestFilter or removeRegisteredPrefix

Definition at line 172 of file face.cpp.

References ndn::Name::empty(), ndn::Data::getName(), setInterestFilter(), and ndn::security::signingByCertificate().

const RegisteredPrefixId * ndn::Face::setInterestFilter ( const InterestFilter interestFilter,
const OnInterest onInterest,
const RegisterPrefixFailureCallback onFailure,
const IdentityCertificate certificate,
uint64_t  flags = nfd::ROUTE_FLAG_CHILD_INHERIT 
)

Set InterestFilter to dispatch incoming matching interest to onInterest callback and register the filtered prefix with the connected NDN forwarder.

Deprecated:
Use override with SigningInfo instead of this function

This version of setInterestFilter combines setInterestFilter and registerPrefix operations and is intended to be used when only one filter for the same prefix needed to be set. When multiple names sharing the same prefix should be dispatched to different callbacks, use one registerPrefix call, followed (in onSuccess callback) by a series of setInterestFilter calls.

Parameters
interestFilterInterest filter (prefix part will be registered with the forwarder)
onInterestA callback to be called when a matching interest is received
onFailureA callback to be called when prefixRegister command fails
flags(optional) RIB flags
certificate(optional) A certificate under which the prefix registration command is signed. When omitted, a default certificate of the default identity is used to sign the registration command
Returns
Opaque registered prefix ID which can be used with unsetInterestFilter or removeRegisteredPrefix

Definition at line 189 of file face.cpp.

References ndn::Name::empty(), ndn::Data::getName(), setInterestFilter(), and ndn::security::signingByCertificate().

const RegisteredPrefixId * ndn::Face::setInterestFilter ( const InterestFilter interestFilter,
const OnInterest onInterest,
const RegisterPrefixSuccessCallback onSuccess,
const RegisterPrefixFailureCallback onFailure,
const Name identity,
uint64_t  flags = nfd::ROUTE_FLAG_CHILD_INHERIT 
)

Set InterestFilter to dispatch incoming matching interest to onInterest callback and register the filtered prefix with the connected NDN forwarder.

Deprecated:
Use override with SigningInfo instead of this function

This version of setInterestFilter combines setInterestFilter and registerPrefix operations and is intended to be used when only one filter for the same prefix needed to be set. When multiple names sharing the same prefix should be dispatched to different callbacks, use one registerPrefix call, followed (in onSuccess callback) by a series of setInterestFilter calls.

Parameters
interestFilterInterest filter (prefix part will be registered with the forwarder)
onInterestA callback to be called when a matching interest is received
onSuccessA callback to be called when prefixRegister command succeeds
onFailureA callback to be called when prefixRegister command fails
identityA signing identity. A prefix registration command is signed under the default certificate of this identity
flags(optional) RIB flags
Returns
Opaque registered prefix ID which can be used with removeRegisteredPrefix

Definition at line 204 of file face.cpp.

References setInterestFilter(), and ndn::security::signingByIdentity().

const RegisteredPrefixId * ndn::Face::setInterestFilter ( const InterestFilter interestFilter,
const OnInterest onInterest,
const RegisterPrefixFailureCallback onFailure,
const Name identity,
uint64_t  flags = nfd::ROUTE_FLAG_CHILD_INHERIT 
)

Set InterestFilter to dispatch incoming matching interest to onInterest callback and register the filtered prefix with the connected NDN forwarder.

Deprecated:
Use override with SigningInfo instead of this function

This version of setInterestFilter combines setInterestFilter and registerPrefix operations and is intended to be used when only one filter for the same prefix needed to be set. When multiple names sharing the same prefix should be dispatched to different callbacks, use one registerPrefix call, followed (in onSuccess callback) by a series of setInterestFilter calls.

Parameters
interestFilterInterest filter (prefix part will be registered with the forwarder)
onInterestA callback to be called when a matching interest is received
onFailureA callback to be called when prefixRegister command fails
identityA signing identity. A prefix registration command is signed under the default certificate of this identity
flags(optional) RIB flags
Returns
Opaque registered prefix ID which can be used with removeRegisteredPrefix

Definition at line 219 of file face.cpp.

References setInterestFilter(), and ndn::security::signingByIdentity().

const RegisteredPrefixId * ndn::Face::registerPrefix ( const Name prefix,
const RegisterPrefixSuccessCallback onSuccess,
const RegisterPrefixFailureCallback onFailure,
const security::SigningInfo signingInfo = security::SigningInfo(),
uint64_t  flags = nfd::ROUTE_FLAG_CHILD_INHERIT 
)

Register prefix with the connected NDN forwarder.

This method only modifies forwarder's RIB and does not associate any onInterest callbacks. Use setInterestFilter method to dispatch incoming Interests to the right callbacks.

Parameters
prefixA prefix to register with the connected NDN forwarder
onSuccessA callback to be called when prefixRegister command succeeds
onFailureA callback to be called when prefixRegister command fails
signingInfo(optional) Signing parameters. When omitted, a default parameters used in the signature will be used.
Returns
The registered prefix ID which can be used with unregisterPrefix

Definition at line 234 of file face.cpp.

References ndn::nfd::CommandOptions::setSigningInfo().

Referenced by ndn::mgmt::Dispatcher::addTopPrefix(), and registerPrefix().

const RegisteredPrefixId * ndn::Face::registerPrefix ( const Name prefix,
const RegisterPrefixSuccessCallback onSuccess,
const RegisterPrefixFailureCallback onFailure,
const IdentityCertificate certificate,
uint64_t  flags = nfd::ROUTE_FLAG_CHILD_INHERIT 
)

Register prefix with the connected NDN forwarder.

Deprecated:
Use override with SigningInfo instead of this function

This method only modifies forwarder's RIB and does not associate any onInterest callbacks. Use setInterestFilter method to dispatch incoming Interests to the right callbacks.

Parameters
prefixA prefix to register with the connected NDN forwarder
onSuccessA callback to be called when prefixRegister command succeeds
onFailureA callback to be called when prefixRegister command fails
certificate(optional) A certificate under which the prefix registration command is signed. When omitted, a default certificate of the default identity is used to sign the registration command
flags(optional) RIB flags
Returns
The registered prefix ID which can be used with unregisterPrefix

Definition at line 252 of file face.cpp.

References ndn::Name::empty(), ndn::Data::getName(), registerPrefix(), and ndn::security::signingByCertificate().

const RegisteredPrefixId * ndn::Face::registerPrefix ( const Name prefix,
const RegisterPrefixSuccessCallback onSuccess,
const RegisterPrefixFailureCallback onFailure,
const Name identity,
uint64_t  flags = nfd::ROUTE_FLAG_CHILD_INHERIT 
)

Register prefix with the connected NDN forwarder and call onInterest when a matching interest is received.

Deprecated:
Use override with SigningInfo instead of this function

This method only modifies forwarder's RIB and does not associate any onInterest callbacks. Use setInterestFilter method to dispatch incoming Interests to the right callbacks.

Parameters
prefixA prefix to register with the connected NDN forwarder
onSuccessA callback to be called when prefixRegister command succeeds
onFailureA callback to be called when prefixRegister command fails
identityA signing identity. A prefix registration command is signed under the default certificate of this identity
flags(optional) RIB flags
Returns
The registered prefix ID which can be used with unregisterPrefix

Definition at line 267 of file face.cpp.

References registerPrefix(), and ndn::security::signingByIdentity().

void ndn::Face::unsetInterestFilter ( const RegisteredPrefixId *  registeredPrefixId)

Remove the registered prefix entry with the registeredPrefixId.

This does not affect another registered prefix with a different registeredPrefixId, even it if has the same prefix name. If there is no entry with the registeredPrefixId, do nothing.

unsetInterestFilter will use the same credentials as original setInterestFilter/registerPrefix command

Parameters
registeredPrefixIdThe ID returned from registerPrefix

Definition at line 280 of file face.cpp.

Referenced by ndn::mgmt::Dispatcher::removeTopPrefix().

void ndn::Face::unsetInterestFilter ( const InterestFilterId *  interestFilterId)

Remove previously set InterestFilter from library's FIB.

This method always succeeds and will NOT send any request to the connected forwarder.

Parameters
interestFilterIdThe ID returned from setInterestFilter.

Definition at line 289 of file face.cpp.

void ndn::Face::unregisterPrefix ( const RegisteredPrefixId *  registeredPrefixId,
const UnregisterPrefixSuccessCallback onSuccess,
const UnregisterPrefixFailureCallback onFailure 
)

Unregister prefix from RIB.

unregisterPrefix will use the same credentials as original setInterestFilter/registerPrefix command

If registeredPrefixId was obtained using setInterestFilter, the corresponding InterestFilter will be unset too.

Parameters
registeredPrefixIdThe ID returned from registerPrefix
onSuccessCallback to be called when operation succeeds
onFailureCallback to be called when operation fails

Definition at line 297 of file face.cpp.

Referenced by ndn::mgmt::Dispatcher::removeTopPrefix().

void ndn::Face::put ( const Data data)

Publish data packet.

This method can be called to satisfy the incoming Interest or to put Data packet into the cache of the local NDN forwarder.

Parameters
dataData packet to publish. It is highly recommended to use Data packet that was created using make_shared<Data>(...). Otherwise, put() will make an extra copy of the Data packet to ensure validity of published Data until asynchronous put() operation finishes.
Exceptions
Errorwhen Data size exceeds maximum limit (MAX_NDN_PACKET_SIZE)

Definition at line 87 of file face.cpp.

References ndn::Data::getName().

Referenced by ndn::util::NotificationStream< Notification >::postNotification(), ndn::mgmt::Dispatcher::removeTopPrefix(), and nfd::rib::RibManager::setConfigFile().

void ndn::Face::processEvents ( const time::milliseconds &  timeout = time::milliseconds::zero(),
bool  keepThread = false 
)

Noop (kept for compatibility)

Definition at line 307 of file face.cpp.

void ndn::Face::shutdown ( )

Shutdown face operations.

This method cancels all pending operations and closes connection to NDN Forwarder.

Note that this method does not stop IO service and if the same IO service is shared between multiple Faces or with other IO objects (e.g., Scheduler).

Definition at line 313 of file face.cpp.

boost::asio::io_service& ndn::Face::getIoService ( )
inline

Return nullptr (kept for compatibility)

Definition at line 548 of file face.hpp.

Referenced by ndn::ValidatorConfig::ValidatorConfig(), and ndn::ValidatorRegex::ValidatorRegex().


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