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.2.tar.gz (21.5 kB view details)

Uploaded Source

File details

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

File metadata

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

File hashes

Hashes for cobs-1.1.2.tar.gz
Algorithm Hash digest
SHA256 b41157191153d4ebce9b151989a7fccb02b1e82e935ef9d35fbdd68254d12b2e
MD5 7266613a96c6233d2f47d8330dc7c0c9
BLAKE2b-256 045e73ae5cea70ee7088c7fc718e4501042fd58968de2c518414a3f8d5bf2656

See more details on using hashes here.

Supported by

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