blob: 8e5d3d6e08f5e9e6557c554e6a1729c376992f7a [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
Steve DiBenedetto99b8a842014-12-22 14:56:16 -070057 + Implicit SHA256 digest component starts with ``sha256digest=`` prefix (case sensitive), followed by the digest represented as a sequence of 64 hexadecimal numbers.
Alexander Afanasyev4b8be212014-10-06 10:55:04 -070058
59 For example, ``sha256digest=893259d98aca58c451453f29ec7dc38688e690dd0b59ef4f3b9d33738bff0b8d``
60
61
62.. _Implicit Digest Component:
63
Alexander Afanasyeveee8c252013-11-21 23:22:41 +000064Implicit Digest Component
65~~~~~~~~~~~~~~~~~~~~~~~~~
66
Alexander Afanasyev072acbd2014-10-16 12:18:13 -070067The full name of every Data packet includes a logical final implicit digest component, which makes the name of every Data packet unique.
68The implicit digest (``ImplicitSha256DigestComponent``) MAY appear in an Interest, either as the last component of Interest Name to request a specific Data packet, or in the Exclude selector to exclude specific Data packet(s).
69``ImplicitSha256DigestComponent`` is never included explicitly in the Data packet when it is transmitted on the wire and, if needed, must be computed by all nodes based on the Data packet content.
Alexander Afanasyeveee8c252013-11-21 23:22:41 +000070
Alexander Afanasyev072acbd2014-10-16 12:18:13 -070071The **implicit digest component** consists of the SHA-256 digest of the entire Data packet bits. Having this digest as the last name component enables us to achieve the following two goals:
Alexander Afanasyeveee8c252013-11-21 23:22:41 +000072
Alexander Afanasyev406749e2014-03-27 18:45:26 -070073- Identify one specific Data packet and no other.
Alexander Afanasyeveee8c252013-11-21 23:22:41 +000074
75- Exclude a specific Data packet in an Interest (independent from whether it has a valid signature).
76
77Canonical Order
78~~~~~~~~~~~~~~~
79
Alexander Afanasyev4b8be212014-10-06 10:55:04 -070080In 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 +000081
Alexander Afanasyev4b8be212014-10-06 10:55:04 -070082The order between individual name components is defined as follows:
Alexander Afanasyeveee8c252013-11-21 23:22:41 +000083
Alexander Afanasyev4b8be212014-10-06 10:55:04 -070084- If components have different type, then
Alexander Afanasyeveee8c252013-11-21 23:22:41 +000085
Alexander Afanasyev4b8be212014-10-06 10:55:04 -070086 + Any ``ImplicitSha256DigestComponent`` is less than any ``GenericNameComponent``
87
88 ::
89
90 ImplicitSha256DigestComponent < GenericNameComponent
91
92 .. note::
93 This order can be enforced by directly comparing TYPE code of the components.
94 Type code ``ImplicitSha256DigestComponent`` is guaranteed to be less than type code ``GenericNameComponent``.
95
96- If components have the same type, then
97
98 + If *a* is shorter than *b* (i.e., has fewer bytes), then *a* comes before *b*.
99
100 + 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 +0000101
102For Names, the ordering is just based on the ordering of the first component where they differ.
103If one name is a proper prefix of the other, then it comes first.