CPSC 441 Computer Communications (Winter 2005)

Assignment 2

A. Mahanti/I. Jirasek

Department of Computer Science

University of Calgary

Total Marks: 50 (accounts for 7.5% of your final mark in the course).

Due Date: By 23:55 hours on March 9, 2005.

Late Submissions are not acceptable.

Submission Method: Use the “submit” system.

Grading Policy: A “demo” is required for part II.

Overview

There are two parts to this assignment. The first part of this assignment will reinforce your understanding of data link layer addressing and network layer addressing.

In the second part of this assignment, you will learn how to implement a real-world network protocol based on publicly available protocol specifications. In particular, you will implement a client and a server program based on the Domain Name System (DNS) protocol.

Part I: Problems (15 marks; each question is worth 3 marks)

  1. Why does the fragmentation field in the IP header measure offset in 8-byte units?
  2. Suppose that an application delivers a UDP message with 2972 bytes of data to IP for delivery across a link. The link uses 8-byte headers and has an MTU of 500 bytes. The link’s MTU gives the size of the largest IP datagram that can be carried in a link-layer frame. Determine the size and offsets of the fragments generated. Assume all IP headers are 20 bytes.
  3. The entries of the Address Resolution Protocol (ARP) table timeout after 15-20 minutes. Comment on the rationale behind the choice of the timeout value. (Hint: Think what happens if the timeout value is too small or too large.)
  4. Suppose that the router receives the following new IP addresses (in address/mask format): 57.6.96.0/21, 57.6.104.0/21, 57.6.112.0/21, and 57.6.120.0/21. If all of them use the same outgoing interface on the router, can they be aggregated? Explain.
  5. Suppose that a router has the following CIDR entries in its routing table:

Address/Mask Next Hop

135.45.56.0/22 Interface 0

135.40.60.0/22 Interface 1

192.53.40.0/23 Interface 3

Default Interface 4

What does the router do if packets with the following IP addresses arrive?

(a)  135.46.63.10

(b)  135.46.52.2

(c)  192.53.40.7

Submission Guideline: Submit your work for this part in ASCII text, Postscript (PS), or Portable Document Format (PDF).

Part II: Under the hood of the Domain Name System

(35 marks; Bonus questions worth an additional 10 marks)

1.  Introduction

The Domain Name System (DNS) is one of the largest distributed systems deployed on the Internet, and is primarily responsible for translating hostnames (such as www.cpsc.ucalgary.ca) to IP addresses (such as 136.159.5.17). Clearly, the functionality of DNS is critical to almost all networking applications, including Web browsing and email.

The DNS infrastructure consists of several components namely, a client resolver, local DNS servers (LDNS), and authoritative DNS servers (ADNS). Lookups are initiated by the client resolver, a software library at an end-user library responsible for initiating DNS queries. These DNS queries are usually forwarded to an LDNS server, typically deployed by the client’s network administrators. These LDNS server’s improve scalability and efficiency of the DNS system by caching DNS records.

The DNS database is distributed across a hierarchy of ADNS servers. If an LDNS server can not respond to a client’s DNS query, it will iteratively query a hierarchy of ADNS servers. Typically, a client’s query is first directed towards a root server. Root servers, however, do not contain hostname to IP address mappings; rather, they contain records for locating top-level domain name servers, which in turn contain pointers to ADNS servers that contain actual hostname to IP address mappings. See references [1-5] for a detailed discussion of the DNS architecture.

For this assignment, you will write the following:

·  A simple DNS resolver that sends queries to a DNS server, receives DNS responses, and extracts and prints information available from the response. Refer to RFC 1034 and 1035 to determine the appropriate formats for DNS queries and DNS responses. (20 marks)

·  A simple DNS server that accepts DNS queries from a set of clients, forwards the client requests to a designated DNS server, reads the replies from the designated DNS server, and relays these replies back to the appropriate clients. You can think of your server implementation to be a mini-LDNS server. Note that your server would forward requests only if it is unable to service them from its cache. Implementing the caching component, however, is optional for this assignment (see the section on bonuses). (15 marks)

2.  Details

The inputs to the DNS resolver will of the format @server port name type, where

1)  server is the IP address of the DNS server to be contacted, specified in dotted-decimal format;

2)  port is the port number on which the DNS server listens for incoming queries;

3)  name is the resource record requiring resolution; and,

