Simple Name Service Assignment for CMSC 417 Computer Networks - Prof. Samrat Bhattacharjee, Assignments of Computer Systems Networking and Telecommunications

A programming assignment for a university course on computer networks (cmsc 417) where students are required to write a simple name server and a resolver. The assignment involves implementing mechanisms for re-transmissions and checksum computation for udp packets. The server and clients communicate using udp and query a resident database for hostname to ip address mappings.

Typology: Assignments

Pre 2010

Uploaded on 07/30/2009

koofers-user-zia-1
koofers-user-zia-1 🇺🇸

10 documents

1 / 6

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
CMSC 417 Computer Networks Spring 2009
Programming Assignment 2 Simple Name Service
Assigned: February 13 Due: February 23, 23:59:59
1 Introduction
In this project,youwill writeasimple nameserver andaresolver.Therealdomain nameservice
in theInternet is used toresolvethemappingbetween ahostnameandanIP address.
Asusual, theserver will runonamachineatawell-knownportnumber.Theclients, called
resolvers, will contact theserver withqueries abouthostnames andIP addresses. Theserver has
aresidentdatabase ofhostnametoIP address mappings. Thedatabase androutines toaccess it
will beprovided toyou.Onreceivinganameservice query,theserver will lookupthequeryin the
database andrespondwithanappropriateanswer.
The server and the client (resolver) will use UDP to communicate with each other. UDP is an
unreliable protocol. Thus, forvariousreasons, UDPpacketsmaybelost in thenetwork.
In this assignment,youwill need toimplementtwonew mechanisms:
Re-transmissions from the client: Since datatransfer in UDPis notreliable, youwill
need to create a re-transmission mechanism in the client for queries that do not lead to a
response fromtheserver.
Checksum computation: To ensure that the data received at either end has not been
corrupted in the network, on receiving a packet from the network, you should first compute
the checksum to see if the data is correct. The server and the resolvers will silently ignore all
corrupted packets.
2 Protocol Specification
The protocol works as shown in Figure 1. The client will construct queries of dierent types and
send them to the server. The server will query its internal database for each client query and send
back a response. The client is responsible for re-transmitting any query that gets lost or corrupted
in the network. Details of the protocol follow.
1
pf3
pf4
pf5

Partial preview of the text

Download Simple Name Service Assignment for CMSC 417 Computer Networks - Prof. Samrat Bhattacharjee and more Assignments Computer Systems Networking and Telecommunications in PDF only on Docsity!

CMSC 417 Computer Networks Spring 2009

Programming Assignment 2 — Simple Name Service

Assigned: February 13 Due: February 23, 23:59:

1 Introduction

In this project, you will write a simple name server and a resolver. The real domain name service in the Internet is used to resolve the mapping between a hostname and an IP address. As usual, the server will run on a machine at a well-known port number. The clients, called resolvers, will contact the server with queries about hostnames and IP addresses. The server has a resident database of hostname to IP address mappings. The database and routines to access it will be provided to you. On receiving a name service query, the server will lookup the query in the database and respond with an appropriate answer. The server and the client (resolver) will use UDP to communicate with each other. UDP is an unreliable protocol. Thus, for various reasons, UDP packets may be lost in the network. In this assignment, you will need to implement two new mechanisms:

  • Re-transmissions from the client: Since data transfer in UDP is not reliable, you will need to create a re-transmission mechanism in the client for queries that do not lead to a response from the server.
  • Checksum computation: To ensure that the data received at either end has not been corrupted in the network, on receiving a packet from the network, you should first compute the checksum to see if the data is correct. The server and the resolvers will silently ignore all corrupted packets.

2 Protocol Specification

The protocol works as shown in Figure 1. The client will construct queries of different types and send them to the server. The server will query its internal database for each client query and send back a response. The client is responsible for re-transmitting any query that gets lost or corrupted in the network. Details of the protocol follow.

Client Server

Query Response

Database

Another query

Response

Retransmitted query

Packet loss

Set

Timeout

Timer

Figure 1: protocol outline

2.1 Packet Format

Both query and response packets have the same packet structure shown below. The maximum size of each packet is 256 bytes. 0 1 2 3 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |Version|T|D|S|U| Length | Checksum | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Query-ID | | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | | | | Data | | .... | | | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

Version (4 bits) The version field for the protocol should be set to 1111.

Packet-type (T) (1 bit) Set to 0 for query packet, and 1 for response packets

Data-type (D) (1 bit) The data bit is set to 0 if the data field is an IP address, and 1 if it is a hostname.

2.2 Retransmission and checksum

If the server does not reply within a pre-defined time period (i.e., the retransmission timer expires before receiving responses from the server), the client will re-try its query. The server is completely stateless, i.e., it does not remember which queries it has served, from whom, and when. If it receives the same query from the same resolver, the server will answer as appropriate. Note: Clients must be able to disambiguate stale responses from the server. Thus, if a client gets a response which does not match the latest Query-Id, it should ignore this response and not re-set the retransmission timer. The checksum is one’s complement of the one’s complement sum of all 16-bit words in the packet. Compute the checksum in the following manner:

  • When sending a packet:
    • Initialize the checksum field to 0.
    • Compute the one’s complement sum of all 16-bit words in the packet.
    • Take one’s complement on the sum obtained above and fill it into the checksum field.
  • When receiving a packet:
    • Compute the one’s complement sum of all 16-bit words in the packet.
    • Take one’s complement on the sum obtained above.
    • Accept the packet iff the checksum is 0

3 Requirements

You will have to write both the server and the client for this assignment. No TCP connections are allowed. We will have a server up and running for you to test and debug your client. The server we provide, however, will not drop, delay, or damage the packets it sends. You may modify your own server to simulate poor network conditions if you want to test your client more intensively, but the server you turn in should operate normally (i.e., no dropping, delaying, or damaging the packets). The name server and the client executables will accept the following command line arguments:

  • Server: server [-p hporti] [-d hdatabase-file-namei]
  • (Optional) port : Port of the host at which the server will run. Note that the ports you can use are the same as the previous assignment. Default value: SERVER PORT.
  • (Optional) database-file-name : Name of the database file name to use for mapping the IP addresses to hostnames. Default value: DEFAULT DB NAME.
  • Resolver: client [-h hhostnamei] [-p hporti]
    [-t htimeouti] [-i hmax-retriesi] [-r] hdatai
  • (Optional) hostname: Hostname of the host at which the server is running. Default value: localhost
  • (Optional) port : Port of the host at which the server is running. Default value: SERVER PORT.
  • (Optional) timeout: Indicates in seconds, how long to wait before regenerating an un- answered query. Default value: 5.
  • (Optional) max-retries: Indicates the number of times the resolver will re-generate the query, before it quits, if no response is received from the server. Default value: 3.
  • (Optional) r flag: Use the -r flag to indicate a reverse DNS lookup, i.e., the resolver queries with an IP address and expects to receive the corresponding hostname from the server. If this flag is not provided, the resolver will query with a hostname.
  • data: This is a string that will form the data portion of the query. Hostname queries must specify a dotted quad here, while IP address queries will specify a hostname. Note that the length of the hostname should be able to fit in a single packet.

4 Database Interface Functions

The server will query entries in the database using the following interface routines :

  • int db open(char *file name); opens and initializes database, where the actual data is stored in the file file name.
  • int db lookup by hostname(char *result, int result size, char *query); queries the IP address associated with a hostname. The hostname is passed in as a string in query, and the result of the query will be stored as a string in result, where result size specifies the size of the result buffer. The calling function is responsible for allocating storage.