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 lifetime=DEFAULT_INTEREST_LIFETIME)
 Construct an Interest with given name and lifetime. More...
 
 Interest (const Block &wire)
 Construct an Interest by decoding from wire. More...
 
template<encoding::Tag TAG>
size_t wireEncode (EncodingImpl< TAG > &encoder) const
 Prepend wire encoding to encoder in NDN Packet Format v0.2. More...
 
const BlockwireEncode () const
 Encode to a Block. More...
 
void wireDecode (const Block &wire)
 Decode from wire in NDN Packet Format v0.2 or v0.3. More...
 
bool hasWire () const
 Check if this instance has cached wire encoding. More...
 
std::string toUri () const
 Return a URI-like string that represents the Interest. 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 getCanBePrefix () const
 Check whether the CanBePrefix element is present. More...
 
InterestsetCanBePrefix (bool canBePrefix)
 Add or remove CanBePrefix element. More...
 
bool getMustBeFresh () const
 Check whether the MustBeFresh element is present. More...
 
InterestsetMustBeFresh (bool mustBeFresh)
 Add or remove MustBeFresh element. More...
 
const DelegationListgetForwardingHint () const
 
InterestsetForwardingHint (const DelegationList &value)
 
template<typename Modifier >
InterestmodifyForwardingHint (const Modifier &modifier)
 Modify ForwardingHint in-place. More...
 
bool hasNonce () const
 Check if the Nonce element is present. More...
 
uint32_t getNonce () const
 Get nonce value. More...
 
InterestsetNonce (uint32_t nonce)
 Set nonce value. More...
 
void refreshNonce ()
 Change nonce value. More...
 
time::milliseconds getInterestLifetime () const
 
InterestsetInterestLifetime (time::milliseconds lifetime)
 Set Interest's lifetime. More...
 
NDN_CXX_DEPRECATED bool hasSelectors () const
 Check if Interest has any selector present. More...
 
NDN_CXX_DEPRECATED const SelectorsgetSelectors () const
 
NDN_CXX_DEPRECATED InterestsetSelectors (const Selectors &selectors)
 
NDN_CXX_DEPRECATED int getMinSuffixComponents () const
 
NDN_CXX_DEPRECATED InterestsetMinSuffixComponents (int minSuffixComponents)
 
NDN_CXX_DEPRECATED int getMaxSuffixComponents () const
 
NDN_CXX_DEPRECATED InterestsetMaxSuffixComponents (int maxSuffixComponents)
 
NDN_CXX_DEPRECATED const KeyLocatorgetPublisherPublicKeyLocator () const
 
NDN_CXX_DEPRECATED InterestsetPublisherPublicKeyLocator (const KeyLocator &keyLocator)
 
NDN_CXX_DEPRECATED const ExcludegetExclude () const
 
NDN_CXX_DEPRECATED InterestsetExclude (const Exclude &exclude)
 
NDN_CXX_DEPRECATED int getChildSelector () const
 
NDN_CXX_DEPRECATED InterestsetChildSelector (int childSelector)
 
- 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  lifetime = DEFAULT_INTEREST_LIFETIME 
)
explicit

Construct an Interest with given name and lifetime.

Exceptions
std::invalid_argumentlifetime 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

Construct an Interest by decoding from wire.

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 Block.

Normally, this function encodes to NDN Packet Format v0.2. However, if this instance has cached wire encoding (hasWire() is true), the cached encoding is returned and it might be in v0.3 format.

Definition at line 103 of file interest.cpp.

References ndn::Block::hasWire().

◆ wireDecode()

void ndn::Interest::wireDecode ( const Block wire)

Decode from wire in NDN Packet Format v0.2 or v0.3.

Definition at line 119 of file interest.cpp.

References getNonce(), hasNonce(), ndn::tlv::Interest, ndn::Block::parse(), setNonce(), ndn::to_string(), and ndn::Block::type().

Referenced by Interest().

◆ hasWire()

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

Check if this instance has cached wire encoding.

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

Return a URI-like string that represents the Interest.

The string starts with getName().toUri(). If the Interest contains selectors, they are included as a query string. Example: "/test/name?ndn.MustBeFresh=1"

