Here's a fun Sunday puzzle for data minded people out there:
* COBS is a bit-stuffing technique, it changes the bitstream when encoding
* CRC is designed to defend against corruptions of the EXACT bit pattern on the wire
If I want to frame my messages with COBS, how do I also CRC them?
* COBS is a bit-stuffing technique, it changes the bitstream when encoding
* CRC is designed to defend against corruptions of the EXACT bit pattern on the wire
If I want to frame my messages with COBS, how do I also CRC them?
Comments
If you COBS then append CRC, the CRC could include a zero byte, confusing the COBS framing
* YOLO it, use a CRC16/32 then COBS encode, accept the weakened CRC properties
* Do something complicated like cobs+ that is smart enough to handle crc zeros, maybe looking for two termination `0x00` bytes that are 2 (crc16) or 4 (crc32) bytes apart
* Use a non-crc message integrity sig
To re-sync, just find the next COBS frame that contains a valid CRC for the previous raw COBS frame bytes.
Length-delimited framing works well over transports that guarantee no data loss (and no data corruption), but aren't reliable over mediums that may lose or corrupt data, which can cause an irreversible loss of synchronization
https://www.youtube.com/watch?v=KTrVpgw82Gg
If you’re running over a UART then that’s random bit flips or dropped bytes. If you’re running over Ethernet or USB then these kinds of errors are very unlikely (modulo off by one errors)
It's still probably "good enough", but you're losing a lot of the main value of choosing CRC over a much simpler integrity check
crcs are designed to protect "bits on the wire in that order", if you change the bits, then you're breaking the contract
Once you're moving or modifying the raw bits on the wire, you're having an effect on the preconditions assumed by the math behind the CRC.
To be clear, it'll never be worse than 1/2^n, so crc32 is still a 1/4B chance to hit, even with "degraded" performance! But CRCs *should* be much stronger than that.
But you're definitely not off-base here.
I don't recall the math of CRC nearly well enough to know whether this is plausible, but I wonder if it would be possible ...