Serial Packet Protocol Stack
Blunk Microsystems’ TargetSPP is a packet-oriented protocol for transferring data over point-to-point connections. Borrowing algorithms from LAPB and TCP, it provides flow control and data reliability, and includes the following features:
- A full selective repeat ARQ (Automatic Repeat Request) protocol implementation.
- Easy-to-use API for configuring, opening, collecting statistics on, and closing connections, waiting for all-acknowledged condition, and sending and receiving data frames whose size ranges from zero to the compile-time configured maximum frame size.
- Sliding window acknowledgments (like TCP and LAPB), so packet flow continues while acknowledgments for packets sent earlier are pending. The window size is set at compile-time to 1, 2, 4, or 8 packets.
- Reliable data transfer via positive acknowledgements of received packet sequence numbers and automatic resends - after timer expiration - of unacknowledged frames.
- Fast recovery from dropped packets: gaps in the sequence of acknowledged packet numbers trigger immediate resends, without waiting for expiration of the resend timer. Packets received out-of-order are immediately acknowledged, to facilitate fast recovery.
- Karn's algorithm is used to automatically calculate the resend and delayed acknowledgment timer values, like TCP.
- Receive window size, sent with each acknowledgment, shows the number of new packets the receiver can accept, for flow control when an application stops reading data. For fast flow resumption if the receive window has closed, the sender repeats automatic window probes if it has more data to send and the receiver sends automatic window advertisements when its receive window reopens.
- Negative acknowledgment (NAK) frames report if a received packet has errors, triggering a fast resend before timer expiration. This is critical for fast recovery if there is only one data frame to send, meaning automatic gap reporting will not be triggered.
- Configuration parameters include initial values for the resend and delayed acknowledgment timeouts, receive window size, and whether SYN frames (for creating new connections) are actively transmitted or merely listened for. These parameters are set independently for each end of a connection.
- Each packet header contains the connection number to support detection and rejection of spurious packets from old connections.
- Supports UDP and UART connections. Includes a SLIP-like framing and CRC layer for UART connections, with a simple driver interface, and a Sockets API layer for UDP connections.
- Statistics are maintained on number of connections/reconnections, frames sent, resent, received, etc. These values may be read and/or printed to stdout with sppStats().
- A compile-time option promotes all errors to fatal errors that call exit(). This helps catch simple programming errors at beginning of development that can otherwise waste time.
- The following events are optionally reported to the application using a user-supplied callback function: connection occurred, disconnect occurred, all sent data has been acknowledged, and data frame arrived.
- Built-in protocol decoder. If enabled at compile-time, a short summary of every packet (SYN, ACK, NAK, I-Frame, or RST) transmitted or received is either printed to stdout on an ongoing basis as the protocol stack runs or logged for later printout.
- Optional application data decoding via user-supplied callback function. If enabled, this function is called for I-frame packets with a pointer to the start of application data.
- Extensively tested over UDP and UART connections. Used by CrossStep's debugger-to-target monitor connections.
- The default maximum flow control window is eight packets, the packet sequence number modulus is 32, and the connection number modulus is 8. Custom TargetSPP configurations are available from Blunk Microsystems.
- Source code is 100% ANSI C and has been tested using PC-lint and multiple ANSI C compilers.
- Developed using TargetOS™, Blunk Microsystems’ full-featured royalty-free real time operating system. Easily ported to other operating systems or used in non-RTOS polling mode.
- Royalty-free. Includes complete source code, a sample application, sample UDP and UART drivers, user’s manual, and one year of technical support. Electronic delivery via FTP account.