How does the reader find the next piece?
03Pack a short note into rows of four bytes. Change its length, remove alignment spacers and watch the reader find or lose the next field.
Follow what happens to this one message.
A short note to pack
Each letter here fills one byte: a small unit of stored information. This note uses 5 bytes.
What do we need to find out?
How does the reader find the next piece?
Watch one change, then try an alternative.
What happens if you change this?
Change one thing and watch the result. Restart restores the original example.
Skip its padding before reading the next attribute.
Key idea: Count data separately from alignment space. The next field starts after both.
Terms
- ASCII
- The character encoding used for these simple Latin-letter notes. Each chosen letter fits in one byte; other writing systems can need more bytes.
- Byte / octet
- Eight bits. Each letter in these ASCII notes uses one byte; that is not true for all written characters.
- Attribute
- A field with a type, a two-byte data length, its data and any alignment padding.
- Padding
- Extra ignored alignment space after data. Attribute lengths exclude it; the message length includes it.
- Magic cookie
- The fixed STUN marker 0x2112A442 in the 20-byte header. It is a format clue, not a secret.
Rules & examples
A length label tells the reader how many data bytes belong to a piece.
- A length label tells the reader how many data bytes belong to a piece.
- Alignment spacers fill out a four-byte boundary; they are not part of the attribute’s data length.
- The message’s own length includes its attributes and their spacers, but excludes its fixed header.
Start with the drawing. The closed explanations introduce the technical names, actual fields and source rules after the idea. These chosen offline examples do not implement a complete STUN, ICE or TURN client.
Fixed header 20 bytes. SOFTWARE data length 5, padding 3, next attribute offset 32. Header message length 20 excludes the fixed header and includes attribute padding and the final FINGERPRINT attribute. This small parser validates the chosen structure, not every method, attribute, multiplexing or credential rule. Extra datagram data is not treated as part of the declared message. Raw chosen bytes: 000100142112a4420102030405060708090a0b0c8022000548454c4c4f000000802800045a1f4f56.
Sources
New to this? Start hereA quick picture + helpful background
Finding a route and sending media are separate jobs.
Some messages set up a conversation or discover a reachable address. Other packets carry the audio or video. Follow those jobs separately.
Helpful first, if these ideas are unfamiliar
These pictures are analogies to help you learn. The linked RFC explains the actual rules.
Related RFCs and changes
“Updates” changes part of an earlier RFC. “Obsoletes” replaces it. This list shows selected related documents.