Reference no: EM132212212
Write python code that will transfer a file reliably between two hosts (a sender and a receiver).
Regarding the transport protocol service, you have to design your own packet format and use UDP as underlying transport protocol. Your packet might include fields for: type, sequence number, acknowledgement number, advertised window / window size, data, checksum or CRC, etc.
This part of the assignment is entirely up to you. Your code MUST adhere to the following:
• The sender must accept data from standard-input (stdin), sending data until an end-of-file (eof) is reached.
• The sender and receiver must work together to transfer the data reliably.
• The receiver must output the received data to standard-output (stdout), in order, and without errors.
• The sender and receiver must print out specified debugging messages to standard-error (stderr).
• The sender and receiver must gracefully exit.
•Your code must be able to transfer a file regardless of file size or type, with any number of packets dropped, damaged, duplicated, and delayed, and under a variety of different available bitrates and link latencies. you should detect errors, send acknowledgments, have timeouts, and retransmit if needed.
You will submit two programs: a sender program that accepts data and sends it across the network, and a receiver program that receives the sent data and outputs it correctly, in-order. You must use Python to implement both programs. The client sender program takes command line arguments of the remote receiver IP address and UDP port number. To aid in grading and debugging, when your sender sends a packet (including retransmissions), it should print the following to stderr:
<timestamp>[sending] start (length)
where timestamp is a timestamp (down to the microsecond), start is the beginning offset of the data sent in the packet, and length is the amount of the data sent in that packet. When your sender receives an acknowledgement, you should also print to stderr:
<timestamp>[recv ack] end
where end is the last offset that was acknowledged. You may also print some messages of your own to indicate timeouts, etc., depending on your design, but make it concise and readable.
The receiver program takes a command line argument which is the UDP port number to use for receiving datagrams. The receiver program will start up and will bind to the local UDP port and once bound, it will print out the following to stderr:
<timestamp> [bound] port
To aid in grading and debugging, when your receiver receives a valid data packet, it should print to stderr:
<timestamp> [recv data] start (length) status
where start is the beginning offset of the data sent in the packet, and length is the amount of the data sent in that packet, and status is one of ACCEPTED (in-order), ACCEPTED (out-of-order), or IGNORED. If a corrupt packet arrives, your receiver should print to stderr:
<timestamp> [recv corrupted packet]
Similar to the sender, you may add your own output messages. Both the sender and the receiver should print out a message to stderr after completion of file transfer, and then exit gracefully:
<timestamp> [completed]