Homework


The goal of the first assignment is to get familiar with the network simulator ns. You task is to implement the Worst Case Weighted Fair Queueing + (WF2Q+) service discipline [1].

Below are the steps that you are going to take.

  1. Download and install ns version 2 from UCB/LBNL/VINT ns web page. To avoid unnecessary installation errors, you are advised to use the option all at once (select Download Instructions form the main page, and then select all at once.)

    NOTE 1: ns-2 is written in C++ and Otcl: C++ is used for implementing the bulk of the simulator, such as traffic sources, routing, scheduling disciplines, while Otcl is in general used for configuring and setting simulations. As a result you have to also download Tcl, Tk, Otcl, and TclCL (this is automatically done when you select all at once option). Since the simulator is quite large (tens of MB), you may want to install it on your local disk. Finally, if you have a choice of the operating system, we recommend you to use Linux or FreeBSD, as these are the main OSes used by ns-2 development teams.

    NOTE 2: There are excellent documentations on-line. For a quick start refer to the manual page and Marc Greis' tutorial web pages. For details consult ns Notes and Documentation. All these documents are accessible from the main page.

  2. To familiarize yourself with using ns, we have prepared a simple example implementing the round-robin scheduling discipline. To add this scheduling discipline to ns-2 and run the simulation proceed as follows:

    1. Download the source file rr.cc and copy it in the main ns-2 directory.

    2. Add rr.o in the Makefile (e.g., after red.o) and then perform
                   make depend
                   make
                
    3. Create directory rr_example, and download rr.tcl, DropTail.tcl, and utils.tcl into this directory. rr.tcl and DropTail.tcl are the configuration files describing the simulation scenarios for the Round Robin discipline (implemented by rr.cc) and the FIFO drop tail discipline (implemented by drop-tail.cc). FIFO drop tail discipline is part of the ns-2 distribution and is used here as a base line for comparison purpose. utils.tcl contains several utility procedures to create TCP and UDP flows; it is used by both rr.tcl and DropTail.tcl.

      In both simulation scenarios, we consider a TCP flow and an UDP flow (sending at 1 Mbps) sharing a 1.5 Mbps link. Both flows use 1000 bytes packets. In both cases the simulation duration is 10 sec.

      NOTE: At this point you are ready to run the simulation by using

                   ../ns rr.tcl
                
      As a result you obtain a trace file out.tr that contains all events (e.g., packet arrivals, departures, and drops) on the shared link.

      Next are some utility programs that help you to parse out.tr and create plots by using gnuplot.

    4. Download into rr_example directory the following files
      • avg_bwidth.c and compile it - utility program used to compute the average bandwidth
      • rr.g and DropTail.g - gnuplot files used to generate bandwidth plots in .ps format
      • run-examples - script used to run both simulations.

    5. In the example_rr directory execute:
                    run-examples
                   
      As a result you should get two postscript files that plots the bandwidth versus time for the two simulation scenarios: rr.ps and DropTail.ps.

  3. Answer the following questions:

  4. Starting from rr.cc implement the Worst-Case Weighted Fair Queueing + (WF2Q+) scheduling discipline [1]. Create a new file wf2q+.cc for this scheduling discipline. Below we give a detailed description of WF2Q+.

    With WF2Q+, each flow is associated a weight, such that the sum of the weights of all flows is no larger than a predefined value W, i.e., if there are n flows, then

               weight[1] + weight[2] + ... + weight[n] <= W
              
    A flow's weight specifies how much share of the capacity of the output link a flow is entitled to receive. For example, if one flow has weight 1, and another flow has weight 2, then the second flow will get twice as much bandwidth as the first flow.

    Each flow i is associated two variables S[i] and F[i] that represent the starting time and the finishing time of the packet at the head of the queue of flow i.

    Finally, a global variable V, called system virtual time, is associated to the system.

    The WF2Q+ can be then described as follows:

    Initialization Set all variable: V, S[i], and F[i], for all flows i, to 0.

    Enqueue Assume packet p of flow i arrives. Then execute the following pseudocode:

                  if (queue[i] == empty) {
                    enqueue(p, queue[i]);
                    // compute starting and finishing times for 
                    // packet at the head of the queue of flow i
                    S[i] = max(V, F[i]);
                    F[i] = S[i] + length(p) / weight[i];
                    // update system virtual time
                    V = max(min_{j}(S[j]), V);
                  } else
                    enqueue(p, queue[i]);
                 
    where min_{j}(S[j]) represents the minimum of starting times among all backlogged flows. A flow is called backlogged if it has at least one packet in the queue.

    Dequeue Consider the set S of all backlogged flows, such that their starting times are no larger than the system virtual time V, i.e., S[j] <= V, for any flow j in S. Then select the flow i in S that has the minimum finishing time F[i]. Finally, execute the following pseudocode:

                  p0 = dequeue(queue[i]); // dequeue and transmit the packet
                  send(p0);  
    
                  p = head(queue[i]); // get packet at the head of the queue, if any
                  
                  if (p) {
                    S[i] = F[i];
                    F[i] = S[i] + length(p) / weight[i];
                 }  
                 // update system virtual time
                 V = max(min_{j}(S[j]), V + length(p0)/W);
                 
    NOTE: If W = C, where C represents the link capacity, then the weight of a flow represents the minimum bandwidth that the flow is guaranteed to receive.

  5. Answer the following questions:

  6. What to submit:

References

  1. Jon C.R. Bennett and H. Zhang, Hierarchical Packet Fair Queueing Algorithms. IEEE/ACM Transactions on Networking, 5(5):675-689, Oct 1997. Also in Proceedings of SIGCOMM'96, Aug, 1996. [.ps.gz] [.pdf]