|
NS-3 based Named Data Networking (NDN) simulator
ndnSIM 2.5: NDN, CCN, CCNx, content centric networks
|
API Documentation
|
Go to the documentation of this file.
22 #ifndef NDN_IMPL_FACE_IMPL_HPP
23 #define NDN_IMPL_FACE_IMPL_HPP
69 , m_nfdController(m_face, keyChain)
71 auto postOnEmptyPitOrNoRegisteredPrefixes = [
this] {
79 m_pendingInterestTable.
onEmpty.connect(postOnEmptyPitOrNoRegisteredPrefixes);
80 m_registeredPrefixTable.
onEmpty.connect(postOnEmptyPitOrNoRegisteredPrefixes);
93 const Interest& interest2 = *interest;
94 auto& entry = m_pendingInterestTable.
put(
id,
std::move(interest), afterSatisfied, afterNacked,
95 afterTimeout, ref(m_scheduler));
98 addFieldFromTag<lp::NextHopFaceIdField, lp::NextHopFaceIdTag>(lpPacket, interest2);
99 addFieldFromTag<lp::CongestionMarkField, lp::CongestionMarkTag>(lpPacket, interest2);
101 entry.recordForwarding();
110 m_pendingInterestTable.
erase(
id);
116 m_pendingInterestTable.
clear();
124 bool hasAppMatch =
false, hasForwarderMatch =
false;
133 entry.invokeDataCallback(data);
136 hasForwarderMatch = true;
143 return hasForwarderMatch || !hasAppMatch;
151 optional<lp::Nack> outNack;
158 optional<lp::Nack> outNack1 = entry.
recordNack(nack);
164 entry.invokeNackCallback(*outNack1);
184 m_interestFilterTable.
put(
id, filter, onInterest);
191 if (record !=
nullptr) {
193 m_interestFilterTable.
erase(
id);
200 const Interest& interest2 = *interest;
201 auto& entry = m_pendingInterestTable.
insert(
std::move(interest), ref(m_scheduler));
223 if (!shouldSendToForwarder) {
230 addFieldFromTag<lp::CachePolicyField, lp::CachePolicyTag>(lpPacket, data);
231 addFieldFromTag<lp::CongestionMarkField, lp::CongestionMarkTag>(lpPacket, data);
250 addFieldFromTag<lp::CongestionMarkField, lp::CongestionMarkTag>(lpPacket, *outNack);
252 const Interest& interest = outNack->getInterest();
266 auto id = m_registeredPrefixTable.
allocateId();
277 filterId = filterRecord.
getId();
280 m_registeredPrefixTable.
put(
id, prefix, options, filterId);
282 if (onSuccess !=
nullptr) {
288 onFailure(prefix, resp.getText());
301 if (record ==
nullptr) {
302 if (onFailure !=
nullptr) {
303 onFailure(
"Unrecognized RegisteredPrefixHandle");
318 m_registeredPrefixTable.
erase(
id);
320 if (onSuccess !=
nullptr) {
326 onFailure(resp.getText());
335 if (!m_face.m_transport->isConnected()) {
336 m_face.m_transport->connect([
this] (
const Block& wire) { m_face.onReceiveElement(wire); });
339 if (wantResume && !m_face.m_transport->isReceiving()) {
340 m_face.m_transport->resume();
347 if (m_pendingInterestTable.
empty() && m_registeredPrefixTable.
empty()) {
348 m_face.m_transport->pause();
355 m_pendingInterestTable.
clear();
356 m_registeredPrefixTable.
clear();
371 if (!lpPacket.empty()) {
373 wire = lpPacket.wireEncode();
385 Scheduler m_scheduler;
387 nfd::Controller m_nfdController;
398 #endif // NDN_IMPL_FACE_IMPL_HPP
void removeIf(const Visitor &f)
Visit all records with the option to erase.
function< void(const Name &, const std::string &)> RegisterPrefixFailureCallback
Callback invoked when registerPrefix or setInterestFilter command fails.
#define NDN_LOG_INIT(name)
declare a log module
void asyncRemoveAllPendingInterests()
const InterestFilter & getFilter() const
associates an InterestFilter with Interest callback
bool satisfyPendingInterests(const Data &data)
@ APP
Interest was received from this app via Face::expressInterest API.
void ensureConnected(bool wantResume)
const nfd::CommandOptions & getCommandOptions() const
Packet & add(const typename FIELD::ValueType &value)
add a FIELD with value
represents a rib/register command
Record & insert(TArgs &&... args)
Insert a record with newly assigned ID.
void recordForwarding()
Record that the Interest has been forwarded to one destination.
#define NDN_LOG_INFO(expression)
Buffer::const_iterator begin() const
Get begin iterator of encoded wire.
stores information about a prefix registered in NDN forwarder
bool doesMatch(const PendingInterest &entry) const
Check if Interest name matches the filter.
void asyncRemovePendingInterest(RecordId id)
void dispatchInterest(PendingInterest &entry, const Interest &interest)
EventId schedule(time::nanoseconds after, EventCallback callback)
Schedule a one-time event after the specified delay.
size_t wireEncode(EncodingImpl< TAG > &encoder, bool wantUnsignedPortionOnly=false) const
Prepend wire encoding to encoder in NDN Packet Format v0.2.
const Name & getName() const
Get name.
void asyncUnregisterPrefix(RecordId id, const UnregisterPrefixSuccessCallback &onSuccess, const UnregisterPrefixFailureCallback &onFailure)
PendingInterestOrigin getOrigin() const
Provide a communication channel with local or remote NDN forwarder.
void asyncSetInterestFilter(RecordId id, const InterestFilter &filter, const InterestCallback &onInterest)
void invokeInterestCallback(const Interest &interest) const
invokes the InterestCallback
Impl(Face &face, KeyChain &keyChain)
Represents an absolute name.
function< void()> UnregisterPrefixSuccessCallback
Callback invoked when unregisterPrefix or unsetInterestFilter command succeeds.
Stores a pending Interest and associated callbacks.
Record * get(RecordId id)
Retrieve record by ID.
void forEach(const Visitor &f)
Visit all records.
void asyncUnsetInterestFilter(RecordId id)
declares the set of Interests a producer can serve, which starts with a name prefix,...
implementation detail of Face
function< void(const InterestFilter &, const Interest &)> InterestCallback
Callback invoked when incoming Interest matches the specified InterestFilter.
The interface of signing key management.
RecordContainer< RegisteredPrefix > RegisteredPrefixTable
util::Signal< RecordContainer< T > > onEmpty
Signals when container becomes empty.
represents a rib/unregister command
optional< lp::Nack > recordNack(const lp::Nack &nack)
Record an incoming Nack against a forwarded Interest.
function< void(const Interest &, const Data &)> DataCallback
Callback invoked when expressed Interest gets satisfied with a Data packet.
RecordContainer< InterestFilterRecord > InterestFilterTable
void start(const ControlParameters ¶meters, const CommandSucceedCallback &onSuccess, const CommandFailCallback &onFailure, const CommandOptions &options=CommandOptions())
start command execution
Record & put(RecordId id, TArgs &&... args)
Insert a record with given ID.
Represents an Interest packet.
const Name & getPrefix() const
Represents a Data packet.
function< void(const Name &)> RegisterPrefixSuccessCallback
Callback invoked when registerPrefix or setInterestFilter command succeeds.
contains options for ControlCommand execution
function< void(const Interest &, const lp::Nack &)> NackCallback
Callback invoked when Nack is sent in response to expressed Interest.
NDN_CXX_NODISCARD bool empty() const noexcept
represents parameters in a ControlCommand request or response
void processIncomingInterest(shared_ptr< const Interest > interest)
Buffer::const_iterator end() const
Get end iterator of encoded wire.
const NackHeader & getHeader() const
#define NDN_LOG_DEBUG(expression)
const size_t MAX_NDN_PACKET_SIZE
practical limit of network layer packet size
RecordId getFilterId() const
Represents a TLV element of NDN packet format.
Exception thrown when attempting to send a packet over size limit.
represents a Network Nack
shared_ptr< const Interest > getInterest() const
RecordContainer< PendingInterest > PendingInterestTable
function< void(const Interest &)> TimeoutCallback
Callback invoked when expressed Interest times out.
const Name & getName() const noexcept
optional< lp::Nack > nackPendingInterests(const lp::Nack &nack)
void onEmptyPitOrNoRegisteredPrefixes()
DummyIoService & getIoService()
RecordId registerPrefix(const Name &prefix, const RegisterPrefixSuccessCallback &onSuccess, const RegisterPrefixFailureCallback &onFailure, uint64_t flags, const nfd::CommandOptions &options, const optional< InterestFilter > &filter, const InterestCallback &onInterest)
size_t wireEncode(EncodingImpl< TAG > &encoder) const
Prepend wire encoding to encoder according to NDN Packet Format v0.3.
void asyncPutData(const Data &data)
void asyncPutNack(const lp::Nack &nack)
function< void(const std::string &)> UnregisterPrefixFailureCallback
Callback invoked when unregisterPrefix or unsetInterestFilter command fails.
const Interest & getInterest() const
void asyncExpressInterest(RecordId id, shared_ptr< const Interest > interest, const DataCallback &afterSatisfied, const NackCallback &afterNacked, const TimeoutCallback &afterTimeout)
bool matchesInterest(const Interest &other) const
Check if this Interest matches other.
Copyright (c) 2011-2015 Regents of the University of California.