Skip to main content

Installing NS-2 on Ubuntu

In this year I started following the Master of Computer Science (MCS) at University of Colombo School of Computing and these days I'm following a module named "Advanced Concepts in Data Communication Networks"

The lecturer asked us to install a program called NS-2 and to play around with it as we will get an assignment on it soon!

As usual when I hear a new name, I just googled for it and found the official website: http://www.isi.edu/nsnam/ns/


What is NS-2?


NS-2 is a Network Simulator. According to Wikipedia, NS-2 is a "discrete event network simulator" and the latest available version as of now is NS-3, which is available at http://www.nsnam.org/

The difference between NS-2 and NS-3


The FAQ at www.nsnam.org clearly mentions the difference between NS-2 and NS-3. NS-3 is a new software development effort and uses C++ programs or python scripts to define simulations. However NS-2 uses OTcl for scripts. 

So the most important thing here is that NS-2 scripts will not run within NS-3.


Installing NS-2 - The Hard Way!


The installation instructions at the website is to download the source and build it. So, I downloaded the latest available ns-allinone version, i.e. ns-2.35, which was released on Nov 4, 2011.

From my experience, it's always better to install software on a Virtual Machine and try. You never know when your machine will crash, especially when doing unknown things such as building from source, which requires to install many development libraries.

I use an excellent virtualization software called VirtualBox. I created a Virtual Machine and installed Ubuntu 13.04 on it.

After installing Ubuntu 13.04, I upgraded existing software packages after updating the package list index.


sudo su
apt-get update && apt-get -y upgrade


Then I extracted the downloaded pack.

tar -xvf ns-allinone-2.35.tar.gz

Then I changed in to the directory, executed install script.

cd ns-allinone-2.35/
./install

The installation script was not successful at the first attempt. It failed many times.

Then I found out some additional packages are also needed to install NS-2 successfully.

Following is the command to install all those packages at once.

sudo apt-get install libx11-dev build-essential autoconf automake xorg-dev g++ libxmu-dev libperl4-corelibs-perl

The last package "libperl4-corelibs-perl" was not needed during installation, however some tests were failing without it.

I also got following error during the installation.

linkstate/ls.h: In instantiation of �void LsMap<Key, T>::eraseAll() [with Key = int; T = LsIdSeq]�:
linkstate/ls.cc:396:28: required from here
linkstate/ls.h:137:20: error: �erase� was not declared in this scope, and no declarations were found by argument-dependent lookup at the point of instantiation [-fpermissive]
linkstate/ls.h:137:20: note: declarations in dependent base �std::map<int, LsIdSeq, std::less<int>, std::allocator<std::pair<const int, LsIdSeq> > >� are not found by unqualified lookup
linkstate/ls.h:137:20: note: use �this->erase� instead
make: *** [linkstate/ls.o] Error 1
Ns make failed!
See http://www.isi.edu/nsnam/ns/ns-problems.html for problems

To fix above error, I edited linkstate/ls.h file as instructed.

I changed the line 137
from
void eraseAll() { erase(baseMap::begin(), baseMap::end()); }
to
void eraseAll() { this->erase(baseMap::begin(), baseMap::end()); }


Now you should be able to install NS-2 successfully by running "./install" command.

Following is the output I got at the end of installation.

Ns-allinone package has been installed successfully.
Here are the installation places:
tcl8.5.10: /home/isuru/ns-allinone-2.35/{bin,include,lib}
tk8.5.10: /home/isuru/ns-allinone-2.35/{bin,include,lib}
otcl: /home/isuru/ns-allinone-2.35/otcl-1.14
tclcl: /home/isuru/ns-allinone-2.35/tclcl-1.20
ns: /home/isuru/ns-allinone-2.35/ns-2.35/ns
nam: /home/isuru/ns-allinone-2.35/nam-1.15/nam
xgraph: /home/isuru/ns-allinone-2.35/xgraph-12.2
gt-itm: /home/isuru/ns-allinone-2.35/itm, edriver, sgb2alt, sgb2ns, sgb2comns, sgb2hierns

----------------------------------------------------------------------------------

Please put /home/isuru/ns-allinone-2.35/bin:/home/isuru/ns-allinone-2.35/tcl8.5.10/unix:/home/isuru/ns-allinone-2.35/tk8.5.10/unix
into your PATH environment; so that you'll be able to run itm/tclsh/wish/xgraph.

IMPORTANT NOTICES:

(1) You MUST put /home/isuru/ns-allinone-2.35/otcl-1.14, /home/isuru/ns-allinone-2.35/lib,
into your LD_LIBRARY_PATH environment variable.
If it complains about X libraries, add path to your X libraries
into LD_LIBRARY_PATH.
If you are using csh, you can set it like:
setenv LD_LIBRARY_PATH <paths>
If you are using sh, you can set it like:
export LD_LIBRARY_PATH=<paths>

(2) You MUST put /home/isuru/ns-allinone-2.35/tcl8.5.10/library into your TCL_LIBRARY environmental
variable. Otherwise ns/nam will complain during startup.


