CSS 432
Program 3: Additive Increase/Multiplicable Decrease

Spring Quarter 2004
Professor: Munehiro Fukuda
Assigned on 4/29/04 and due on 5/13/04


1. Purpose

This assignment implements the additive increase/multiplicable decrease algorithm (AIMD) and RTT estimation for controlling network congestion. You are to observe the number of packets retransmitted when sending packets from 1Gbps to 100Mbps network with the stop-and-wait, sliding window, AIMD algorithms and RTT estimation.

2. Congestion Control Algorithms

  1. Original RTT Estimation:
    Refer to the textbook pages 397-398. The origianl RTT estimation uses the following formula:
       EstimatedRTT = a * EstimatedRTT + ( 1 - a ) * SampleRTT
       Timeout = 2 * EstimatedRTT
    
    Your implementation is to initaialize EstimatedRTT with 1000usec and to set a to 0.85. Follow the RTT sampling algorithm shown in below:

  2. Karn/Partridge Algorithm:
    Refer to the textbook pages 398-399. The Karn/Partridge algorithm does not sample the RTT for retransmitted messages. Therefore, whenever your implementation retransmits a previous message, it should not record the current timestamp in this retransmitted message. To distinguish it from other transmitted messages, you should modify the RTT sampling algorithm specified above:

  3. Slow Start:
    First of all, like HW2, the window size means the number of messages but not bytes. Similary, congestionThreshold defined below is referred as of the number of messages. Read the textbook through pages 471-473. The slow start algorithmn increments the window size by 2 whenever it receives a new acknowledgment as far as it is below the congestion threshold. To use this algorithm, define the valuable congestionThreshold as follows:
         int congestionThreshold = maxWindowSize;
    
         where windowSize is given by the main function indicating the maximum
         window size.
    
    This means that the very first packet transfers follow slow start until the current window size reaches congestionThreshold that has been initially set to the maximum window size. This increase the current window size rapidly until the first network congestion is detected.

  4. AIMD:
    Refer to the textbook page 468-471. Once the current window size reaches congestionThreshold, it must be incremented by 1 but not 2 whenever the AIDM algorithm receives a new acknowledgment. This additive increment is repeated unless a congestion is detected.

    In general, A congestion is detected if packets began to be dropped off. In our implementation, we assume that a congestion has occurred if the number of unacknowledged messages has reached the current window size and the client hasn't received any new acknowledgment within TIMEOUT that has been recently estimated with our RTT estimation.

    Upon detecting a congestion, the AIMD algorithm sets congestionThreshold to half of the current window size, and then resets the window size to 1. In this way, it restarts slow start until another congestion takes place.

  5. Sliding window:
    We uses the sliding window algorithm implemented in HW2, where a cilent keeps writing a message sequence number in message[0] and sending message[] as far as the number of in-transit messages is less than the ucrrent window size, while the server recieves message[], memorizes this message's sequence number in its array and returns a cumulative acknowledgment.

3. HW3 Test Program

Copy ~css432/hw3/hw3.cpp to your directory. This program is the same as hw2.cpp we used previously excpet performing five different test cases:
  1. Case 1: Unreliable test is the same as hw2.cpp.
  2. Case 2: Stop-and-wait test is the same as hw2.cpp except it counts the average number of packets retransmitted, when repeating a 20,000-message transfer 10 times.
  3. Case 3: Sliding window is exactly the same as hw2 and repeats evaluating an elapsed time for 20,000-message transmission as increasing the window size from 0 to 30.
  4. Case 4: Sliding window + congestion is a new test case that uses hw2's clientSlidingWindow( ) function but focuses on the average elapsed time for the window size = 30 and counts the average number of packets retransmitted, when repeating a 20,000-message transfer 10 times.
  5. Case 5: Slow start AIMD test + congestion follows the all congestion control algorithms explained above. The test measures the average elasped time and counts the average number of packets retransmitted, when repeating a 20,000-message transfer 10 times. This test case asks a user if he/she wants to activate or inactivate the RTT estimation algorithm. If it is inactivated, the test assumes that timeout is statically set to 1000usec.

4. udp.o Object File

This is an object file obtained by compiling the professor's udp.cpp which is a key answer for HW2. The file includes another version of serverEarlyRetrans function. This version imitates network congestions at a server side by repeatedly sleeping for a while and thus dropping off messages sent from the client:
Message sequence Behavior
0 - 6666 Keep receiving as many messages as possible
6667 - 9999 Sleep for 1 second every 200 messages
10000 - 15000 Keep receiving as many messages as possible
15001 - 15999 Sleep for 2 seconds every 500 messages
16000 - 19999 Keep receiving as many messages as possible

