Pedro Vale Estrela - NS2 Beginners Page

This page contains information regarding my NS2 Simulator experiences, on the topic of beginner first steps.

Files and Patches (contains the patches mentioned in these pages)

Contact: pedro.estrela@inesc.pt


Index:

1 - Very good Advice in Asking and Receiving help. 1

2 - Instalation: 1

3 - Tutorials: 2

4 - “Finally” performing actual work: 3

5 - Visualisation. 4

Some Unsorted Links. 4

 


1 - Very good Advice in Asking and Receiving help

How To Ask Questions The Smart WayESSENTIAL READING - Especially these parts

a) Use smart subjects:  http://www.catb.org/~esr/faqs/smart-questions.html#bespecific

b) Don't flag your question as “Urgent”, even if it is for you:  http://www.catb.org/~esr/faqs/smart-questions.html#urgent

c) Follow up with a brief note on the solution: http://www.catb.org/~esr/faqs/smart-questions.html#followup

 

Why Ask Questions in Public?
How to Report Bugs Effectively

2 - Instalation:

Until there is more specific information, check these references:
NS2 Installation and Basic Usage2
NS2 Installation with Windows specific info
Building ns-2 on Cygwin (Windows)
Instalation of tcl-debug-2.0 onto Cygwin + ns2 release 2.28 (thanks for Tae-hyung Kim)

Also check an very important tip on this page concerning the linux distributions to avoid: assorted tips

3 - Tutorials:

NS2 is a very complex subject, but there is some good tutorials around. I suggest you to check this complete lecture notes, its very good.

0 - NS Simulator for Beginners, lecture notes  (NEW)

Then check the available tutorials, by this order, from more basic to more complex:

 

1: Sandeep Gupta NS tutorial – simple introductory slides

2: NS by Example - This is a very good tutorial. I suggest you to actually try the several scripts that the authors made available. If some of them don’t work in your version of NS2, please see the comment below.

3: Marc Greis' Tutorial
This is the classic and most important tutorial. I fully recommend you to Master the step-by-step exercises it describes, especially if you are going to change the NS2 code.

The Ping Agent that he describes is very important to do it yourself, instead of simply downloading the c++ files and compiling it.

When I've used the tutorial myself, I was using NS-2.26. At that time, the examples and solutions of the later parts of the tutorial, that deal with wireless and Mobility code, didn't worked exactly as it is told, because the API changed. In this case, you should refer not to the examples, that are not required to bt 100% correct, but to the scripts that perform the validation of NS2 itself, which will always be in sync with the latest version of the API. These files are tcl/ex/wireless*test.tcl

UPDATE: You should refer to this post on the ns2 mailing list to know the additional steps required on the ping agent on the newest versions of NS2.
http://mailman.isi.edu/pipermail/ns-users/2006-January/053697.html
If you find this information useful, then please volunteer some of your time and help other users to move this tutorial into the new NS2 wiki  and update its information to the latest NS2. Thanks!

4: After you have more experience with NS2, you should check additional scripts like the ones here NS Simulator Courses for Beginners, and the /ns/tcl/ex and /ns/tcl/test directories of your ns2 source tree.

5: And then peek the reference documentation here: The NS Manual

6: Implementing a New Manet Unicast Routing Protocol in NS2

7: ns2 for the Impatient

8: ns2measure manual

4 - “Finally” performing actual work:

Then, and only then, you are ready to actually start performing your work. It normally falls into these fields, from simpler to tougher:

1: Very simple experimentation and visualization with NAM network animator
For this you only need to set up the static scenario you want, run the simulation and observe it in NAM.

2: Simple measurements of simple metrics, like delay or packet loss, relying only on standard NS2 components
For this you will need skills concerning the processing of the trace files that the simulation generates
- packet processing: To count the events you want; either do a simple C program, or learn and use AWK or perl (very flexible to experiment)
- graph generating: you need simple knowledge in xgraph or gnuplot. The former is simpler as it can receive data via stdin to plot.

