CSE461 Final Exam Programming Exercise: DNS Client

Out: Sunday Jun 5, 2016
Due: Wednesday June 8, 2016 by noon (note the "noon").
Teams Allowed: No

Overview

Implement a skeletal DNS client. Your client is similar in spirit to dig, although much less complete.

Your client should be fronted by a run.sh script, so that it can be invoked like this:

$ ./run.sh 8.8.8.8 cs.washington.edu ANY

Querying 8.8.8.8 for ANY records for name cs.washington.edu

Receiving answer
Header:
  transid = 1
  flags = 0x8180
  numQuestions = 1
  numAnswers = 16
  numAuths = 0
  numAdditional = 0

Answers:
	SOA	cs.washington.edu
	LOC	cs.washington.edu
	TXT	cs.washington.edu
	MX	cs.washington.edu
	MX	cs.washington.edu
	MX	cs.washington.edu
	MX	cs.washington.edu
	MX	cs.washington.edu
	MX	cs.washington.edu
	A	cs.washington.edu
	NS	cs.washington.edu
	NS	cs.washington.edu
	NS	cs.washington.edu
	NS	cs.washington.edu
	NS	cs.washington.edu
	NS	cs.washington.edu
The arguments are, in order, the IP address of the name server to which your client should send the query, the DNS name to resolve, and the type of query. You should handle query types A, AAAA, and ANY. You can rely on the IP address argument being an IP address (not a domain name). You don't have to deal with any errors in the arguments. (You do have to deal with the possibility there will be no response to your query, though.)

The output shows some of the information returned in the response. The header is dumped, in a crude fashion. For each resource record in the answer section, the type of the record and the name field from that record is printed. Nothing is printed about records in the query, authority, or additional information sections of the response.

Detailed Specifications
Part of the exercise is figuring out on your own what to do.

Restrictions

You must implement on top of raw sockets, not using any library/package that provides more functionality than that.

You must not copy code from any source, except for code you may have written yourself.

Your code must run on attu on an account that has only the most basic, default environment -- just because it works for you doesn't mean it will for me, especially if you use an exotic language or toolset.

Available Resources
There is a sample executable. Your output should be similar to what it produces, except that it's fine for you implementation to produce results where the sample solution seems to produce nothing. Your output should not be substantially more complicated, visually, than what the sample or dig produce, however -- I will manually scan your output to decide if your implementation has passed a series of tests.

There is a run.sh that I used during development of the sample solution. It may or may not be useful.

There is a driver.sh that invokes run.sh on a number of sites for a number of query types.

Debugging Tip
Both dig and wireshark are useful. Running wireshark may require root.

Turn-in
Hand in whatever is needed so I can invoke run.sh in a directory full of whatever you've turned in and get good results. (I will run on attu.)