Hi All, Our website moved to a new URL. Please bookmark the new link: https://ns2bloggers.blogspot.com/

BEGINNERS TUTORIAL

In ns2; for analysis and creation of a network we have to do the following procedures;

1. Write OTCL program.
2. Run program in terminal.
3. Analyse trace file using gawk.

1. Write OTCL Program
In ns2 ,we use object oriented tool command language as front end language or simply to write programs to generate a network scenario.One of the reason is that it is simple and easy to code.To know more about ns2 languages,click here. To write an OTCL script, we use editors [notepad] in the linux.

Open gedit
For that go to accessories-> gedit or search gedit on dashhome [For ubundu 12.04]

you will get the following window;
gedit window

Write your tcl script on here. For tcl scripting tutorials, go through following links: Link 1  Link 2

After writing program, save it in .tcl format.[ for ex: dd.tcl ].



After that you can see your program changed like this i.e as multicolored



Now we have to run the tcl scripting................................................................!!!!!!


2. Run program in Terminal
To run the program, open terminal window from accessories->terminal or search on dash home.

You will get the following window;
Terminal window
now you have to run the tcl script, for that you have to change to the directory where the program is located.
For example: In here we are going to run aodv.tcl which is located at folder program. In terminal we have to change to directory where program located.For that use command cd

It can shown as below;


The directory is changed....!!!!!!

Now we have to run the TCL script, for that type ns filename in terminal. For example; ns aodv.tcl



Now simulation starts..........................!!!!!!!



Now simulation started and you can get network animator window,xgraph and trace files [You will get this only depend upon the codes wriiten on TCL script].

3. Analyse trace file using awk scripts
We add it in the later pages. Click here to read.

Click different topics to know more about NS2.


HAPPY HUNTING......................!!!!!!!


6 comments :

  1. THANKS FOR YOUR EFFORTS :)

    But i want trace on your program:

    What u mean by set window-15?
    This mean the interface window size for the tcp protocol that named above (tcp1)

    I think this program have a two source and two destination nodes, but the question here when the first source node start to send the packets first target node. u don't include the time to the ftp1 that responsible for this operation. and in same way ftp2.

    Are u synchronized the operation of the two ftps (ftp1, ftp2) at the same time?

    ReplyDelete
  2. What u mean by----> queue-limit =25

    Are u mean the maximum number of packets that must hold in the queue between the two given nodes (r1 -----> r2), and also ( r2 -----> r1)

    THANKS IN ADVANCE TO ALL :)

    ReplyDelete
  3. Ok now i understand u have two source nodes(s1, s2) and one destination node (s3)

    0 means at 0 sec send packets form source s1 ----> s3 (TRUE)
    1 means at 1 sec send packets form source s2 ----> s3 (TRUE)

    In abbreviation it means that the difference between the two sources is one second :)

    ReplyDelete
  4. There is a missing lines in ur program, the program is executed, but no result to the simulation, because

    First: u must add the following lines after the first line ===> set ns [new Simulator]
    =============================================================
    set nf [open out.nam w]
    $ns namtrace-all $nf
    ============================================================
    where nf is a variable represent nam trace file
    where out.nam is the nam trace file that will save the information about ur program

    Second: u must add procedure to close this nam trace file. these lines must add after the last line in ur tcl script ===> set redq [[???]queue]
    ==========================================================
    proc finish {} {
    global ns nf
    $ns flush-trace
    close $nf
    exec nam out.nam &
    exit 0
    }
    ===========================================================

    Third: u must schedule the events for each ftp protocol u defined in ur program:
    =============================
    $ns at 0.1 "$ftp1 start"
    $ns at 0.2 "$ftp2 start"
    $ns at 4.5 "$ftp1 stop"
    $ns at 4.6 "$ftp2 stop"
    =============================
    Fourth: u must add time to close the procedure finish:
    ==============
    $ns at 5.0 "finish"
    ==============

    Fifth: at last, u must add the very important line to run ur simulation file:
    =======
    $ns run
    =======

    ReplyDelete
  5. Hello

    Iam a student i want to compare AODV,DSR and FSR protocol . please provide me source code of FSR and how to draw xgraph for more than one xg files on a single graph to compare the values for different protocol.

    please tell me how to do that
    my mail id is richagoyal323@gmail.com please send source code in my mail id and idea of xgraph. thanks

    ReplyDelete
  6. good but WCA ALGORITHM I NEED

    ReplyDelete