NDN Packet Format 0.3

class ndn.encoding.ndn_format_0_3.ContentType

Numbers used in ContentType.

Type

Description

BLOB

Payload identified by the data name

LINK

A list of delegation names

KEY

Public Key

NACK

Application-level NACK

class ndn.encoding.ndn_format_0_3.InterestParam(can_be_prefix=False, must_be_fresh=False, nonce=None, lifetime=4000, hop_limit=None, forwarding_hint=<factory>)

A dataclass collecting the parameters of an Interest, except ApplicationParameters.

Variables
  • can_be_prefix (bool) – CanBePrefix. False by default.

  • must_be_fresh (bool) – MustBeFresh. False by default.

  • nonce (int) – Nonce. None by default.

  • lifetime (int) – InterestLifetime in milliseconds. 4000 by default.

  • hop_limit (int) – HopLimit. None by default.

  • forwarding_hint (List [ Tuple [ int , NonStrictName ]]) – ForwardingHint. The type should be list of Names. e.g.: ["/ndn/name1", ["ndn", "name2"]]

class ndn.encoding.ndn_format_0_3.KeyLocator
class ndn.encoding.ndn_format_0_3.MetaInfo(content_type=0, freshness_period=None, final_block_id=None)
class ndn.encoding.ndn_format_0_3.SignatureInfo
class ndn.encoding.ndn_format_0_3.SignaturePtrs(signature_info=None, signature_covered_part=<factory>, signature_value_buf=None, digest_covered_part=<factory>, digest_value_buf=None)

A set of pointers used to verify a packet.

Variables
  • signature_info (SignatureInfo) – the SignatureInfo.

  • signature_covered_part (List [ memoryview ]) – a list of pointers, each of which points to a memory covered by signature.

  • signature_value_buf (memoryview) – a pointer to SignatureValue (TL excluded).

  • digest_covered_part (List [ memoryview ]) – a list of pointers, each of which points to a memory covered by ParametersSha256DigestComponent.

  • digest_value_buf (memoryview) – a pointer to ParametersSha256DigestComponent (TL excluded).

class ndn.encoding.ndn_format_0_3.SignatureType

Numbers used in SignatureType.

Type

Description

NOT_SIGNED

Not signed

DIGEST_SHA256

SHA-256 digest (only for integrity protection)

SHA256_WITH_RSA

RSA signature over a SHA-256 digest

SHA256_WITH_ECDSA

An ECDSA signature over a SHA-256 digest

HMAC_WITH_SHA256

SHA256 hash-based message authentication codes

NULL

An empty signature for testing and experimentation

class ndn.encoding.ndn_format_0_3.TypeNumber

TLV Type numbers used in NDN Packet Format 0.3.

Constant names are changed to PEP 8 style, i.e., all upper cases with underscores separating words.

ndn.encoding.ndn_format_0_3.make_data(name, meta_info, content=None, signer=None)

Make a Data packet.

Parameters
  • name (NonStrictName) – the Name field.

  • meta_info (MetaInfo) – the MetaIndo field.

  • content (Optional [ BinaryStr ]) – the Content.

  • signer (Optional[Signer]) – a Signer to sign this Interest. None if it is unsigned.

Return type

Union[bytearray, memoryview]

Returns

TLV encoded Data packet.

ndn.encoding.ndn_format_0_3.make_interest(name, interest_param, app_param=None, signer=None, need_final_name=False)

Make an Interest packet.

Parameters
  • name (NonStrictName) – the Name field.

  • interest_param (InterestParam) – basic parameters of the Interest.

  • app_param (Optional [ BinaryStr ]) – the ApplicationParameters field.

  • signer (Optional[Signer]) – a Signer to sign this Interest. None if it is unsigned.

  • need_final_name (bool) – if True, also return the final Name with ParametersSha256DigestComponent.

Returns

TLV encoded Interest packet. If need_final_name, return a tuple of the packet and the final Name.

ndn.encoding.ndn_format_0_3.parse_data(wire, with_tl=True)

Parse a TLV encoded Data.

Parameters
  • wire (BinaryStr) – the buffer.

  • with_tl (bool) – True if the packet has Type and Length. False if wire only has the Value part.

Returns

a Tuple of Name, MetaInfo, Content and SignaturePtrs.

Return type

Tuple [ FormalName , MetaInfo , Optional [ BinaryStr ], SignaturePtrs ]

ndn.encoding.ndn_format_0_3.parse_interest(wire, with_tl=True)

Parse a TLV encoded Interest.

Parameters
  • wire (BinaryStr) – the buffer.

  • with_tl (bool) – True if the packet has Type and Length. False if wire only has the Value part.

Returns

a Tuple of Name, InterestParameters, ApplicationParameters and SignaturePtrs.

Return type

Tuple [ FormalName , InterestParam , Optional [ BinaryStr ], SignaturePtrs ]