Support for the SLIP protocol (RFC 1055)
sliplib — A module for the SLIP protocol
The sliplib module implements the encoding and decoding functionality for SLIP packets, as described in RFC 1055. It defines encoding and decoding functions and classes, and registers these in the codecs module.
The SLIP protocol is described in RFC 1055 (A Nonstandard for Transmission of IP Datagrams over Serial Lines: SLIP, J. Romkey, June 1988). The original purpose of the protocol is to provide a mechanism to indicate the boundaries of IP packets, in particular when the IP packets are sent over a connection that does not provide a framing mechanism, such as serial lines or dial-up connections.
There is, however, nothing specific to IP in the SLIP protocol. SLIP offers a generic framing method that can be used for any type of message that must be transmitted over a (continuous) byte stream. In fact, the main reason for creating this module was the need to communicate with a third-party application that used SLIP over TCP (which is a continuous byte stream) to frame variable length messages.
The SLIP protocol uses four special byte values:
||END||to delimit messages|
||ESC||to escape END or ESC bytes in the message|
||ESC_END||the escaped value of the END byte|
||ESC_ESC||the escaped value of the ESC byte|
An END byte in the message is encoded as the sequence
in the slip packet,
and an ESC byte in the message is encoded
as the sequence ESC+ESC_ESC (
As a consequence, an ESC byte in a slip packet must always be followed by an ESC_END or an ESC_ESC byte; anything else is a protocol error. Although the implementation code proposed by RFC 1055 ignores such errors, the sliplib module raises an exception in such cases.