After these steps, you can now run the ns validation suite with
cd ns-2.35; ./validate

For trouble shooting, please first read ns problems page
http://www.isi.edu/nsnam/ns/ns-problems.html. Also search the ns mailing list archive
for related posts.


NS-2 Successful Installation



As instructed, I also executed validate script inside ns-2.35 directory. All tests were passed! :)

All tests were passed


Now you need to export paths to environment. For that, just add following to your ~/.bashrc file.

# LD_LIBRARY_PATH
# LD_LIBRARY_PATH
OTCL_LIB=/home/isuru/ns-allinone-2.35/otcl-1.14
NS2_LIB=/home/isuru/ns-allinone-2.35/lib
USR_LOCAL_LIB=/usr/local/lib
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$OTCL_LIB:$NS2_LIB:$USR_LOCAL_LIB

# TCL_LIBRARY
TCL_LIB=/home/isuru/ns-allinone-2.35/tcl8.5.10/library
USR_LIB=/usr/lib
export TCL_LIBRARY=$TCL_LIB:$USR_LIB

# PATH
XGRAPH=/home/isuru/ns-allinone-2.35/bin:/home/isuru/ns-allinone-2.35/tcl8.5.10/unix:/home/isuru/ns-allinone-2.35/tk8.5.10/unix
NS=/home/isuru/ns-allinone-2.35/ns-2.35/
NAM=/home/isuru/ns-allinone-2.35/nam-1.15/
export PATH=$PATH:$XGRAPH:$NS:$NAM


Now you can start a new terminal or run "source ~/.bashrc" to start using NS-2!

Installing NS-2 - The Easy Way!


Apparently the NS-2 is also available on Ubuntu Software Center! I got to know that only after installing the NS-2 in the hard way! :)

There is just one command to install!

sudo apt-get install ns2 nam xgraph



Testing NS-2 Installation



After installing you should be able to run commands "ns" & "nam".

The "ns" command will go in to a prompt with "%".

You can type "exit"! :)

I'm hoping to write another blog post on using NS-2 soon. May be after I get the assignment! :)

Comments

Popular posts from this blog

Finding how many processors

I wanted to find out the processor details in my laptop and I found out that there are several ways to check. For example, see The RedHat community discussion on  Figuring out CPUs and Sockets . In this blog post, I'm listing few commands to find out details about CPUs. I'm using Ubuntu in my Lenovo ThinkPad T530 laptop and following commands should be working any Linux system. Display information about CPU architecture $ lscpu Architecture: x86_64 CPU op-mode(s): 32-bit, 64-bit Byte Order: Little Endian CPU(s): 4 On-line CPU(s) list: 0-3 Thread(s) per core: 2 Core(s) per socket: 2 Socket(s): 1 NUMA node(s): 1 Vendor ID: GenuineIntel CPU family: 6 Model: 58 Model name: Intel(R) Core(TM) i7-3520M CPU @ 2.90GHz Stepping: 9 CPU MHz: 1199.988 CPU max MHz: 3600.0000 CPU min MHz: 1200.0000 BogoMIPS: 5787.1...

Java Mission Control & Java Flight Recorder

Last year, I got two opportunities to talk about Java Mission Control & Java Flight Recorder. I first talked about " Using Java Mission Control & Java Flight Recorder " as an internal tech talk at WSO2 . I must thank Srinath for giving me that opportunity. After that, Prabath also invited me to do a talk at Java Colombo Meetup . Prabath, Thank you for inviting me and giving me the opportunity to talk at the Java Colombo Meetup! I'm also very excited to see that Marcus Hirt , the Team Lead for Java Mission Control has mentioned about the Java Colombo Meetup in his blog post: " My Favourite JMC Quotes ". It's so nice to see "Sri Lanka" was mentioned in his blog post! :) From Marcus' Blog Here are the slides used at the meetup. Java Colombo Meetup: Java Mission Control & Java Flight Recorder from Isuru Perera Marcus Hirt's blog posts really helped me to understand JMC & JFR concepts and his tutorials were very helpful...

Flame Graphs with Java Flight Recordings

Flame Graphs Brendon D. Gregg , who is a computer performance analyst , has created  Flame Graphs to visualize stack traces in an interactive way. You must watch his talk at USENIX/LISA13 , titled Blazing Performance with Flame Graphs , which explains Flame Graphs in detail. There can be different types of flame graphs and I'm focusing on  CPU Flame Graphs  with Java in this blog post. Please look at the Flame Graphs Description  to understand the Flame Graph visualization. CPU Flame Graphs and Java Stack Traces As  Brendon  mentioned in his talk, understanding why CPUs are busy is very important when analyzing performance.  CPU Flame Graphs  is a good way to identify hot methods from sampled stack traces. In order to generate CPU Flame Graphs for Java Stack Traces , we need a way to get sample stack traces. Brendon has given examples to use jstack  and Google's lightweight-java-profiler . Please refer to his perl program on g...