Skip to content
Packet & bit fields templates

Packet — DNS Message Header (RFC 1035)

Twelve bytes with a four-bit opcode and a four-bit response code packed either side of five single-bit flags, which is the layout most often drawn wrong because the flag byte is easier to describe in prose than to lay out. Complete over three 32-bit words.

Template previewPacket & bit fields
DNS message header (RFC 1035)32-bit words · 3 words · 96 bits laid out · 13 fields · ruler shows ABSOLUTE bit indicesMSB-first: bit 0 is the most significant bit of each 32-bit word, drawn leftmost; indices increase to the right.In both orders the most significant bit of a word is the leftmost column — only the numbering flips.Layout checks passed — 13 fields, 3 words, 96 bits: no gaps, no overlaps, nothing past the last word.MSBLSBword 0bits 0–31+0B012345678910111213141516171819202122232425262728293031word 1bits 32–63+4B3233343536373839404142434445464748495051525354555657585960616263word 2bits 64–95+8B6465666768697071727374757677787980818283848586878889909192939495IDbits 0–15 · 16bQRbi…OPCODEbits 17–20 · 4bAAbi…TCbi…RDbi…RAbi…Zbits 25–27 =…RCODEbits 28–31 · 4bQDCOUNTbits 32–47 · 16bANCOUNTbits 48–63 · 16bNSCOUNTbits 64–79 · 16bARCOUNTbits 80–95 · 16bNo overlaps: each of the 96 checked bits belongs to at most one field.No gaps: bits 0–95 fully covered by 13 fields.Every field ends inside the 3-word layout.

Make it your own.

title "DNS message header (RFC 1035)"
width 32
bitorder msb
words 3

0-15:  ID

16:    QR
17-20: OPCODE
21:    AA
22:    TC
23:    RD
24:    RA
25-27: Z = 0
28-31: RCODE

32-47: QDCOUNT
48-63: ANCOUNT
64-79: NSCOUNT
80-95: ARCOUNT