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

represents an Interest packet More...

#include <interest.hpp>

Inheritance diagram for ndn::Interest:
Collaboration diagram for ndn::Interest:

Classes

class  Error
 

Public Member Functions

 Interest ()
 Create a new Interest with an empty name (ndn:/) More...
 
 Interest (const Name &name)
 Create a new Interest with the given name. More...
 
 Interest (const Name &name, const time::milliseconds &interestLifetime)
 Create a new Interest with the given name and interest lifetime. More...
 
 Interest (const Block &wire)
 Create from wire encoding. More...
 
template<encoding::Tag TAG>
size_t wireEncode (EncodingImpl< TAG > &encoder) const
 Fast encoding or block size estimation. More...
 
const BlockwireEncode () const
 Encode to a wire format. More...
 
void wireDecode (const Block &wire)
 Decode from the wire format. More...
 
bool hasWire () const
 Check if already has wire. More...
 
std::string toUri () const
 Encode the name according to the NDN URI Scheme. More...
 
bool hasLink () const
 Check whether the Interest contains a Link object. More...
 
Link getLink () const
 Get the link object for this interest. More...
 
void setLink (const Block &link)
 Set the link object for this interest. More...
 
void unsetLink ()
 Reset the wire format of the given interest and the contained link. More...
 
bool hasSelectedDelegation () const
 Check whether the Interest includes a selected delegation. More...
 
Name getSelectedDelegation () const
 Get the name of the selected delegation. More...
 
void setSelectedDelegation (const Name &delegationName)
 Set the selected delegation. More...
 
void setSelectedDelegation (size_t delegationIndex)
 Set the selected delegation. More...
 
void unsetSelectedDelegation ()
 Unset the selected delegation. More...
 
bool matchesName (const Name &name) const
 Check if Interest, including selectors, matches the given name. More...
 
bool matchesData (const Data &data) const
 Check if Interest can be satisfied by data. More...
 
const NamegetName () const
 
InterestsetName (const Name &name)
 
const time::milliseconds & getInterestLifetime () const
 
InterestsetInterestLifetime (const time::milliseconds &interestLifetime)
 
bool hasNonce () const
 Check if Nonce set. More...
 
uint32_t getNonce () const
 Get Interest's nonce. More...
 
InterestsetNonce (uint32_t nonce)
 Set Interest's nonce. More...
 
void refreshNonce ()
 Refresh nonce. More...
 
nfd::LocalControlHeadergetLocalControlHeader ()
 
const nfd::LocalControlHeadergetLocalControlHeader () const
 
uint64_t getIncomingFaceId () const
 
InterestsetIncomingFaceId (uint64_t incomingFaceId)
 
uint64_t getNextHopFaceId () const
 
InterestsetNextHopFaceId (uint64_t nextHopFaceId)
 
bool hasSelectors () const
 
const SelectorsgetSelectors () const
 
InterestsetSelectors (const Selectors &selectors)
 
int getMinSuffixComponents () const
 
InterestsetMinSuffixComponents (int minSuffixComponents)
 
int getMaxSuffixComponents () const
 
InterestsetMaxSuffixComponents (int maxSuffixComponents)
 
const KeyLocatorgetPublisherPublicKeyLocator () const
 
InterestsetPublisherPublicKeyLocator (const KeyLocator &keyLocator)
 
const ExcludegetExclude () const
 
InterestsetExclude (const Exclude &exclude)
 
int getChildSelector () const
 
InterestsetChildSelector (int childSelector)
 
int getMustBeFresh () const
 
InterestsetMustBeFresh (bool mustBeFresh)
 
bool operator== (const Interest &other) const
 
bool operator!= (const Interest &other) const
 
- Public Member Functions inherited from ndn::TagHost
template<typename T >
shared_ptr< T > getTag () const
 get a tag item More...
 
template<typename T >
void setTag (shared_ptr< T > tag) const
 set a tag item More...
 
template<typename T >
void removeTag () const
 remove tag item More...
 

Friends

class nfd::LocalControlHeader
 

Detailed Description

represents an Interest packet

Definition at line 45 of file interest.hpp.

Constructor & Destructor Documentation

ndn::Interest::Interest ( )

Create a new Interest with an empty name (ndn:/)

Warning
In certain contexts that use Interest::shared_from_this(), Interest must be created using make_shared. Otherwise, .shared_from_this() will throw an exception.

Definition at line 36 of file interest.cpp.

Referenced by ndn::Interest::Error::Error().

ndn::Interest::Interest ( const Name name)

Create a new Interest with the given name.

Parameters
nameThe name for the interest.
Note
This constructor allows implicit conversion from Name.
Warning
In certain contexts that use Interest::shared_from_this(), Interest must be created using make_shared. Otherwise, .shared_from_this() will throw an exception.

Definition at line 42 of file interest.cpp.

ndn::Interest::Interest ( const Name name,
const time::milliseconds &  interestLifetime 
)

Create a new Interest with the given name and interest lifetime.

