Consistent Overhead Byte Stuffing—Reduced (COBS/R)
This COBS C implementation includes code for a variant on COBS, which I am calling "Consistent Overhead Byte Stuffing—Reduced" (COBS/R).
COBS/R is a small modification of the COBS encoding algorithm, which can often avoid the +1 byte overhead that occurs in COBS. Thus it decreases the average encoding overhead, especially when encoding many small packets.
The COBS/R encoding is never larger than the COBS encoding; often the COBS/R encoded data can be the same size as the original data, thus being 1 byte smaller than the COBS encoding. It does not increase the worst-case encoding overhead compared to COBS.
COBS/R was originally developed in the
cobs module for the Python language. The Python
cobs module documentation contains a more detailed explanation of the COBS/R encoding variation, including a mathematical analysis of the expected reduction in encoding overhead.