How to Integrate Mannasim with NS-2.35

The Mannasim framework is a third party Wireless Sensor Network Simulation environment based on the Network Simulator (NS). In this DIY we will learn how we can integrate the Mannasim with the NS-2.35. You can learn more about the Mannasim here.


Step 1: Prerequisites

1. First of all we need a working NS-2.35, installed on Ubuntu-12.04/13.10/14.04. You can find the DIY on installation of NS-2.35 in Ubuntu-12.04 here and in Ubuntu-13.10/14.04 here.

2. Second, we need the Mannasim patch files for NS-2.35, which can be downloaded from here. I assume you have downloaded the "mannasim-NS-2.35.tar.gz" in '/home/user_name/Documents' and have your NS-2.35installed in '/home/user_name/Documents/ns-allinone-2.35/'.


Step 2: Integrating Mannasim with NS-2.35

1. Extract the downloaded Mannasim patch either using the right click context menu "Extract here" or using the following command from a terminal:

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

2. Go to the directory where you have extracted the package, in our case its '/home/user_name/Documents'. Now move the extracted "mannasim" folder inside the already installed "ns-allinone-2.35/ns-2.35".

3. Inside the mannasim folder there will be a "ns-modified-folder" that contains set of files to be pasted to different locations (image 1).

Image 1. ns-modified-files

Copy these files and paste (replace) them in following locations:

File Copy to
udp.cc ns-allinone-2.35/ns-2.35/apps/
ns-process.h ns-allinone-2.35/ns-2.35/common/
packet.cc ns-allinone-2.35/ns-2.35/common/
packet.h ns-allinone-2.35/ns-2.35/common/
ns-default.tcl ns-allinone-2.35/ns-2.35/tcl/lib/
ns-lib.tcl ns-allinone-2.35/ns-2.35/tcl/lib/
Makefile.in ns-allinone-2.35/ns-2.35/

4. Once everything is done, go to the terminal and move to the "ns-allinone-2.35/ns-2.35" directory. Now run the following commands one by one:

1 ./configure
2 make clean
3 make


Step 3: Test the Integration

To test Mannasim installation two simulation scripts are provided below. The first one simulates a flat network of homogeneous sensors and the second a hierarchical network composed of two different classes of sensor nodes.

Click on the links to get the TCL code:
1. Flat homogeneous network TCL Script.
2. Hierarchical heterogeneous network TCL Script.

You can run these files using:

1 ns mannasim-rede-plana.tcl
2 ns mannasim-rede-hierarquica.tcl

You should get output as shown in image 2.

Image 2. Testing the Integration.

You have successfully integrated the Mannasim with NS-2.35. Congratulations !! Have fun !

— * — * — * — * —

Source

How to Install NS-2.35 in Ubuntu-13.10 / 14.04 (in 4 easy steps)

In this DIY we will learn how to install Network Simulator (NS)-2.35 in Ubuntu 13.10 OR Ubuntu 14.04. If you found yourself here then I assume you already know about the NS, so I will skip the introduction part. And if you don't then you may want to follow this link.


Step 1: Setting up the Prerequisites

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

2 [Optional]. Now we have to update the Ubuntu with its latest components. Open up a terminal and run these commands:

1 sudo apt-get update
2 sudo apt-get dist-upgrade
3 sudo apt-get update

Make sure that your Ubuntu is fully updated ( i.e. there should be no pending updates in your Ubuntu Software Center and in Software Updater).

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

1 sudo apt-get install build-essential autoconf automake
2 sudo apt-get install tcl8.5-dev tk8.5-dev
3 sudo apt-get install perl xgraph libxt-dev libx11-dev libxmu-dev
4 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:

1 cd /home/user_name/Documents
2 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) with this—>erase (image 2) and save the file.

Image 1. Replace erase.

Image 2. With this->erase.

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

Image 3. Error (Please Follow the Previous Step).

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/Documents' and install NS using the following commands (image 4):

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

It will take around 15 minutes so have patience.

Image 4. Installation in Progress.


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:

1 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').

