:mod:`ndn.app` package
The :mod:`ndn.app` package contains the class :any:`NDNApp` , which connects an NDN application and an NFD node.
:any:`NDNApp` provides the functionalities similar to application Face in ndn-cxx, which include:
- Establish a connection to an NFD node.
- Express Interests and handle the Data coming back.
- Register and unregister a route with an Interest handling function.
This package does not support PIT token. To use PIT token, consider using :mod:`ndn.appv2` package.
Some functions which create a Interest or Data packet accept a kwargs
,
which can be used to support diversity in arguments provided to create a packet.
These arguments are used to fill in the MetaInfo field of a Data packet.
- meta_info (:any:`MetaInfo`) - the MetaInfo field of Data. All other related parameters will be ignored.
- content_type (int) - :any:`ContentType`.
ContentType.BLOB
by default. - freshness_period (int) - FreshnessPeriod in milliseconds.
None
by default. - final_block_id (:any:`BinaryStr`) - FinalBlockId. It should be an encoded :any:`Component`.
None
by default.
These arguments are used to fill in fields of an Interest packet.
interest_param (:any:`InterestParam`) - a dataclass containing all parameters. All other related parameters will be ignored.
can_be_prefix (bool) - CanBePrefix.
False
by default.must_be_fresh (bool) - MustBeFresh.
False
by default.nonce (int) - Nonce. A random number will be generated by default. To omit Nonce, please explicitly pass
None
to this argument.lifetime (int) - InterestLifetime in milliseconds.
4000
by default.Warning
On Windows, a too small number may cause a memory failure of the NameTrie. Currently,
>=10
is safe.hop_limit (int) - HopLimit.
None
by default.forwarding_hint (list[NonStrictName]) - see :any:`InterestParam`.
These arguments are used to decide how the Interest or Data packet is signed and by which Signer. Supported arguments are different with each Keychain. Only those supported by the default Keychain are listed here. If there is a conflict, the earlier an argument is listed the higher priority it has.
Note
Only Interests with ApplicationParameters are signed.
b''
can be used if that field is not needed by the application.
- signer (Signer) - the Signer used to sign this packet. All other related parameters will be ignored. The Keychain will not be used.
- no_signature (bool) - not signed. Not recommended.
- digest_sha256 (bool) - using SHA-256 digest to protect integrity only.
False
by default. - cert (:any:`NonStrictName`) - using the speficied Certificate to sign this packet. The Key name will be derived from the certificate name.
- key - using the specified Key to sign this packet. Either a Key object or the :any:`NonStrictName` of a Key is acceptable. KeyLocator will be set to the default Certificate name of this Key unless specified.
- identity - using the default Key of the specified Identity to sign this packet. Either an Identity object or the :any:`NonStrictName` of an Identity is acceptable. The default Identity will be used if all of the above arguments are omitted.
- key_locator (:any:`NonStrictName`) - using the specified KeyLocator Name regardless of which Key is used.
.. automodule:: ndn.app :members: