This page describes how to get started with the network simulator ns.
Full ns distribution is quite large (over 130Mb after installation). In order to complete the midterm class project you do not need to install it yourself. Instead you can work with the world-readable installation in directory /net/thing2/disk3/dzagorod/ns-allinone-2.1b7a that should be accessible on all APE lab machines. The binaries are for Solaris.
In order to use ns, you will need to set or update three evironment variables: PATH, LD_LIBRARY_PATH, and TCL_LIBRARY. The first one allows you to run nm, nam and other needed executables, the other two point to directories with run-time libraries. I also recommend setting the fourth variable NS in order to make references to files in ns distribution easier. The sh/ksh/bash syntax is:
export PATH=/net/thing2/disk3/dzagorod/ns-allinone-2.1b7a/bin:\ /net/thing2/disk3/dzagorod/ns-allinone-2.1b7a/tcl8.3.2/unix:\ /net/thing2/disk3/dzagorod/ns-allinone-2.1b7a/tk8.3.2/unix:$PATH export LD_LIBRARY_PATH=/net/thing2/disk3/dzagorod/ns-allinone-2.1b7a\ /otcl-1.0a6:/net/thing2/disk3/dzagorod/ns-allinone-2.1b7a/lib export TCL_LIBRARY=/net/thing2/disk3/dzagorod/ns-allinone-2.1b7a/tcl8.3.2/library export NS=/net/thing2/disk3/dzagorod/ns-allinone-2.1b7a/
If you are using csh or tcsh then use setenv instead of export and omit = sign. If you want to set the variables automatically every time you log in, add these lines to the approapriate shell startup file (.profile, .cshrc or whatever).
In order to make sure everything works try running one of the scripts that comes with the distrubution:
ns $NS/ns-2/tcl/ex/simple.tcl
If all is well the script will print a couple of numbers, produce two files in the current directory (total size of about 1Mb) and start nam -- a graphical tool for parsing the trace of the script. If ns cannot be found check that PATH is set right. If the script produces a runtime error then check that the other two variables are set correctly. Some of these scripts produce a lot of output and you may run out of disk space allocated to you on the APE lab machines. That can be another cause of a run-time error. If script works, but nam fails to start check that your DISPLAY variable is set correctly and access to your X display is permitted.
Once you are in nam the network topology described by the script is evident. Press "play". Nothing happens for the first second. Then the packets start flowing. You probably should reduce the step to 500us or so in order to see better what's going on. The red and blue packets are UDP. At 1.2 seconds into the simulation an FTP connection opens between nodes 0 and 3 which causes the queue on the router 2 to fluctuate.
A really good way to get to know ns and nam is to complete several sections of Marc Greis' excellent tutorial. More specifically, we recommend that you complete sections IV, V and maybe VI. They will guide you through creation of a topology, assignment of traffic sources and sinks to nodes, as well as scheduling of events during the run.
Since the scripts you will be working on for the midterm assignment are written in OTcl (object-oriented Tcl) you may also want to go over a quick OTcl Tutorial. Oh, and if you've never seen Tcl before then this Introduction from Scriptics webiste should be sufficient. Don't worry, you won't have to become an expert in Tcl or OTcl in order to complete the assignments. You'll need just enough knowledge to understand an OTcl script and make a few modifications to it.