# LD_LIBRARY_PATH
OTCL_LIB=/path_to/ns-allinone-2.35/otcl-1.14/
NS2_LIB=/path_to/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=/path_to/ns-allinone-2.35/tcl8.5.10/library/
USR_LIB=/usr/lib/
export TCL_LIBRARY=$TCL_LIBRARY:$TCL_LIB:$USR_LIB

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

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

1 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:

1 ./validate

And That is it ! You can now run ns from a terminal window by executing: ns
If you received the "%" sign, it means that NS is running (image 5). Congratulations !!

Image 5. Installation Successful.


* Uninstalling the NS

If you want to remove the NS from your system then follow these steps:

1 Delete the directory 'ns-allinone-2.35'.
2 Delete the ns related files from '/user/local/bin'.
3 Edit the '.bashrc file' and remove the paths that you have added during the installation.
4 Restart the system and run following commands one by one:
5 sudo apt-get autoremove
6 sudo apt-get clean


* Some Common Problems

1. Many people are getting the following error when they run the ns after the installation:

Image 6. Error: 'ns' is currently not installed.

If you get this error then kindly ensure that you have set the path (as in step 3) correctly and try restarting the system. If the error persists then try running the ns from '/ns-allinone-2.35/ns-2.35/bin/'.


You can start working on NS now, the standard Marc Greis' tutorial on NS can be found here. Another tutorial is 'NS by example' by Jae Chung and Marc Claypool, and is available here.


P.S.

I am not working on ns anymore, if you face any problems then feel free to contact, comment but it's guaranteed that I would be able to help you. Also go through the comments before making your query. Thank you!

Have Fun !!
— * — * — * — * —

How to Install NS-2.35 in Ubuntu-12.04 (in 4 easy steps)

In this DIY we will learn how to install Network Simulator (NS)-2.35 in Ubuntu 12.04. If you found yourself here then I assume you already know about the NS, so I will skip the introduction part. And if you don't then you may want to follow this link.


Step 1: Setting up the Prerequisites

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

2. Now we have to update the Ubuntu with its latest components. Open up a terminal and run these commands:

1 sudo apt-get update
2 sudo apt-get dist-upgrade
3 sudo apt-get update

Make sure that your Ubuntu is fully updated ( i.e. there should be no pending updates in your Ubuntu Software Center and in Software Updater).

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

1 sudo apt-get install build-essential autoconf automake
2 sudo apt-get install tcl8.5-dev tk8.5-dev
3 sudo apt-get install perl xgraph libxt-dev libx11-dev libxmu-dev


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 command from a terminal:

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

2. 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/Documents’ and install NS using the following command (image 1):

1 cd /home/user_name/Documents/ns-allinone-2.35
2 ./install

It will take around 15 minutes so have patience.

Image 1. Installation in Progress.


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:

1 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').

# LD_LIBRARY_PATH
OTCL_LIB=/path_to/ns-allinone-2.35/otcl-1.14/
NS2_LIB=/path_to/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=/path_to/ns-allinone-2.35/tcl8.5.10/library/
USR_LIB=/usr/lib/
export TCL_LIBRARY=$TCL_LIBRARY:$TCL_LIB:$USR_LIB

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

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

1 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:

1 ./validate

And That's it ! You can now run ns from a terminal window by executing: ns
If you received the "%" sign, it means that NS is running (image 2). Congratulations !!

Image 2. Installation Successful.


* Uninstalling the NS

If you want to remove the NS from your system then follow these steps:

1 Delete the directory 'ns-allinone-2.35'.
2 Delete the ns related files from '/user/local/bin'.
3 Edit the '.bashrc file' and remove the paths that you have added during the installation.
4 Restart the system and run following commands one by one:
5 sudo apt-get autoremove
6 sudo apt-get clean


P.S.

Many people are getting the following error when they run the ns after the installation:

Image 3. Error: 'ns' is currently not installed.

If you get this error then kindly ensure that you have set the path (as in step 3) correctly and try restarting the system. If the error persists then try running the ns from '/ns-allinone-2.35/ns-2.35/bin/'.


You can start working on NS now, the standard Marc Greis' tutorial on NS can be found here. Another tutorial is 'NS by example' by Jae Chung and Marc Claypool, and is available here.

Have Fun !!
— * — * — * — * —