# Improvements of the xAAL Home Automation System
## 5 The xAAL Communication Protocol
### Changes in the xAAL Communication Protocol  
As in previous versions, xAAL messages are carried on an IP multicast bus (IPv4 or IPv6). Messages are still made of two layers: a _Security Layer_ that encapsulates an _Application Layer_. Data fields, the associated semantic and behaviors are the same. The novelty is that data are now serialized in CBOR [12; 33]. For instance, instead of JSON objects, one may use the CBOR map. Also, instead of using the textual representation of UUID (RFC 4122), one now uses its binary representation as a CBOR definite byte string of 16 bytes. JSON was a fine message format for prototyping xAAL. As a textual format, this greatly has helped developers to diagnose issues. Now xAAL has grown in maturity. Moreover, since a former xAAL version has brought ciphering of messages, keeping a textual format is no longer of interest. CBOR brings compactness (xAAL messages are now about three times smaller), but its main advantage since xAAL has ciphered data is that CBOR can manage byte string properly (i.e., without base64 encoding onto a textual string, as JSON does). CBOR has many other concurrent binary coding formats. Appendix E of RFC 7049 provides a brief comparison. Not surprisingly, this technical comparison is positive for CBOR. Another argument in favor of CBOR is that CBOR is a published standard. Maps vs. Arrays  
JSON is deeply linked to the JavaScript programming language and inherits some of its concepts: object-oriented, dynamic typing, etc. Within the JSON community, data is frequently organized into so-called objects data structures (also called maps, associative arrays, or dictionaries, depending on programming language vocabulary). So that, each piece of data is associated with a name, which, if well chosen, may make sense in the head of other developers of the community, bringing a kind of intuitive semantic. This is one of the reasons why JSON is said a _self-describing_ format. (The other reason is about the serialization/serialization point of view: thanks to punctuation marks and syntactic salt, the format of strings carries enough information to decode bytes into data types of usual programming languages without any other specification document.) Within the CBOR community, habits slightly differ. Maybe due to its binary basement, developers prefer array structures, used as _struct_ in C programming language. However, associative maps are also available: it is still useful to associate well-chosen names to data items. Moreover, CBOR provides another means to give semantic to data in a more formal way: data items may be tagged with a number that refers either a standardized tag or an application-specific tag. (Note that CBOR is also said a _self-describing_ format from the serialization/serialization point of view: the format carries enough information to decode bytes into data types of usual programming languages without any other specification document.) In conclusion, the new xAAL version chose to use array structures for its Security Layer and its Application Layer. There are no more keywords associated with data items for these two layers. Data items are provided in a strict order, in a strict way. Messages are even shorter, and this brings simplicity for receivers, without so much complexity for senders. Moreover, there are no CBOR Tags in these two low-level layers. xAAL nodes already must know those layers format, there is no need to carry tags for the meaning of fields. Figure 5: The decrypted payload of an xAAL message (_Application Layer_). Definite vs. Indefinite Data Structures  
CBOR data containers (maps, array, strings, byte strings) are proposed in two variants: definite (with a predefined size), and indefinite (the container is open at the beginning, items follow in sequence, the container is closed on reception of a special end mark). Both variants have pros and cons, with a balance between the complexity of the sender versus the complexity of the receiver. Indefinite data containers are fine for streaming data on the fly.