Home Assignment #5

Due by 19.07.2007, till midnight (24:00)

You need to write a simple server over UDP for text file sharing. The server will be operated on a port, which number it will get as a parameter, and will wait for the client requests. The server needs to handle only one request at a time. When the server gets a request for a file upload, it checks if the file already exists and returns error if so. If file does not exist the server returns OK and waits for the file transfer.

Client starts to send the file by segments of 1K each. The length of the file is negotiated in the beginning of connection, i.e. the server is notified about the file length in the command line after the name of the file. Each segment has a segment No. that is sent to the server. The server will check the order of the segments, and will ACK every received segment. It will save the received file on the local disk

If the received segment is out of order, then the server NACK for a re-send of in-order packet. If the client is getting into a time-out state (no ACK from the server for 1sec), then it will re-send the last segment again. It will continue to re-send the message till it has been successfully acknowledged or 9 times lost. In case of 9 successful losses, the communication is aborted and appropriate notification is printed.

The client implements the following algorithm for sending a data. It starts with sending one segment and waits for and ACK to this message. Upon receiving a successful ACK, the sender doubles an amount of the sent data, i.e. it sends 2 new segments upon receiving notification of every in-order segment received. The exponential growth stops with the first sent segment loss, i.e. first NACK received from a server. Then the sender freezes the size of the sending window (SW) at the value it had at the time of sending lost packet and continues with the same value till the end of communication, i.e. there is at most SW message in transit at any time.

You should simulate packets loss in your model. The client randomly skips sending of approximately 5% of all messages (simulating lost messages). While the server randomly skips sending of approximately 10% of all acknowledgments.

The client will be operated with four parameters: the server name, the server port, the file name and the file size. For example:

MyClient CM700 2006 my_hw5.dat 100

The server will be operated with one parameter: the server port. It should have the same value as for the client. For example:

MyServer 2006

The client and the server should monitor and display the file transfer. Each time the server sees a duplicate message, it prints a corresponding notification. Before the client exits, it prints the number of transferred messages and the number of re-transmissions.

Example:

Server:

.

.

Received segment 6…..Send ACK

Received segment 7….. Send ACK

Duplicate segment 7 ….. Send ACK

Received segment 8….. Send ACK

End of File

Client:

.

.

Send segment 6…..Received ACK

Send segment 7

Timeout

Send segment 7 ….. Received ACK

Send segment 8…..Received ACK

End of File

The number of the segments sent successfully: 8

The number of re-transmissions: 1

The program goes like this:

A User
MyClient CM700 2006 mypicture.jpg / Server (CM700 machine)
MyServer2006
Processing the user parameters, get IP address of CM700 / The server waits for requests
Sending the appropriate UDP request
(with the file name).
Waiting for reply / Receiving the request and processing it
Check if the file exist - return error if yes, and OK if not.
Send the first segment and segment No.
The server needs to know that this is ACK/NACK and not a new request; it should be updated in the ACK data. / Get a segment, and send ACK to the client, including the segment No.
If ACK, send the next segment, else if timeout, re-send the first one.
…….continue until the end of the file / …….continue until the end of the file
Print the final statistics. Terminate the connection. / Send ACK with the last segment number. Return to waiting for the next request.

Implementation

·  The programs should be written in C language, under a Unix platform (should be run on the t2, tx or csd).

·  The programs should be written in separate files, named myclient.c (client) and myserver.c (server).

·  You should submit via the course site: all source files, a Makefile, run scripts for one or more sample test cases, and a README document(ASCII file), which starts with your names and IDs, then describes your solution with the output of the program for the test cases you used, and a usage explanation.

Assumptions

You don't have to check for permissions on the server machine.

*** Good luck!!! ***