Can anybody recommend some resources that discuss the common patterns found in communication protocol design and programming?
For protocol design patterns, I'm thinking of things like how delimiters are used to mark the start/end of messages, using escaping so that a delimiter can appear within the message data, the pros/cons of various checksum methods, fixed-length vs. variable-length messages, the various ways of representing data within a message (e.g. plaintext, little/big endian binary encoding), and so forth.
For protocol programming patterns, I'm referring to techniques used when writing software to communicate using these protocols. As an example - for various protocol designs, what techniques exist to re-synchronize on a message boundary when the datastream is momentarily corrupted (e.g. looking for the next start-of-message delimiter if one is defined, sliding a window over the input buffer looking for a well-formed message), or when an existing conversation is picked up mid-stream?
For my projects I'm mostly concerned with communicating with hardware over unreliable links, such as RS-232, so error detection and message framing techniques are of particular interest to me, though a general treatment of the topic would be excellent.
Most of what I know about this topic was learned in an ad-hoc way from looking at existing protocols. I'd like to formalize my understanding a bit and hopefully pick up a few new techniques along the way, as well as have something that I can point to when training others to do this sort of work.