Alexander Afanasyev | e280023 | 2013-11-27 02:24:14 +0000 | [diff] [blame] | 1 | .. _Name: |
Alexander Afanasyev | eee8c25 | 2013-11-21 23:22:41 +0000 | [diff] [blame] | 2 | |
| 3 | Name |
| 4 | ---- |
| 5 | |
Alexander Afanasyev | 406749e | 2014-03-27 18:45:26 -0700 | [diff] [blame] | 6 | An NDN Name is a hierarchical name for NDN content, which contains a sequence of name components. |
Alexander Afanasyev | eee8c25 | 2013-11-21 23:22:41 +0000 | [diff] [blame] | 7 | |
| 8 | NDN Name Format |
| 9 | ~~~~~~~~~~~~~~~ |
| 10 | |
| 11 | We use a 2-level nested TLV to represent a name. |
| 12 | The Type in the outer TLV indicates this is a Name. |
Alexander Afanasyev | 4b8be21 | 2014-10-06 10:55:04 -0700 | [diff] [blame] | 13 | Inner TLVs should be one of ``NameComponent`` blocks, as defined in the following: |
Alexander Afanasyev | e280023 | 2013-11-27 02:24:14 +0000 | [diff] [blame] | 14 | |
| 15 | :: |
Alexander Afanasyev | eee8c25 | 2013-11-21 23:22:41 +0000 | [diff] [blame] | 16 | |
| 17 | Name ::= NAME-TYPE TLV-LENGTH NameComponent* |
Alexander Afanasyev | 4b8be21 | 2014-10-06 10:55:04 -0700 | [diff] [blame] | 18 | |
| 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 Afanasyev | eee8c25 | 2013-11-21 23:22:41 +0000 | [diff] [blame] | 31 | |
Alexander Afanasyev | eee8c25 | 2013-11-21 23:22:41 +0000 | [diff] [blame] | 32 | |
| 33 | NDN URI Scheme |
| 34 | ~~~~~~~~~~~~~~ |
| 35 | |
| 36 | For textual representation, it is often convenient to use URI to represent NDN names. |
| 37 | Please refer to RFC 3986 (URI Generic Syntax) for background. |
| 38 | |
Alexander Afanasyev | 406749e | 2014-03-27 18:45:26 -0700 | [diff] [blame] | 39 | - The scheme identifier is ``ndn``. |
Alexander Afanasyev | eee8c25 | 2013-11-21 23:22:41 +0000 | [diff] [blame] | 40 | |
Alexander Afanasyev | eee8c25 | 2013-11-21 23:22:41 +0000 | [diff] [blame] | 41 | - The authority component (the part after the initial ``//`` in the familiar http and ftp URI schemes) is not relevant to NDN. |
Alexander Afanasyev | 406749e | 2014-03-27 18:45:26 -0700 | [diff] [blame] | 42 | It should not be present, and it is ignored if it is present. |
Alexander Afanasyev | eee8c25 | 2013-11-21 23:22:41 +0000 | [diff] [blame] | 43 | |
Alexander Afanasyev | 4b8be21 | 2014-10-06 10:55:04 -0700 | [diff] [blame] | 44 | - 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 DiBenedetto | 99b8a84 | 2014-12-22 14:56:16 -0700 | [diff] [blame^] | 57 | + Implicit SHA256 digest component starts with ``sha256digest=`` prefix (case sensitive), followed by the digest represented as a sequence of 64 hexadecimal numbers. |
Alexander Afanasyev | 4b8be21 | 2014-10-06 10:55:04 -0700 | [diff] [blame] | 58 | |
| 59 | For example, ``sha256digest=893259d98aca58c451453f29ec7dc38688e690dd0b59ef4f3b9d33738bff0b8d`` |
| 60 | |
| 61 | |
| 62 | .. _Implicit Digest Component: |
| 63 | |
Alexander Afanasyev | eee8c25 | 2013-11-21 23:22:41 +0000 | [diff] [blame] | 64 | Implicit Digest Component |
| 65 | ~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 66 | |
Alexander Afanasyev | 072acbd | 2014-10-16 12:18:13 -0700 | [diff] [blame] | 67 | The full name of every Data packet includes a logical final implicit digest component, which makes the name of every Data packet unique. |
| 68 | The 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 Afanasyev | eee8c25 | 2013-11-21 23:22:41 +0000 | [diff] [blame] | 70 | |
Alexander Afanasyev | 072acbd | 2014-10-16 12:18:13 -0700 | [diff] [blame] | 71 | The **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 Afanasyev | eee8c25 | 2013-11-21 23:22:41 +0000 | [diff] [blame] | 72 | |
Alexander Afanasyev | 406749e | 2014-03-27 18:45:26 -0700 | [diff] [blame] | 73 | - Identify one specific Data packet and no other. |
Alexander Afanasyev | eee8c25 | 2013-11-21 23:22:41 +0000 | [diff] [blame] | 74 | |
| 75 | - Exclude a specific Data packet in an Interest (independent from whether it has a valid signature). |
| 76 | |
| 77 | Canonical Order |
| 78 | ~~~~~~~~~~~~~~~ |
| 79 | |
Alexander Afanasyev | 4b8be21 | 2014-10-06 10:55:04 -0700 | [diff] [blame] | 80 | In several contexts in NDN packet processing, it is necessary to have a consistent ordering of names and name components. |
Alexander Afanasyev | eee8c25 | 2013-11-21 23:22:41 +0000 | [diff] [blame] | 81 | |
Alexander Afanasyev | 4b8be21 | 2014-10-06 10:55:04 -0700 | [diff] [blame] | 82 | The order between individual name components is defined as follows: |
Alexander Afanasyev | eee8c25 | 2013-11-21 23:22:41 +0000 | [diff] [blame] | 83 | |
Alexander Afanasyev | 4b8be21 | 2014-10-06 10:55:04 -0700 | [diff] [blame] | 84 | - If components have different type, then |
Alexander Afanasyev | eee8c25 | 2013-11-21 23:22:41 +0000 | [diff] [blame] | 85 | |
Alexander Afanasyev | 4b8be21 | 2014-10-06 10:55:04 -0700 | [diff] [blame] | 86 | + 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 Afanasyev | eee8c25 | 2013-11-21 23:22:41 +0000 | [diff] [blame] | 101 | |
| 102 | For Names, the ordering is just based on the ordering of the first component where they differ. |
| 103 | If one name is a proper prefix of the other, then it comes first. |