                         Computer Science 826
                             Assignment 2

Due: 21 September

How to submit: (read these directions!! Failure to follow them
WILL lead to deductions!)

1. In this assignment you MAY work in teams of up to 2 persons.

2. Each of you will have a directory on system jmw on the sun net
   in /local/jmw2/826/a1

   You will own that directory and MUST NOT modify the permissions
   on it. If working as a team submit the code in ONLY ONE DIRECTORY.
   The name of BOTH TEAM MEMBERS must appear in all source modules.

3. In addition to the required code you must supply a makefile
   that will compile and link your assignment and create an executable
   named a.out.


Specification:

Write a multi-threaded program using the pthreads library that
will send a burst of pings to a specified destination and report
the estimated bandwidth, latency, and drop rate. Small packet
pings should be 125 bytes in size. Large packet pings should be
1250 bytes in size.  The maximum burst will be 100 packets.

The program will be invoked as:

   a.out intermediate-host destination-host #of-pings ping-delay-ms

The transmit thread should alternate between sending short and
large pings. The transmitter must NOT use "usleep(n)" to sleep
between samples because it will drift from the required ping
rate. You must use a time of day based approach. The pthreads
package provides a nice one.

The receive thread should receive replies and match them with
transmissions.

When the specified number of pings have been sent. The
transmitting thread should wait one second and then print a
table of results. For each valid sample, (those in which both ts
and tl were received and ts < tl) compute B and L using the
method outlined in class. If ts or tl was dropped, print an *.
otherwise print the roundtrip time is msec in format %6.1f.
Print the computed bandwidth in Kbps in format %6.0f and the
latency in average latency in msec in format %6.1f.

Then print three averaged estimators of B an L:

        0) Simple averaging of the B and L columns

        1) Using averaged values of the ts and tl columns

        2) Minimum estimation..
           Compute B and L using the minimum of the individual
           columns..

Your final output should look like this:

     Sample      ts1      tl1   ts2    tl2     B     L

       1         32.1    38.1   36.4   45.2   1234.  8.0
       2          *      43.1
       :
  #of-pings/4
   ---------------------------------------
     Drops       10      13     11      8
     Avg 1                      1234.  8.4
     Avg 2                      1235.  8.2
     Avg 3                      1236.  8.4

Take particular care in converting between BITS and BYTES
and getting the UNITS CORRECT.  Incorrect UNITS WILL BE
CONSIDERED INCORRECT RESULTS!!

-----------------------------

See /home/westall/class/826/source/snmpmon.c for an example
framework. NOTE WELL: in the example the transmit increment
is in SECONDs and NOT in msecs as is required for your
program.



