Diagrams / Mermaid Packet Diagram: Syntax & Examples
Mermaid Packet Diagram: Syntax & Examples
Document bit fields with Mermaid packet syntax. Edit a header example, check ranges and units, and distinguish a format diagram from packet analysis.
When to use Packet Diagram
Show the bit layout of a structured message with a Mermaid packet diagram. Define field ranges and labels to explain a header or a compact binary record. This documents a format; it does not capture network traffic or decode a packet file.
- Start with the example in the editor and identify the elements that answer your question.
- Replace the sample labels and values, previewing after each structural change.
- Review the diagram at its intended reading size, then keep the source and export the format your document accepts.
Read the Packet Diagram example
Diagram source
packet-beta
0-15: "Message ID"
16-23: "Version"
24-31: "Flags"
32-63: "Payload length"Syntax and interpretation
| Concept | How to apply it |
|---|---|
| Ranges | Check that field boundaries match the protocol specification. Look for accidental gaps or overlap. |
| Units | State whether the surrounding document uses bits or bytes. Do not silently switch between the two. |
| Interpretation | Byte order, signedness, and allowed field values need accompanying documentation; the box layout alone does not define them. |
Common questions
Can I use it as a protocol validator?
No. It visualizes the supplied ranges. Test encoders and decoders separately against the actual protocol specification.