Skip to main content

Consistent Overhead Byte Stuffing (COBS)

Project description

Author:

Craig McQueen

Contact:
http://craig.mcqueen.id.au/

Python functions for encoding and decoding COBS.

Complete cobs documentation is at http://packages.python.org/cobs/

Intro

The cobs package is provided, which contains modules containing functions for encoding and decoding according to COBS methods.

What Is COBS?

COBS is a method of encoding a packet of bytes into a form that contains no bytes with value zero (0x00). The input packet of bytes can contain bytes in the full range of 0x00 to 0xFF. The COBS encoded packet is guaranteed to generate packets with bytes only in the range 0x01 to 0xFF. Thus, in a communication protocol, packet boundaries can be reliably delimited with 0x00 bytes.

The COBS encoding does have to increase the packet size to achieve this encoding. However, compared to other byte-stuffing methods, the packet size increase is reasonable and predictable. COBS always adds 1 byte to the message length. Additionally, for longer packets of length n, it may add n/254 (rounded down) additional bytes to the encoded packet size.

For example, compare to the PPP protocol, which uses 0x7E bytes to delimit PPP packets. The PPP protocol uses an “escape” style of byte stuffing, replacing all occurences of 0x7E bytes in the packet with 0x7D 0x5E. But that byte-stuffing method can potentially double the size of the packet in the worst case. COBS uses a different method for byte-stuffing, which has a much more reasonable worst-case overhead.

COBS/R

I have included a variant on COBS, which I am calling “Consistent Overhead Byte Stuffing—Reduced” (COBS/R). It is a small variation that can often avoid the +1 byte overhead that occurs in COBS, thus decreasing the average encoding overhead. Yet it does not increase the worst-case encoding overhead compared to COBS. See the COBS/R documentation for full details.

Complete cobs documentation is at http://packages.python.org/cobs/

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

cobs-1.1.1.tar.gz (21.4 kB view details)

Uploaded Source

File details

Details for the file cobs-1.1.1.tar.gz.

File metadata

  • Download URL: cobs-1.1.1.tar.gz
  • Upload date:
  • Size: 21.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for cobs-1.1.1.tar.gz
Algorithm Hash digest
SHA256 8001e76e0bdada2110786290ac08cfe62400ae307bfe8b4ef28c395d4bf45cbd
MD5 3724c053a6eb86de398fbbf9c3d7692f
BLAKE2b-256 22dd7cd3e172c7e820f98cac7419f7f6d7725a1041c365e6bd7b1488e2524d82

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page