This new version of serverEarlyRetrans( ) function is used in the test case 4 and 5 of the main function. It sends the client an acknowledgment formatted below:

   int acknowledgment[3];
   acknowledgment[0] = message[0];  // the original message sequence
   acknowledgment[1] = message[1];  // the original message's tv_sec timestamp
   acknowledgment[2] = message[2];  // the original message's tv_usec timestamp

5. Statement of Work

Copy the following files from ~css432/hw3 to your directory:
  1. hw3.cpp
  2. UdpSocket.h
  3. UdpSocket.cpp
  4. Timer.h
  5. Timer.cpp
  6. udp.o
Code in aimd.cpp the following function that implements our congestion control algorithms:

  • int clientSlowAIMD( UdpSocket &sock, const int max, int message[], int windowSize, bool rttOn );
    repeats sending message[] and receiving an acknowledgment at a client side max (=20,000) times using the sock object. The initial congestionThreshold is set to windowSize (=30). The function implements all congestion control algorithm described above. It internally calls the following two functions:

    1. long estimateRtt( arguments ); estimates and returns a new timeout value in usec.
    2. int estimateWindow( arguments ); estimates and returns a new window size.

    Arguments passed to those two functions depend on your implementation. If the clientSlowAIMD( ) function has received rttOn = false, it does not call estimateRtt( ) and always uses 1000usec as its constant timeout value. Change the PORT definitio to the last five digits of your student ID, and thereafter compile them with g++ as follows:

       $ g++ UdpSocket.cpp Timer.cpp udp.o aimd.cpp hw3.cpp -o hw3
    
    If a compilation results in success, you will get the hw3 executable file. Run this program both on a client and a server side. Choose a client machine among uw1-320-16 ~ uw1-320-31 connected to a 1Gbps network and a server machinie among uw1-320-00 ~ uw1-320-15 connected to a 100Mbps network. The program will display the following messages to the standard error:
    Client side example:
       $ ./hw3 uw1-320-10 > data
       Choose a testcase
          1: unreliable test
          2: stop-and-wait test
          3: sliding windows
          4: sliding windows + congestion
          5: slow-start-aimd test + congeestion
       --> 5
       use RTT estimation? (y or n): y
    
    Server side example:
       $ ./hw3 
    
    Type 2, 4, and 5 for evaluating the performance of the three different test cases respectively. In particular for test case 5, type "y" or "n" to activate or inactivate the RTT estimation algorithm. The main function in hw3.cpp will store the performance results in the data file. Use cerr to print out any debugging information or message sequence numbers. Don't use cout, otherwise your debugging and message sequence information will be mixed up with performance results in the data file. If you hope to store cerr information in the data file, you should type:
    Client side example:
       $ ./hw3 uw1-320-10 2> data1
    
    Server side example:
       $ ./hw3 2> data2
    
    In summary, you have to measure the average elapsed time and number of packet retransmissions for the following four teste cases:
    1. Test Case 2: the stop-and-wait algorithm
    2. Test Case 4: the sliding window algorithm
    3. Test Case 5: the slow-start and AIMD algorithm without RTT estimation
    4. Test Case 5: the slow-start and AIMD algorithm with RTT estimation

    6. What to Turn in

    The homework is due at the beginning of class on the due date. You have to turn in the following materials in hard copy. No email submission is accepted.
    Criteria Percentage
    Documentation of your implementations in terms of (1) RTT estimation, (2) window size estimation based on AIMD, (3) slow start implementation, and (4) timeout and message resending, including including explanations and illustrations in details 4pts(20%)
    Source code that adheres good modularization, coding style, and an appropriate amount of comments. The source code is graded in terms of (1) timestamp information in mesasge[1] and message[2], (2) original RTT estimation algorithm, (3) Karn/Partridge algorithm, (4) AIMD used in window estimation, (5) slow start, (6) timeout and duplicated message re-transfer, and (7) comments. Write as many comments as possible, otherwise the professor/the grader cannot keep track of these complicated algorithms. 8pts(40%)
    Execution output such as a snapshot of your display/windows or partial contents of standard error redirected to a file. You don't have to print out all data. Just a 2-or-3-page evidence is enough. 1pts(5%)
    Performance evaluation that summarizes in a table the elapsed time and the number of packet retransmissions of your implementations: (1) stop-and-wait, (2) sliding window, (3) AIMD with RTT estimation, and (4) AIMD without RTT estimation. 4pts(20%)
    Disussions should be given for difference among (1) stop-and-wait, (2) sliding window, (3) AIMD with RTT estimation, nad (4) AIMD without RTT estimation in terms of their elapsed time and # of packet retransmissions 4pts(20%)
    Total 20pts(100%)