Parameters
nameThe name for the interest.
interestLifetimeThe interest lifetime in time::milliseconds, or -1 for none.
Warning
In certain contexts that use Interest::shared_from_this(), Interest must be created using make_shared. Otherwise, .shared_from_this() will throw an exception.

Definition at line 49 of file interest.cpp.

ndn::Interest::Interest ( const Block wire)
explicit

Create from wire encoding.

Warning
In certain contexts that use Interest::shared_from_this(), Interest must be created using make_shared. Otherwise, .shared_from_this() will throw an exception.

Definition at line 56 of file interest.cpp.

References wireDecode().

Member Function Documentation

const Block & ndn::Interest::wireEncode ( ) const

Encode to a wire format.

Definition at line 277 of file interest.cpp.

References ndn::Block::hasWire(), and wireDecode().

Referenced by ndn::Interest::Error::Error(), and operator==().

bool ndn::Interest::hasWire ( ) const
inline
std::string ndn::Interest::toUri ( ) const
inline

Encode the name according to the NDN URI Scheme.

If there are interest selectors, this method will append "?" and add the selectors as a query string. For example, "/test/name?ndn.ChildSelector=1"

Definition at line 456 of file interest.hpp.

Referenced by hasWire().

bool ndn::Interest::hasLink ( ) const

Check whether the Interest contains a Link object.

Returns
True if there is a link object, otherwise false

Definition at line 361 of file interest.cpp.

References ndn::Block::hasWire().

Referenced by getLink(), hasWire(), wireDecode(), and wireEncode().

Link ndn::Interest::getLink ( ) const

Get the link object for this interest.

Returns
The link object if there is one contained in this interest
Exceptions
Interest::Errorif there is no link object contained in the interest

Definition at line 369 of file interest.cpp.

References hasLink().

Referenced by hasWire().

void ndn::Interest::setLink ( const Block link)

Set the link object for this interest.

Parameters
linkThe link object that will be included in this interest (in wire format)
Postcondition
!hasSelectedDelegation()

Definition at line 379 of file interest.cpp.

References ndn::Block::hasWire(), ndn::Block::reset(), and unsetSelectedDelegation().

Referenced by hasWire().

void ndn::Interest::unsetLink ( )

Reset the wire format of the given interest and the contained link.

Definition at line 390 of file interest.cpp.

References ndn::Block::reset(), and unsetSelectedDelegation().

Referenced by hasWire().

bool ndn::Interest::hasSelectedDelegation ( ) const

Check whether the Interest includes a selected delegation.

Returns
True if there is a selected delegation, otherwise false

Definition at line 398 of file interest.cpp.

References ndn::INVALID_SELECTED_DELEGATION_INDEX.

Referenced by getSelectedDelegation(), hasWire(), and wireEncode().

Name ndn::Interest::getSelectedDelegation ( ) const

Get the name of the selected delegation.

Returns
The name of the selected delegation
Exceptions
ErrorSelectedDelegation is not set.

Definition at line 408 of file interest.cpp.

References ndn::Link::getDelegationFromWire(), and hasSelectedDelegation().

Referenced by hasWire().

void ndn::Interest::setSelectedDelegation ( const Name delegationName)

Set the selected delegation.

Parameters
delegationNameThe name of the selected delegation
Exceptions
ErrorLink is not set.
std::invalid_argumentdelegationName does not exist in Link.

Definition at line 417 of file interest.cpp.

References ndn::Link::findDelegationFromWire(), ndn::INVALID_SELECTED_DELEGATION_INDEX, and ndn::Block::reset().

Referenced by hasWire().

void ndn::Interest::setSelectedDelegation ( size_t  delegationIndex)

Set the selected delegation.

Parameters
delegationThe index of the selected delegation
Exceptions
ErrorLink is not set.
std::out_of_rangedelegationIndex is out of bound in Link.

Definition at line 430 of file interest.cpp.

References ndn::Block::reset().

void ndn::Interest::unsetSelectedDelegation ( )

Unset the selected delegation.

Definition at line 440 of file interest.cpp.

References ndn::INVALID_SELECTED_DELEGATION_INDEX, and ndn::Block::reset().

Referenced by hasWire(), setLink(), and unsetLink().

bool ndn::Interest::matchesName ( const Name name) const

Check if Interest, including selectors, matches the given name.

Parameters
nameThe name to be matched. If this is a Data name, it shall contain the implicit digest component

Definition at line 105 of file interest.cpp.

References ndn::Exclude::empty(), getExclude(), getMaxSuffixComponents(), getMinSuffixComponents(), ndn::Exclude::isExcluded(), ndn::Name::isPrefixOf(), and ndn::Name::size().

Referenced by hasWire().

bool ndn::Interest::matchesData ( const Data data) const
Interest& ndn::Interest::setName ( const Name name)
inline
const time::milliseconds& ndn::Interest::getInterestLifetime ( ) const
inline

Definition at line 230 of file interest.hpp.

Referenced by ndn::operator<<(), nfd::pit::FaceRecord::update(), and wireEncode().

Interest& ndn::Interest::setInterestLifetime ( const time::milliseconds &  interestLifetime)
inline

Definition at line 236 of file interest.hpp.

