Description
Objective:
In this assignment, you need to create a file transfer server and a file transfer client using sockets.
For each server and client, you need to create a TCP and a UDP variant for the transport layer
services. The basic file transfer application that you have to implement, is as follows.
1. The file transfer client sends a file to the server (file size should be at least 1 MB)
2. The file transfer server receives the file, and returns back an acknowledgement (after the file
transfer is complete) with the MD5 checksum of the file.
3. The protocol works as follows.
a. The client first Informs the file name and the file size to the server by sending a hello
message.
b. The server acknowledges the hello message.
c. The client forwards file data over the stream/datagram socket to the server
d. The server receives the data, reconstruct the file at the server side, creates the MD5
checksum of the entire file
e. The server acknowledges the client with the MD5 checksum of the file.
f. The client creates MD5 checksum of the original file before transfer, and matches it
with the received MD5 checksum from the server. The client prints a message at the
console “MD5 Matched” or “MD5 Not Matched”, and exists. You need to implement two
variants of the protocol – one using reliable data delivery through TCP, and another using
unreliable data delivery through UDP. The details of each are as follows.
Client/Server Using TCP Socket
Here all the communications between the client and the server will be over TCP sockets. As
TCP handles reliability and byte ordering by itself, so the implementation of the protocol is
straightforward.
Client/Server Using UDP Socket
Here all the communications between the client and the server will be over UDP sockets. As
UDP is unreliable, you need to implement reliability on top of transport layer, that is at the
application layer itself. To ensure reliability, the client implements the following additional
functionalities at the application layer.
1. Divide the file into chunks of 1 KB (last chunk can be less than 1 KB)
2. Inform the server about the file name, the total file size and the number of chunks to be sent
3. Add an application header to every chunk. Each header should contain following fields,
a. Sequence number – 4 Bytes
b. Length of the chunk – 4 Bytes
This additional information appended with the application header will help you to ensure
the reliability.
4. Forward the chunks using a Stop and Wait protocol with timeout=1 second, to ensure the
reliability of data transfer at the application layer. The details of the protocol is given later.
For both the TCP based and UDP based implementation of the file transfer application, capture
the packets using Wireshark at the receiver side (server) and at the sender side (client), and
compute the followings.
a. Total number of segments received for TCP and the segment size distribution
b. Total number of datagrams received for UDP and the datagram size distribution
c. Total number of retransmitted segments for TCP
g. Total number of retransmitted datagrams for UDP
h. Total time to receive the file for TCP and UDP. Give justifications if you see any time
difference between the two protocols.
Note
1. It is better to run the client and server in separate machines – then you may be able to
see the effect of unreliable data delivery through UDP.
2. Sample code for TCP/UDP server-client are provided.