pyndn.impl package¶
Submodules¶
pyndn.impl.delayed_call_table module¶
This module defines DelayedCallTable which is an internal class used by the Node implementation of callLater to store callbacks and call them when they time out.
-
class
pyndn.impl.delayed_call_table.
DelayedCallTable
[source]¶ Bases:
object
pyndn.impl.interest_filter_table module¶
This module defines InterestFilterTable which is an internal class to hold a list of entries with an interest Filter and its OnInterestCallback.
-
class
pyndn.impl.interest_filter_table.
InterestFilterTable
[source]¶ Bases:
object
-
class
Entry
(interestFilterId, filter, onInterest, face)[source]¶ Bases:
object
An Entry holds an interestFilterId, an InterestFilter and the OnInterestCallback with its related Face. Create a new InterestFilterEntry with the given values.
Parameters: - interestFilterId (int) – The ID from Node.getNextEntryId().
- filter (InterestFilter) – The InterestFilter for this entry.
- onInterest (function object) – The callback to call.
- face (Face) – The face on which was called registerPrefix or setInterestFilter which is passed to the onInterest callback.
-
getFilter
()[source]¶ Get the InterestFilter given to the constructor.
Returns: The InterestFilter. Return type: InterestFilter
-
getMatchedFilters
(interest, matchedFilters)[source]¶ Find all entries from the interest filter table where the interest conforms to the entry’s filter, and add to the matchedFilters list.
Parameters: - interest (Interest) – The interest which may match the filter in multiple entries.
- matchedFilters (List<InterestFilterTable.Entry>) – Add each matching InterestFilterTable.Entry from the interest filter table. The caller should pass in an empty list.
-
setInterestFilter
(interestFilterId, filterCopy, onInterest, face)[source]¶ Add an entry to the table.
Parameters: - interestFilterId (int) – The ID from Node.getNextEntryId().
- filterCopy (InterestFilter) – The InterestFilter for this entry.
- onInterest (function object) – The callback to call.
- face (Face) – The face which is passed to the onInterest callback.
-
unsetInterestFilter
(interestFilterId)[source]¶ Remove the interest filter entry which has the interestFilterId from the interest filter table. This does not affect another interest filter with a different interestFilterId, even if it has the same prefix name. If there is no entry with the interestFilterId, do nothing.
Parameters: interestFilterId (int) – The ID returned from setInterestFilter.
-
class
pyndn.impl.pending_interest_table module¶
This module defines PendingInterestTable which is an internal class to hold a list of pending interests with their callbacks.
-
class
pyndn.impl.pending_interest_table.
PendingInterestTable
[source]¶ Bases:
object
-
class
Entry
(pendingInterestId, interest, onData, onTimeout, onNetworkNack)[source]¶ Bases:
object
Create a new Entry with the given fields. Note: You should not call this directly but call PendingInterestTable.add.
Parameters: - pendingInterestId (int) – A unique ID for this entry, which you should get with Node.getNextEntryId().
- interest (Interest) – The interest.
- onData (function object) – A function object to call when a matching data packet is received.
- onTimeout (function object) – A function object to call if the interest times out. If onTimeout is None, this does not use it.
- onNetworkNack (function object) – A function object to call when a network Nack packet is received.
-
getInterest
()[source]¶ Get the interest given to the constructor.
Returns: The interest. Return type: int
-
getIsRemoved
()[source]¶ Check if setIsRemoved() was called.
Returns: True if setIsRemoved() was called. Return type: bool
-
getOnData
()[source]¶ Get the onData function object given to the constructor.
Returns: The onData function object. Return type: function object
-
getOnNetworkNack
()[source]¶ Get the onNetworkNack function object given to the constructor.
Returns: The onNetworkNack function object. Return type: function object
-
add
(pendingInterestId, interestCopy, onData, onTimeout, onNetworkNack)[source]¶ Add a new entry to the pending interest table. However, if removePendingInterest was already called with the pendingInterestId, don’t add an entry and return None.
Parameters: - pendingInterestId (int) – A unique ID for this entry, which you should get with Node.getNextEntryId().
- interest (Interest) – The interest which was sent, which has already been copied by expressInterest.
- onData (function object) – A function object to call when a matching data packet is received.
- onTimeout (function object) – A function object to call if the interest times out. If onTimeout is None, this does not use it.
- onNetworkNack (function object) – A function object to call when a network Nack packet is received.
Returns: The new PendingInterestTable.Entry, or None if removePendingInterest was already called with the pendingInterestId.
Return type:
-
extractEntriesForExpressedInterest
(data, entries)[source]¶ Find all entries from the pending interest table where data conforms to the entry’s interest selectors, remove the entries from the table, set each entry’s isRemoved flag, and add to the entries list.
Parameters: - data (Data) – The incoming Data packet to find the interest for.
- entries (List<PendingInterestTable.Entry>) – Add matching PendingInterestTable.Entry from the pending interest table. The caller should pass in an empty list.
-
extractEntriesForNackInterest
(interest, entries)[source]¶ Find all entries from the pending interest table where the OnNetworkNack callback is not None and the entry’s interest is the same as the given interest, remove the entries from the table, set each entry’s isRemoved flag, and add to the entries list. (We don’t remove the entry if the OnNetworkNack callback is None so that OnTimeout will be called later.) The interests are the same if their default wire encoding is the same (which has everything including the name, nonce, link object and selectors).
Parameters: - interest (Interest) – The Interest to search for (typically from a Nack packet).
- entries (List<PendingInterestTable.Entry>) – Add matching PendingInterestTable.Entry from the pending interest table. The caller should pass in an empty list.
-
removeEntry
(pendingInterest)[source]¶ Remove the specific pendingInterest entry from the table and set its isRemoved flag. However, if the pendingInterest isRemoved flag is already True or the entry is not in the pending interest table then do nothing.
Parameters: pendingInterest (PendingInterestTable.Entry) – The Entry from the pending interest table. Returns: True if the entry was removed, False if not. Return type: bool
-
removePendingInterest
(pendingInterestId)[source]¶ Remove the pending interest entry with the pendingInterestId from the pending interest table and set its isRemoved flag. This does not affect another pending interest with a different pendingInterestId, even if it has the same interest name. If there is no entry with the pendingInterestId, do nothing.
Parameters: pendingInterestId (int) – The ID returned from expressInterest.
-
class
pyndn.impl.registered_prefix_table module¶
This module defines RegisteredPrefixTable which is an internal class to hold a list of registered prefixes with information necessary to remove the registration later.
-
class
pyndn.impl.registered_prefix_table.
RegisteredPrefixTable
(interestFilterTable)[source]¶ Bases:
object
Create a new RegisteredPrefixTable with an empty table.
Parameters: interestFilterTable (InterestFilterTable) – See removeRegisteredPrefix(), which may call interestFilterTable.unsetInterestFilter(). -
add
(registeredPrefixId, prefix, relatedInterestFilterId)[source]¶ Add a new entry to the table.
Parameters: - registeredPrefixId (int) – The ID from Node.getNextEntryId().
- prefix (Name) – The name prefix.
- relatedInterestFilterId (int) – (optional) The related interestFilterId for the filter set in the same registerPrefix operation. If omitted, set to 0.
Returns: True if added an entry, false if removeRegisteredPrefix was already called with the registeredPrefixId.
Return type: bool
-
removeRegisteredPrefix
(registeredPrefixId)[source]¶ Remove the registered prefix entry with the registeredPrefixId from the registered prefix table. This does not affect another registered prefix with a different registeredPrefixId, even if it has the same prefix name. If an interest filter was automatically created by registerPrefix, also remove it. If there is no entry with the registeredPrefixId, do nothing.
Parameters: registeredPrefixId (int) – The ID returned from registerPrefix.
-