EE566 ns-2 Assignment

For each of these excercises, in addition to answering the questions below, please e-mail your Tcl script as an attachment to: hussein@ee.washington.edu



Exercise 1: Routing

Write a Tcl script that forms a network consisting of 7 nodes, numbered from 1 to 7, forming a ring topology. The links have a 512Kbps bandwidth with 5ms delay.
Set the routing protocol to DV (Distance vector). Send UDP packets from node 1 to node 4 with the rate of 100 packets/sec (using default packet size). Start
transmission at 0.01. Bring down the link between node 2 and node 3 at 0.4. Finish the transmission at 1.000. Then run nam to view the results. Answer the
following:
a. What path does the packets follow initially? and why?
b. What path does the packets take after the link fails? and why?

You can download a skeleton file below.

        set ns [new Simulator]

        set nam_file prob1.nam
        set nf [open $nam_file w]
        $ns namtrace-all $nf

        # Create the topology
        # Frist, the nodes
                ......

        # Create the connection
                ......

        # Set the routing protocol
                ......

        # Now create agents and attach them to the appropriate nodes
                ......

        # schedule transmitting packets
                ......

        # Bring down the link between nodes 2 and 3 at 0.4

                ........

        # Final wrapup
        proc finish {} {
                global ns nf nam_file

                $ns flush-trace
                close $nf
                exec nam $nam_file &
                exit 0
        }
        $ns at 1.00 "finish"

        $ns run
 



Exercise 2: Multicast (Note the change in the question)

Create a network which looks like the following:

                        4
                        |
                        |
          0-------------1----------2
                        |
                        |
                        3

All links are 1 Mbps, 5 ms delay.

Choose DM (instead of CtrMcast) as the multicast routing protocol for the experiment. Node 0 is a UDP source for group 0
and node 2 is the source for group 1. The sources will start transmission at time 0.05. Nodes 3 and 4 will join the multicast group0 at times 0.10 and 0.12,
respectively. Node 3 will leave the multicast group at 0.5, and then join group1 at 0.6. The execution will terminate at 0.8 . You can use the skeleton file below.
 

        # Create event scheduler
        set ns [new Simulator]

        set nam_file prob2.nam
        set nf [open $nam_file w]
        $ns namtrace-all $nf

        # Create the topology
        # First the nodes
        ......

        # Make the links
        ......

        # Use the following to make the orientation right.
        $ns duplex-link-op $n(0) $n(1) orient right
        $ns duplex-link-op $n(1) $n(2) orient right
        $ns duplex-link-op $n(2) $n(3) orient right
        $ns duplex-link-op $n(1) $n(3) orient down
        $ns duplex-link-op $n(1) $n(4) orient up

        # Create the multicast groups
        ......

        # Choose the routing protocol
        ......

        # Create the UDP agents and tie each to the corresponding multicast group
        ......
        # create cbr traffic, attach to the udp and schedule their start

        ......
        # Schedule join/leave events
        ......

        # Final wrapup
        proc finish {} {
                global ns nf nam_file

                $ns flush-trace
                close $nf
                exec nam $nam_file &
                exit 0
        }
        $ns at 5.0 "finish"

        # Start the simulator
        $ns run
 



Exercise 3: Analyze Bandwidth Share of TCP and UDP Traffic
 

It is equivalently important to understand the ns-2 output trace format and have some knowledge on how to extract relevant information.  This exercise is dedicated
to familiarize you with ns-2's output format, in particular by trace-all, and techniques to do trace post-processing.

Topology: Use the simple.tcl example discussed in class, but first swap the source/destination of udp1 i.e. make its source be n1 and destination n3.

As a result of running ns on the modified simple.tcl, we obtain an output file "simple.tr". It contains information of all packets enqueued (+), dequeued (-), received
(r) and dropped (d).

a. Modify the simple.tcl (name this, say, simple1.tcl)  so that
    - there is only one UDP/CBR flow (i.e. do not start the second UDP/CBR flow)
    - start the two flows (1 TCP and 1 UDP) at the same time 0.1 s
    - run the script for 6s.
Extract information from the "simple.tr" file and compute the total bytes of TCP (tcp) and UDP (cbr) traffic over link 2-3 for the duration of the simulation. Then,
compute total TCP and UDP/CBR traffic in bytes and ratios of TCP and UDP/CBR to the total. Finally, Comment on the bandwidth share of TCP vs. UDP/CBR.

b. Modify the simple1.tcl file (name this simple2.tcl) so that
    - there are two UDP/CBR flows
    - start the TCP and the 2 UDP flows at the same time 0.1 s
    - run the script for 6s.
Extract the information from the new simple.tr file and recompute the parameters above. What do you notice?
 

Note:  Fill in the blanks according to your understanding of trace format in the following awk command for computing the total bytes of TCP or UDP traffic

          awk '$1=="r" && ??==2 && ??==3 && $5=="??" {a += ??} END {print a}' simple1.tr