Referenced by ndn::nfd::Controller::Controller().

bool ndn::Interest::hasNonce ( ) const
inline

Check if Nonce set.

Definition at line 246 of file interest.hpp.

References getNonce(), refreshNonce(), and setNonce().

Referenced by ndn::operator<<(), and refreshNonce().

uint32_t ndn::Interest::getNonce ( ) const

Get Interest's nonce.

If nonce was not set before this call, it will be automatically assigned to a random value

Definition at line 62 of file interest.cpp.

References ndn::random::generateWord32(), ndn::Block::hasWire(), ndn::encoding::readNonNegativeInteger(), ndn::Block::value(), and ndn::Block::value_size().

Referenced by hasNonce(), ndn::operator<<(), refreshNonce(), nfd::pit::FaceRecord::update(), wireEncode(), and nfd::Forwarder::~Forwarder().

Interest & ndn::Interest::setNonce ( uint32_t  nonce)

Set Interest's nonce.

If wire format already exists, this call simply replaces nonce in the existing wire format, without resetting and recreating it.

Definition at line 76 of file interest.cpp.

References ndn::Block::hasWire(), ndn::encoding::makeBinaryBlock(), ndn::tlv::Nonce, ndn::Block::reset(), ndn::Block::value(), and ndn::Block::value_size().

Referenced by nfd::compare_pickInterest(), hasNonce(), and refreshNonce().

void ndn::Interest::refreshNonce ( )

Refresh nonce.

It's guaranteed that new nonce value differs from the existing one.

If nonce is already set, it will be updated to a different random value. If nonce is not set, this method does nothing.

Definition at line 91 of file interest.cpp.

References ndn::random::generateWord32(), getNonce(), hasNonce(), and setNonce().

Referenced by ndn::util::SegmentFetcher::fetch(), and hasNonce().

const nfd::LocalControlHeader& ndn::Interest::getLocalControlHeader ( ) const
inline

Definition at line 284 of file interest.hpp.

uint64_t ndn::Interest::getIncomingFaceId ( ) const
inline
Interest& ndn::Interest::setIncomingFaceId ( uint64_t  incomingFaceId)
inline
uint64_t ndn::Interest::getNextHopFaceId ( ) const
inline
Interest& ndn::Interest::setNextHopFaceId ( uint64_t  nextHopFaceId)
inline
bool ndn::Interest::hasSelectors ( ) const
inline
Returns
true if Interest has any selector present

Definition at line 322 of file interest.hpp.

Referenced by wireEncode().

const Selectors& ndn::Interest::getSelectors ( ) const
inline

Definition at line 328 of file interest.hpp.

Referenced by nfd::Pit::insert(), and wireEncode().

Interest& ndn::Interest::setSelectors ( const Selectors selectors)
inline

Definition at line 334 of file interest.hpp.

int ndn::Interest::getMinSuffixComponents ( ) const
inline

Definition at line 342 of file interest.hpp.

Referenced by matchesData(), matchesName(), and ndn::operator<<().

Interest& ndn::Interest::setMinSuffixComponents ( int  minSuffixComponents)
inline

Definition at line 348 of file interest.hpp.

References setMinSuffixComponents().

Referenced by setMinSuffixComponents().

int ndn::Interest::getMaxSuffixComponents ( ) const
inline

Definition at line 356 of file interest.hpp.

Referenced by matchesData(), matchesName(), and ndn::operator<<().

Interest& ndn::Interest::setMaxSuffixComponents ( int  maxSuffixComponents)
inline

Definition at line 362 of file interest.hpp.

References setMaxSuffixComponents().

Referenced by setMaxSuffixComponents().

const KeyLocator& ndn::Interest::getPublisherPublicKeyLocator ( ) const
inline

Definition at line 370 of file interest.hpp.

Referenced by matchesData().

Interest& ndn::Interest::setPublisherPublicKeyLocator ( const KeyLocator keyLocator)
inline

Definition at line 376 of file interest.hpp.

References setPublisherPublicKeyLocator().

Referenced by setPublisherPublicKeyLocator().

const Exclude& ndn::Interest::getExclude ( ) const
inline

Definition at line 384 of file interest.hpp.

Referenced by matchesData(), matchesName(), and ndn::operator<<().

Interest& ndn::Interest::setExclude ( const Exclude exclude)
inline

Definition at line 390 of file interest.hpp.

References setExclude().

Referenced by setExclude().

int ndn::Interest::getChildSelector ( ) const
inline
Interest& ndn::Interest::setChildSelector ( int  childSelector)
inline
int ndn::Interest::getMustBeFresh ( ) const
inline
Interest& ndn::Interest::setMustBeFresh ( bool  mustBeFresh)
inline
bool ndn::Interest::operator== ( const Interest other) const
inline

Definition at line 427 of file interest.hpp.

References wireEncode().

bool ndn::Interest::operator!= ( const Interest other) const
inline

Definition at line 433 of file interest.hpp.

Friends And Related Function Documentation

friend class nfd::LocalControlHeader
friend

Definition at line 449 of file interest.hpp.


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