• Existing tools with built in support for editing
Scheme can be used, such as Emacs.
• The Scheme language can be used to provide error
handling and reporting.
• The use of quasi-quote can provide a mecha-
nism for replicating user-defined abstract types in
ASN.1.
• Other language features such as comments can eas-
ily be added to the specification.
The disadvantage of applying such a dynamic ap-
proach is the loss of runtime performance. However,
by using a practical subset of ASN.1 the amount of
processing that is required can be constrained.
2 ENCODING RULES
ASN.1 provides notation for defining abstract values
which carry information. Applying encoding rules to
an abstract syntax produces a series of bits ready for
network transmission. Various encoding rules have
been defined, including variants within encoding rules
themselves (Mitra, 1994). A clear advantage exists
when separating the way in which information is rep-
resented on a communications link from the abstract
syntax used to describe the information. Depending
on the nature of the application, different encoding
rules may be selected without requiring any change
to the protocol specification. It therefore may be pos-
sible to exploit advancements made in encoding tech-
niques over the years.
-- Baseball Card Abstract Syntax (BCAS)
BCAS DEFINITIONS ::= BEGIN
BBCard ::= SEQUENCE {
name IA5String (SIZE (1..60)),
team IA5String (SIZE (1..60)),
age INTEGER (1..100),
position IA5String (SIZE (1..60)),
handedness ENUMERATED {
left-handed(0),
right-handed(1),
ambidextrous(2)},
batting-average REAL
}
myCard BBCard ::= {
name "Casey",
team "Mudville Nine",
age 32,
position "left field",
handedness ambidextrous,
batting-average {
mantissa 250,
base 10,
exponent -3}
}
END
The above code is an example of how ASN.1 can be
used to describe a baseball score card. The specifi-
cation is given with corresponding values. Although
some notation is unique to the standard, it is fairly in-
tuitive. Indeed, it can be useful as a means of sim-
ply communicating a protocol in a verbal or writ-
ten sense between application developers. The lan-
guage provides a set of atomic and composite types.
The example provided is comprised of the atomic
types ’IA5String’, ’INTEGER’, ’ENUMERATED’
and ’REAL’ together with the composite type ’SE-
QUENCE’. The composite types are a collection of
one or more atomic and/or composite types. To trans-
form this abstract syntax into a concise bit stream we
can apply PER. A PER specification may use visi-
ble subtype constraints to optimise the encoding. In
the example, constraints are placed on the size of the
’IA5String’ and ’INTEGER’ type. Subtyping is a
powerful mechanism to restrict the set of values that
may be allowed for a given type (ITU-T, 1988a). Typ-
ically, subtyping is used to restrict the allowable range
of an integer type, provide a maximum and/or mini-
mum size for the length of a string, and place bounds
on the number of iterations that may occur in a ’SE-
QUENCE OF’ or ’SET OF’ type. The ability to cus-
tomise data types produces efficient PER encodings.
Not only are less bits sent across the communications
link but also more optimised encoder/decoder imple-
mentations can be built to handle specific protocols.
3 PACKEDOBJECTS
packedobjects is an open source project implemented
in Chicken Scheme (Winkelmann, 2006) and the C
programming language. The software has been made
available (Moore, 2006) under the BSD license. Cur-
rently the project uses Chicken as its host language,
although it is possible to embed Chicken within C
and therefore use C as the host language
1
. Scheme
is used to provide all the high level data handling rou-
tines while C provides all the low level bit manipu-
lation. The project is highly portable. Chicken has
been ported to numerous platforms and the C code
conforms to the ANSI standard.
One of the motives of the project was to allow
prototyping and development on embedded hardware.
The user has the choice of working within the inter-
preter or compiling the code. Using the interpreter
provides a simple method for designing and testing
protocol specifications on embedded hardware with-
out the need to cross compile. packedobjects has been
successfully tested on a handheld device running em-
bedded Linux.
1
The term ”host language” is used to indicate the lan-
guage the developer would be using.