Description
Objectives
In this assignment, you will implement a client and server for file transfer. After completing this assignment, you should
- be able to construct application layer packets
- have a good understanding of communication protocol design.
The Unreliable Channel
We have implemented 3 simulators on the machine 172.28.176.63, to mimic unreliable channels. Your server and client have to connect to the simulators and transfer files.
- The simulator waits for both the client and server to connect the simulator via TCP connection before enabling the channel.
- The architecture can be found in fig:1
- Task
- connect to the simulator with a handshake. The handshake is similar to Assignment 1, with an extra character C to signify client and S to signify server. The handshake details can be found in fig:2
- The simulator will send you the current waiting list number; you need to wait till you receive 0_. We allow only 30 students to connect to a simulator at any given time.
- Then you transfer file from the server to the client. The input_file_name will be provided as command line parameter to the server
- Save the received file to the file name provided to client as command line parameter
- You earn 1 mark per correct file transfer in the case of Reliable Channel.
- You earn 2 mark per correct file transfer in the case of other channels.
- Forgot to mention; the simulator really hates making friends. It will timeout and terminate in 100 seconds.
Figure 1: Architecture.
Figure 2: Handshake FSM.
Let us understand the Simulator further:
- All the simulators have the following constraints
- The packet size from the server is fixed to 1024 B.
- The packet size from the client is fixed to 64 B.
- Partial packets will not be delivered
- No packets will be dropped
- The 3 Simulators are:
- Reliable Channel (Mode 0): This channel introduces no error or reordering of packets. Fig 3
- Error Channel (Mode 1): This channel introduces errors in packets. Fig 4
- Reordering Channel (Mode 2): This channel reorders packets. Fig 5
Testing Your Program
To test your program, please use your SoC UNIX ID and password to log on to stu as instructed in Assignment_0.
Figure 3: Reliable channel FSM.
Figure 4: Error channel FSM. • Since you have 2 programs, you will be running them on 2 separate terminals
- Your program should receive five command-line argument as the following command shows:
python3 Sever-A0165432X.py <ip_address> <port_num> <input_file_name> <mode> <st key> python3 Client-A0165432X.py <ip_address> <port_num> <output_file_name> <mode> <s key>
- <ip_address>: The IP address of the machine on which the simulator is running.
- <port_num>: The port number of the TCP socket corresponding to the simulator.
- <input_file_name>: The file to be transferred
- <output_file_name>: The destination file name
- <mode>: Is the integer input corresponding to the simulator we are connecting to – <student_key>: The 6 digit key is the same as the one used in Assignment_1.
- During the evaluation, we will change the input files, the IP address and the port number; hence your code should accept all the above mentioned command line parameters.
- Note that your program should not read from stdin.
- Your program can print anything to stdout or stderr, and our test script will silently ignore them.
- We also release a set of grading scripts to you under the test
- To use the grading script, please upload your program along with the test folder given in the package, to stu. Ensure that your program and the test folder are
Figure 5: Reorder channel FSM.
in the same directory. You can run the following command for help: bash test/FileTransfer.sh -h
- To run the test script for the server, kindly use the -s option
“con | ges |
All of you will be connected to a single simulator, hence start the assignment early to avoid tion” during the last few days.
Template
We have released the template of the code.
- The entire code structure is implemented.
- Handshake code is implemented.
- Few helper functions like Packet reception code are implemented.
- Kindly implement only the part of the code with #TODO
Enjoy!!!