@duponin@bortzmeyer "I can't work out how to make sure the query is well-formed, neither find a validation tool anywhere" That part should be easy. Any good DNS library should have the equivalent of `to_wire/from_wire` methods (they are called like that in DNSPython), which allows to either pass a buffer of bytes as captured in theory from network and see how they are parsed, or the opposite.
@duponin@bortzmeyer But then how can you compare/validate your results (from need X to bytes ABCDE...)? With just the RFC? tough luck, there are 1) too many of them for DNS 2) contradictory between themselves or ambiguous at times and 3) just impossible to draw a concise exhaustive view of what is "the DNS". Hence my suggestions to use external existing libraries (at least Python and Go ones are very good DNS wise) to help building you own case. But YMMV.