Miscellaneous packages

ndn.types package

exception ndn.types.InterestCanceled

Raised when an Interest is cancelled due to the loss of connection to NFD.

Note

A very large packet may cause NFD shutting down the connection. More specifically,

  • The face is shutdown.

  • All pending Interests are cancelled with this exception.

  • App.run_forever() returns True.

exception ndn.types.InterestNack(reason)

Raised when receiving a NetworkNack.

Variables

reason (int) – reason for Nack.

exception ndn.types.InterestTimeout

Raised when an Interest times out.

exception ndn.types.NetworkError

Raised when trying to send a packet before connecting to NFD.

ndn.types.Route

An OnInterest callback function for a route.

alias of Callable[[List[Union[bytes, bytearray, memoryview]], InterestParam, Optional[Union[bytes, bytearray, memoryview]]], None]

class ndn.types.ValidResult(value)

Validation result returned by a validator. Most of them are designed for the union checker, which chains multiple checkers in order. For NDNApp (v2), only PASS and ALLOW_BYPASS are considered as True.

ALLOW_BYPASS = 2

The validator allows bypassing all following checkers. Succeed immediately.

FAIL = -2

Negative. The validation fails and the packet should be discarded. Abort.

PASS = 1

Affirmative. Passes the current check. Continue.

SILENCE = 0

The validator does not handle this type of packet and thus cannot decide. Continue.

TIMEOUT = -1

The validation process exceeds the Interest deadline. Abort.

exception ndn.types.ValidationFailure(name, meta_info, content, sig_ptrs, result=ValidResult.FAIL)

Raised when failing to validate a Data packet.

Variables
ndn.types.Validator

A validator used to validate an Interest or Data packet.

alias of Callable[[List[Union[bytes, bytearray, memoryview]], SignaturePtrs], Coroutine[Any, None, bool]]

ndn.utils package

ndn.utils.gen_nonce()

Generate a random nonce.

Returns

a random 32-bit unsigned integer.

ndn.utils.gen_nonce_64()

Generate a random 64-bit nonce.

Returns

a random 64-bit unsigned integer.

ndn.utils.timestamp()

Generate a timestamp number.

Returns

the time in milliseconds since the epoch as an integer