4)  type indicates what type of query is desired. Your program should support the following query types: A (hostname resolution), MX (mail exchange for domain), and NS (authoritative name server for domain).

Upon receiving an input, your resolver will build a DNS query, send this query to the specified DNS server, and wait for a response. Upon receiving a response, the client will extract and interpret the contents of the header portion and the answer resource record portion of the DNS response message. Specifically, your program will parse the header and print the ID, OPCODE, RCODE, number of entries in the question section, number of resource records in the answer section, number of name server resource records in the authority records section, and additional records. In addition, your program should parse the contents of the answer resource record and interpret all of its contents, namely the domain name the record belongs to, type of record, class of record, TTL, resource data length, and contents of the resource data. Note that the format of the resource data depends on the type of resource record requested. Finally, also print the elapsed time between sending a request and obtaining a response.

Note that the functionality desired in the resolver program is similar to that of the domain information groper (dig) utility, available on most Linux machines. Therefore, a good idea might be to compare the results obtained from your resolver program with that obtained by dig. After completing and debugging the resolver program, you can start working on the DNS server program.

Note that the DNS server you will be designing is actually acting as a proxy server. That is, it acts as a server to the clients that connect to it and acts as a client to the DNS server it forwards the client queries to. Therefore, you should try to reuse code, as much as possible, from the DNS resolver program you write. Note that your server could act as a cache for resource records; however, for simplicity you should start with the non-caching server.

3.  Additional Requirements

Your programs should adhere to the following:

·  You are required to implement your programs using C or C++ on Unix.

·  DNS queries/responses can be sent using either TCP or UDP. Your programs should use UDP as the transport-layer protocol.

·  Your client program should timeout if no response is obtained from the DNS server within two minutes of sending the query.

·  Your program should not use gethostbyname or any of its variants.

·  Your code should be well-written. For example, you should check the return values for all system calls and appropriately handle errors. Include useful comments in your code.

4.  Bonus Questions (10 marks; accounts for an additional 1.5% of your final mark)

You can win bonus marks in this assignment by adding additional functionality to your DNS resolver and/or your DNS server program.

·  The first bonus question is concerned with adding support for inverse queries in the resolver program – that is support for looking up the hostname corresponding to an IP address.

·  The second bonus question requires that you provide support for DNS resource record caching at your server.

5.  Useful References

1)  P. V. Mockapetris, Domain Names – Concepts and Facilities, Request for Comments 1034, Internet Engineering task Force, November 1987.

2)  P. V. Mockapetris, Domain Names – Implementation and Specifications, Request for Comments 1035, Internet Engineering task Force, November 1987.

3)  J. F. Kurose and K. W. Ross, Computer Networking: A Top-Down Approach Featuring the Internet, Addison Wesley, Third Edition, 2005. (Refer to Section 2.5)

4)  A. S. Tanenbaum, Computer Networks, Prentice Hall, Fourth Edition, 2003. (Refer to Section 7.1)

5)  A. Rodriguez, J. Gatrell, J. Karas, and R. Peschke, TCP/IP Tutorial and Technical Overview, IBM Redbooks, http://www.redbooks.ibm.com/redbooks.nsf/redbooks/, August 2001. (Refer to Chapter 8)

6.  Deliverables

You are required to submit the following items:

·  A manual that briefly describes the logical flow of your program, how requests are generated, and responses are processed etc. A description of the limitations of your programs should also be included. Submit your manual in PS, PDF, or ASCII text format.

·  A ReadMe file listing all the files being submitted, your name and student number, and any other relevant information.

·  Your DNS resolver and DNS server programs. Provide a Makefile to compile your code. Include your name and student number in the source code.

7.  Marking Guide

To get credit for this portion of the assignment, you are required to give a demonstration to your tutorial leader. Demonstrations are to be given during normal tutorial hours. To enable you to better organize your submission, we are providing you with the marking guide for this portion of the assignment in advance.

·  Resolver implementation (14 marks).

·  Documentation for the resolver such as manual and ReadMe files (4 marks).

·  Resolver code quality (2 marks).

·  DNS server implementation (11 marks).

·  Documentation for the server (2 marks).

·  Server code quality (2 marks).

·  Inverse query support in the resolver (Bonus of 5 marks).

·  Caching support in the sever (Bonus of 5 marks).

1