V22.0480-005 Lab 6: Reliable transport, part 2

Due date: Monday May 3, 11:59pm

Reading:

Introduction and Requirements

Your task is to implement more functionality into the reliable transport layer we started in the previous lab. In this second half of the assignment, your implementation should add the following functionality: More specifically, your transport layer, in addition to the functionality from the previous lab, must support the following:

Getting Started

You will reuse many of the same code from last week's lab, although you should get a new tester source file and Makefile. More specifically, do the following, where [reliable1] is the directory of your previous lab, and [reliable2] is the directory that you wish to create for this lab.
% mkdir [reliable2]
% cp -R [reliable1]/* [reliable2]
% cd [reliable2]
% setenv AUTOCONF_VERSION 2.13
% cp ~class/src/reliable2/rlbtester2.c ~class/src/reliable2/Makefile.am .
% sh ./setup
...
% setenv DEBUG -g
% ./configure
...
% gmake clean
% gmake
...

Interfaces and hints

You should modify your files clntd.c and srvd.c from last week to implement this functionality.

To send MTU-sized packets, there are two cases to consider.

First, you should pack as much data received during separates reads (i.e., received by handle_data) during one intra-timer period into a single packet. Thus, if handle_data receives 10 bytes, then 44 bytes, then 12 bytes during one timer cycle, you should send this out as one packet: 1 reliable_hdr followed by 66 bytes of payload.

Second, you should spam large reads across multiple packets. If during one intra-timer period, you received 1500 bytes, then another 1500 bytes, and say sizeof (struct reliable_hdr) is 12 and pkt_mtu is 1460, this algorithm should create the first packet of payload length 1448, the second packet of length 1448 (the last 52 bytes from the first 1500 bytes read, and the first 1396 bytes of the second read), and the last packet of payload length 54 bytes.

Note that, optimally, you always want to send out full MTU-sized packets. However, "TCP" neads a fast response as it is often using for "real-time" protocols like telnet. Thus, even if you only have a little bit of data, you still want to push it out relatively fast, which is why you should only assemble packets during the intra-timer period (the time between 2 calls to your timer function), as opposed to waiting (possibly indefinately) to read MTU bytes.

Testing the assignment

You should initially test your program by hand, i.e., creating a server and client, then typing data into the client's STDIN. Note that you need to start the server before starting the client, as the client should immediately attempt to connect to the server at the port specified.
% ./srvd [port]
% ./clntd [port]

The server (svrd) and client (clntd) expect you to give them the same port (> 1024). If your program is working correctly, anything you type into the client should output by the server to STDOUT in the same order it was input.

Our new official test program can be run via;

%  ./rlbtester2 ./clntd ./srvd

Turning in the assignment

To build a software distribution, run the command:
% gmake distcheck
rm -rf reliable-0.0
...
==============================================
reliable-0.0.tar.gz is ready for distribution
==============================================
% 
To turn in your distribution, copy it to the directory ~class/handin/lab6/username where username is your username:
% cp reliable-0.0.tar.gz ~class/handin/lab6/`logname`/
% 
To create a script file, use the script command. When you run script, everything you type gets saved in a file called typescript. Press CTRL-D to finish the script. The typescript should be copied to the same directory as the software distribution. For example:
% script
Script started, output file is typescript
%  ./test-reliable ./rlbtester2 ./clntd ./srvd
rlbtester: success: read [Hello.This is only a test.]
Finished test for packing messages to prevent short writes...
rlbtester: success: have multiple outstanding packets
Finished test for sending multiple outstanding messages...
rlbtester: success: read [Testing 000 Testing 000 Testing 000 Testing 000 Testing
Testing 000 Testing 000 Testing 000 Testing 000 Testing
Testing 000 Testing 000 Testing 000 Testing 000 Testing
Testing 000 Testing 000 Testing 000 Testing 000 Testing
...
Testing 555 Testing 555 Testing 555 Testing 555 Testing
Testing 555 Testing 555 Testing 555 Testing 555 Testing
Testing 555 Testing 555 Testing 555 Testing 555 Testing
]
Finished test for handling packet reordering...
Finishing experiment: 10 out of 10 points

[Internal use only: mfreed @ Fri Apr 23 16:04:28 EDT 2004
    MD5 (./clntd) = cbecd21ba118ac8ec05991058f4a5996
    MD5 (./srvd) = 8f8915c52ef29ebc548549cb8e8d0f0e
% ^D Script done, output file is typescript
% cp typescript ~class/handin/lab6/`logname`/
% 
If you have any questions, please contact us at   netstaff (at) class cs nyu edu.