Frame Synchronisation with COBS

When sending messages as bits across the web, you need a way of deciding where one packet ends and another begins.

Consistent Overhead Byte Stuffing (COBS) is an algorithm for encoding data bytes that results in efficient, reliable, unambiguous packet framing regardless of packet content, thus making it easy for receiving applications to recover from malformed packets

See Wikipedia, or, less dry, the Self-Directed Research Podcast on Frame Synchronization. This is not really a topic I ever think about or have worked on, but the podcast is always a great time.