22 August 2014

NS3 installation in Linux Mint 17

This post tells you how to install ns3 in Linux Mint 17 64 bit OS or Ubuntu 14.04. For both the OS, the installation procedure is same.

OS Used: Ubuntu 14.04 and Linux Mint 17
Instruction Set: 64 bits
NS3 Version: ns-allinone-3.20

Steps1: Open the Terminal and execute the command one by one
pradeep@localhost $] sudo apt-get update
pradeep@localhost $]sudo apt-get install build-essential autoconf automake libxmu-dev python-pygoocanvas python-pygraphviz cvs mercurial bzr git cmake NetAnim p7zip-full

the following screenshot shows the installation.
ns3 in mint
NS3 installation in Linux Mint
Step 2: Download the ns-allinone-3.20.tar.bz2 from the http://www.nsnam.org website.
Step 3: Copy the file to the /home/user/  and execute the commands one by one by opening the terminal
pradeep@localhost $] tar jxvf ns-allinone-3.20.tar.bz2
pradeep@localhost $] cd ns-allinone-3.20/
pradeep@localhost $] ./build.py --enable-examples --enable-tests


This process will take some amount of time to get it installed. Once installation is over, check a simple program to test whether ns3 is working,

pradeep@localhost $] cd ns-allinone-3.20/ns-3.20/
pradeep@localhost $] ./waf --run hello-simulator
ns3
ns3 hello simulator output
see the above output "Hello Simulator" that indicates the ns3 is installed and the output of a given example is shown.

To test other scripts or examples of ns3, you can go to the folder
~ns-3.20/examples/tutorial/ 
there are quite number of .cc files of various network. For example, you can copy the first.cc file to ~ns-3.20/scratch/ 
Once copied, execute the command from the ~ns-3.20/ folder.
pradeep@localhost $] cd ns-allinone-3.20/ns-3.20
pradeep@localhost $]./waf --run scratch/first
Waf: Entering directory `/home/nsnam/ns-allinone-3.20/ns-3.20/build'
Waf: Leaving directory `/home/nsnam/ns-allinone-3.20/ns-3.20/build'
'build' finished successfully (1.564s)
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


and you can see the output as shown in the figure
ns3 example
UDPEcho Example in NS3

There are so many other examples in the examples/tutorial/ folder and you can try using these.
if you have anything more to share, please respond in the comment section below.

T S Pradeep Kumar