Starting from:
$35

$29

Lab 2 Solution

Write a file transfer application using TCP sockets in Python. The file-transfer protocol will include a server called ftps.py and a client called ftpc.py. In the following, we assume the client is running on beta.cse.ohio-state.edu and the server is running on gamma.cse.ohio-state.edu.1 First, start the server on gamma.cse.ohio-state.edu using the command:

python3 ftps.py <local-port-on-gamma

Then, start ftpc.py on beta.cse.ohio-state.edu with the command:

python3 ftpc.py <remote-IP-on-gamma <remote-port-on-gamma

<local-file-to-transfer

The ftpc.py client will send all bytes of that local file. The ftps.py server should receive the file and then store it. Make sure that the new file created by ftps.py is in a different directory to avoid overwriting the original file since all CSE machines have your root directory mounted.

The file-transfer application will use a simple protocol. The first 4 bytes (in network byte order) will contain the number of bytes in the file to follow. The next 20 bytes will contain the name of the file (assume the name fits in 20 bytes). The rest of the bytes in the TCP stream to follow will contain the data in the file. Note that TCP is not packet-oriented, but it is stream-oriented. Submit well-documented code using the following command:

submit c3461aa lab2 <code-directory-name

Your program should work for binary files (images, etc.) of arbitrary size. “Chunk” the file into “pieces,” each of which is at most 1,000 bytes. Submit a README.txt file with your lab. The client and server should be running on different machines on stdlinux (see the footnote). You can use the sample images on the course webpage to test your program. Use diff or md5sum at the terminal to ensure that the transferred file is the same as the original one.













• In your lab, you can substitute any machine on stdlinux (e.g., zeta.cse.ohio-state.edu or epsilon.cse.ohio-state.edu) for beta.cse.ohio-state.edu and gamma.cse.ohio-state.edu, respec-tively. You should do so to avoid “overloading” these machines.


1

More products