Monday, March 8, 2010

For NS2 Newbies

Starting to Use NS2 is Easy

At first glance, learning NS2 is not very hard. You can go through the tutorial by Mark Greis' Tutorial, and learn NS2 in few hours.

Then you will feel like you are on the right track. NS2 is a very simple. The Tcl is a very simple and intuitive language. You can construct a complex network (e.g., TCP over wireless networks) very easily. Moreover, you can get a nice animation from nam (network animator) and plot graphs using Xgraph. What's more do you want?

Hit by Reality when Extending NS2 beyond its Scope

There is only one problem. One big problem. Things are simple as long as what you would like to work on is built-in to NS2. What's the odds? Very slim! If you are doing research, you would do something innovative. Something that no one has done before. And, that thing, my friends, is not very likely to be one of NS2 built-in modules.

From this point, everything goes downhill. A common question everyone ask is as follow. I have a great research idea. How can run NS2 to validate my idea.? Good question but the answer can be harsh.

Nothing in Life is Easy

I don't mean to discourage you. But learning NS2 beyond its scope is excruciatingly painful. You've got a lot of work to do. If you really want to know NS2, here is the step that I would suggest you should learn.

Quick Fix: An Easy Way in Doing Simulation in NS2 (not Recommended)

I started learning NS2 in a wrong way. I did not start from basic. So I chose a quick and easy way, trying to modified the NS2 codes to fit my needs and hoping that it'll work. Sometimes, it did. Sometimes, it did not. In the end, I had to abandon NS2, and wrote my own simulation code in C++. Do not follow my footstep!

Prerequisite

If you are reading upto this point, it means you do not want to follow my mistake, and you are commit yourself to seriously learn NS2. Here are few things that you need to do before proceed further:

1. Learn C++: Not just C. The OOP (object oriented programming) concept is the very core of NS2.
2. Learn Tcl: The scripting language by NS2. I find the following book quite useful. You only need to read chapters 3-7.

3. Learn OTcl: Objected Oriented version of OTcl. The most useful resource is [This website].
4. Install NS2. Go to [NS2 Webpage] for further instuction.
5. Go through Mark Greis' Tutorial.

    After you clear the above checklist, you can proceed to the key steps in learning NS2 below.

    Key Steps in Learning NS2

    Regardless of you research work, I believe you should get the basic first. And, here are the key steps.

    1. Learn how NS2 pass packets from one object to another (e.g., from a Node to a SimpleLink).
    2. Learn how to bind C++ and OTcl. This is a hard one. But, it will be easier when you understand the first step.
    3. Learn the module you are interested in. Really, it's quite hard if you don't have the basic in NS2, and want to jump start to do your own work. It's like a baby trying to jump before learning how to crawl!
    4. Modify, include, and build. This would be the final thing that you need to learn.
    -----------------------------------------------------------------------------------------
    The details of NS2 can be found in the following book from Springer:
    T. Issaraiyakul and E. Hossain, “Introduction to Network Simulator NS2”, Springer 2009. Buy it now from

    You may also find lecture notes and other resource at the following website: http://www.ece.ubc.ca/~teerawat/NS2.htm

    3 comments:

    ganapathi.kp128@gmail.com said...

    i m new to ns2
    i need a awk script for extracting necessary information from trace file for ploting graph.
    So please send me some awk script to draw a graph and some link for understanding xgraph and awk script

    i need to compare the performance and qos parameter of different protocol.
    thx in advance :)

    Teerawat Issariyakul said...

    If you are interested in learning how tracing works in NS2, please read

    http://www.ns2ultimate.com/post/3995318343/post-processing-ns2-result-using-ns2-trace-main-post

    Rohini said...

    Sir

    I wanted to analze energy information of nodes from a trace file.

    I want to do it for leach protocol.

    Please provide a awk script.

    Thanks