blob: 4dd81995f4584db7db67793d97bed514f32632cc [file] [log] [blame]
Alexander Afanasyeve2800232013-11-27 02:24:14 +00001.. _Name:
Alexander Afanasyeveee8c252013-11-21 23:22:41 +00002
3Name
4----
5
Alexander Afanasyev406749e2014-03-27 18:45:26 -07006An NDN Name is a hierarchical name for NDN content, which contains a sequence of name components.
Alexander Afanasyeveee8c252013-11-21 23:22:41 +00007
8NDN Name Format
9~~~~~~~~~~~~~~~
10
11We use a 2-level nested TLV to represent a name.
12The Type in the outer TLV indicates this is a Name.
Alexander Afanasyev4b8be212014-10-06 10:55:04 -070013Inner TLVs should be one of ``NameComponent`` blocks, as defined in the following:
Alexander Afanasyeve2800232013-11-27 02:24:14 +000014
15::
Alexander Afanasyeveee8c252013-11-21 23:22:41 +000016
17 Name ::= NAME-TYPE TLV-LENGTH NameComponent*
Alexander Afanasyev4b8be212014-10-06 10:55:04 -070018
19 NameComponent ::= GenericNameComponent |
20 ImplicitSha256DigestComponent
21
22 GenericNameComponent ::= NAME-COMPONENT-TYPE TLV-LENGTH BYTE*
23
24 ImplicitSha256DigestComponent ::= IMPLICIT-SHA256-DIGEST-COMPONENT-TYPE TLV-LENGTH(=32)
25 BYTE{32}
26
27
28- ``GenericNameComponent`` is a generic name component, without any restrictions on the content of the value.
29
30- ``ImplicitSha256DigestComponent`` is an implicit SHA256 digest component and it is required to contain a value of 32 octets.
Alexander Afanasyeveee8c252013-11-21 23:22:41 +000031
Alexander Afanasyeveee8c252013-11-21 23:22:41 +000032
33NDN URI Scheme
34~~~~~~~~~~~~~~
35
36For textual representation, it is often convenient to use URI to represent NDN names.
37Please refer to RFC 3986 (URI Generic Syntax) for background.
38
Alexander Afanasyev406749e2014-03-27 18:45:26 -070039- The scheme identifier is ``ndn``.
Alexander Afanasyeveee8c252013-11-21 23:22:41 +000040
Alexander Afanasyeveee8c252013-11-21 23:22:41 +000041- The authority component (the part after the initial ``//`` in the familiar http and ftp URI schemes) is not relevant to NDN.
Alexander Afanasyev406749e2014-03-27 18:45:26 -070042 It should not be present, and it is ignored if it is present.
Alexander Afanasyeveee8c252013-11-21 23:22:41 +000043
Alexander Afanasyev4b8be212014-10-06 10:55:04 -070044- Component types have the following URI representations:
45
46 * ``GenericNameComponent``
47
48 + When producing a URI from an NDN Name, only the generic URI unreserved characters are left unescaped.
49 These are the US-ASCII upper and lower case letters (A-Z, a-z), digits (0-9), and the four specials PLUS (+), PERIOD (.), UNDERSCORE (\_), and HYPHEN (-).
50 All other characters are escaped using the percent-encoding method of the URI Generic Syntax.
51
52
53 + To unambiguously represent name components that would collide with the use of . and .. for relative URIs, any component that consists solely of zero or more periods is encoded using three additional periods.
54
55 * ``ImplicitSha256DigestComponent``
56
57 + Implicit SHA256 digest component starts with ``sha256digest=`` prefix (case sensitive), following the digest represented as a sequence of 32 hexadecimal numbers.
58
59 For example, ``sha256digest=893259d98aca58c451453f29ec7dc38688e690dd0b59ef4f3b9d33738bff0b8d``
60
61
62.. _Implicit Digest Component:
63
Alexander Afanasyeveee8c252013-11-21 23:22:41 +000064Implicit Digest Component
65~~~~~~~~~~~~~~~~~~~~~~~~~
66
67The Name of every piece of content includes as its final component a derived digest that ultimately makes the name unique.
Alexander Afanasyev4b8be212014-10-06 10:55:04 -070068This digest may occur in an Interest Name as an ``ImplicitSha256DigestComponent`` and MUST appear as the last component in the name.
Alexander Afanasyeveee8c252013-11-21 23:22:41 +000069This final component in the name is never included explicitly in the Data packet when it is transmitted on the wire.
70It can be computed by any node based on the Data packet content.
71
72The **implicit digest component** consists of the SHA-256 digest of the entire Data packet without the signature component. Having this digest as the last name component enables us to achieve the following two goals:
73
Alexander Afanasyev406749e2014-03-27 18:45:26 -070074- Identify one specific Data packet and no other.
Alexander Afanasyeveee8c252013-11-21 23:22:41 +000075
76- Exclude a specific Data packet in an Interest (independent from whether it has a valid signature).
77
78Canonical Order
79~~~~~~~~~~~~~~~
80
Alexander Afanasyev4b8be212014-10-06 10:55:04 -070081In several contexts in NDN packet processing, it is necessary to have a consistent ordering of names and name components.
Alexander Afanasyeveee8c252013-11-21 23:22:41 +000082
Alexander Afanasyev4b8be212014-10-06 10:55:04 -070083The order between individual name components is defined as follows:
Alexander Afanasyeveee8c252013-11-21 23:22:41 +000084
Alexander Afanasyev4b8be212014-10-06 10:55:04 -070085- If components have different type, then
Alexander Afanasyeveee8c252013-11-21 23:22:41 +000086
Alexander Afanasyev4b8be212014-10-06 10:55:04 -070087 + Any ``ImplicitSha256DigestComponent`` is less than any ``GenericNameComponent``
88
89 ::
90
91 ImplicitSha256DigestComponent < GenericNameComponent
92
93 .. note::
94 This order can be enforced by directly comparing TYPE code of the components.
95 Type code ``ImplicitSha256DigestComponent`` is guaranteed to be less than type code ``GenericNameComponent``.
96
97- If components have the same type, then
98
99 + If *a* is shorter than *b* (i.e., has fewer bytes), then *a* comes before *b*.
100
101 + If *a* and *b* have the same length, then they are compared in lexicographic order based on absolute value of octet values (e.g., ordering based on memcmp() operation.)
Alexander Afanasyeveee8c252013-11-21 23:22:41 +0000102
103For Names, the ordering is just based on the ordering of the first component where they differ.
104If one name is a proper prefix of the other, then it comes first.