Debian Codegraph @

texmf-dist/doc/latex/bytefield/bf-example.tex

raw
1 \documentclass[11pt]{article}
2 \usepackage[margin=1in]{geometry}
3 \usepackage{longtable}
4 \usepackage[bitheight=6ex]{bytefield}
5 \usepackage{color}
6 \usepackage[bookmarksopen=true]{hyperref}
7
8 \title{Integrating \texttt{bytefield} and \texttt{hyperref}}
9 \author{\href{http://www.pakin.org/~scott}{Scott Pakin
10 \texttt{<[email protected]>}}}
11 \date{18 January 2011}
12 \hypersetup{%
13 pdftitle={Integrating bytefield and hyperref},
14 pdfauthor={Scott Pakin <[email protected]>},
15 pdfsubject={Example of bytefield package},
16 pdfkeywords={bytefield, hyperref, multicast transport protocol, hyperlink, example}}
17
18 % Set up hyperlink colors
19 \definecolor{darkred}{rgb}{0.5,0,0}
20 \definecolor{darkgreen}{rgb}{0,0.3,0}
21 \definecolor{darkblue}{rgb}{0,0,0.5}
22 \definecolor{darkbrown}{rgb}{0.28,0.07,0.07}
23 \hypersetup{%
24 colorlinks=true,
25 citecolor=darkblue,
26 urlcolor=darkgreen,
27 linkcolor=darkred,
28 menucolor=darkbrown}
29
30 \begin{document}
31 \sloppy
32 \maketitle
33
34 \begin{abstract}
35 This document is a demonstration of how the \texttt{bytefield} package can
36 integrate seamlessly with \texttt{hyperref}. The text that follows was
37 copy-and-pasted from
38 \href{http://www.rfc-editor.org/rfc/rfc1301.txt}{RFC~1301, ``Multicast
39 Transport Protocol''}~\cite{Armstrong92}.
40
41 The important thing to note is the way the fields in the protocol diagrams
42 (drawn with \texttt{bytefield}) are hyperlinked to their descriptions (with
43 \texttt{hyperref}). Few typesetting systems enable authors to specify
44 hyperlinks from within a figure to the surrounding text. Fewer still do
45 not require hyperlinks to be re-specified when the figure changes.
46 \texttt{bytefield}~+ \texttt{hyperref} can do both.
47 \end{abstract}
48
49 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
50
51 \setcounter{section}{1}
52
53 \section{Protocol description}
54
55 MTP is a transport in that it is a client of the network layer (as
56 defined by the OSI networking model).\footnote{The network layer is not
57 specified by MTP. One of the goals is to specify a transport that can be
58 implemented with equal functionality on many network architectures.}
59 MTP provides reliable delivery of client data between one or more
60 communicating processes, as well as a predefined principal process. The
61 collection of processes is called a web.
62
63 In addition to transporting data reliably and efficiently, MTP
64 provides the synchronization necessary for web members to agree on
65 the order of receipt of all messages and can agree on the delivery of
66 the message even in the face of partitions. This ordering and
67 agreement protocol uses serialized tokens granted by the master to
68 producers.
69
70 The processes may have any one of three levels of capability. One
71 member must be the master. The master instantiates and controls the
72 behavior of the web, including its membership and performance. Non
73 master members may be either producer/consumers or pure consumers.
74 The former class of member is permitted to transmit user data to the
75 entire membership (and expected to logically hear itself), while the
76 latter is prohibited from transmitting user data.
77
78 MTP is a negative acknowledgement protocol, exploiting the highly
79 reliable delivery of the local area and wide area network
80 technologies of today. Successful delivery of data is accepted by
81 consuming stations silently rather than having the successful
82 delivery noted to the producing process, thus reducing the amount of
83 reverse traffic required to maintain synchronization.
84
85 \subsection{Definition of terms}
86
87 \begin{center}
88 \fbox{Skipped; see~\cite{Armstrong92}}
89 \end{center}
90
91 \subsection{Packet format}
92
93 An MTP packet consists of a transport protocol header followed by a
94 variable amount of data. The protocol header, shown in
95 Figure~\ref{fig:packet-format}, is part of every packet. The remainder
96 of the packet is either user data (packet type = data) or additional
97 transport specific information. The fields in the header are statically
98 defined as n-bit wide quantities. There are no undefined fields or
99 fields that may at any time have undefined values. Reserved fields, if
100 they exist, must always have a value of zero.
101
102 \begin{figure}[htbp]
103 \centering
104 \begin{bytefield}{32}
105 \bitheader{0,7-8,15-16,23-24,31} \\
106
107 \begin{rightwordgroup}{transport \\ header}
108 % We have to do the \parbox explicitly in the next line because
109 % \hyperlink typesets its argument in horizontal mode.
110 \bitbox{8}{\hyperlink{protocol-version}{\parbox{\width}{\centering protocol version}}} &
111 \bitbox{8}{\hyperlink{packet-type-modifier}{packet type}} &
112 \bitbox{8}{\hyperlink{packet-type-modifier}{type modifier}} &
113 \bitbox{8}{\hyperlink{subchannel}{client channel}} \\
114
115 \wordbox{1}{\hyperlink{source-connect}{source connection identifier}} \\
116
117 \wordbox{1}{\hyperlink{dest-connect}{destination connection identifier}} \\
118
119 \wordbox{1}{\hyperlink{msg-accept}{message acceptance criteria}} \\
120
121 \wordbox{1}{\hyperlink{heartbeat}{heartbeat}} \\
122
123 \bitbox{16}{\hyperlink{window}{window}} &
124 \bitbox{16}{\hyperlink{retention}{retention}}
125 \end{rightwordgroup} \\
126
127 \begin{rightwordgroup}{data \\ fields}
128 \wordbox[lrt]{1}{%
129 \parbox{0.6\width}{\centering (data content and format dependent on packet type and modifier)}} \\
130 \skippedwords \\
131 \wordbox[lrb]{1}{}
132 \end{rightwordgroup}
133 \end{bytefield}
134 \caption{MTP packet format}
135 \label{fig:packet-format}
136 \end{figure}
137
138 \hypertarget{protocol-version}{\subsubsection{Protocol version}}
139
140 The first 8 bits of the packet are the protocol version number. This
141 document describes version 1 of the Multicast Transport Protocol and
142 thus the version field has a value of 0x01.
143
144 \hypertarget{packet-type-modifier}{\subsubsection{Packet type and modifier}}
145
146 The second byte of the header is the packet type and the following
147 byte contains the packet type modifier. Typical control message
148 exchanges are in a request/response pair. The modifier field
149 simplifies the construction of responses by permitting reuse of the
150 incoming message with minimal modification. The following table gives
151 the packet type field values along with their modifiers. The
152 modifiers are valid only in the context of the type. In the prose of
153 the definitions and later in the document, the syntax for referring
154 to one of the entries described in the following table will be
155 type[modifier]. For example, a reference to data[eow] would be a
156 packet of type data with an end of window modifier.
157
158 \begin{center}
159 \renewcommand{\arraystretch}{1.5}
160 \begin{longtable}{llp{0.6\textwidth}}
161 type & modifier & description \\ \hline
162
163 data(0) & data(0) & The packet is one that contains user
164 information. Only the process possessing a
165 transmit token is permitted to send data
166 unless specifically requested to retransmit
167 previously transmitted data. All packets of
168 type data are multicast to the entire web. \\
169
170 & eow(1) & A data packet with the eow (end of window)
171 modifier set indicates that the transmitter
172 intends to send no more packets in this
173 heartbeat either because it has sent as many
174 as permitted given the window parameter or
175 simply has no more data to send during the
176 current heartbeat. This is not client
177 information but rather a hint to be used by
178 transport providers to synchronize the
179 computation and transmission of naks. \\
180
181 & eom(2) & Data[eom] marks the end of the message to the
182 consumers, and the surrendering of the
183 transmit token to the master. And like a
184 data[eow] a data[eom] packet implies the end
185 of window. \\
186 nak(1) & request(0) & A nak[request] packet is a consumer
187 requesting a retransmission of one or more
188 data packets. The data field contains an
189 ordered list of packet sequence numbers that
190 are being requested. Naks of any form are
191 always unicast. \\
192
193 & deny(1) & A nak[deny] message indicates that the
194 producer source of the nak[deny]) cannot
195 retransmit one or more of the packets
196 requested. The process receiving the
197 nak[deny] must report the failure to its
198 client. \\
199
200 empty(2) & dally(0) & An empty[dally] packet is multicast to
201 maintain synchronization when no client data
202 is available. \\
203
204 & cancel(1) & If a producer finds itself in possession of a
205 transmit token and has no data to send, it
206 may cancel the token[request] by multicasting
207 an empty[cancel] message. \\
208
209 & hibernate(2)&If the master possesses all of the web's
210 transmit tokens and all outstanding messages
211 have been accepted or rejected, the master
212 may transmit empty[hibernate] packets at a
213 rate significantly slower than indicated by
214 the web's value of heartbeat. \\
215
216 join(3) & request(0) & A join[request] packet is sent by a process
217 wishing to join a web to the web's unknown
218 TSAP (see section~\ref{sec:dest-connect}). \\
219
220 & confirm(1) & The join[confirm] packet is the master's
221 confirmation of the destination's request to
222 join the web. It will be unicast by the
223 master (and only the master) to the station
224 that sent the join[request]. \\
225
226 & deny(2) & A join[deny] packet indicates permission to
227 join the web was denied. It may only be
228 transmitted by the master and will be unicast
229 to the member that sent the join[request]. \\
230
231 quit(4) & request(0) & A quit[request] may be unicast to the master
232 by any member of the web at any time to
233 indicate the sending process wishes to
234 withdraw from the web. Any member may unicast
235 a quit to another member requesting that the
236 destination member quit the web due to
237 intolerable behavior. The master may
238 multicast a quit[request] requiring that the
239 entire web disband. The request will be
240 multicast at regular heartbeat intervals
241 until there are no responses to retention
242 requests. \\
243
244 & confirm(1) & The quit[confirm] packet is the indication
245 that a quit[request] has been observed and
246 appropriate local action has been taken.
247 Quit[confirm] are always unicast. \\
248
249 token(5) & request(0) & A token[request] is a producing member
250 requesting a transmit token from the master.
251 Such packets are unicast to the master. \\
252
253 & confirm(1) & The token[confirm] packet is sent by the
254 master to assign the transmit token to a
255 member that has requested it. token[confirm]
256 will be unicast to the member being granted
257 the token. \\
258
259 isMember(6)&request(0)& An isMember[request] is soliciting
260 verification that the target member is a
261 recognized member of the web. All forms of
262 the isMember packet are unicast to a specific
263 member. \\
264
265 & confirm(1) & IsMember[confirm] packets are positive
266 responses to isMember[requests]. \\
267
268 & deny(2) & If the member receiving the isMember[request]
269 cannot confirm the target's membership in the
270 web, it responds with a isMember[deny].
271 \end{longtable}
272 \end{center}
273
274 \hypertarget{subchannel}{\subsubsection{Subchannel}}
275
276 The fourth byte of the transport header contains the client's
277 subchannel value. The default value of the subchannel field is zero.
278 Semantics of the subchannel value are defined by the transport client
279 and therefore are only applicable to packets of type data. All other
280 packet types must have a subchannel value of zero.
281
282 \hypertarget{source-connect}{\subsubsection{Source connection identifier}}
283
284 The source connection identifier field is a 32 bit field containing a
285 transmitting system unique value assigned at the time the transport
286 is created. The field is used in identifying the particular transport
287 instantiation and is a component of the TSAP\@. Every packet
288 transmitted by the transport must have this field set.
289
290 \hypertarget{dest-connect}{\subsubsection{Destination connection identifier}}
291 \label{sec:dest-connect}
292
293 The destination connection identifier is the 32 bit identifier of the
294 target transport. From the point of view of a process sending a
295 packet, there are three types of destination connection identifiers.
296 First, there is the unknown connection identifier (0x00000000). The
297 unknown value is used only as the destination connection identifier
298 in the join[request] packet.
299
300 Second, there is the multicast connection identifier gleaned from the
301 join[confirm] message sent by the master. The multicast connection
302 identifier is used in conjunction with the multicast NSAP to form the
303 destination TSAP of all packets multicast to the entire
304 web.\footnote{There's only one such multicast connection identifier per
305 web. If there are multiple processes on the same machine participating
306 in a web, the transport must descriminate between those processes by
307 using the connnection identifier.}
308
309 The last class of connection identifier is a unicast identifier and
310 is used to form the destination TSAP when unicasting packets to
311 individual members. Every member of the web has associated with it a
312 unicast connection identifier that is used to form its own unicast
313 TSAP.
314
315 \hypertarget{msg-accept}{\subsubsection{Message acceptance}}
316
317 MTP ensures that all processes agree on which messages are accepted
318 and in what order they are accepted. The master controls this aspect
319 of the protocol by controlling allocation of transmit tokens and
320 setting the status of messages. Once a token for a message has been
321 assigned (see section 3.2.1) the master sets the status of that
322 message according to the following rules~\cite{Armstrong91}:
323
324 \begin{itemize}
325 \item If the master has seen the entire message (i.e., has seen the
326 data[eom] and all intervening data packets), the status is accepted.
327
328 \item If the master has not seen the entire message but believes the
329 message sender is still operational and connected to the master (as
330 determined by the master), the status is pending.
331
332 \item If the master has not seen the entire message and believes the
333 sender to have failed or partitioned away, the status is rejected.
334 \end{itemize}
335
336 Message status is carried in the message acceptance record (see
337 Figure~\ref{fig:msg-accept}) of every packet, and processes learn the
338 status of earlier messages by processing this information.
339
340 The acceptance criteria is a multiple part record that carries the rules
341 of agreement to determine the message acceptance.
342 \hypertarget{synchro}{The most significant 8 bits is a flag that, if not
343 zero, indicates synchronization is required.} The field may vary on a
344 per message basis as directed by producing transport's client. The
345 default is that no synchronization is required.
346
347 \hypertarget{tri-state}{The second part of the record is a 12 element
348 vector that represents the status of the last 12 messages transmitted
349 into the web.}
350
351 \begin{figure}[htbp]
352 \centering
353 \begin{bytefield}{32}
354 \bitheader{0,7-8,15-16,23-24,31} \\
355
356 \bitbox{8}{\hyperlink{synchro}{synchro}} &
357 \bitbox{24}{\hyperlink{tri-state}{tri-state bitmask{[12]}}} \\
358
359 \bitbox{16}{\hyperlink{msg-seq}{message sequence number}} &
360 \bitbox{16}{\hyperlink{packet-seq}{packet sequence number}}
361 \end{bytefield}
362 \caption{Message acceptance record}
363 \label{fig:msg-accept}
364 \end{figure}
365
366 Each element of the array is two bits in length and may have one of
367 three values: accepted(0), pending(1) or rejected(2). Initially, the
368 bit mask is set to all zeros. When the token for message $m$ is
369 transmitted, the first (left-most) element of the vector represents
370 the the state of message $m - 1$, the second element of the vector is
371 the status of message $m - 2$, and so forth. Therefore the status of
372 the last 12 messages are visible, the status of older messages are
373 lost, logically by shifting the elements out of the vector. Only the
374 master is permitted to set the status of messages. The master is not
375 permitted to shift a status of pending beyond the end of the vector.
376 If that situation arises, the master must instead not confirm any
377 token[request] until the oldest message can be marked as either
378 rejected or accepted.
379
380 \hypertarget{msg-seq}{Message sequence numbers are 16 bit unsigned
381 values.} The field is initialized to zero by the master when the
382 transport is initialized, and incremented by one after each token is
383 granted. Only the master is permitted to change the value of the message
384 sequence number. Once granted, that message sequence number is consumed
385 and the state of the message must eventually become either accepted or
386 rejected. No transmit tokens may be granted if the assignment of a
387 message sequence number that would cause a value of pending to be
388 shifted beyond the end of the status vector.
389
390 \hypertarget{packet-seq}{Packet sequence numbers are unsigned 16 bit
391 numbers assigned by the producing process on a per message basis.}
392 Packet sequence numbers start at a value of zero for each new message
393 and are incremented by one (consumed) for each data packet making up the
394 message. Consumers detecting missing packet sequence numbers must send a
395 nak[request] to the appropriate producer to recover the missed data.
396
397 Control packets always contain the message acceptance criteria with a
398 synchronization flag set to zero (0x00), the highest message sequence
399 number observed and a packet sequence number one greater than
400 previously observed. Control packets do not consume any sequence
401 numbers. Since control messages are not reliably delivered, the
402 acceptance criteria should only be checked to see if they fall within
403 the proper range of message numbers, relative to the current message
404 number of the receiving station. The range of acceptable sequence
405 numbers should be $m-11$ to $m-13$, inclusive, where $m$ is the current
406 message number.
407
408 \hypertarget{heartbeat}{\subsubsection{Heartbeat}}
409
410 Heartbeat is an unsigned 32 bit field that has the units of
411 milliseconds. The value of heartbeat is shared by all members of the
412 web. By definition at least one packet (either data, empty or quit
413 from the master) will be multicast into the web within every
414 heartbeat period.
415
416 \hypertarget{window}{\subsubsection{Window}}
417
418 The allocation window (or simply window) is a 16 bit unsigned field
419 that indicates the maximum number of data packets that can be
420 multicasted by a member in a single heartbeat. It is the sum of the
421 retransmitted and new data packets.
422
423 \hypertarget{retention}{\subsubsection{Retention}}
424
425 The retention field is a 16 bit unsigned value that is the number of
426 heartbeats for which a producer must retain transmitted client data
427 and state for the purpose of retransmission.
428
429 \subsection{Transport addresses}
430
431 Associated with each transport are logically three transport service
432 access points (TSAP), logically formed by the concatenation of a
433 network service access point (NSAP) and a transport connection
434 identifier. These TSAPs are the unknown TSAP, the web's multicast
435 TSAP and each individual member's TSAP.
436
437 \subsubsection{Unknown transport address}
438
439 Stations that are just joining must use the multicast NSAP associated
440 with the transport, but are not yet aware of either the web's
441 multicast TSAP the master process' TSAP\@. Therefore, joining stations
442 fabricate a temporary TSAP (referred to as a unknown TSAP) by using a
443 connection identifier reserved to mean unknown (0x00000000). The
444 join[confirm] message will be sourced from the master's TSAP and will
445 include the multicast transport connection identifier in the data
446 field. Those values must be extracted from the join[confirm] and
447 remembered by the joining process.
448
449 \subsubsection{Web's multicast address}
450
451 The multicast TSAP is formed by logically concatenating the multicast
452 NSAP associated with the transport creation and the transport
453 connection identifier returned in the data field of the join[confirm]
454 packet. If more than one network is involved in the web, then the
455 multicast transport address becomes a list, one for each network
456 represented. This list is supplied in the data field of
457 token[confirm] packets.
458
459 The multicast TSAP is used as the target for all messages that are
460 destined to the entire web, such as data and empty. The master's
461 decision to abandon the transport (quit) is also sent to the
462 multicast transport address.
463
464 \subsubsection{Member addresses}
465
466 The member TSAP is formed by using the process' unicast NSAP
467 concatenated with a locally generated unique connection identifier.
468 That TSAP must be the source of every packet transmitted by the
469 process, regardless of its destination, for the lifetime of the
470 transport.
471
472 Packets unicast to specific members must contain the appropriate
473 TSAP\@. For producers and consumers this is not difficult. The only
474 TSAPs of interest are the master and the station(s) currently
475 transmitting data.
476
477
478
479
480 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
481
482 \begin{thebibliography}{AFM91}
483 \bibitem[AFM91]{Armstrong91}
484 S.~Armstrong, A.~Freier, and K.~Marzullo.
485 \emph{MTP: An atomic multicast transport protocol}.
486 Xerox Webster Research Center technical report X9100359,
487 March 1991.
488
489 \bibitem[AFM92]{Armstrong92}
490 S.~Armstrong, A.~Freier, and K.~Marzullo.
491 \emph{Multicast transport protocol}.
492 RFC 1301, Internet Engineering Task Force, February 1992.
493 Available from \url{http://www.rfc-editor.org/rfc/rfc1301.txt}.
494 \end{thebibliography}
495
496 \end{document}