PROGRAMMING ASSIGNMENT 1:  Domain Name System (DNS) Client

 

 

In this assignment you will build a client for the Domain Name System.  Begin by reviewing Chapter 18 from your textbook.   

 

Build a client program that uses UDP to send a query message containing one question to a DNS server on port 53.  The message consists of the ten items listed below.  All integer values in the message must be represented in network byte order (use function "htons" or an equivalent).

 

Field              Type               Value

ID                 16-bit integer     any

Parameter          16-bit integer     0x100

Question Count     16-bit integer     1

Answer Count       16-bit integer     0

Authority Count    16-bit integer     0

Addl Info Count    16-bit integer     1

Length             8-bit integer      L

Domain name        L bytes            ASCII

Lookup type        16-bit integer     1

Lookup class       16-bit integer     1

 

Write a program with a user interface ("command line" UI is OK) that accepts a file name consistent with the file system on your machine.  The first line of this input file will contain the name of the output file, where your program's results will be written.  Subsequent lines of this file will contain an arbitrary number of domain names, one per line. 

 

Your program will issue a recursive resolution query for each domain name in the file.  For each query your program will output the domain name followed by the entire query result, e.g., "answer" records, "authoritative" records and "additional" records.  These records should be output with labels and in a clear format to assist readability.  Naturally, your program should not rely on a call to "gethostbyname", unless used simply to check the result of your DNS query message.

 

You can download the file "domain.h" that defines the format of DNS messages using C/C++ declarations from the course web site.

 

The input file should contain the following domain names (one per line):

 

unlv.edu

cs.unlv.edu

web.cs.unlv.edu

expedia.com

state.nv.us

www.technion.ac.il

amazon.com

www.uq.edu.au

rest.cs.unlv.edu

 

Next create another file containing the following IP addresses (one per line):

 

131.216.119.5

64.236.24.12

127.1.2.3     (may generate an error)

131.216.18.59

192.168.0.1   (may generate an error)

 

 

Your program will perform a reverse DNS lookup (PTR query) to obtain domain names given IP addresses using this set of addresses.  For each query your program will output the IP addresses followed by the entire query result.  Again, these records should be output with labels and in a clear format to assist readability.

 

You are welcome to use your own hardware and software resources for development however your submission must compile and execute using the lab machines so the GA can test and experiment with your application. 

 

The source code you create should include sufficient comments as to be self-documenting.  Feel free to ask the GA for his opinion as to the readability of your source.  This will be assessed.  Your program's class structure will also be included in the assessment.

 

Please submit:

1.      hardcopy of all source code 

2.      hardcopy of all program output

3.      a floppy disk or CD containing all source code.  Include any makefiles you may have created to compile and link your application.  If you are using an IDE, e.g., MS Visual Studio, ensure that the complete Project/Workspace environment files are present.

4.      The above materials must be submitted in a 9x12 envelope, with your name and programming assignment name (as above) written at the top, before the submission deadline.  Late or incomplete submissions with either not be accepted, or will be penalized severely.

 

Last Updated: 03FEB04