In this assignment, you are provided with a channel emulator for an unreliable channel. You must implement the selective repeat versions of reliable pipelined data transfer and a simple file transfer application. The reliable transfer protocol must be able to handle network errors such as packet loss, duplication, and reordering. For simplicity, the protocol only needs to be unidirectional, i.e. data flows in one direction only (from sender to receiver) and acknowledgements (ACKs) in the opposite direction. To implement this protocol, you need to write two programs: a sender and a receiver with the specifications given below. Communication to and from the channel emulator uses UDP. You can implement your solution in any programming language. The overall setup is shown in the schematic diagram below
Sender | S | UDP | B | Channel Emulator | C | UDP | E | Receiver |
and uses the following addressing scheme (see Addressing for further information):
S: address/port learned automatically by channel emulator using 'recvfrom'
B: address/port written into 'channelInfo' by channel emulator, read by sender
C: address/port learned automatically by receiver using 'recvfrom'
E: address/port written in 'recvInfo' by receiver, read by channel emulator
When the sender needs to send packets to the receiver, it sends them to the channel emulator at 'B' instead of sending them directly to the receiver. The channel emulator then forwards the received packets to the receiver at 'E'. However, it may randomly discard or delay packets. The receiver sends ACKs to the sender via the channel at 'C', which may also randomly discard or delay ACKs.
Field | Type |
Packet Type | 32 bit unsigned integer, big endian |
Sequence Number | 32 bit unsigned integer, big endian |
Packet Length | 32 bit unsigned integer, big endian |
Payload | byte sequence, maximum 500 bytes |
The Packet Type field indicates the type of the packet. It is set to
For data packets, the Sequence Number is the modulo 32 sequence number of the packet, i.e. the sequence number range is [0,31]. For ACK packets, Sequence Number is the sequence number of the packet being acknowledged.
The Packet Length field specifies the total length of the packet in bytes, including the packet header. For ACK and EOT packets, the size of the packet is just the size of the header.
You must implement a sender program that takes two arguments: the value of a timeout in milliseconds and a filename. The sender then transfers the file reliably to the receiver program. The timeout is used as the timeout period for the reliable data transfer. During the transfer, the sender program should create packets as big as possible, i.e. containing 500 bytes payload, if enough data is available. After all contents of the file have been transmitted successfully to the receiver and the corresponding ACKs have been received, the sender should send an EOT packet to the receiver. The sender can close its connection and exit, after the receiver has responded with an EOT packet. You can assume that EOT packets are never lost. The sender must be robust in the presence of a faulty receiver. For example, when receiving unsolicited ACKs or EOT, the sender must report this as error to standard error, but otherwise continue.
You must implement a receiver program. The receiver program takes one argument: the filename to which the transferred file is written. When the receiver program receives the EOT packet, it sends an EOT packet back and exits. The receiver must be robust in the presence of a faulty sender. For example, when receiving data packets out of range or an EOT while packets are still missing, the receiver must report this as error, but otherwise continue.
For both testing and marking purposes, your sender and receiver program must print log messages to standard output - a line for each data packet being sent and received (including duplicates) in the following format:
PKT <SEND|RECV> {DAT,ACK,EOT} <sequence number> <total length>For example:
PKT SEND DAT 17 512 PKT RECV ACK 17 12You must follow this format to avoid problems during testing and marking.
Further, whenever your program executes a potentially blocking function call (read, recv, select, sleep, etc.), it must print a message to standard output, describing the call that is being made. The format of this message is not important, but it should not contain the string "PKT". If the program ever hangs, this output will help to determine why.
channel <max delay> <discard probability> <random seed> <verbose>
cpu06.student.cs 38548
sender <sendfilename> <timeout> receiver <recvfilename>