PacketDiag
PacketDiag turns bit ranges into a wire format diagram: a grid of the right width with each field spanning the right number of bits.
It removes the entire class of errors that comes from drawing header diagrams by hand.
#What it is good at
Protocol specifications and RFC-style documentation.
Custom binary protocols where offsets must be exact.
Explaining an existing header in a design document.
#What it draws
Element | Syntax |
|---|---|
Field | 0-15: Source port; |
Word width | colwidth = 32; |
Row height | node_height = 72; |
Colour | 0-15: Field [color = "#ddeeff"]; |
#A worked example
A custom message header, 32 bits wide:
The source, which you can paste into a new diagram and edit:
#A few things that catch people out
colwidth must match the real word size or every offset misleads the reader.
Ranges are inclusive on both ends, so 0-15 is sixteen bits.
For byte-oriented structures with nesting, Bytefield is the better fit.
#Related
Thirty-one languages. Nobody knows them all.
