ndn-embeds 0.1.0
Lightweight NDN protocol stack for embedded systems
Loading...
Searching...
No Matches
ndn::Pit Class Reference

Pending Interest Table. More...

#include <ndn/pit.hpp>

Classes

struct  Stats
 PIT statistics. More...
 

Public Member Functions

Interest management
PitInsertResult insert (const Interest &interest, FaceId incomingFace, PitEntry **outEntry=nullptr)
 Insert an Interest.
 
PitEntryfind (const Name &name)
 Find an entry by Name.
 
const PitEntryfind (const Name &name) const
 Find an entry by Name (const version)
 
void remove (PitEntry *entry)
 Remove an entry.
 
void remove (const Name &name)
 Remove an entry by Name.
 
Statistics
size_t size () const
 Get the current number of entries.
 
size_t capacity () const
 Get the maximum number of entries.
 
const Statsstats () const
 Get statistics.
 

Timeout handling

using TimeoutCallback = std::function< void(const PitEntry &)>
 Timeout callback.
 
void processTimeouts (TimeMs now, TimeoutCallback callback=nullptr)
 Process timed-out entries.
 

Detailed Description

Pending Interest Table.

One of the core components of the forwarder. Records received Interests and manages which Faces to forward Data to when the corresponding Data arrives.

Pit pit;
// Insert an Interest
PitEntry* entry;
auto result = pit.insert(interest, incomingFaceId, &entry);
if (result == PitInsertResult::New) {
// New Interest -> forward
} else if (result == PitInsertResult::Aggregated) {
// Existing Interest -> no forwarding needed
}
// On Data reception
if (auto* entry = pit.find(dataName)) {
// Forward Data to registered Faces
for (size_t i = 0; i < entry->faceCount(); i++) {
sendData(entry->face(i), data);
}
pit.remove(entry);
}
PIT entry.
Definition pit.hpp:46
size_t faceCount() const
Get the number of registered Faces.
Definition pit.hpp:74
FaceId face(size_t index) const
Get the Face ID at a given index.
Definition pit.cpp:9
Pending Interest Table.
Definition pit.hpp:137
PitInsertResult insert(const Interest &interest, FaceId incomingFace, PitEntry **outEntry=nullptr)
Insert an Interest.
Definition pit.cpp:40
PitEntry * find(const Name &name)
Find an entry by Name.
Definition pit.cpp:88
void remove(PitEntry *entry)
Remove an entry.
Definition pit.cpp:106

Definition at line 137 of file pit.hpp.

Member Typedef Documentation

◆ TimeoutCallback

using ndn::Pit::TimeoutCallback = std::function<void(const PitEntry&)>

Timeout callback.

Called when an entry times out.

Definition at line 193 of file pit.hpp.

Member Function Documentation

◆ capacity()

size_t ndn::Pit::capacity ( ) const
inline

Get the maximum number of entries.

Returns
Maximum number of entries

Definition at line 220 of file pit.hpp.

References ndn::PIT_MAX_ENTRIES.

◆ find() [1/2]

PitEntry * ndn::Pit::find ( const Name name)

Find an entry by Name.

Parameters
nameName to search for
Returns
Pointer to the entry if found, nullptr otherwise

Definition at line 88 of file pit.cpp.

Referenced by ndn::Forwarder::putData(), and remove().

◆ find() [2/2]

const PitEntry * ndn::Pit::find ( const Name name) const

Find an entry by Name (const version)

Parameters
nameName to search for
Returns
Const pointer to the entry if found, nullptr otherwise

Definition at line 97 of file pit.cpp.

◆ insert()

PitInsertResult ndn::Pit::insert ( const Interest interest,
FaceId  incomingFace,
PitEntry **  outEntry = nullptr 
)

Insert an Interest.

If an entry with the same Name exists, aggregation is performed. If the same nonce is detected, it is treated as a loop.

Parameters
interestInterest to insert
incomingFaceID of the Face that received the Interest
outEntryStores a pointer to the created/updated entry (optional)
Returns
Insertion result

Definition at line 40 of file pit.cpp.

References ndn::PitEntry::addFace(), ndn::Pit::Stats::aggregations, ndn::currentTimeMs(), ndn::Pit::Stats::duplicates, ndn::Pit::Stats::insertions, ndn::Interest::lifetime(), ndn::Interest::name(), and ndn::Interest::nonce().

Referenced by ndn::Forwarder::expressInterest().

◆ processTimeouts()

void ndn::Pit::processTimeouts ( TimeMs  now,
TimeoutCallback  callback = nullptr 
)

Process timed-out entries.

Removes entries that have expired beyond the current time and invokes the callback.

Parameters
nowCurrent time (milliseconds)
callbackTimeout callback (optional)

Definition at line 121 of file pit.cpp.

References ndn::Pit::Stats::timeouts.

Referenced by ndn::Forwarder::processEvents().

◆ remove() [1/2]

void ndn::Pit::remove ( const Name name)

Remove an entry by Name.

Parameters
nameName of the entry to remove

Definition at line 114 of file pit.cpp.

References find(), and remove().

◆ remove() [2/2]

void ndn::Pit::remove ( PitEntry entry)

Remove an entry.

Parameters
entryPointer to the entry to remove

Definition at line 106 of file pit.cpp.

Referenced by ndn::Forwarder::putData(), and remove().

◆ size()

size_t ndn::Pit::size ( ) const
inline

Get the current number of entries.

Returns
Number of entries

Definition at line 214 of file pit.hpp.

◆ stats()

const Stats & ndn::Pit::stats ( ) const
inline

Get statistics.

Returns
Const reference to statistics

Definition at line 236 of file pit.hpp.


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