Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Tommy Olofsson
LabComm
Commits
6a6c1b11
Commit
6a6c1b11
authored
Jan 10, 2015
by
Sven Gestegård Robertz
Browse files
updated grammar appendix
parent
44279f2c
Changes
1
Hide whitespace changes
Inline
Side-by-side
doc/tech_report.tex
View file @
6a6c1b11
...
@@ -289,6 +289,7 @@ With the following `example.lc` file:
...
@@ -289,6 +289,7 @@ With the following `example.lc` file:
and this
\verb
+
example_encoder.c
+
file
and this
\verb
+
example_encoder.c
+
file
\lstinputlisting
[basicstyle=\footnotesize,language=C]
{
../examples/wiki
_
example/example
_
encoder.c
}
\lstinputlisting
[basicstyle=\footnotesize,language=C]
{
../examples/wiki
_
example/example
_
encoder.c
}
\newpage
Running
\verb
+
./example_encoder one two
+
, will yield the following result in example.encoded:
Running
\verb
+
./example_encoder one two
+
, will yield the following result in example.encoded:
\begin{verbatim}
\begin{verbatim}
...
@@ -306,7 +307,9 @@ Running \verb+./example_encoder one two+, will yield the following result in exa
...
@@ -306,7 +307,9 @@ Running \verb+./example_encoder one two+, will yield the following result in exa
i.e.,
i.e.,
\begin{verbatim}
\begin{verbatim}
<version> <length: 12> <string: <len: 11> <"LabComm2014">>
<version> <length: 12> <string: <len: 11> <"LabComm2014">>
<sample
_
decl> <length: 48 <user
_
id: 0x40> <string: <len: 11> <"log
_
message">
<sample
_
decl> <length: 48
<user
_
id: 0x40>
<string: <len: 11> <"log
_
message">
<signature
_
length: 34>
<signature
_
length: 34>
<struct
_
decl:
<struct
_
decl:
<number
_
of
_
fields: 2>
<number
_
of
_
fields: 2>
...
@@ -379,37 +382,25 @@ VariableSize : Exp;
...
@@ -379,37 +382,25 @@ VariableSize : Exp;
\section
{
The LabComm protocol
}
\section
{
The LabComm protocol
}
\label
{
sec:ProtocolGrammar
}
\label
{
sec:ProtocolGrammar
}
Each LabComm2014 packet has the layout
\begin{verbatim}
<id> <length> <data...>
\end{verbatim}
where
\verb
+
length
+
is the number of bytes of the
\verb
+
data
+
part
(i.e., excluding the
\verb
+
id
+
and
\verb
+
length
+
fields), and
the
\verb
+
id
+
gives the layout of the
\verb
+
data
+
part as defined
in
\ref
{
sec:ConcreteGrammar
}
\subsection
{
Data encoding
}
LabComm primitive types are encoded as fixed width values, sent in
network order. Type fields, user IDs, number of indices and lengths are
sent in a variable length (
\emph
{
varint
}
) form. A varint integer value
is sent as a sequence of bytes where the lower seven bits contain a
chunk of the actual number and the high bit indicates if more chunks
follow. The sequence of chunks are sent with the least significant chunk
first.
The built-in data types are encoded as follows:
\begin{verbatim}
\begin{verbatim}
<packet> := ( <type
_
decl> | <sample
_
decl> | <sample
_
data> )*
<type
_
decl> := 0x01 ''(packed)'' <user
_
id> <string> <type>
<sample
_
decl> := 0x02 ''(packed)''<user
_
id> <string> <type>
<user
_
id> := 0x40..0xffffffff ''(packed)''
<string> := <string
_
length> <char>*
<string
_
length> := 0x00..0xffffffff ''(packed)''
<char> := any UTF-8 char
<type> := ( <basic
_
type> | <user
_
id> | <array
_
decl> | <struct
_
decl> )
<basic
_
type> := ( <boolean
_
type> | <byte
_
type> | <short
_
type> |
<integer
_
type> | <long
_
type> | <float
_
type> |
<double
_
type> | <string
_
type> )
<boolean
_
type> := 0x20 ''(packed)''
<byte
_
type> := 0x21 ''(packed)''
<short
_
type> := 0x22 ''(packed)''
<integer
_
type> := 0x23 ''(packed)''
<long
_
type> := 0x24 ''(packed)''
<float
_
type> := 0x25 ''(packed)''
<double
_
type> := 0x26 ''(packed)''
<string
_
type> := 0x27 ''(packed)''
<array
_
decl> := 0x10 ''(packed)'' <number
_
of
_
indices> <indices> <type>
<number
_
of
_
indices> := 0x00..0xffffffff ''(packed)''
<indices> := ( <variable
_
index> | <fixed
_
index> )*
<variable
_
index> := 0x00 ''(packed)''
<fixed
_
index> := 0x01..0xffffffff ''(packed)''
<struct
_
decl> := 0x11 ''(packed)'' <number
_
of
_
fields> <field>*
<number
_
of
_
fields> := 0x00..0xffffffff ''(packed)''
<field> := <string> <type>
<sample
_
data> := <user
_
id> <packed
_
sample
_
data>
<packed
_
sample
_
data> := is sent in network order, sizes are as follows:
||Type ||Encoding/Size ||
||Type ||Encoding/Size ||
||---------------||------------------------------------------------------||
||---------------||------------------------------------------------------||
||boolean || 8 bits ||
||boolean || 8 bits ||
...
@@ -419,18 +410,46 @@ VariableSize : Exp;
...
@@ -419,18 +410,46 @@ VariableSize : Exp;
||long || 64 bits ||
||long || 64 bits ||
||float || 32 bits ||
||float || 32 bits ||
||double || 64 bits ||
||double || 64 bits ||
||string || length
''(packed)''
, followed by UTF8 encoded string ||
||string || length
(varint)
, followed by UTF8 encoded string
||
||array || each variable index
''(packed)'',
||
||array || each variable index
(varint),
||
|| || followed by encoded elements ||
|| || followed by encoded elements ||
||struct || concatenation of encoding of each element ||
||struct || concatenation of encoding of each element ||
|| || in declaration order ||
|| || in declaration order ||
\end{verbatim}
\end{verbatim}
Type fields, user IDs, number of indices and lengths are sent in a packed, or
\subsection
{
Protocol grammar
}
variable length, form. An integer is sent as a sequence of bytes where the
\label
{
sec:ConcreteGrammar
}
lower seven bits contain a chunk of the actual number and the high bit
\begin{verbatim}
indicates if more chunks follow. The sequence of chunks are sent with the least
<packet> := ( <version> | <type
_
decl> | <sample
_
decl> | <sample
_
data> )*
significant chunk first. (The numbers encoded in this form are indicated above
<version> := 0x01 <length> <string>
with
\textit
{
(packed)
}
.)
<sample
_
def> := 0x02 <length> <user
_
id> <string> <type>
<type
_
def> := 0x03 <length> <user
_
id> <string> <type>
<user
_
id> := 0x40..0xffffffff
<string> := <string
_
length> <char>*
<string
_
length> := 0x00..0xffffffff
<char> := any UTF-8 char
<type> := <length> ( <basic
_
type> | <user
_
id> | <array
_
decl> | <struct
_
decl> )
<basic
_
type> := ( <boolean
_
type> | <byte
_
type> | <short
_
type> |
<integer
_
type> | <long
_
type> | <float
_
type> |
<double
_
type> | <string
_
type> )
<boolean
_
type> := 0x20
<byte
_
type> := 0x21
<short
_
type> := 0x22
<integer
_
type> := 0x23
<long
_
type> := 0x24
<float
_
type> := 0x25
<double
_
type> := 0x26
<string
_
type> := 0x27
<array
_
decl> := 0x10 <number
_
of
_
indices> <indices> <type>
<number
_
of
_
indices> := 0x00..0xffffffff
<indices> := ( <variable
_
index> | <fixed
_
index> )*
<variable
_
index> := 0x00
<fixed
_
index> := 0x01..0xffffffff
<struct
_
decl> := 0x11 <number
_
of
_
fields> <field>*
<number
_
of
_
fields> := 0x00..0xffffffff
<field> := <string> <type>
<sample
_
data> := <user
_
id> <packed
_
sample
_
data>
<packed
_
sample
_
data> := is sent in network order, encoded :
\end{verbatim}
\end{document}
\end{document}
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment