Network Working Group M. Uruena Internet-Draft D. Larrabeiti Expires: May 12, 2006 UC3M November 08, 2005 eXtensible Binary Encoding (XBE32) Status of this Memo By submitting this Internet-Draft, each author represents that any applicable patent or other IPR claims of which he or she is aware have been or will be disclosed, and any of which he or she becomes aware will be disclosed, in accordance with Section 6 of BCP 79. Internet-Drafts are working documents of the Internet Engineering Task Force (IETF), its areas, and its working groups. Note that other groups may also distribute working documents as Internet- Drafts. Internet-Drafts are draft documents valid for a maximum of six months and may be updated, replaced, or obsoleted by other documents at any time. It is inappropriate to use Internet-Drafts as reference material or to cite them other than as "work in progress." The list of current Internet-Drafts can be accessed at http://www.ietf.org/ietf/1id-abstracts.txt. The list of Internet-Draft Shadow Directories can be accessed at http://www.ietf.org/shadow.html. This Internet-Draft will expire on May 12, 2006. Copyright Notice Copyright (C) The Internet Society (2005). Abstract This document defines the eXtensible Binary Encoding (XBE32). It has been designed to represent hierarchical data in a compact and extensible format. Data elements are binary encoded inside Type- Length-Value (TLV) structures, which are 32-bit aligned to be easily processed by computers. XBE32 is NOT a binary encoding for XML documents, but an encoding format for small, lightweight network protocols. Uruena & Larrabeiti Expires May 12, 2006 [Page 1] Internet-Draft XBE32 Binary Encoding November 2005 Table of Contents 1. Introduction . . . . . . . . . . . . . . . . . . . . . . . . 3 1.1 Notation Conventions . . . . . . . . . . . . . . . . . . . 3 2. Common TLV Format . . . . . . . . . . . . . . . . . . . . . 4 2.1 Unspecified Length . . . . . . . . . . . . . . . . . . . . 6 3. XBE32 TLVs . . . . . . . . . . . . . . . . . . . . . . . . . 7 3.1 TLV with inner TLV Values . . . . . . . . . . . . . . . . 7 3.2 TLV with one Variable-Length Value . . . . . . . . . . . . 8 3.3 TLV with 1 Octet Values . . . . . . . . . . . . . . . . . 8 3.4 TLV with 2 Octets Values . . . . . . . . . . . . . . . . . 9 3.5 TLV with 4 Octets Values . . . . . . . . . . . . . . . . . 9 3.6 TLV with 8 Octets Values . . . . . . . . . . . . . . . . . 10 3.7 TLV with 12 Octets Values . . . . . . . . . . . . . . . . 10 3.8 TLV with 16 Octets Values . . . . . . . . . . . . . . . . 11 3.9 Opaque TLV Values . . . . . . . . . . . . . . . . . . . . 11 3.10 String TLV Values . . . . . . . . . . . . . . . . . . . 12 3.11 Boolean TLV Values . . . . . . . . . . . . . . . . . . . 12 3.12 Integer TLV Values . . . . . . . . . . . . . . . . . . . 12 3.13 Float TLV Values . . . . . . . . . . . . . . . . . . . . 13 4. XBE32 Elements . . . . . . . . . . . . . . . . . . . . . . . 14 4.1 Simple Elements . . . . . . . . . . . . . . . . . . . . . 14 4.2 Extensible Elements: Ids and Names . . . . . . . . . . . . 14 4.3 Extensible Complex Elements . . . . . . . . . . . . . . . 15 4.4 Extensible Attribute Elements . . . . . . . . . . . . . . 16 5. Acknowledgements . . . . . . . . . . . . . . . . . . . . . . 17 6. References . . . . . . . . . . . . . . . . . . . . . . . . . 17 Authors' Addresses . . . . . . . . . . . . . . . . . . . . . 17 A. XBE32 Examples . . . . . . . . . . . . . . . . . . . . . . . 18 Intellectual Property and Copyright Statements . . . . . . . 20 Uruena & Larrabeiti Expires May 12, 2006 [Page 2] Internet-Draft XBE32 Binary Encoding November 2005 1. Introduction Nowadays, the most popular format to represent hierarchical structured information is XML, and it is being employed in multiple network protocols. Although its textual representation allows extensible protocols, and ease protocol development and debugging, it requires more bandwidth than a binary counterpart. This document defines the XBE32 encoding, a simple binary encoding for network protocols that carry hierarchical data. All XBE32 Elements are encoded inside 32 bit aligned TLV structures to ease the parsing process. As data is clearly delimited, XBE32 does not require to escape characters as XML does, thus easing message creation. As TLVs have 2 octet Type an Length fields, XBE32 is well suited for simple protocols with short messages and a small set of identifiers. However, in order to be extensible, it supports variable-length binary and string identifiers. Also, XBE32 allows complex elements with an undefined length in order to start sending a message before its total length is known. In order to be employed by modern programming languages, XBE32 defines common data types for its Attibute Element, as Integer, Float, Boolean, String or Arrays. Other data types can be represented as Opaque binary data, which are also allowed by XBE32. 1.1 Notation Conventions The keywords MUST, MUST NOT, REQUIRED, SHALL, SHALL NOT, SHOULD, SHOULD NOT, RECOMMENDED, NOT RECOMMENDED, MAY, and OPTIONAL, when they appear in this document, are to be interpreted as described in RFC2119 [1]. Uruena & Larrabeiti Expires May 12, 2006 [Page 3] Internet-Draft XBE32 Binary Encoding November 2005 2. Common TLV Format 0 1 2 3 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Type | Length | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ : : : Values : : : +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ Type (16 bits): This field describes which kind of data is carried inside this TLV. This field has the following internal structure: 0 1 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |C|E| Meta | Subtype | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ C and E bits: These two bits specify the actions that must be taken if the processing entity does not recognize this Type: C - Continue Processing: 0 - Discard this mandatory TLV and stop processing TLVs left. 1 - Skip this optional TLV and continue processing remaining TLVs. E - Notify Error: 0 - Do not report to the sender that this Type is unknown. 1 - Report to the sender that this Type is unknown. Meta and Value Type: Uruena & Larrabeiti Expires May 12, 2006 [Page 4] Internet-Draft XBE32 Binary Encoding November 2005 This field describes the internal structure of the TLV's Values field, as well as the type of the data it contains: Meta TLV Value Description --------- ------------------------------------ 0x00-0x03 Multiple, variable-length TLVs 0x04 Single, variable-length opaque Value 0x05 Single, variable-length string Value 0x08 Multiple, opaque1 Values 0x09 Multiple, int8 Values 0x0A Multiple, boolean Values 0x0C Multiple, opaque2 Values 0x0D Multiple, int16 Values 0x10 Multiple, opaque4 Values 0x11 Multiple, int32 Values 0x12 Multiple, float32 Values 0x14 Multiple, opaque8 Values 0x15 Multiple, int64 Values 0x16 Multiple, float64 Values 0x18 Multiple, opaque12 Values 0x1C Multiple, opaque16 Values The unlisted values are reserved by the IETF and MUST NOT be employed. Subtype: This field identifies the meaning of the data carried inside this TLV, and therefore its values should be defined by the upper application/protocol that employs XBE32 as encoding. Values 0x00 and 0xFF are reserved for XBE32 use and MUST NOT be employed for other purposes. Length (16 bits): This field contains the unsigned length of the whole TLV structure measured in octets, padding not included. Length SHOULD be always equal or greater than 4 octets, that is, the length of the Type and Length values. The only exception to this rule is a complex TLV with a zero (0x0000) length value, whose meaning is explained at the next subsection. Values (variable length): The Values field contains the actual XBE32-encoded data as described by the Type and Length fields. If a primitive Value is not aligned to 4 octet words, padding space MUST be filled with zeros (0x00). Uruena & Larrabeiti Expires May 12, 2006 [Page 5] Internet-Draft XBE32 Binary Encoding November 2005 2.1 Unspecified Length In some circumstances a message can not be delayed/stored until all the data to be encoded is available. However, as the TLV header should contain the total length of the structure, it can not be sent before all the data becomes available or the length can be inferred somehow. For that reason, XBE32 allows a complex TLV (i.e. containing other TLVs) to have an "undefined" length. In that case, the last of the inner TLVs MUST be an End-of-data TLV. "Undefined" length is specified by setting the complex TLV Length field to zero (0x0000). End-of-data TLV has the Type field set to zero (0x0000) and the Length field set to 4 octets, thus it MUST NOT contain any value: 0 1 2 3 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Type = 0x0000 | Length = 4 | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ This mechanism allows XBE32 to encode complex TLVs of arbitrary length. However, only complex elements may have an unspecified length. Primitive Values MUST NOT be longer than 65532 octets. Uruena & Larrabeiti Expires May 12, 2006 [Page 6] Internet-Draft XBE32 Binary Encoding November 2005 3. XBE32 TLVs Some Values transmitted may not be 4 octet word aligned, thus in that case, padding MUST be added (up to 3 padding octets) to align the TLV structure to 4 octet words. Padding octets MUST be filled with zeros (0x00) in transmission and MUST be ignored in reception. 3.1 TLV with inner TLV Values This figure displays a Complex TLV containing several TLV Values. If Length field is "undefined" (0x0000), Complex TLV MUST end with a 4 octet End-of-data TLV. If total length is specified, End-of-data TLV MUST NOT appear. 0 1 2 3 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Type.Meta = 0x00-0x03 | Length = 0 or 4 + TLVs Length | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Type #1 | Length #1 | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ : : : Values #1 : : : +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ : : : : +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Type #N | Length #N | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ : : : Values #N : : : +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | [ End-of-data TLV ] | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ As XBE32 TLVs are always aligned to 4 octets words, the global TLV will be also aligned to 4 octet words, thus padding MUST NOT be added, and the Length field defines the total length of the TLV. Note that, in the case of TLVs Values with padding, the Length of the Complex TLV MUST NOT be calculated as 4 plus the sum of the Length fields of all the inner TLVs, because they do not include the padding octets. Uruena & Larrabeiti Expires May 12, 2006 [Page 7] Internet-Draft XBE32 Binary Encoding November 2005 3.2 TLV with one Variable-Length Value This figure displays a XBE32 TLV containing a single Value: 0 1 2 3 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Type.Meta = 0x04-0x05 | Length = 4 + Value.length | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ : : : Value : : : : +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ : | [ 0x00 ] | [ 0x00 ] | [ 0x00 ] | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ The length field contains the sum of the TLV header (Type and Length) plus the length in octets of the encoded Value. As the Value may not be aligned to 4 octet words, padding MUST be added. In that case the Length field does not contain the total length of the TLV structure but the length without the padding octets. 3.3 TLV with 1 Octet Values This figure displays a XBE32 TLV containing N, 1 octet Values: 0 1 2 3 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Type.Meta = 0x08-0x0A | Length = 4 + N | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Value #1 | Value #2 | Value #3 | Value #4 | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ : : : : +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Value #N | [ 0x00 ] | [ 0x00 ] | [ 0x00 ] | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ The Length field contains the sum of the TLV header (Type and Length) plus the number of 1 octet values. As the number of Values may not multiple of 4, up to 3 padding octets SHOULD be added. In that case the length field does not contain the total length of the TLV structure but the length without the padding octets. Uruena & Larrabeiti Expires May 12, 2006 [Page 8] Internet-Draft XBE32 Binary Encoding November 2005 3.4 TLV with 2 Octets Values This figure displays a XBE32 TLV containing N, 2 octet Values: 0 1 2 3 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Type.Meta = 0x0C-0x0D | Length = 4 + 2*N | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Value #1 | Value #2 | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ : : : : +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Value #N | [ 0x0000 ] | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ The Length field contains the sum of the TLV header (Type and Length), plus the number of 2 octet values multiplied by two. As the number of Values may not multiple of 2, two padding octets SHOULD be added. In that case the length field does not contain the total length of the TLV structure but the length without the padding octets. 3.5 TLV with 4 Octets Values This figure displays a XBE32 TLV containing N, 4 octet Values: 0 1 2 3 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Type.Meta = 0x10-0x12 | Length = 4 + 4*N | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Value #1 | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ : : : : +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Value #N | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ These TLVs are always aligned to 4 octet words. Length field MUST contain the total length of the TLV as padding MUST NOT be added. Uruena & Larrabeiti Expires May 12, 2006 [Page 9] Internet-Draft XBE32 Binary Encoding November 2005 3.6 TLV with 8 Octets Values This figure displays a XBE32 TLV containing N, 8 octet Values: 0 1 2 3 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Type.Meta = 0x14-0x16 | Length = 4 + 8*N | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | | + Value #1 + | | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ : : +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | | + Value #N + | | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ These TLVs are always aligned to 4 octet words. Length field MUST contain the total length of the TLV as padding MUST NOT be added. 3.7 TLV with 12 Octets Values This figure displays a XBE32 TLV containing N, 12 octet Values: 0 1 2 3 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Type.Meta = 0x18 | Length = 4 + 12*N | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | | + + | Value #1 | + + | | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ : : +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | | + + | Value #N | + + | | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ These TLVs are always aligned to 4 octet words. Length field MUST Uruena & Larrabeiti Expires May 12, 2006 [Page 10] Internet-Draft XBE32 Binary Encoding November 2005 contain the total length of the TLV as padding MUST NOT be added. 3.8 TLV with 16 Octets Values This figure displays a XBE32 TLV containing N, 16 octet Values: 0 1 2 3 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Type.Meta = 0x1C | Length = 4 + 16*N | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | | + + | | + Value #1 + | | + + | | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ : : +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | | + + | | + Value #N + | | + + | | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ These TLVs are always aligned to 4 octet words. Length field MUST contain the total length of the TLV as padding MUST NOT be added. 3.9 Opaque TLV Values An Opaque value is a sequence of octets that should not be parsed by a XBE32 entity but just being delivered to the upper layer. Uruena & Larrabeiti Expires May 12, 2006 [Page 11] Internet-Draft XBE32 Binary Encoding November 2005 The Opaque TLV Values defined by XBE32 are: Meta TLV Value Description ---- ------------------------------------ 0x04 Single, variable-length opaque Value 0x08 Multiple, opaque1 Values 0x0C Multiple, opaque2 Values 0x10 Multiple, opaque4 Values 0x14 Multiple, opaque8 Values 0x18 Multiple, opaque12 Values 0x1C Multiple, opaque16 Values 3.10 String TLV Values String values MUST be encoded as specified in [2]. This TLV contains a single UTF-8 encoded String: Meta TLV Value Description ---- ------------------------------------ 0x05 Single, variable-length string Value 3.11 Boolean TLV Values A boolean value is encoded inside an octet value. "False" is encoded as 0x00 while "True" is encoded as 0xFF. Other values than 0x00 or 0xFF MUST NOT appear as an encoded boolean value. This TLV contains multiple Boolean values: Meta TLV Value Description ---- ------------------------------------ 0x0A Multiple, boolean Values 3.12 Integer TLV Values Signed integer values MUST be encoded as a two's complement binary number in network byte order (a.k.a. Big Endian, i.e., the most significant byte first). Uruena & Larrabeiti Expires May 12, 2006 [Page 12] Internet-Draft XBE32 Binary Encoding November 2005 The integer TLV Values defined by XBE32 are: Meta TLV Value Description ---- ------------------------------------ 0x09 Multiple, int8 Values 0x0D Multiple, int16 Values 0x11 Multiple, int32 Values 0x15 Multiple, int64 Values 3.13 Float TLV Values Float values MUST be encoded as specified in [3]. The floating point TLV Values defined by XBE32 are: Meta TLV Value Description ---- ------------------------------------ 0x12 Multiple, float32 Values 0x16 Multiple, float64 Values Uruena & Larrabeiti Expires May 12, 2006 [Page 13] Internet-Draft XBE32 Binary Encoding November 2005 4. XBE32 Elements XBE32 has been designed to encode hierarchical data in a compact binary format easily generated and processed by machines. Hierarchical data can be represented as a tree, where each node has a name. The "leaf" nodes of the tree are also named but they are the only ones that carry data. In XBE32 each node on the tree is known as "Element". Every Element is encoded employing one or more XBE32 TLVs, and it has an identifier, that could be a binary one or a human-readable name. There are two kinds of Elements in XBE32 whether they carry primitive data or not. "Attribute Elements" are the "leafs" of the tree and contain primitive values. "Complex Elements", on the other hand, do not carry primitive data, but they are the parents of other XBE32 Elements, that could be Attribute Elements or other Complex Elements themselves. 4.1 Simple Elements As most of the protocols will employ a small set of elements to build their messages, Simple XBE32 Elements are encoded in a single TLV and be identified just by the 16-bit Type field, including all its sub- fields, as the C and E bits. Every application/protocol may define its own set of Subtypes, which are not employed in the base specification of XBE32. Therefore they are allowed to employ the following TLV Types: Meta Element --------- -------------------------------- 0x00-0x03 0x01-0xFE Complex Element TLV 0x04-0x1C 0x01-0xFE Attribute Element TLV Simple Attribute TLVs MUST fill the remaining Value Type field according to the primitive type of their data, as defined in the XBE32 TLV Values section of this document. For example, a mandatory Attribute carrying an integer value of 32 bits may be encoded inside a single TLV with a Type in the 0x1101-0x11FE range. 4.2 Extensible Elements: Ids and Names The above mechanism allows a compact representation and is suitable for the initial definition of the mandatory operations and parameters of a simple protocol. However, a 2 octet Type field is not enough for truly extensible protocols, as it could be a too small namespace for vendor extensions or experimental operations. Uruena & Larrabeiti Expires May 12, 2006 [Page 14] Internet-Draft XBE32 Binary Encoding November 2005 In order to cope with this requirement, XBE32 allows Extensible Elements. This kind of XBE32 Elements are not identified by their Type field but they employ a Complex TLV including an initial TLV with its identifier Value. After that identifier TLV, it may contain zero or more inner TLVs with the specified Values (in the case of an Extensible Attribute Element) of sub-elements (if the Extensible Element is a Complex one). All the TLV's Types with the Meta field set to 0x0, Value Type bits set to 00, and the Subtype field set to 0xFF are reserved for Extensible Element TLVs and MUST not be employed for other purposes. Note that C and E bits may have any value, and therefore up to four different Extensible Elements could be defined. For example, an optional Complex Element that should not notified if unknown, will have the 0x0CFF Type Value. Meta Subtype Description ---- ------- ---------------------- 0x00 0xFF Extensible Element TLV A XBE32 Extensible Element MUST have an identifier, which can be a human-readable UTF-8 string called "Name" or an opaque sequence of octets called "Identifier". XBE32 has reserved two single-value TLVs to carry those identifiers: Type TLV Description ------ --------------------------------- 0x05FF Extensible Element Name TLV 0x10FF Extensible Element Identifier TLV The Extensible Element Name TLV Value MUST be a non-empty string encoded in UTF-8. The Extensible Element Identifier TLV Value MUST be 4 octets long. 4.3 Extensible Complex Elements An Extensible Complex Element is a XBE32 Extensible Element TLV containing an Extensible Element Name TLV or an Extensible Element Identifier TLV, followed by zero or more XBE32 Elements that could be Simple or Extensible ones, Attributes or Complex ones, or any combination of them. Extensible Complex Elements are identified by a Name or an Identifier TLV Value. Therefore the first TLV inside the Extensible Complex Element TLV MUST be a Extensible Element Name TLV (Type=0x05FF) or a Extensible Element Identifier TLV (Type=0x10FF). Therefore, although the Type field of the Extensible Complex Element TLV must not be employed to identify the Complex Element, its C and E bits are fully Uruena & Larrabeiti Expires May 12, 2006 [Page 15] Internet-Draft XBE32 Binary Encoding November 2005 meaningful, and SHOULD be employed to identify which actions must be taken if the processing entity does not recognize this Element. 4.4 Extensible Attribute Elements An Extensible Attribute Element is very similar to an Extensible Complex Element, as it is a XBE32 Extensible Element TLV containing an Extensible Element Name TLV or an Extensible Element Identifier TLV, but it does not include other XBE32 Elements, but one or more special TLVs carrying the attribute Values. As the Extensible Complex Elements, Extensible Attributes TLVs MUST be identified by a Extensible Element Name or Identifier TLV, that MUST be the first TLV inside the Attribute complex TLV. But, also as in the Complex case, the C and E bits of the Attribute Extensible Element TLV MUST be considered instead of the corresponding bits of the Name/Id TLV when the Attribute Element is unknown for the parsing entity. After the Extensible Element Name/Identifier TLV there MUST be one of the following TLVs, that carry the Attribute Values: Type TLV Description ------ ------------------------------------ 0x0400 Extensible Attribute opaque Value 0x0500 Extensible Attribute string Value 0x0800 Extensible Attribute opaque1 Values 0x0900 Extensible Attribute int8 Values 0x0A00 Extensible Attribute boolean Values 0x0C00 Extensible Attribute opaque2 Values 0x0D00 Extensible Attribute int16 Values 0x1000 Extensible Attribute opaque4 Values 0x1100 Extensible Attribute int32 Values 0x1200 Extensible Attribute float32 Values 0x1400 Extensible Attribute opaque8 Values 0x1500 Extensible Attribute int64 Values 0x1600 Extensible Attribute float64 Values 0x1800 Extensible Attribute opaque12 Values 0x1C00 Extensible Attribute opaque16 Values Therefore the complex TLV of an Extensible Attribute Element MUST contain only two TLVs: an Extensible Element Identifier/Name TLV to identify the Attribute first, followed by a single Extensible Attribute Value TLV from the above list, depending on the Attribute's Value type. Uruena & Larrabeiti Expires May 12, 2006 [Page 16] Internet-Draft XBE32 Binary Encoding November 2005 5. Acknowledgements We would like to thank Miguel Fernandez and Roy T. Fielding for their valuable comments. 6. References [1] Bradner, S., "Key words for use in RFCs to Indicate Requirement Levels", BCP 14, RFC 2119, March 1997. [2] Yergeau, F., "UTF-8, a transformation format of ISO 10646", RFC 2279, January 1998. [3] Institute of Electrical and Electronics Engineers, "Standard for Binary Floating-Point Arithmetic", IEEE Standard 754, August 1985. Authors' Addresses Manuel Uruena Universidad Carlos III de Madrid Av. Universidad 30 Leganes, Madrid 28911 ES Phone: +34 91 624 87 47 Email: muruenya@it.uc3m.es David Larrabeiti Universidad Carlos III de Madrid Av. Universidad 30 Leganes, Madrid 28911 ES Phone: +34 91 624 99 53 Email: dlarra@it.uc3m.es Uruena & Larrabeiti Expires May 12, 2006 [Page 17] Internet-Draft XBE32 Binary Encoding November 2005 Appendix A. XBE32 Examples 123456789 AUTH_ERROR Invalid Password en 0 1 2 3 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Type = 0x0001 (error) | Length = 0x0000 (unspecified) | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Type = 0x1101 (code) | Length = 8 | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | 0x07 | 0x5B | 0xCD | 0x15 | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Type = 0x0501 (name) | Length = 14 | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | 'A' | 'U' | 'T' | 'H' | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | '_' | 'E' | 'R' | 'R' | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | 'O' | 'R' | 0x00 | 0x00 | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Type = 0x0002 (desc) | Length = 32 | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Type = 0x0502 (text) | Length = 20 | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | 'I' | 'n' | 'v' | 'a' | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | 'l' | 'i' | 'd' | ' ' | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | 'P' | 'a' | 's' | 's' | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | 'w' | 'o' | 'r' | 'd' | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Type = 0x0503 (lang) | Length = 6 | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | 'e' | 'n' | 0x00 | 0x00 | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Type = 0x0000 (End-of-data) | Length = 4 | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ Uruena & Larrabeiti Expires May 12, 2006 [Page 18] Internet-Draft XBE32 Binary Encoding November 2005 Alice 2e2312c1-4f8d-431d-ac6e-500880b42e2c, 0399eac8-69ac-4ee6-95df-9f72d128f33a 0 1 2 3 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Type = 0x00FF (user) | Length = 24 | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Type = 0x10FF | Length = 8 | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | 0x01 | 0x00 | 0x00 | 0x01 | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Type = 0x0500 | Length = 9 | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | 'A' | 'l' | 'i' | 'c' | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | 'e' | 0x00 | 0x00 | 0x00 | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Type = 0x00FF (ids) | Length = 48 | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Type = 0x05FF | Length = 7 | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | 'i' | 'd' | 's' | 0x00 | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Type = 0x1C00 | Length = 36 | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | 0x2E | 0x23 | 0x12 | 0xC1 | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | 0x4F | 0x8D | 0x43 | 0x1D | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | 0xAC | 0x6E | 0x50 | 0x08 | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | 0x80 | 0xB4 | 0x2E | 0x2C | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | 0x03 | 0x99 | 0xEA | 0xC8 | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | 0x69 | 0xAC | 0x4E | 0xE6 | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | 0x95 | 0xDF | 0x9F | 0x72 | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | 0xD1 | 0x28 | 0xF3 | 0x3A | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ Uruena & Larrabeiti Expires May 12, 2006 [Page 19] Internet-Draft XBE32 Binary Encoding November 2005 Intellectual Property Statement The IETF takes no position regarding the validity or scope of any Intellectual Property Rights or other rights that might be claimed to pertain to the implementation or use of the technology described in this document or the extent to which any license under such rights might or might not be available; nor does it represent that it has made any independent effort to identify any such rights. Information on the procedures with respect to rights in RFC documents can be found in BCP 78 and BCP 79. Copies of IPR disclosures made to the IETF Secretariat and any assurances of licenses to be made available, or the result of an attempt made to obtain a general license or permission for the use of such proprietary rights by implementers or users of this specification can be obtained from the IETF on-line IPR repository at http://www.ietf.org/ipr. The IETF invites any interested party to bring to its attention any copyrights, patents or patent applications, or other proprietary rights that may cover technology that may be required to implement this standard. Please address the information to the IETF at ietf-ipr@ietf.org. Disclaimer of Validity This document and the information contained herein are provided on an "AS IS" basis and THE CONTRIBUTOR, THE ORGANIZATION HE/SHE REPRESENTS OR IS SPONSORED BY (IF ANY), THE INTERNET SOCIETY AND THE INTERNET ENGINEERING TASK FORCE DISCLAIM ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTY THAT THE USE OF THE INFORMATION HEREIN WILL NOT INFRINGE ANY RIGHTS OR ANY IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Copyright Statement Copyright (C) The Internet Society (2005). This document is subject to the rights, licenses and restrictions contained in BCP 78, and except as set forth therein, the authors retain all their rights. Acknowledgment Funding for the RFC Editor function is currently provided by the Internet Society. Uruena & Larrabeiti Expires May 12, 2006 [Page 20]