1. Network Simulator NS2
The
purpose of this tutorial is to make it easier for new ns users to use ns and
nam, to create their own simulation scenarios for these tools and to eventually
add new functionality to ns. We have found the existing documentation
to be rather useful for users who already know the basic features of ns, while
it can be a bit tedious for new users to extract the necessary information from
the manuals and the example scripts.
In this tutorial we will lead you through some simple examples,
introducing more and more new features as we go along. The ultimate goal is
that after a short time you are able to efficiently use ns and to find any
further information you might need in the existing documentation. For this
purpose We will also try to tell you where we found the information in this
tutorial ourselves, so you not only learn how to use ns, but also how to use
its documentation.
1.1. Downloading/
Installing & nam
You can build ns either from the various packages (Tcl/Tk, otcl, etc.), or you can download an 'all-in-one' package. We would recommend that you start with the all-in-one package, especially if you're not entirely sure which packages are installed on your system, and where exactly they are installed. The disadvantage of the all-in-one distribution is the size, since it contains some components that you don't need any more after you compiled ns and nam. It's still good for first tests, and you can always switch to the single-package distribution later.
You can build ns either from the various packages (Tcl/Tk, otcl, etc.), or you can download an 'all-in-one' package. We would recommend that you start with the all-in-one package, especially if you're not entirely sure which packages are installed on your system, and where exactly they are installed. The disadvantage of the all-in-one distribution is the size, since it contains some components that you don't need any more after you compiled ns and nam. It's still good for first tests, and you can always switch to the single-package distribution later.
Note:
The all-in-one package only works on Unix systems.
You can download the package from the at UCB.
If you have any doesn't solve your problem, you might want to ask the ns-users
mailing list After the
installation is complete, you should make sure that your path points to the
'ns-allinone/bin' directory (if you installed the ns-allinone package) where
links to the ns and nam executables in the 'ns-2' and 'nam-1' directories can
be found or (if you built ns and nam from the pieces) let your path point
directly to the directories with the ns and nam executables.
On
some systems you will also have to make sure that ns can find the library
'libotcl.so'. If you installed the ns-allinone package, it should be in
'ns-allinone/otcl/'.
You start ns with the command 'ns <tclscript>'
(assuming that you are in the directory with the ns executable, or that your
path points to that directory), where '<tclscript>' is the name of a Tcl
script file which defines the simulation scenario (i.e. the topology and the
events). You could also just start ns without any arguments and enter the Tcl
commands in the Tcl shell, but that is definitely less comfortable.
Everything
else depends on the Tcl script. The script might create some output on stdout,
it might write a trace file or it might start nam to visualize the simulation
or all of the above. These possibilities will all be discussed in later
sections.
In this section, you are going to develop a Tcl script
for ns which simulates a simple topology. You are going to learn how to set up
nodes and links, how to send data from one node to another, how to monitor a
queue and how to start nam from your simulation script to visualize your
simulation.
3. NAM
You can either start nam with the command
'nam <nam-file>' where '<nam-file>' is the name of a nam trace file
that was generated by ns, or you can execute it directly out of the Tcl
simulation script for the simulation which you want to visualize. Below you can see a screenshot of a nam
window where the most important functions are being explained.
The first Tcl script,In this section, you
are going to develop a Tcl script for ns which simulates a simple topology. You
are going to learn how to set up nodes and links, how to send data from one
node to another, how to monitor a queue and how to start nam from your
simulation script to visualize your simulation.

No comments:
Post a Comment