Definition at line 314 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 324 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 forwarding hint. The current implementation checks only name+selectors (Issue #3162).

Definition at line 435 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 143 of file interest.hpp.

References ndn::Block::reset().

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

◆ getCanBePrefix()

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

Check whether the CanBePrefix element is present.

This is a getter for the CanBePrefix element as defined in NDN Packet Format v0.3. In this implementation, it is mapped to the closest v0.2 semantics: MaxSuffixComponents=1 means CanBePrefix is absent.

Definition at line 157 of file interest.hpp.

References ndn::Selectors::getMaxSuffixComponents().

◆ setCanBePrefix()

Interest& ndn::Interest::setCanBePrefix ( bool  canBePrefix)
inline

Add or remove CanBePrefix element.

Parameters
canBePrefixwhether CanBePrefix element should be present.

This is a setter for the CanBePrefix element as defined in NDN Packet Format v0.3. In this implementation, it is mapped to the closest v0.2 semantics: MaxSuffixComponents=1 means CanBePrefix is absent.

Definition at line 170 of file interest.hpp.

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

◆ getMustBeFresh()

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

Check whether the MustBeFresh element is present.

This is a getter for the MustBeFresh element as defined in NDN Packet Format v0.3. In this implementation, it is mapped to the closest v0.2 semantics and appears as MustBeFresh element under Selectors.

Definition at line 184 of file interest.hpp.

References ndn::Selectors::getMustBeFresh().

Referenced by nfd::cs::Entry::canSatisfy(), ndn::operator<<(), and ndn::InMemoryStorage::selectChild().

◆ setMustBeFresh()

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

Add or remove MustBeFresh element.

Parameters
mustBeFreshwhether MustBeFresh element should be present.

This is a setter for the MustBeFresh element as defined in NDN Packet Format v0.3. In this implementation, it is mapped to the closest v0.2 semantics and appears as MustBeFresh element under Selectors.

Definition at line 197 of file interest.hpp.

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

◆ getForwardingHint()

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

Definition at line 205 of file interest.hpp.

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

◆ setForwardingHint()

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

Definition at line 487 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 225 of file interest.hpp.

References ndn::Block::reset().

◆ hasNonce()

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

Check if the Nonce element is present.

Definition at line 235 of file interest.hpp.

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

◆ getNonce()

uint32_t ndn::Interest::getNonce ( ) const

Get nonce value.

If nonce was not present, it is added and assigned a random value.

Definition at line 445 of file interest.cpp.

References ndn::random::generateWord32().

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

◆ setNonce()

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

Set nonce value.

Definition at line 454 of file interest.cpp.

References ndn::Block::reset().

Referenced by refreshNonce(), and wireDecode().

◆ refreshNonce()

void ndn::Interest::refreshNonce ( )

Change nonce value.

If the Nonce element is present, the new nonce value will differ from the old value. If the Nonce element is not present, this method does nothing.

Definition at line 462 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 261 of file interest.hpp.

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

◆ setInterestLifetime()

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

Set Interest's lifetime.

Exceptions
std::invalid_argumentlifetime is negative

Definition at line 476 of file interest.cpp.

References ndn::Block::reset().

◆ hasSelectors()

NDN_CXX_DEPRECATED bool ndn::Interest::hasSelectors ( ) const
inline

Check if Interest has any selector present.

Definition at line 277 of file interest.hpp.

References ndn::Selectors::empty().

Referenced by wireEncode().

◆ getSelectors()

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

Definition at line 284 of file interest.hpp.

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

◆ setSelectors()

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

Definition at line 291 of file interest.hpp.

References ndn::Block::reset().

◆ getMinSuffixComponents()

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

Definition at line 300 of file interest.hpp.

References ndn::Selectors::getMinSuffixComponents().

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

◆ setMinSuffixComponents()

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

Definition at line 307 of file interest.hpp.

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

◆ getMaxSuffixComponents()

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

Definition at line 316 of file interest.hpp.

References ndn::Selectors::getMaxSuffixComponents().

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

◆ setMaxSuffixComponents()

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

Definition at line 323 of file interest.hpp.

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

◆ getPublisherPublicKeyLocator()

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

Definition at line 332 of file interest.hpp.

References ndn::Selectors::getPublisherPublicKeyLocator().

Referenced by matchesData().

◆ setPublisherPublicKeyLocator()

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

◆ getExclude()

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

Definition at line 348 of file interest.hpp.

References ndn::Selectors::getExclude().

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

◆ setExclude()

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

Definition at line 355 of file interest.hpp.

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

◆ getChildSelector()

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

◆ setChildSelector()

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

Definition at line 371 of file interest.hpp.

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


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