โ† Back to the chapter

Technical detail ยท CoAP Messages: Format Foundations

Count the header bits and retained exchange state

The base CoAP message format over UDP has a four-byte fixed header followed by any Token, options and application content.

The first byte divides into 2 version bits, 2 type bits and 4 Token Length bits. The version selects the format, the type selects message handling, and Token Length states the number of Token bytes after the header. Code adds 8 bits and Message ID adds 16: 2 + 2 + 4 + 8 + 16 = 32 bits, or four bytes. This accounts for the specified size; it does not establish a theoretical minimum.

UDP avoids TCP connection setup for this exchange; TCP is the connection-oriented Transmission Control Protocol. The client still retains outstanding requests and their Tokens, together with the peer endpoint needed to match responses. Confirmable messages require reliability state for tracking acknowledgements and retries. A small header does not remove that work from either end of the exchange.

โ† Back to the chapter