5 ms·
Ask HN: Is there a tool to generate binary protocol figures out of a spec?
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?
- RonaldOlzheim 5y agoCan you send me a linkedin request to talk about it?
- Shastick 5y agoIIRC, thrift (https://thrift.apache.org/ https://thrift.apache.org/) could render defined types/structs to an SVG. Edited to add: it’s the graphviz generator -> https://thrift.apache.org/tutorial/graphviz.html https://thrift.apache.org/tutorial/graphviz.html I’d guess gRPC and other such IDLs have a way to render similar things as well.
- curiousfab 5y agoI used Wavedrom to generate beautiful SVGs for a similar purpose in the past. Maybe it is useful for you, too: https://github.com/wavedrom/wavedrom https://github.com/wavedrom/wavedrom
- vodou 5y agoDoesn't seem to solve the current problem, but definitely looks like a useful tool since I sometimes need to do timing diagrams as well. Good recommendation!
- renewiltord 5y agoThe same guys also have a bitfield renderer https://github.com/wavedrom/bitfield https://github.com/wavedrom/bitfield
- OJFord 5y agoRecently - 'Why isn't there an OpenAPI for binary formats': https://news.ycombinator.com/item?id=30806032 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.
- zelphirkalt 5y agoDoes this help with documentation and automatically create diagrams: https://github.com/gsingh93/ob-bitfield https://github.com/gsingh93/ob-bitfield ? 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.
- memen 5y agoSeems to be based on a tool of wavedrom https://github.com/wavedrom/bitfield https://github.com/wavedrom/bitfield
- tylergetsay 5y agohttps://github.com/ReFirmLabs/binwalk https://github.com/ReFirmLabs/binwalk might help, it won't generate the visuals but can give you offsets
- renewiltord 5y agoYou can’t specify the width of a single bit in the diagram but I found https://www.luismg.com/protocol/ https://www.luismg.com/protocol/ otherwise nice. It’s ASCII though.
- kuroguro 5y agoI think Kaitai had an export feature trough GraphViz (haven't tried it tho) _edit_ Yeah, there's some samples on their page: https://formats.kaitai.io/rar/rar.svg https://formats.kaitai.io/rar/rar.svg Not sure if that's what you're looking for?
- sennight 5y agoThis isn't used for bitfields (er, shouldn't really be), but you might find it useful for less granular parsing documentation: https://en.wikipedia.org/wiki/Railroad_Diagrams https://en.wikipedia.org/wiki/Railroad_Diagrams
- sgoto 5y agoI've been using SVG bob as a wasm binary. Here is a demo: https://code.sgo.to/2021/12/07/ascii-diagrams.html https://code.sgo.to/2021/12/07/ascii-diagrams.html
- memalign 5y agoNot 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 https://memalign.github.io/m/pceimage/index.html I made this so I can embed images in code.
- sgtnoodle 5y agoMaybe look into mermaid? It has like a dozen different modes.
- contingencies 5y agoI 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/ https://www.luismg.com/protocol/ See https://graphviz.readthedocs.io/en/stable/examples.html#structs-py 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 https://github.com/the-tcpdump-group/tcpdump [2] https://github.com/wireshark/wireshark/tree/master/epan/dissectors https://github.com/wireshark/wireshark/tree/master/epan/diss...
- rurban 5y agoextraction not imho. but the usual tools are pic (for diagrams) and grap (for graphs), as linked from here: http://n-t-roff.github.io/heirloom/doctools.html http://n-t-roff.github.io/heirloom/doctools.html this is the manual https://pikchr.org/home/uv/pic.pdf https://pikchr.org/home/uv/pic.pdf I've also used postscript for extreme usages, the doctools can also include ps verbatim.