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.<p>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.<p>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.<p>So far I have only found tools for generating such figures in text format.<p>Any suggestions?
I used Wavedrom to generate beautiful SVGs for a similar purpose in the past. Maybe it is useful for you, too:<p><a href="https://github.com/wavedrom/wavedrom" rel="nofollow">https://github.com/wavedrom/wavedrom</a>
Does this help with documentation and automatically create diagrams: <a href="https://github.com/gsingh93/ob-bitfield" rel="nofollow">https://github.com/gsingh93/ob-bitfield</a> ? Was recently posted here on HN. Org format is a powerful format and it can be exported to many other formats using Emacs or maybe Pandoc.
I always appreciated the clarity of diagrams in <i>TCP/IP Illustrated Volume 1: The Protocols</i>.[0] IIRC the diagrams were generated with graphviz using <i>dot</i>, which can output SVG. You can trivially post-process the SVG to alter fonts or other display related attributes as necessary.<p>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 <a href="https://www.luismg.com/protocol/" rel="nofollow">https://www.luismg.com/protocol/</a><p>See <a href="https://graphviz.readthedocs.io/en/stable/examples.html#structs-py" rel="nofollow">https://graphviz.readthedocs.io/en/stable/examples.html#stru...</a> for a tabular example.<p>[0] A decade or more ago someone posted the source TeX. Unfortunately I lost it. If anyone has it, sharing is caring.
[1] <a href="https://github.com/the-tcpdump-group/tcpdump" rel="nofollow">https://github.com/the-tcpdump-group/tcpdump</a>
[2] <a href="https://github.com/wireshark/wireshark/tree/master/epan/dissectors" rel="nofollow">https://github.com/wireshark/wireshark/tree/master/epan/diss...</a>
Recently - 'Why isn't there an OpenAPI for binary formats': <a href="https://news.ycombinator.com/item?id=30806032" rel="nofollow">https://news.ycombinator.com/item?id=30806032</a><p>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.
You can’t specify the width of a single bit in the diagram but I found <a href="https://www.luismg.com/protocol/" rel="nofollow">https://www.luismg.com/protocol/</a> otherwise nice.<p>It’s ASCII though.
IIRC, thrift (<a href="https://thrift.apache.org/" rel="nofollow">https://thrift.apache.org/</a>) could render defined types/structs to an SVG.<p>Edited to add: it’s the graphviz generator -> <a href="https://thrift.apache.org/tutorial/graphviz.html" rel="nofollow">https://thrift.apache.org/tutorial/graphviz.html</a><p>I’d guess gRPC and other such IDLs have a way to render similar things as well.
This isn't used for bitfields (er, shouldn't really be), but you might find it useful for less granular parsing documentation:<p><a href="https://en.wikipedia.org/wiki/Railroad_Diagrams" rel="nofollow">https://en.wikipedia.org/wiki/Railroad_Diagrams</a>
I think Kaitai had an export feature trough GraphViz (haven't tried it tho)<p>_edit_<p>Yeah, there's some samples on their page: <a href="https://formats.kaitai.io/rar/rar.svg" rel="nofollow">https://formats.kaitai.io/rar/rar.svg</a><p>Not sure if that's what you're looking for?
I've been using SVG bob as a wasm binary. Here is a demo: <a href="https://code.sgo.to/2021/12/07/ascii-diagrams.html" rel="nofollow">https://code.sgo.to/2021/12/07/ascii-diagrams.html</a>
<a href="https://github.com/ReFirmLabs/binwalk" rel="nofollow">https://github.com/ReFirmLabs/binwalk</a> might help, it won't generate the visuals but can give you offsets
extraction not imho.<p>but the usual tools are pic (for diagrams) and grap (for graphs), as linked from here: <a href="http://n-t-roff.github.io/heirloom/doctools.html" rel="nofollow">http://n-t-roff.github.io/heirloom/doctools.html</a><p>this is the manual <a href="https://pikchr.org/home/uv/pic.pdf" rel="nofollow">https://pikchr.org/home/uv/pic.pdf</a><p>I've also used postscript for extreme usages, the doctools can also include ps verbatim.
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”):<p><a href="https://memalign.github.io/m/pceimage/index.html" rel="nofollow">https://memalign.github.io/m/pceimage/index.html</a><p>I made this so I can embed images in code.