30-05-2013, 03:37 PM
TUTORIAL FOR THE NETWORK SIMULATOR
NETWORK SIMULATOR.pdf (Size: 385.93 KB / Downloads: 24)
Introduction
Disclaimer: This tutorial was originally developed by Marc Greis. Currently the tutorial is
maintained and being expanded by the VINT group.
Please note: if there is any problem with the example scripts provided below, please refer to the
test suites (~ns/tcl/test/test-suite-greis.tcl and test-suite-WLtutorial.tcl) for and lastest updates
Since you have found this page, I assume that you already know what ns is and where you can
get it from. If not, I suggest you either go to the web page for the VINT project or the web page
for ns (version 2). Note: In these pages I describe ns version 2. Version 1 is different, though
there is a backwards compatibility library in version 2.
The purpose of these pages 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. I 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 I 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 I will also try to tell you where I found the
information in this tutorial myself, so you not only learn how to use ns, but also how to use its
documentation.
The web is probably the best medium for a tutorial like this, because it's not only possible to add
pictures (or even animations) for the examples, but you can also directly download the examples
if you don't have the time for typing them in yourself (though I would suggest doing that at least
for the first few examples). I chose a frame-oriented design for these pages, since it makes them
easier to navigate. If you find that the left frame with the contents takes up too much room or if
you just don't like frames, you can switch to a frameless version.
Documentation for ns&nam
The following documentation for ns and nam is available from the main ns web page at UCB.
· "ns Notes and Documentation (now renamed the ns Manual)" could be called the "main
manual" for ns and is available in Postscript format.
· An HTML version (currently without diagrams ) of nsN&D (now renamed ns Manual) is
available here.
· A manual page for ns is included in the distribution in the ns directory. There is a HTMLized
version here, but it might be out-dated.
· There is a ps version of the nam user-manual which is available from the nam page. You
can also get an ASCII version from here.
· You can also get slides from the second ns workshop from this page. They don't really
contain more information than the "ns Notes and Documentation" (now renamed ns
Manual) document, though it might be a bit easier to understand and use.
· If you can't get ns to compile, if it crashes, or if you have any other similar problems, take
a look at the ns-problems page before you ask on the mailing list.
· If you have any general questions about ns or nam, you can send them to the ns-users
mailing list. If you're not sure if your question has been asked before, check the Archive
for the mailing list.
Downloading/Installing ns&nam
You can build ns either from the the various packages (Tcl/Tk, otcl, etc.), or you can download
an 'all-in-one' package. I 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 anymore after you compiled ns and nam. It's still good for first
tests, and you can always switch to the single-package distribution later.
Making it more interesting
In this section we are going to define a topology with four nodes in which one node acts as router
that forwards the data that two nodes are sending to the fourth node. I will explain find a way to
distinguish the data flows from the two nodes from each other, and I will show how a queue can
be monitored to see how full it is, and how many packets are being discarded.
The topology
As always, the first step is to define the topology. You should create a file 'example2.tcl', using
the code from section IV.1 as a template. As I said before, this code will always be similar. You
will always have to create a simulator object, you will always have to start the simulation with
the same command, and if you want to run nam automatically, you will always have to open a
trace file, initialize it, and define a procedure which closes it and starts nam.
Now insert the following lines into the code to create four nodes.