USC CSD Home



Homework #3

(70 points total)

Due 11:45PM (firm)
 
Problem 1 (35 points)

Description

In this problem, we will learn how to use ns-2 to simulate mobile networks. We will build a simple network by which we can see the difference between building wired networks as we had seen before and building wireless networks. We will set up the simple network as follows.
  • The network covers a 500m X 500m square area.
  • There are 2 wireless nodes n0 and n1. Both n0 and n1 use 802.11 MAC and have radio range 250m. The initial locations of n0 and n1 are (0, 250) and (500, 250), respectively.
  • At 10s, node n0 starts to send TCP traffic destined for n1.
  • At 20s, node n0 and n1 start to move towards each other at the speed 10m/s. n0 will stop at point (125, 250) and n1 will stop at point (375, 250).
  • At 50s, node n0 and n1 start to move away from each other at the speed 10m/s. n0 will stop at point (50, 250) and n1 will stop at point (450, 250).
  • The entire simulation terminates at around 80.0s.

Requirements

  1. Write an ns-2 tcl script based on the template given below.
  2. Run your script, observe all the phenomena, and then read the ns-2 trace file to complete the problem.
  3. Prepare a short write-up where you describe what you have seen and answer the following two question:
    1. Other than by looking at the NAM animation, how can you tell that two nodes are with the radio range of each other?
    2. Other indicating the location of each node in our scripts, what else means can we use to set node locations and movements?
  4. See the submission section below regarding what you need to submit.

Template

To write your ns-2 script, you can start with hw3-1.tmpl.txt, a template provided for your convenience, and fill in your own code.
 
Problem 2 (35 points)

Description

Study the given script hw3-2.tcl and anwser the questions. If you are on Windows and have problem downloading the above link, try viewing a text version of hw3-2.tcl.

Requirements

  1. Run the script, observe all the phenomena, and try to answer the following questions. You may want to resort to the online tutorial and the ns document.

    1. What does the script show?

    2. Explain the following code:
          set mproto DM
          set mrthandle [$ns mrtproto $mproto {}]
          set group0 [Node allocaddr]
          set group1 [Node allocaddr]

    3. Explain the following code:
          set rcvr [new Agent/LossMonitor]
          $ns attach-agent $n2 $rcvr
          $ns at 1.2 "$n2 join-group $rcvr $group1"
          $ns at 1.25 "$n2 leave-group $rcvr $group1"
          $ns at 1.3 "$n2 join-group $rcvr $group1"
          $ns at 1.35 "$n2 join-group $rcvr $group0"
  2. See the submission section below regarding what you need to submit.
Submission
You must follow the Electronic Submission Guidelines to submit HW3. Please note that the event ID for HW3 is:
    
Your submission should contain at least 3 files:
  • hw3-1.tcl - your ns-2 script for problem 1, based on hw3-1.tmpl.txt.
  • hw3-1.txt - your answer to the question posed in problem 1.
  • hw3-2.txt - your answer to the question posed in problem 2.
The preferred format for the .txt files is ASCII text. PDF, Postscript, and HTML are also acceptable.

You can create your submission by doing the following:

    % tar cvf hw3.tar hw3-1.tcl hw3-1.txt hw3-2.txt
    % gzip hw3.tar
    % ~csci551b/bin/bsubmit upload \
          -event  \
          -file hw3.tar.gz

   [Please see copyright regarding copying.]