Interactive engineering lab

DNS compression: trace pointers, boundaries and malformed names

DNS compression: trace pointers, boundaries and malformed names. Decode eight synthetic packets with adjustable bounds.

By Sandeep Belgavi · Published 2026-11-21

Scenario: a parser reads one compressed domain name from a synthetic DNS message under example.com. Synthetic inputs; every calculation stays in this page and nothing is sent anywhere.

Experiment workspace

Decision trace

    What this lab models

    Decoding one domain name from a DNS message, with the compression scheme of RFC 1035 section 4.1.4 and the checks RFC 9267 recommends. Eight synthetic packets are built in this page under example.com: a valid compressed answer and seven malformed or unusual ones. The decoder reads labels and pointers one octet at a time and refuses when a bound is broken. It reports the name, how many pointers it followed, the length on the wire and where the next field of the record starts. Nothing is sent on a network.

    How to experiment

    Start with the valid packet: help.books.example.com., one pointer, 24 octets, next field at 42. Choose the self-loop packet: strict mode refuses it because the pointer does not point backward. Set backward-only pointers to No: the hop limit stops it at 16 pointers. Set the hop limit to 0 as well, which means no limit, and the decoder never ends; this page stops it after 10,000 steps. Try the forward pointer with backward-only off, the header pointer with the header check off, and the long name with a maximum length of 300.

    Expected outcomes to check

    Strict defaults: valid accepted; self_loop, two_pointer_loop and forward_pointer refused as not before it; header_pointer refused as inside the header; reserved_label refused for the 01 prefix; too_long refused at 257 octets; truncated refused with 5 octets remaining. Backward-only off with 8 hops: both loops stop at more than 8 pointers and forward_pointer decodes to com. with the next field at 14. Header check off: the header pointer reads 0x81 as a reserved 10 prefix.

    Trace, reset and export

    The trace starts with every bound, then lists each label and pointer the decoder read with its offset, and ends with the outcome and the refusal reason. Start trace, Next step, Show all and the slider control how much is visible. The octet table shows the packet, or for the long packet its header and the name being decoded. Reset inputs restores the defaults. Export JSON saves the inputs, the packet in hex, the result and the trace.

    Limits

    Name decoding only. A real parser also checks record data lengths, record counts and section boundaries, which RFC 9267 sections 5 and 6 cover, and handles EDNS. The packets are fixed fixtures, not live traffic, and the decoder is a teaching model, not a resolver.

    Original lab by Sandeep Belgavi. Views are my own and do not represent any employer, past or present.