TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

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

51 pointsby vodouabout 3 years ago
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?

14 comments

curiousfababout 3 years ago
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:&#x2F;&#x2F;github.com&#x2F;wavedrom&#x2F;wavedrom" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;wavedrom&#x2F;wavedrom</a>
评论 #30897059 未加载
评论 #30896310 未加载
zelphirkaltabout 3 years ago
Does this help with documentation and automatically create diagrams: <a href="https:&#x2F;&#x2F;github.com&#x2F;gsingh93&#x2F;ob-bitfield" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;gsingh93&#x2F;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.
评论 #30897075 未加载
contingenciesabout 3 years ago
I always appreciated the clarity of diagrams in <i>TCP&#x2F;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:&#x2F;&#x2F;www.luismg.com&#x2F;protocol&#x2F;" rel="nofollow">https:&#x2F;&#x2F;www.luismg.com&#x2F;protocol&#x2F;</a><p>See <a href="https:&#x2F;&#x2F;graphviz.readthedocs.io&#x2F;en&#x2F;stable&#x2F;examples.html#structs-py" rel="nofollow">https:&#x2F;&#x2F;graphviz.readthedocs.io&#x2F;en&#x2F;stable&#x2F;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:&#x2F;&#x2F;github.com&#x2F;the-tcpdump-group&#x2F;tcpdump" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;the-tcpdump-group&#x2F;tcpdump</a> [2] <a href="https:&#x2F;&#x2F;github.com&#x2F;wireshark&#x2F;wireshark&#x2F;tree&#x2F;master&#x2F;epan&#x2F;dissectors" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;wireshark&#x2F;wireshark&#x2F;tree&#x2F;master&#x2F;epan&#x2F;diss...</a>
OJFordabout 3 years ago
Recently - &#x27;Why isn&#x27;t there an OpenAPI for binary formats&#x27;: <a href="https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=30806032" rel="nofollow">https:&#x2F;&#x2F;news.ycombinator.com&#x2F;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.
renewiltordabout 3 years ago
You can’t specify the width of a single bit in the diagram but I found <a href="https:&#x2F;&#x2F;www.luismg.com&#x2F;protocol&#x2F;" rel="nofollow">https:&#x2F;&#x2F;www.luismg.com&#x2F;protocol&#x2F;</a> otherwise nice.<p>It’s ASCII though.
Shastickabout 3 years ago
IIRC, thrift (<a href="https:&#x2F;&#x2F;thrift.apache.org&#x2F;" rel="nofollow">https:&#x2F;&#x2F;thrift.apache.org&#x2F;</a>) could render defined types&#x2F;structs to an SVG.<p>Edited to add: it’s the graphviz generator -&gt; <a href="https:&#x2F;&#x2F;thrift.apache.org&#x2F;tutorial&#x2F;graphviz.html" rel="nofollow">https:&#x2F;&#x2F;thrift.apache.org&#x2F;tutorial&#x2F;graphviz.html</a><p>I’d guess gRPC and other such IDLs have a way to render similar things as well.
sennightabout 3 years ago
This isn&#x27;t used for bitfields (er, shouldn&#x27;t really be), but you might find it useful for less granular parsing documentation:<p><a href="https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Railroad_Diagrams" rel="nofollow">https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Railroad_Diagrams</a>
kuroguroabout 3 years ago
I think Kaitai had an export feature trough GraphViz (haven&#x27;t tried it tho)<p>_edit_<p>Yeah, there&#x27;s some samples on their page: <a href="https:&#x2F;&#x2F;formats.kaitai.io&#x2F;rar&#x2F;rar.svg" rel="nofollow">https:&#x2F;&#x2F;formats.kaitai.io&#x2F;rar&#x2F;rar.svg</a><p>Not sure if that&#x27;s what you&#x27;re looking for?
sgotoabout 3 years ago
I&#x27;ve been using SVG bob as a wasm binary. Here is a demo: <a href="https:&#x2F;&#x2F;code.sgo.to&#x2F;2021&#x2F;12&#x2F;07&#x2F;ascii-diagrams.html" rel="nofollow">https:&#x2F;&#x2F;code.sgo.to&#x2F;2021&#x2F;12&#x2F;07&#x2F;ascii-diagrams.html</a>
tylergetsayabout 3 years ago
<a href="https:&#x2F;&#x2F;github.com&#x2F;ReFirmLabs&#x2F;binwalk" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;ReFirmLabs&#x2F;binwalk</a> might help, it won&#x27;t generate the visuals but can give you offsets
rurbanabout 3 years ago
extraction not imho.<p>but the usual tools are pic (for diagrams) and grap (for graphs), as linked from here: <a href="http:&#x2F;&#x2F;n-t-roff.github.io&#x2F;heirloom&#x2F;doctools.html" rel="nofollow">http:&#x2F;&#x2F;n-t-roff.github.io&#x2F;heirloom&#x2F;doctools.html</a><p>this is the manual <a href="https:&#x2F;&#x2F;pikchr.org&#x2F;home&#x2F;uv&#x2F;pic.pdf" rel="nofollow">https:&#x2F;&#x2F;pikchr.org&#x2F;home&#x2F;uv&#x2F;pic.pdf</a><p>I&#x27;ve also used postscript for extreme usages, the doctools can also include ps verbatim.
memalignabout 3 years ago
Not exactly what you’re looking for (this doesn’t generate an image from a spec&#x2F;protocol), but I created a simple image encoding in ASCII and editor that generates PNG (choose “Still” instead of “Wobble”):<p><a href="https:&#x2F;&#x2F;memalign.github.io&#x2F;m&#x2F;pceimage&#x2F;index.html" rel="nofollow">https:&#x2F;&#x2F;memalign.github.io&#x2F;m&#x2F;pceimage&#x2F;index.html</a><p>I made this so I can embed images in code.
RonaldOlzheimabout 3 years ago
Can you send me a linkedin request to talk about it?
sgtnoodleabout 3 years ago
Maybe look into mermaid? It has like a dozen different modes.