CS 640 Introduction to Computer Networks

 

Programming Assignment 1: Mock Name Server (MNS)

 

Instructions & FAQs

 

Please check this page for FAQs and frequent updates on instructions. 

 

Testing your program:

 Once you have coded up a client program that meets all the specifications, you can test your program by sending request packets to one of the servers running at the following ports.

 Server IP (common to all servers):  128.105.165.16

 

Returns invalid responses?

Server #

Port #

 

1

5200

*

2

5201

 

3

5202

*

4

5203

 

5

5204

*

6

5205

Please Note:

·        Note that servers 2, 4 and 6 (marked with an * ) return invalid response packets. Use these servers to test the robustness of  your client program.

·        The test servers are designed to be running perennially and will not terminate upon received of a client request of type 6.

·        Please ensure that your client program is complete and adheres to all project specifications before sending test packets to the server.

·        For testing purposes, the database used by the servers to respond to client requests contains the following records:

    Server 1:

     Mapping File:
 
machine1.cs.wisc.edu  128.45.6.1
  machine2.cs.wisc.edu  128.45.6.2
  tom3.cs.wisc.edu          128.45.10.3
  tomcat4.cs.wisc.edu     128.45.11.4
Redirect File:
 
tom4.cs.wisc.edu 128.105.165.16 5202
  128.45.6.3 128.105.165.16 5202

    Server 3:

     Mapping File:
  tom4.cs.wisc.edu          128.45.10.4
  tomcat5.cs.wisc.edu       128.45.10.5
Redirect File:
 
machine1.cs.wisc.edu 128.105.165.16 5200
  128.45.6.3 128.105.165.16 5204
  machine5.cs.wisc.edu 128.105.165.16 5200


Server 5:

     Mapping File:
 
machine3.cs.wisc.edu    128.45.6.3
  tomcat6.cs.wisc.edu       128.45.10.6
Redirect File:
 
tomcat4.cs.wisc.edu 128.105.165.16 5200
  machine1.cs.wisc.edu 128.105.165.16 5202
  machine5.cs.wisc.edu 128.105.165.16 5202



Example Queries:
./client -s 128.105.165.16 -p 5200 -r 0 -d 128.45.6.3 -t 4 -n 4
machine3.cs.wisc.edu

./client -s 128.105.165.16 -p 5202 -r 1 -d
tomcat5.cs.wisc.edu -t 4 -n 4
128.45.10.5

/client -s 128.105.165.16 -p 5202 -r 1 -d
tomcat7.cs.wisc.edu -t 4 -n 4
unresolved

/client -s 128.105.165.16 -p 5206 -r 1 -d
tomcat5.cs.wisc.edu -t 4 -n 4
timeout


      If you encounter any problems while attempting to connect to a particular server try connecting again after a few minutes. If the problem persists, send email to the TA (shukla[AT]cs.wisc.edu)

 
Submission Instructions:

 
·        What to submit:

 

You will need to submit the source code along with the Makefiles in a single tar.gz file (name it p1.tar.gz). The extracted directory p1 should in turn have two sub-directories - client and server. The sub-directories should have their respective codes and Makefiles. Do not submit object files, or compiled executables. The Makefile should have two rules: clean and all.
clean will delete previous .o files, executables, etc.
all should produce a single executable called client/server.
The directory structure should look like this:


                                                                                                                                         p1(dir)

                                                                                                                                             |                             
                                                                                                                             ---------------------------

                                                                                                                             |                                 |

                                                                                                                         server(dir)                client(dir)

                                                                                                                         |               |                 |             |
                                                                                                                 server.c     Makefile       client.c   Makefile

      
The TA will run the following sequence of operations to execute your code: 


tar xvfz p1.tar.gz
cd p1/
cd server/
make clean
make all
./server -p <port1> -f <mapping-file1> -r <redirect-file1>
./server -p <port2> -f <mapping-file2> -r <redirect-file2>
./server -p <port3> -f <mapping-file3> -r <redirect-file3>

cd ../client
make clean
make all
./client -s <server-name> -p <port> -r <req-type> -d <data> -t <timeout> -n <seq-no>

  
Please test to make sure that these commands can execute in sequence without any intervention.

 
· How to submit:

    First add the following line to your .cshrc.local file (located in your home directory):
    set path = ($path /s/handin/bin)

 

Then run the following command at the shell prompt:

    source ~/.cshrc.local

 

Finally, to handin your files, enter the following command:

    handin -c cs640-1 -a PA1 -d <directory>

where <directory> is the path to the directory where  p1.tar.gz is located

 handin will go through the specified directory and hand in the tar ball.


Make sure both the group members submit the same code.


Frequently Asked Questions:

(1) The man pages for some of the  functions needed for the assignment are retrieving  documentation for the perl functions first. To change this, please enter the following command at the command prompt:
               
               setenv MANPATH /usr/share/man
      
(2) For running the client, make sure that you provide the integer value of the request type for the -r option.

(3) Constructing the packet -- There are many ways to create a packet. memcpy is one of the safest and easiest ways. Here is a small example how you can use memcpy.
 //2 bytes of protocol
char replyPacket[replysize]; //it will hold the final packet. you will have to compute the size of the packet beforehand. it will be 8+the size of data filed.
unsigned short int n_protocol= htons(640);  // make sure that you convert it into network byte order as the server expects
memcpy(replyPacket, (char *) &n_protocol, sizeof(n_protocol));  //see the man page for memcpy
int offset = sizeof(n_protocol);//should be 16 bits(2 bytes)

//2 bytes of sequence number
short int seq=10;
short int n_seq_num =htons(seq);
memcpy(replyPacket+offset,(char *) &n_seq_num, sizeof(n_seq_num));
offset += sizeof(n_seq_num);

(4) When you put the hostname in the packet, you should not count the \0 in the size of the hostname.
      eg,   tom3.cs.wisc.edu is 16 bytes long and thus needs no padding.