You are on page 1of 3

Indian institute of Space Science and Technology AV 341 2013: Computer Networks Lab 2013

Date: 25/02/2013 and 01/03/2013 Experiment No: 3 Objectives: To create a simple file transfer protocol (FTP) program called MyFTP to transfer files from a Client machine/process to a Server machine/process. MyFTP should use separate control and data channels. The control channel must use a UDP socket and the data transfer should be over a TCP socket connection. The client should take the file name of an existing file at the client machine as user input. The client side program should read the file and transfer the content to the server. Server program should write the received contents to a local file at the server machine. The size of the file at the server and client should match.

Requited Approach:
MyFTP Client Control channel (UDP) MyFTP Server

Data channel (TCP)

Procedure: Client: Step 1: Take in user input (name of an existing file at the client to be sent to the server). Step 2: Read the file and estimate the size of the file.

Step 3: Create a control channel using UDP socket and send the filename and file size information as two separate data packets to the MyFTP server. File name/file size may be sent to the server with header containing the following format:
NAME Filename.txt

SIZE

File size in bytes.

CLOSE

DATA/CTRL

NAME, SIZE, and CLOSE are text commands for the UDP control channel to convey necessary information to the server. For example, NAME in the header of the packet indicates that the payload is file name, SIZE in the header indicates that the file size is contained in the payload, and CLOSE in the header of the packet can instruct the server to close the DATA or Control channel sockets. Step 4: Create a data channel using TCP client-side socket and connect to the server process/machine. Step 5: Read the contents of the clients file and transfer the file contents to the server process/machine over TCP socket. Step 6: After file transfer completed, close both the UDP and TCP sockets at the client and exit from the program. Step 7: Verify, that the file transferred to the server is received exactly same as the file at the client.

Procedure: Server: Step 1: Create a UDP server and wait for file name and file size information from client machine/process. Step 1.a: Once the file name and file size information are available, create a new local file with name received over the UDP Control channel.

Step 2: Create a TCP socket, bind it, listen on it, and be ready to accept connections on it. Step 3: Accept incoming data connections and start receiving bytes. Count the bytes received from the client. Step 4: Write the contents received from the TCP Connection to the file created in Step 1.a. Check the number of bytes received from the client. Step 5: After successfully receiving the entire file contents (by matching with the file size), when the CLOSE packet is received from client, close DATA/CTRL sockets and exit the program. Step 6: Compare the files sent and received to make sure the MyFTP program you developed transfers files without an error.

Documents Required: You may bring your entire past lab documents. Most importantly, the UDP client/server and TCP client server programs may be of significant use.

References: Linux Manual pages on Socket APIs. Unix Network Programming by Richard Stevens et. al.

Homework/Documentation: Prepare a lab record/notebook documenting the code and outcome for the experiment. Each student must prepare his own lab document.

You might also like