6.894 Lab 1: Multifinger

Due date: Thursday Sep. 14. Don't wait until the last minute.


The submission for Multifinger lab is over, the following people have submmitted. Here is the old sample program for your reference, a more elegant one is here. For those of you who do not know how to use ref counted objects and rely on global variables to keep track of per connection state, you may learn some interesting stuff from this program.

The tar file 6894-0.1.tar.gz distributed previously only allows maximum 5 arguments to the callbacks. Since we mentioned in our documentation that callbacks have default maximum 7 arguments restriction, you can download the new tar file if you need more than 5 arguments for your callbacks. Otherwise, the old tar file works just fine. :-)


The first programming project in 6.894 is meant to introduce you to some programming tools you'll be using for the rest of the course, particularly the C++ asynchronous programming library. You'll download source to the library and to the multifinger demonstration program, make a small modification to multifinger, test your code, and submit it to the 6.894 staff.

Fetching the Source

First, copy this file -- 6894-0.1.tar.gz -- to your machine. It's a compressed UNIX tar file containing C++ source. It's only likely to be useful under Linux or UNIX (e.g. on Athena). To extract, configure, and compile the sources:
% add -f gnu (only on Athena)
% gzcat < 6894-0.1.tar.gz | tar xf -
% cd 6894-0.1
% ./configure
% make
Click here if you run out of disk quota while compiling. For your purposes the result of all this is the executable multifinger/multifinger, which is described in Using TCP Through Sockets. Here's how to test it:
% multifinger/multifinger rtm@amsterdam.lcs.mit.edu kaashoek@ny.lcs.mit.edu
This should produce information for Robert Morris and Frans Kaashoek, though perhaps not in that order.

Adding Timeouts

Now try this:
% multifinger/multifinger rtm@frenulum.lcs.mit.edu
The problem is that while frenulum accepts finger requests, it never produces any responses.

Your assignment is to modify multifinger/multifinger.C to terminate connections that don't finish producing a response within 10 seconds of the connection setup. That is, after connect_cb is called, your multifinger should spend no more than 10 seconds waiting for the write()s and read()s to complete. If 10 seconds pass without a complete answer from the server, close the file descriptor and move on to another command-line argument. For example, when your multifinger is run thus:

% multifinger/multifinger yy@frenulum.lcs.mit.edu maxp@mit.edu
it should quickly print the information for Max Poletto, then wait 10 seconds, then exit.

You'll want to use the delaycb function mentioned in Section 5.3 of Using TCP Through Sockets.


We've prepared a few tests to help make sure your multifinger works. Fetch test-mf.pl and run it in the same directory as your multifinger executable, as follows:
% limit descriptors 64
% perl ./test-mf.pl
If the limit command doesn't work, try limit openfiles 64 or ulimit -n 64 instead. If all goes well, test-mf.pl should finish in about 40 seconds and print out
Finger one user: passed
Finger two users: passed
Time out a stuck host in 10 seconds: passed
Combination of good and stuck hosts: passed
More than 64 hosts: passed
Lots of good and stuck hosts: passed
We'll also test your program with test-mf.pl, and perhaps other tests.

How/What to hand in

September 14 - Multifinger

Please e-mail your modified multifinger.C file to 6.894-submit@pdos.lcs.mit.edu, using this command:
% Mail -s '6.894 lab 1' 6.894-submit@pdos.lcs.mit.edu < multifinger.C

We must be able to compile your software with our standard async library, so don't modify the async library. We will compile your source in the same kind of sub-directory as multifinger, so that (for example) the async library source and header files will be in ../async. If you have any problems about submission, please contact jinyang@lcs.mit.edu. The lab is due by the beginning of class on Thursday, September 14th.