Sunday, November 20, 2016

Introduction & Installation of NS2 on Ubuntu

Network Simulator-2:-

ns is a name for series of discrete event network simulators, specifically ns-1, ns-2 and ns-3. All of them are discrete-event event computer network simulators, primarily used in research and teaching. ns-3 is free software, publicly available under the GNU GPLv2 license for research, development, and use.

Ns began as a variant of the REAL network simulator in 1989 and has evolved substantially over the past few years. ns-2 is often criticized because modelling is a very complex and time-consuming task, since it has no GUI and one needs to learn scripting language, queuing theory and modelling techniques. Also, of late, there have been complaints that results are not consistent (probably because of continuous changes in the code base) and nd that certain protocols have unacceptable bugs.

if your ubuntu version is 12.04 lts or less follow these steps:

Step 1: Setting up the Prerequisites  or dependencies

1. First of all, download Network Simulator (NS-2.35), assume you have downloaded it into your '/home/user_name/Documents' directory.

2. [Optional].Now we have to update and run these commands:

sudo apt apt-get update
sudo apt apt-get dist-upgrade

3. Before installing the NS we have to install some essential packages required by the NS. So run the following commands:

sudo apt-get install build-essential autoconf automake
sudo apt-get install tcl8.5-dev tk8.5-dev
sudo apt-get install perl xgraph libxt libxt-dev libx11-dev libxmu-dev
sudo apt-get install gcc-4.4

Step 2: Extract and Install NS

1.Extract the downloaded NS package either using the right click context menu "Extract here" or using the following commands from a terminal:

cd /home/user_name/Documents
tar -xvzf ns-allinone-2.35.tar.gz

2. After extracting the "ns-allinone-2.35" folder, open up the file "/ns-allinone-2.35/ns-2.35/linkstate/ls.h" in an editor. You can do it either from the terminal or from the file explorer Nautilus). We have to make some changes in the ls.h file else it will show an error while installing the NS. Once you have opened the file move to the line 137 and replace the erase (image 1) withhis—>erase (image 2) and save the file.

NOTE:If you don't make the above stated change then you will see an error while installing the NS

3. Now its time to finally install the NS. Open up a terminal and move to the directory where you have extracted the package, in our case its '/home/user_name
'/home/user_name/Documents' and install NS using the following commands

cd /home/user_name/Documents/ns-allinone-2.35
sudo ./install

It will take around 15 minutes so have patience.

Step 3: Set the Environment Variables

1.Assuming everything went well in the previous step and you have successfully installed your NS. Now that NS is installed, there are some environment variables that need to be added to your profile. This can be done by editing the .bashrc file. Open a new terminal and open the file using:

sudo gedit .bashrc

NOTE:You may want to create a backup of the .bashrc before editing, the easiest way is to copy the file to a different location. Later you can replace the edited .bashrc with the copied one in case something goes sideways or if you want to remove the NS.


2.Add the following lines AT THE END of the file. Be sure to change "/path_to" to the path of where you have extracted the NS (e.g. '/home/user_name/Documents').

Save the file and restart the system, alternatively you can just reload the .bashrc as:

source ~/.bashrc

Step 4: Validate the Installation

You need to validate NS to check if everything is OK but keep in mind that it will take a lot of time (about 1:30 hrs). Open up a terminal and move to the directory ‘/home/user_name/Documents/ns- allinone-2.35/ns-2.35/' and run:
./validate

And run ns from a terminal window by executing: ns
If you received the "%" sign, it means that NS is running.


if your ubuntu version is 14.04 lts or later, just do following simple steps:

1) apt-get install build-essential
2) apt-get install ns2
3) apt-get install nam
4) apt-get install xgraph

you have done with installing with ns2 on your system.
now run ns from a terminal window by executing: ns
If you received the "%" sign, it means that NS is running.

0 comments:

Post a Comment

    Translate

    Protected by Copyscape