CS 4514
Assignment 2
Prof. D. Finkel
Due date: Tuesday February 18
1. Overview
The purpose of this program is write a client-server program to
implement a stop-and-wait protocol for acknowledgments and retransmissions,
using Unix sockets.
You will have two processes running: a sender (the client), which
creates and sends packets with a checksum, and a receiver (the
server), which receives the packets and acknowledges each packet
if its checksum is correct.
We will discuss Unix sockets in detail in class on Tuesday, February
4. Sample programs using sockets can be found in Chapter 12 of
the Horspool book.
Until you are sure that your program is working correctly,
run all the processes on the same machine.
You may assume that input files in this assignment are a multiple
of 64 bytes, so each frame will contain exactly 64 bytes of data.
You will need to write two programs, a sender program and a receiver
program.
The command line arguments for the sender program will be a filename,
filename.in, the server machine name and the server port
number and up to three three frame numbers of frames to have errors.
So the command line for the sender program would look like this:
sender testfile.in wpi.wpi.edu 2345 2 5 8
When the sender program begins, it will establish a connection
to the receiver. The sender will read 64 bytes from the file,
append a checksum, and send the resulting frame to the receiver.
The sender will now wait for an acknowledgment (ACK) or negative
acknowledgment (NACK) from the receiver. If an ACK is received
the sender sends the next 64 bytes. If a NACK is received, the
sender resends the frame. The sender will write a log file, named
filename.in.log, to record each of the following events
with the frame number: frame sent, frame re-sent, ACK received,
NACK received. When the complete file has been successfully transmitted,
the receiver will close its connection to the sender and terminate
Note that the sender does not do framing or sequence numbers.
You may use either the one-byte parity checksum or the CRC-16
checksum from Assignment 1. If you do not have a working checksum
function from Assignment 1, the TAs will give you one. In order
to produce some errors, you will need to write two checksum programs,
one that calculates checksums correctly, and one that calculates
incorrect checksums. The frames indicated on the command line
will receive an incorrect checksum the first time they are sent.
All of the other frames will receive the correct checksum.
The receiver program will have an filename, filename.out,
and a port number as a its command line arguments. The receiver
program establishes a port, and then waits for frames. As each
frame is received, the receiver checks the checksum. If the checksum
is correct, the receiver writes the data to an output file, filename.out
and send an ACK to the sender. If the checksum is incorrect, the
receiver sends a NACK to the sender and discards the data. The
receiver will also write a log file, filename.out.log,
in which it will record, with the frame number, correct frame
received or incorrect frame received.
For extra credit, eliminate the NACK, and have the sender set
a timer for each frame sent. If the sender receives an ACK before
the timer expires, it sends the next frame. If the timer expires,
the same frame is re-sent.
To receive a C in this assignment, implement the program with
only correct checksums and no acknowledgments. To receive a B
in this assignment, implement correct and incorrect checksums
and acknowledgments and negative acknowledgments, but no retransmissions.
Both the sender and receiver should terminate after sending or
receiving an incorrect checksum. To receive an A on this assignment,
implement the complete assignment. Indicate in the readme file
which level you have implemented. Also indicate whether you implemented
your programs on the MIPS machines or Alpha machines.
Turn in your assignment using the turnin program. Turn in your
two programs, named sender.c and receiver.c, the required documentation
files and the readme file. Test input files will be made available
a few days before the assignment is due. Turn in the sender and
receiver log files for these input files.