Ask HN: Is there a tool to generate binary protocol figures out of a spec?

51 points by vodou ↗ HN
I need to document quite many different binary formats and would like to present them with a figure visualizing the different fields, their length and names.

Similar to how internet protocols are presented in RFC documents, but rather not in text mode. Preferably in some vector format, like SVG, to make it easy to embed these figures in different kind of documents.

Up to now I have mainly used Microsoft Visio or even Excel for this. This is very tedious and ineffective. I think there must exist a tool for this where you just define the protocol (e.g. using Kaitai Struct syntax or something simlar) and then generate the protocol figure.

So far I have only found tools for generating such figures in text format.

Any suggestions?

17 comments

[ 3.0 ms ] story [ 52.1 ms ] thread
Recently - 'Why isn't there an OpenAPI for binary formats': https://news.ycombinator.com/item?id=30806032

You might find something suitable there, from what I recall there was some disagreement about whether there is or not depending on what the scope is of what you want to achieve.

Not exactly what you’re looking for (this doesn’t generate an image from a spec/protocol), but I created a simple image encoding in ASCII and editor that generates PNG (choose “Still” instead of “Wobble”):

https://memalign.github.io/m/pceimage/index.html

I made this so I can embed images in code.

Maybe look into mermaid? It has like a dozen different modes.
I always appreciated the clarity of diagrams in TCP/IP Illustrated Volume 1: The Protocols.[0] IIRC the diagrams were generated with graphviz using dot, which can output SVG. You can trivially post-process the SVG to alter fonts or other display related attributes as necessary.

In terms of data sources, you can potentially parse the metadata for known protocols out of a good protocol dissector like tcpdump[1] or Wireshark[2], or https://www.luismg.com/protocol/

See https://graphviz.readthedocs.io/en/stable/examples.html#stru... for a tabular example.

[0] A decade or more ago someone posted the source TeX. Unfortunately I lost it. If anyone has it, sharing is caring. [1] https://github.com/the-tcpdump-group/tcpdump [2] https://github.com/wireshark/wireshark/tree/master/epan/diss...

Can you send me a linkedin request to talk about it?