NS-3 based Named Data Networking (NDN) simulator
ndnSIM 2.5: 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 (const Name &name=Name(), time::milliseconds interestLifetime=DEFAULT_INTEREST_LIFETIME)
 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 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...
 
bool matchesInterest (const Interest &other) const
 Check if Interest matches other interest. More...
 
const NamegetName () const
 
InterestsetName (const Name &name)
 
bool hasNonce () const
 Check if Nonce set. More...
 
uint32_t getNonce () const
 Get nonce. More...
 
InterestsetNonce (uint32_t nonce)
 Set nonce. More...
 
void refreshNonce ()
 Refresh nonce. More...
 
time::milliseconds getInterestLifetime () const
 
InterestsetInterestLifetime (time::milliseconds interestLifetime)
 Set Interest's lifetime. More...
 
const DelegationListgetForwardingHint () const
 
InterestsetForwardingHint (const DelegationList &value)
 
template<typename Modifier >
InterestmodifyForwardingHint (const Modifier &modifier)
 modify ForwardingHint in-place More...
 
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)
 
- Public Member Functions inherited from ndn::PacketBase
uint64_t getCongestionMark () const
 get the value of the CongestionMark tag More...
 
void setCongestionMark (uint64_t mark)
 set the CongestionMark tag to the specified value More...
 
- 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...
 

Detailed Description

represents an Interest packet

Definition at line 42 of file interest.hpp.

Constructor & Destructor Documentation

◆ Interest() [1/2]

ndn::Interest::Interest ( const Name name = Name(),
time::milliseconds  interestLifetime = DEFAULT_INTEREST_LIFETIME 
)
explicit

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

Exceptions
std::invalid_argumentInterestLifetime is negative
Warning
In certain contexts that use Interest::shared_from_this(), Interest must be created using make_shared. Otherwise, .shared_from_this() will trigger undefined behavior.

Definition at line 38 of file interest.cpp.

◆ Interest() [2/2]

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 trigger undefined behavior.

Definition at line 47 of file interest.cpp.

References wireDecode().

Member Function Documentation

◆ wireEncode() [1/2]

◆ wireEncode() [2/2]

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

Encode to a wire format.

Definition at line 103 of file interest.cpp.

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

◆ wireDecode()

◆ hasWire()

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

Check if already has wire.

Definition at line 93 of file interest.hpp.

References ndn::Block::hasWire().

Referenced by ns3::ndn::L3RateTracer::InNack(), and ns3::ndn::L3RateTracer::OutNack().

◆ toUri()

std::string ndn::Interest::toUri ( ) const

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 170 of file interest.cpp.

◆ matchesName()

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 180 of file interest.cpp.

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

◆ matchesData()

◆ matchesInterest()

bool ndn::Interest::matchesInterest ( const Interest other) const

Check if Interest matches other interest.

Interest matches other if both have the same name, selectors, and link. Other fields (e.g., Nonce) may be different.

Todo:
Implement distinguishing interests by link. The current implementation checks only name+selectors (Issue #3162).

Definition at line 291 of file interest.cpp.

References getName(), and getSelectors().

Referenced by face::Face::Impl::nackPendingInterests().

◆ getName()

◆ setName()

Interest& ndn::Interest::setName ( const Name name)
inline

Definition at line 145 of file interest.hpp.

References ndn::Block::reset().

Referenced by ndn::security::v2::KeyChain::sign().

◆ hasNonce()

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

Check if Nonce set.

Definition at line 155 of file interest.hpp.

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

◆ getNonce()

uint32_t ndn::Interest::getNonce ( ) const

Get nonce.

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

Definition at line 301 of file interest.cpp.

References ndn::random::generateWord32().

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

◆ setNonce()

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

Set nonce.

Definition at line 310 of file interest.cpp.

References ndn::Block::reset().

Referenced by refreshNonce().

◆ 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 318 of file interest.cpp.

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

Referenced by ndn::security::v2::CertificateFetcherDirectFetch::doFetch().

◆ getInterestLifetime()

time::milliseconds ndn::Interest::getInterestLifetime ( ) const
inline

Definition at line 183 of file interest.hpp.

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

◆ setInterestLifetime()

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

Set Interest's lifetime.

Exceptions
std::invalid_argumentspecified lifetime is < 0

Definition at line 332 of file interest.cpp.

References ndn::Block::reset().

◆ getForwardingHint()

const DelegationList& ndn::Interest::getForwardingHint ( ) const
inline

Definition at line 196 of file interest.hpp.

Referenced by nfd::fw::Strategy::lookupFib().

◆ setForwardingHint()

Interest & ndn::Interest::setForwardingHint ( const DelegationList value)

Definition at line 343 of file interest.cpp.

References ndn::Block::reset().

◆ modifyForwardingHint()

template<typename Modifier >
Interest& ndn::Interest::modifyForwardingHint ( const Modifier &  modifier)
inline

modify ForwardingHint in-place

Template Parameters
Modifiera unary function that accepts DelegationList&

This is equivalent to, but more efficient (avoids copying) than:

auto fh = interest.getForwardingHint();
modifier(fh);
interest.setForwardingHint(fh);

Definition at line 216 of file interest.hpp.

References ndn::Block::reset().

◆ hasSelectors()

bool ndn::Interest::hasSelectors ( ) const
inline
Returns
true if Interest has any selector present

Definition at line 228 of file interest.hpp.

References ndn::Selectors::empty().

Referenced by wireEncode().

◆ getSelectors()

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

Definition at line 234 of file interest.hpp.

Referenced by nfd::pit::Entry::canMatch(), matchesInterest(), and wireEncode().

◆ setSelectors()

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

Definition at line 240 of file interest.hpp.

References ndn::Block::reset().

◆ getMinSuffixComponents()

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

Definition at line 248 of file interest.hpp.

References ndn::Selectors::getMinSuffixComponents().

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

◆ setMinSuffixComponents()

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

Definition at line 254 of file interest.hpp.

References ndn::Block::reset(), and ndn::Selectors::setMinSuffixComponents().

◆ getMaxSuffixComponents()

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

Definition at line 262 of file interest.hpp.

References ndn::Selectors::getMaxSuffixComponents().

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

◆ setMaxSuffixComponents()

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

Definition at line 268 of file interest.hpp.

References ndn::Block::reset(), and ndn::Selectors::setMaxSuffixComponents().

◆ getPublisherPublicKeyLocator()

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

Definition at line 276 of file interest.hpp.

References ndn::Selectors::getPublisherPublicKeyLocator().

Referenced by matchesData().

◆ setPublisherPublicKeyLocator()

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

◆ getExclude()

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

Definition at line 290 of file interest.hpp.

References ndn::Selectors::getExclude().

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

◆ setExclude()

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

Definition at line 296 of file interest.hpp.

References ndn::Block::reset(), and ndn::Selectors::setExclude().

◆ getChildSelector()

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

◆ setChildSelector()

Interest& ndn::Interest::setChildSelector ( int  childSelector)
inline

Definition at line 310 of file interest.hpp.

References ndn::Block::reset(), and ndn::Selectors::setChildSelector().

◆ getMustBeFresh()

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

◆ setMustBeFresh()

Interest& ndn::Interest::setMustBeFresh ( bool  mustBeFresh)
inline

Definition at line 324 of file interest.hpp.

References ndn::Block::reset(), and ndn::Selectors::setMustBeFresh().


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