Hello, dear friend, you can consult us at any time if you have any questions, add WeChat: THEend8_
Assignment 2
CS 436
A Reliable Data Transfer Protocol
Due Date: Tuesday, April 6 2021, at 10:00am
Work on this assignment is to be completed individually
Assignment Objective
The goal of this assignment is to implement a Reliable Data Transfer (RDT) protocol, which could be used
to reliably transfer a text file from one host to another across an unreliable network. The protocol should
be able to handle network errors (packet loss), packet reordering, and duplicate packets. For simplicity,
your protocol is unidirectional, i.e., data will flow in one direction (from the sender to the receiver) and
the acknowledgements (ACKs) in the opposite direction. To implement this protocol, you will write two
programs: a sender and a receiver, with the specifications given below. To test your implementation, you
will write a third program that will emulate an unreliable network link.
When the sender needs to send packets to the receiver, it sends them to the network emulator instead
of sending them directly to the receiver. The network emulator then forwards the received packets to
the receiver. However, it may randomly discard received packets. The same scenario happens when the
receiver sends ACKs to the sender.
Packet Format
All packets exchanged between the sender and the receiver should have the following structure:
integer type; // 0: ACK, 1: Data, 2: EOT
integer seqnum; // sequence number of the packet
integer length; // Length of the String variable ‘data’
String data; // String with Max Length 500
The type field indicates the type of the packet. It is set to 0 if it is an ACK, 1 if it is a data packet, 2 if it is
an end-of-transmission (EOT) packet (see the definition and use of an end-of-transmission packet below).
For data packets, seqnum is sequence number of the packet. The sequence number of the first packet
should be zero. For ACK packets, seqnum is the sequence number of the packet being acknowledged. The
length field specifies the number of characters carried in the data field. It should be in the range of 0 to
500. For ACK packets, length should be set to zero.
2
Sender Program (sender)
You should implement a sender program, named sender. Its command line input includes the following:
,
Upon execution, the sender program should be able to read data from a text file (10KB to 15KB) and send
it using the RDT protocol to the receiver via the network emulator. The RDT is pipelined. The window size
should be set to N=30 packets so that the sender can pipeline the entire file. After all contents of the file
have been transmitted successfully to the receiver (and corresponding ACKs have been received), the
sender should send an EOT packet to the receiver. The EOT packet is in the same format as a regular data
packet, except that its type field is set to 2 and its length is set to zero. The sender can close its connection
and exit only after it has received ACKs for all data packets it has sent and received an EOT from the
receiver. To keep the project simple, you can assume that the end-of-transmission packet never gets lost
in the network.
In order to ensure reliable transmission and congestion control, your program should implement the RDT
protocol as follows:
If the sender has a packet to send, it first checks to see if the window is full, that is, whether there are N
outstanding, unacknowledged packets. If the window is not full (which should be the case here given the
maximum size of the file, the size of the packet payload and the size of the window), the packet is sent.
After all packets in the window are sent, the sender will start a countdown timer set to the inputted
. When the sender receives an acknowledgement
packet with seqnum n, the ACK will be taken to be a selective acknowledgement, indicating that the
packet with sequence number n has been correctly received at the receiver. When a timeout occurs, the
sender retransmits all non-ACKed packets and restarts the timer. These steps are repeated until there
are no outstanding packets.
Output