Everything Counts in Small Amounts

Everything Counts in Small Amounts

View metadata, citation and similar papers at core.ac.uk brought to you by CORE provided by UWL Repository Everything counts in small amounts John P. T. Moore, Thames Valley University, UK, [email protected] Abstract stract syntax to binary. The abstract syntax allows the pro- tocol designer to think at a higher level and provides a com- This paper describes an encoding tool which utilises mon ground between application developers working in dif- the ”data is code” principle of symbolic expressions avail- ferent programming languages. Google’s Protocol Buffers1 able in Lisp-like languages to allow the scripting of tightly- adopts a similar approach where the abstract syntax used to packed, cross-platform network protocols. This dynamic describe a message is transformed into classes together with approach provides specific flexibility when working on em- methods to set, query and encode the data. bedded systems as it reduces the amount of cross compi- In this paper we describe Packedobjects [7], a tool which lation and deploy cycles that occur following more tradi- takes a more dynamic approach. Packedobjects uses s- tional development approaches. In addition, the separation expressions from the Scheme programming language to ex- of how the data is encoded from the compiled application ploit the concept of ”data is code” and therefore bypasses facilitates a concept known as extensibility of the network the need for code generation. In keeping with a minimalist protocol without requiring special handling. tradition adopted by Scheme, Packedobjects uses a simpli- fied subset of the ASN.1 standard when describing proto- cols. By simplifying the abstract syntax we can provide 1 Introduction a dynamic runtime representation within an s-expression which encourages exploration in the Read-Eval-Print-Loop (REPL). Serialising data structures for transmission across a network A novel aspect of the tool originates from its foundations is a common technique. The programmer might have to as an extension language. In the following sections we will handle differences in byte ordering if communication takes introduce this concept and also explain how this supports place across different hardware platforms. In addition, the a feature such as extensibility. The remaining sections of protocol designer is restricted to describing the network the paper will describe the language used by Packedobjects protocol in terms of the native data structures available in as well as illustrate the encoding process. Finally we will the language used. Although languages such as Erlang pro- present a simple example, describe some challenges and vide excellent support for working with binary data [1], an then conclude. alternative more abstract approach is often taken. Describing network protocols in a way that is indepen- dent of the application programming language used intro- 2 Extension language duces some complexity. Ultimately this abstract syntax will need to be represented by the programming language. The Packedobjects is available2 as a module for GNU Guile traditional way of handling this is not dynamic and involves which in turn is available3 as a C library. By linking with code generation. A compiler is used to transform the ab- this library you gain access to a Scheme interpreter which stract syntax into native language code. Typically the code amongst other things will allow manipulation of structured generated will be combined with application specific code data in the form of symbolic expressions (s-expressions). and linked with vendor supplied code. This is the approach This approach of embedding an interpreter allows a sepa- of Abstract Syntax Notation One (ASN.1) [2] which origi- ration of the network code and the compiled C program. nates from the world of telecommunications. The philoso- Being able to script a binary protocol means we can dy- phy of ASN.1 is to provide a rich abstract syntax to describe namically alter its structure without the need to recompile network protocols and this syntax should be transferred into 1http://code.google.com/apis/protocolbuffers/ binary before transmission. Different techniques, or encod- 2http://gitorious.org/packedobjects/ 3 ing rules, can be applied to make this transition from ab- http://www.gnu.org/software/guile/ Proceedings of SIMPAR 2010 Workshops Intl. Conf. on SIMULATION, MODELING and PROGRAMMING for AUTONOMOUS ROBOTS Darmstadt (Germany) November 15-16, 2010 ISBN 978-3-00-032863-3 pp. 278-283 the main program. This facilitates a development cycle to indicate the likelihood that specific parts of the specifi- which reduces the amount of cross compilation that would cation will be extended and then encode some extra struc- be required for an embedded device if we exclusively used ture to facilitate this [3]. Packedobjects does not require the traditional programming languages such as C and C++. this. What is required is that both parties obtain the same Often, the traditional methods which require a compiler to version-2 protocol. In this case, even though party A will transform an abstract syntax into program code are untested never use message-C, it can still receive the message and in cross compilation environments and therefore may not can choose to silently ignore it. The party A program does work. In addition to this added flexibility we also obtain a not need to be recompiled because the protocol is available degree of extensibility of the network protocol. via a Scheme script which can be dynamically loaded or bootstrapped over a simple HTTP request. This provides a 3 Extensibility more stable upgrade option for deployed devices allowing them to continue working with restricted functionality until a software upgrade can be authorised by the user. The abil- The concept of extensibility can be confusing, especially to ity to maintain communication across mass-deployed de- those who have worked exclusively with text-based network vices can be a key goal in the domain of embedded commu- protocols that highly structure the data they communicate. nication technologies. Having introduced some of the novel With this extra structure comes flexibility. It allows an ap- aspects of the tool we will now describe the language used. plication to receive a message and silently ignore parts of the message it does not understand or recognise. XML is a good example of a technology which facilitates this ap- 4 Integer Encoding Rules proach. The structure or tags placed around the data within the message provide all the information required to under- The domain specifc language (DSL)4 used by stand the real payload. This approach is in direct conflict Packedobjects consists of two categories of data type: for a protocol designer who strives to minimise every bit atomic and compound. An atomic data type specifies a of information communicated. Although binary protocols single value to be encoded whereas a compound data type can still follow a similar tag based approach it is common consists of one or more atomic and/or compound data to try and further optimise the solution so only the mini- types. The compound data types include the various se- mal amount of data required to be decoded successfully is quence types and the choice type. The process of encoding actually communicated. The challenge is producing binary types involves combining a protocol and some data and protocols which are not fragile or easily broken by simple transforming this into an integer form. The integer form is changes in the protocol definition. This future proof de- then transformed into a core form before being supplied sign approach is known as extensibility. Thus, extensibility to the low-level encoder [6]. In the following subsections refers to the way that network communications can continue we will describe the transformation which we call Integer between parties A and B even though party B may have Encoding Rules. The integer form can be summarised as updated the way it communicates. The following will illus- follows trate a simple example. Party A uses the following protocol: (integer (range x y) n) (define protocol-version-1 x y n ’(foo choice where and restrict the range of values may take. We (message-A boolean) can then determine whether we need to encode signed or (message-B boolean))) unsigned values and how many bits are required to encode this range. The resulting core form can be expressed as Party B updates its protocol to the following: (or (signed (bits z) n) (define protocol-version-2 (unsigned (bits z) n)) ’(foo choice (message-A boolean) where we show a choice between the signed and unsigned (message-B boolean) representation and z which represents the number of bits (message-C boolean))) required to encode value n. Integers may be unconstrained, semi-constrained or con- At this point parties A and B may produce incompatible en- strained. All unconstrained and semi-constrained integers codings. For example, it is not possible for party B to com- require a length encoding to represent the number of bytes municate message-C with party A because party A has no required to encode the value. In the following subsections knowledge of such a message. Party A would be expecting we will first describe length encoding and then show by ex- an encoding based on a choice between 2 messages. Encod- ample how other types are handled. ing standards such as Packed Encoding Rules (PER) handle 4 this situation using special notation in the protocol syntax http://zedstar.org/packedobjects/#Protocol-grammar Proceedings of SIMPAR 2010 Workshops Intl. Conf. on SIMULATION, MODELING and PROGRAMMING for AUTONOMOUS ROBOTS Darmstadt (Germany) November 15-16, 2010 ISBN 978-3-00-032863-3 pp. 278-283 4.1 Length encoding bound restricts the size of the value we encode. The off- set result will always be positive and is therefore encoded Values are encoded within 8, 16 or 32 bit ranges.

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    6 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us