Index

Free, with Google

Keep going, free.

A free account opens lessons 2 and 3 of every track, 33 more lessons, and keeps your progress and review cards on every device.

Start free with Google

A chalk plan

Open everything on chalk.

Every lesson, board, video, lab and paper, and the full review decks. Yearly is $39/year.

See plansStart free instead

Networking the lesson

DNS on the wire a show in 8 chapters

Goal: send every question and its answer in one packet each way

1 of 8 Your guess

Before we start

You type example.com, and your computer asks a resolver for its address, the concierge from the last lesson. That question leaves your machine as a message, and the answer comes back as one.

What does the question look like the moment it goes out on the wire?

Pick the closest. You find out which fits at the end.

Ethernet · dial-up · satelliteA small messagearrives wholeA big onesplit in two, half lost

The links of 1987. Some carried only a few hundred bytes whole.

2 of 8 The problem

1987: the postcard rule

November 1987, the University of Southern California's Information Sciences Institute. Paul Mockapetris signs off RFC 1035, the document that still defines every DNS message sent today.

The internet then was a patchwork: Ethernet, dial-up lines, satellite hops. Some of those links refused to carry a big message whole. They split it in two, and two pieces are two chances to lose one.

Step 1 of 2

07= 765= 101= the letter eff= 255the biggest

3 of 8 The idea

Every letter, counted

A computer sees only bytes, in an order both ends agreed on in advance. Written in hex, a byte is two characters, 00 to ff.

The same byte can be read two ways. 65 in hex is 6 × 16 + 5 = 101, and in the numbering everyone agreed on in the 1960s, 101 is also the letter e. The format decides which reading applies where.

Why write a byte in hex?

Any byte fits in exactly two hex characters, 00 to ff, so every byte in a dump lines up in the same width. In ordinary numbers a byte takes one, two or three digits.

Step 1 of 3

the question, echoed: 29header 12example.com 134answer 1: 16c0 0ctype, classTTL 89 slenaddress→ 104.20.23.154answer 2: 16c0 0ctype, classTTL 89 slenaddress→ 172.66.147.243byte 1229 + 16 + 16 = 61 bytes

4 of 8 Try it

The ditto mark

The answer to your question repeats the name once per address it hands back, and example.com has two. DNS never retypes it. It writes two bytes, c0 0c, meaning "same name as the one at byte 12 of this message". That is the ditto mark, a compression pointer.

Each answer is the 2-byte ditto mark, 10 fixed bytes, and the 4-byte address: 16 bytes. The reply echoes your 29-byte question, then adds two answers: 29 + 16 + 16 = 61 bytes.

Step 1 of 2

the reply17bytesanswers: 012 header + 5 question(the root's name is 1 byte)TCtoo long, call me

5 of 8 The cost

Too long, call me

By the late 1990s DNS had new jobs. An answer might carry a security signing key, and answers that size stopped being rare. Ask for the root's signing keys while saying you take only 512 bytes, and this comes back.

17 bytes: the header and your question echoed, no answer at all. One bit is set, TC, truncated. Not an error: "ask me again the slow way".

Step 1 of 2

the questionyour machine sendsI can take1,232 bytesknows the noteanswers up to 1,232never heard of itanswers up to 512Nothing already running had to change.

6 of 8 The fix

1999: Vixie's note

August 1999. Paul Vixie, then at the Internet Software Consortium, writes RFC 2671: a note a machine can clip to its own question, saying "actually, I can take more than 512 bytes back".

A server that understands the note uses it. A server that has never heard of it ignores it and answers the old way. One extra record, twelve years later, moved the limit without breaking anything already running. It is called EDNS0.

Step 1 of 2

7 of 8 Your guess

Your picture now

Goal met: a question is 29 bytes, the root's reply 242 with its ditto marks, and with Vixie's note the root's 853-byte keys come back in one packet. Which picture is closest now?

Pick one.

DNS on the wireEvery byte counted, no name written twice, a hard edge at the limit.12307 example 03 com 00:counted, never a dot29bytes: 12 + 13 + 4c0 0c2 bytes: "same name asbyte 12", never retyped242bytes from the root, not 658over: TC, call meVixie's 1999 note:"I can take more"512 › 1,232the root's keys: 853, 1 tripchalkbrain.com
DNS on the wireEvery byte counted, no name writtentwice, a hard edge at the limit.107 example 03 com 00: counted,never a dot29bytes: 12 + 13 + 42c0 0c, 2 bytes: "same nameas byte 12", never retyped242bytes, not 6583Over the limit: TC, call me.Vixie's note: I can take more.512 › 1,232chalkbrain.com

8 of 8 Keep this

Keep this

A DNS message is bytes in an agreed order: a 12-byte header, names as counted chunks, and a 2-byte ditto mark wherever a name repeats. It is small on purpose, so a question and its answer each fit in one packet.

The price: past the limit the reply comes back empty and stamped, and the redial over TCP costs two more round trips, unless the question carries the EDNS0 note.

Read the full lesson