Network Simulator -2

For .pdf file please click here.
I will share my experiences about NS-2

Why did I need NS-2 even though no one knows anything about it around me.

When I chose my thesis topic I needed to use it. My thesis is about collected data analysis, Welllll how can I collect the data. This is the question and it was answered after a long time. In brief, I used vehicles and vehicles communicated each other and I should the simulate this data exchanging. That’s why I need to use ns-2 and I had to learn it.

Before starting to use ns-2 I installed ubuntu on my computer. At the beginning I used Windows XP and I installed “virtal machine” then I installed “Ubuntu” on it.

When I have Ubuntu I can install ns-2. You can find many things about ns-2 installation.
First of all open your Operating system UBUNTU

Open your console(terminal)

Download ns-allinone-2.32 and Install
$ wget

$ tar -xzvf ns-allinone-2.32.tar.gz

$ cd ns-allinone-2.32

(before install ns-2 you will need the packages that are shown below )
$ sudo apt-get install build-essential autoconf automake libxmu-dev

Now run this command


after install ns-2 you should introduce ns-2 to your computer and edit the bash file

$ gedit ~/.bashrc

Add the following lines to the end of it. Remember replace “/your/path” by something like “/home/wexins”


than it take effect immediately.
$ source ~/.bashrc
you should write command at the above, otherwise you cant write ns2 succesfully

Now, open new console and write ns, you will see % at the console.
be carefull!!! you can see % after write ns at any path…by the way to exit from % you should write “exit” on your console.

After these steps, you can now run the ns validation suite with

$ cd ns-2.32 $ ./validate
after this process you can run some files from ns-allinone/ns-2.32/tcl/ex/…..tcl and see the results.

when you run the tcl file if it generates a nam file you can trace it. HOW? go to path where is the tcl source code. than run your tcl code. and write “nam” on your console than small window will appear and click open file than choose your nam file and open it. after that you will see the simulation of your tcl code.

15 thoughts on “Network Simulator -2

  1. Good morning! Walter’m from Brazil. I’m trying to insert a scene in motion NS2.31, is a simulation of umts-wimax handover, but when the script reads the file gives the following error:
    ns: _o444 setdest 35.1252 271.5388 14.1653:
    (_o73 cmd line 1)
    invoked from within
    “_o73 cmd setdest 35.1252 271.5388 14.1653”
    invoked from within
    “catch” $ self cmd $ args “ret”
    invoked from within
    “if [catch” $ self cmd $ args “ret] {
    September cls [$ self info class]
    global errorInfo
    September savedInfo $ errorInfo
    error “error When calling class $ cls: $ args” $ … ”
    (procedure “_o73” line 2)
    (SplitObject unknown line 2)
    invoked from within
    “[ifaceArray_ $ ($ i) GetInterface] setdest dstX $ $ $ dstY speed”
    (procedure “_o444” line 16)
    (MultiFaceNode setdest line 16)
    invoked from within
    “_o444 setdest 35.1252 271.5388 14.1653”

    Can you help me?

  2. hi mam,

    can i have the tcl syntax to know the node position and energy…,

    for ex:
    position of node 1 is: x:____ y:_____
    energy of node 1 is: ___________

    1. You can enable the energy level and the other specifications in the trace file and read it from there.
      How to enabled them read ns-2 user manual

  3. hello ­čÖé
    i want to simulate VANET in ns2, can you guide me on how to start.
    i will have 10 cars sending control messages to each other. i m concerned in calculating the probability of how many message is received.
    i really appreciate your help

    1. Dear Andrew,

      Just do what i did. Create your protocol that what u want to message between the cars.then create wireless nodes. Define some start end positions for the cars, most probably u r gonna do broadcasting so just define a certain distance between the cars then they can communicate. Also enable the tracing. At the end collect the data from the trace file and analyze. It is almost same as my thesis. If i have time i am gonna upload it. It is required quiet a lot even i gave the insight …
      Hope it helps

  4. please give me ns2 code for congestion control in wireless sensor network so that i can start on it
    pls help this is my research area…………..

  5. how i can change the shape and color of node
    Nodes with Color
    $n0 color blue
    $n1 color red

    Nodes with shape
    $n0 shape box
    $n1 shape circle
    theses commands are not working..please help me

  6. Dear mam,
    I am asking about the procedure to convert .cc file to object file because i read many tutorials of NS2 but no fruitful result found. please briefly describe the steps so that i will be implemented on the project.

  7. Merhaba. NS-2 ile ilgili ara┼čt─▒rma yaparken sayfan─▒za rastlad─▒m. Bu konuda bu kadar tecr├╝beli bir T├╝rk’e rastlad─▒─č─▒ma ├žok sevindim a├ž─▒k├žas─▒. NS-2 ile excelde ├žizilmi┼č bir grafi─čin olabildi─čince benzerini ├žizmek istiyorum. Yapt─▒─č─▒m ara┼čt─▒rmalarda random de─či┼čkenler kullanarak exponential ve uniform grafik olu┼čturabilece─čim gibi bir fikir olu┼čtu. Ama istedi─čim gibi kullanamad─▒m. E─čer yard─▒m etmek konusunda igilenirseniz size grafi─či ve daha detayl─▒ bilgi g├Ânderebilirim.

  8. I dont know how to change the path when misbehaviour occurs in the routing path using aodv protocol

    Pls help me to know this

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s