Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Part 1 (25 points): Unencrypted File Transfer In Part 1, you will use network sockets to transfer a file from a client to a
Part 1 (25 points): Unencrypted File Transfer In Part 1, you will use network sockets to transfer a file from a client to a server. To simplify operation, the client will "read" a file from STDIN and the server will "save" the file to STDOUT. Your code for the client and server must reside in the same Python script file (uft). Your program must differentiate between client and server mode using command line arguments which must conform to the following format: uft [-1 PORT > OUTFILE] [SERVER_IP_ADDRESS PORT < INFILE] For example, the following is an example execution in two different terminal windows. [server]$ ./uft -1 9999> outfile.txt [client]$ /uft 127.0.0.1 9999 < infile.txt Both programs must terminate after the file is sent. You may assume the server is started before the client. The provided starter code includes command line argument parsing and will execute the client or server function based on the provided arguments. You may not add extra command line arguments. Network Data Exchange: The client will generate Packet Data Units (PDUs) containing binary file data that are then transmitted to the server. The PDUs must conform to the following specifications: Data PDU Element Size in Bytes Encoding Length 2 Data Length Raw Bytes Raw Bytes Description Number of data bytes following this element File Data So the beginning of an example data segment with 70 bytes of data could look as follows: 00 46 53 6F 6D 65 74 69 6D 65 73 20 79 6F 75 20 6E 65 65 64 20 74 6F 20 75 6E 64 65 72 73 74 61 6E 64 20 74 68 65 20 62 69 74 73 20 74 68 61 74 20 6D 61 6B 65 20 6F 72 20 62 72 65 61 6B 20 70 72 6F 74 6F 63 6F 6C 73 with the first two bytes 00 46 encoding the length of the following data (0x46=70). The total length of the PDU is thus 72 bytes to account for the header. Ensure the length bytes are sent in network order (big-endian). Network Sequence: The PDUs will be transmitted as shown in the following network sequence diagram. Server Data PDU 1 Data PDU 2 Client - Data PDU n -1 Important: All parts of this assignment must work for both small and big files, both text based and binary based. I recommend trying first with a simple text file and then testing with a PDF before submitting. Tip: The entire file does not need to be sent in a single PDU. Multiple PDUs may be sent, each containing a portion of the file. The autograder will by default send 1024 bytes of data at a time, but it will accept any length up to 65535 bytes. Each PDU will contain the length of the data within that PDU, not the total number of bytes in the file. Tip: Use sys.stdn.buffer.read() to read from STDIN and sys.stdout. buffer.write() to write to STDOUT. Wrappers for these functions are provided in the starter code.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started