Puzzle 5 - Error control

In this puzzle you implement a simple error control protocol. You will send a file from one machine to another over a faulty link.

This puzzle is much simpler than the last two puzzles and should only take one session (e.g. one evening) to complete. Since this is the last puzzle in cs519 we encourage you to complete it as soon as possible and be done with the cs519 puzzles.

Main goal

The main goal of this puzzle is to point out that you can have reliable communications over a faulty link.

How to do the puzzle

In this puzzle you will use the network topology below. A program running on m0 will send a file to a receiver running on m2 over a faulty link. Instead of changing the properties of a link we create a proxy that serves as the faulty link. The faulty link proxy is placed on m1.All packets going from m0 and m2 or from m2 to m0 must go through the proxy on m1. When the proxy receives a packet from m0 it will either forward it to m2 (unchanged) or drop it, depending on selected loss rate. The same goes for packets from m2 to m0.

Your assignment is to select and implement a protocol that will detect packet losses and correct for them. Your protocol runs at the end points, i.e. at the sender and the receiver. You cannot modify the faulty link proxy.

In general, you have to make sure that the file sent by the sender is received correctly at the receiver.

puzzle5.gif (1801 bytes)

You will find the init file for the topology above at /home/cs519/entrapid/topology/puzzle5.init. You do not need to setup any routes for this topology.

We provide a prototype for the sender and the receiver, and the faulty_link proxy. You will find all three programs along with makefiles in /home/cs519/entrapid/puzzle5/.

The sender

The sender reads a file from stdin and sends it over to the receiver. The sender will be running on m0. The prototype we provide reads in the file from stdin (note: since we do not need non-blocking stdin we will not have the same problem some students experienced in puzzle 3). Then it sends a UDP packet of size 64 to m1 on port 15000 until it reaches the end of the input file. At the very end it sends a special control packet to m1 to indicate EOF. Since we do not have notion of connection when using UDP, m1 and m2 have no idea when m0 closes. We use the EOF packet to tell both m1 and m2 that there are no more data coming. EOF packets are never dropped at m1. The EOF packet is simply 64 bytes of '\0'.

You can change the sender (and the receiver) as you want but it has to:

Usage of sender:

% sender < <text-file>
%

The faulty_link

The faulty_link proxy serves as faulty link between m0 and m2. It takes one parameter, loss rate: from 0.0 (no losses) to 1.0 (drop all).

The proxy reads on UDP port 15000. All packets it gets from m0 are forwarded to m2 or dropped and vice versa. You should run faulty_link on m1.

When the faulty_link sees EOF packet, it forwards it and quits.

Usage of faulty_link:

% faulty_link <loss-rate>

To make the fault_link program do:

% make -f Makefile.faulty_link

The receiver

The receiver should receive the whole file from the sender and print it out to stdout. If it receives a packet containing '\0' then it should print out the data up to the '\0' and quit. Note: If, for example, the last data packet sent by the sender has only 37 bytes of data it sets the 38th byte to '\0' and sends it (as 64 byte packet) - this packet is then followed by an EOF packet. The receiver will get a packet of size 64. It should only print out the first 37 bytes of data (up tp the first '\0') and then quit.

Note: If you want to print some progress messages from the receiver use stderr. If you print something else than the data file you will spoil your output - and your grade.

Usage of receiver:

% receiver > <file>

Assumptions and hints

Grading

We will run your sender on m0 and your receiver on m2. We will feed the sender of some large text file. If the output of your receiver matches exactly the input file you will get a full grade. If it has some errors, missing data, or extra data, you will get 0.

Note: This puzzle is simple and we will not give 80% grade - even if your implementation only has a minor bug.

What to submit

Please first read the overall submission instructions. In addition, please follow these instructions:

Submit all files you need to build the sender and the receiver. This includes sender.cpp, receiver.cpp, Makefile (the Makefile should build only the sender and the receiver, but not the faulty_link proxy) and other source files needed to build the sender and the receiver.

Instead of sending many files you should tar all files needed and uuencode it before submitting it. If you need instructions on how to use tar and uuencode please read the man pages or see the instructions given for puzzle 4.

IMPORTANT

Then mail the uuencoded tar file to snorri@cs.cornell.edu as usual using mailx.

In the email you send me the subject line must be: CS519: Homework 5

Put a one line comment at the top of your code with your name and Cornell ID (6 digits) with the prefixes "Student:"  and "CornellID:".
Example:

/* Student: John Doe CornellID: 123456 */