A cheap alternative to this stage is to use existing tools that are useful to process results that are commonly used. Check tracegraph and this page for more info.
For a fine example of using AWK script to generate end-to-end packet lifetime statistics: http://www.isi.edu/nsnam/archive/ns-users/webarch/1999/msg02093.html

3: The above, but for a series of situations closely related (example: same scenarios with varying link delays; Mobile node movement; etc)
For this you need to pass parameters to the .tcl script. more info soon

4: The above, but using contributed extensions to NS2.
Although NS2 provides support for many many useful network technologies, protocols etc, some of them are only present as contributed modifications to NS2, and might not be updated to the lastest version. more info soon

5: The above, but modifying the NS2 simulator yourself.
When you are doing cutting edge research, that nobody did before, the only solution is to model your own additions to NS2.
The first thing you should do is to locate a similar module that does something that you want to do also. perhaps another ad-hoc routing protocol, another QoS queue discipline, etc etc. Then you should clone the code, and change ALL names of variables, TCL bindings (*), C++ classes, packet headers, etc etc, to YOUR component name. When you do this you'll get a working component that you can start to SLOWLY modify to make YOUR algorithms and operations.
If you do this way, instead of simply start coding from scratch, you'll be able to work with a working component, step by step, that you are able to validate every day. The alternative way, you spend months, or even more, before the component worked for the first time.

UPDATE: This tutorial http://masimum.dif.um.es/nsrt-howto/html/ and marc greis’s tutorials, on the part of the ping agent http://www.isi.edu/nsnam/ns/tutorial/nsnew.html#third are very helpful to know which modifications are needed to integrate a new module in NS2:

6: Combining several extensions into a single NS2 / upgrading a old extension to the latest NS / how to upgrade a module for a old version of NS2 to latest NS2:

One can and should try to upgrade modules written to previous versions of NS2 to latest NS.

These are the steps that I’ve done for the CIMS micro-mobility suite:

a) start using the module on the proper ns2 version until you can use all parts of it

b) make modifications on C++ and TCL parts to learn the inside of the code;

c) learn to use diff and patch

d) make a diff between "original old ns version" and "old ns version with that module"

e) try to apply that patch to ns-2.29, and solve the inconsistencies that appear

Warning: this is a fairly amount of work!

5 - Visualisation

For visualization of the results (eg, making the graphs), I suggest:

1 – www.tracegraph.com – very nice program with lots of useful out-of-the box graphs

2 – AWK scripts + Gnuplot: check these information sources:

cap 3 of NS Simulator for Beginners, lecture notes

Introduction to GnuPlot (basic)  http://www.cs.uni.edu/Help/gnuplot/

Gnuplot not so FAQ (advanced) (VERY RECOMMENDED!) http://t16web.lanl.gov/Kawano/gnuplot/intro/index-e.html

Awk Syntax   http://www.vectorsite.net/tsawk2.html

3 – http://poisson.ecse.rpi.edu/~harrisod/graph.html -  RPI ns-2 Graphing and Statistics Package – look promising

Some Unsorted Links

TCL syntax information pages:

"Why can I not place unmatched braces in Tcl comments?

http://phaseit.net/claird/comp.lang.tcl/fmm.html
http://mini.net/tcl/1669.html

 

A similar page to this one: http://web.umr.edu/~tk424/links4NS2Users.htm

NS2 Building experiences http://zzlinux.blogspot.com/2004/12/ns2-building-experiences.html

Trpr (TRace Plot Real-time) is a program which analyzes output from the tcpdump packet sniffing program and creates output suitable for plotting
http://proteantools.pf.itd.nrl.navy.mil/trpr.html

CVS usage notes: http://www.eyrie.org./%7Eeagle/notes/cvs/

Modified instantaneous ARP: http://mailman.isi.edu/pipermail/ns-users/2002-March/020912.html


Check the files, patches, etc in this directory

Go back to my NS2 page

Contact: pedro.estrela@inesc.pt

www.terraview.org Programa de apoio cartográfico (SIG) para planeamento agricola, florestal e ambiental