How to Install NS-3 in Ubuntu

Installing NS-3 in Ubuntu

ns-3 is a discrete-event network simulator, targeted primarily for research and educational use. ns-3 is a free software, licensed under the GNU GPLv2 license, and is publicly available for research, development and use.

ns-3 can be installed on any version of linux platform like ubuntu. So in order to install ns-3 you first have to upgrade your operating system to ubuntu (dual-boot or standalone).

Once ubuntu is installed open the terminal by runing the following command ( ctrl+alt+T ).

Also Read - Network Simulator, NS2 versus NS3

To install Prerequisites-

sudo apt-get install gcc g++ python python-dev mercurial bzr gdb valgrind gsl-bin libgsl0-dev libgsl0ldbl flex bison tcpdump sqlite sqlite3 libsqlite3-dev libxml2 libxml2-dev libgtk2.0-0 libgtk2.0-dev uncrustify doxygen graphviz imagemagick texlive texlive-latex-extra texlive-generic-extra texlive-generic-recommended texinfo dia texlive texlive-latex-extra texlive-extra-utils texlive-generic-recommended texi2html python-pygraphviz python-kiwi python-pygoocanvas libgoocanvas-dev python-pygccxml



Now, downloading NS-3( version 3.19 ) 

cd
mkdir ns3
cd ns3
wget http://www.nsnam.org/release/ns-allinone-3.19.tar.bz2
tar xjf ns-allinone-3.19.tar.bz2
cd ns-allinone-3.19
ls

Then you can find build.py along with other files.
Then to build the examples in ns-3 run

./build.py --enable-examples --enable-tests

If the build is successful then it will give output "Build finished successfully".

Now run the following command to configure with waf (build tool)

./waf -d debug --enable-exmples --enable-test configure

but if you get -  No such file or directory
then check that you must be in the ns-3.19 directory. If you are in ns-allinone-3.19 directory then run the following command to move to the ns-3.19 directory

cd ns-3.19
ls

After ls command you will find the waf name listed in the terminal as the command execute then again run the command to configure with waf i.e.

./waf -d debug --enable-examples --enable-test configure

To build with waf, run the following command

./waf

To test everything allright

./test.py

It will take some time, if the test are ok then run the first example.
But first check in the ubuntu file for ns3/ns-allinone-3.19/ns-3.19/examples.
In example folder you will get the default examples provided by the ns3.
In order to run these examples first check that in terminal you must be at ns-3.19 directory.
But if by-mistake you have closed your terminal window then again use the command to open the new command terminal window i.e. ( ctrl+alt+T )
now run the following commands to move to the ns-3.19 directory-

cd ns3/ns-allinone-3.19/ns-3.19

you will be redirected to the ns-3.19 directory now here you can run your examples -
Lets runt the first example by using the following command -

./waf --run first

Output of the above command will be 

At time 2s client sent 1024 bytes to 10.1.1.2 port 9
At time 2.00369s server received 1024 bytes from 10.1.1.1 port 49153
At time 2.00369s server sent 1024 bytes to 10.1.1.1 port 49153
At time 2.00737s client received 1024 bytes from 10.1.1.2 port 9

Result is successful.

Now close the terminal and open a new command terminal window 
Run the following command to check for updates -

sudo apt-get update

After updates got installed now run the following command -

sudo apt-get install nam

Now run one more command after the above command executes perfectly -

sudo apt-get install ns2

In order to get the updates of ns2 in order to run the network simulator examples more precisely.
once the ns2 update installs perfectly then run the command

ns

Output for the ns command will be " % " sign, this shows that now you can write or make your own programs for networking.

Thanks for reading, enjoy ns3

Reference - nsnam.org, ns3help.blogspot.in

Comments

Popular posts from this blog

Artificial Intelligence

Smart Card

Biometrics