Installing Ns2.34 with Mannasim in Linux Mint 14

Post Version: 1.1

Version of GCC I use: 4.7.2

This is the version of GCC that comes default with Linux Mint 14.

gcc_VersionIf you wish to install ns2.34 without Mannasim skip steps 4 and 9.

1. Download ns-allinone-2.34 from this site:
http://sourceforge.net/projects/nsnam/files/allinone/ns-allinone-2.34/ns-allinone-2.34.tar.gz/download
2. Extract the downloaded file into your home folder(say, /home/micman)

Throughout this post, I shall be mentioning my home folder /home/micman. When you follow these procedures, replace my username micman with your username.
3. Place the file ns2.34-mannasim-gcc4.3.patch into the following folder:

 /home/micman/ns-allinone-2.34 

4. In Terminal, type the following commands:

cd /home/micman/ns-allinone-2.34
path -p1 < ns2.34-mannasim-gcc4.3.patch

5. If the patch gets applied without any error, proceed to next step open the following file

 /home/micman/ns-allinone-2.34/otcl-1.13/configure 

Replace the following lines:

Linux*)
SHLIB_CFLAGS="-fpic"
SHLIB_LD="ld -shared"
SHLIB_SUFFIX=".so"
DL_LIBS="-ldl"
SHLD_FLAGS=""

with the following:

Linux*)
SHLIB_CFLAGS="-fpic"
SHLIB_LD="gcc -shared"
SHLIB_SUFFIX=".so"
DL_LIBS="-ldl"
SHLD_FLAGS=""

6. Next, open the following file:

/home/micman/ns-allinone-2.34/ns-2.34/tools/ranvar.cc

In line 219, make the following changes:
Find this line:

return GammaRandomVariable::GammaRandomVariable(1.0 + alpha_, beta_).value() * pow (u, 1.0 / alpha_);

and replace it with:

 return GammaRandomVariable(1.0 + alpha_, beta_).value() * pow (u, 1.0 / alpha_);

7. Next, open the following file:

/home/micman/ns-allinone-2.34/ns-2.34/mac/mac-802_11Ext.h

In line 65, make the following changes:

Include this header file

#include "cstddef" 

8. Open the following file:

 /home/micman/ns-allinone-2.34/ns-2.34/mobile/nakagami.cc

Find the following code:

if (int_m == m) {
resultPower = ErlangRandomVariable::ErlangRandomVariable(Pr/m, int_m).value();
} else {
resultPower = GammaRandomVariable::GammaRandomVariable(m, Pr/m).value();
}
return resultPower;
}

Replace it with the code below:

if (int_m == m) {
resultPower = ErlangRandomVariable(Pr/m, int_m).value();
} else {
resultPower = GammaRandomVariable(m, Pr/m).value();
}
return resultPower;
}
}

9. In the following file, some code needs to be commented:

/home/micman/ns-allinone-2.34/ns-2.34/mannasim/onDemandData.cc


Comment the following lines:

OnDemandData :: OnDemandData()
{
/// REAL request type is default.
OnDemandData::OnDemandData(REAL);
}

10. Finally, in the following file:

/home/micman/ns-allinone-2.34/ns-2.34/linkstate/ls.h

Make the following changes:
In line 137, change the following line

void eraseAll() { erase(baseMap::begin(), baseMap::end()); }

into

void eraseAll() { this->erase(baseMap::begin(), baseMap::end()); }

11. When all the above steps have been completed successfully, run the following commands in Terminal before we begin installing ns2:

sudo apt-get install build-essential autoconf automake libxmu-dev

Once the above updates are successful, we shall proceed with installing ns2.

12. Navigate into the ns-allinone-2.34 folder:

cd /home/micman/ns-allinone-2.34

13. Just run the following command:

./install

14. Meanwhile, while the installation is happening, create the following file in /home/micman, if it doesn’t exist(else use the existing file):

.bashrc

15. Copy the following contents into .bashrc file created now:

# LD_LIBRARY_PATH
OTCL_LIB=/home/micman/ns-allinone-2.34/otcl-1.13
NS2_LIB=/home/micman/ns-allinone-2.34/lib
X11_LIB=/usr/X11R6/lib
USR_LOCAL_LIB=/usr/local/lib
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$OTCL_LIB:$NS2_LIB:$X11_LIB:$USR_LOCAL_LIB

# TCL_LIBRARY
TCL_LIB=/home/micman/ns-allinone-2.34/tcl8.4.18/library
USR_LIB=/usr/lib
export TCL_LIBRARY=$TCL_LIB:$USR_LIB

# PATH
XGRAPH=/home/micman/ns-allinone-2.34/bin:/home/micman/ns-allinone-2.34/tcl8.4.18/unix:/home/micman/ns-allinone-2.34/tk8.4.18/unix
NS=/home/micman/ns-allinone-2.34/ns-2.34/
NAM=/home/micman/ns-allinone-2.34/nam-1.14/
PATH=$PATH:$XGRAPH:$NS:$NAM

Here, micman is my username, replace it with your system username.

16. Meanwhile, in the Terminal, if the installation completes without any error, then close the terminal, and reopen it and type the following command:

ns
if % sign appears then the installation has been successful.

Additional Links:

Download Linux Mint: http://www.linuxmint.com/download.php

Download mannasim patch for ns2.34: https://www.box.com/shared/th6qi9b5v0

Download PowerIso: http://www.poweriso.com/download.htm

This article is sponsored by: http://hikmainfotech.com

hikma

Was this post helpful? Then thank me by clicking <this link>

Installing Tracegraph2.02 application in Ubuntu

Tracegraph is a great application that comes handy to ns2 users. It eliminates the need to configure and run perl/awk scripts over the trace file. Trace file analysis simplified. Though I feel that Tracegraph is still in its infancy, its  existing scope just provides all that a researcher using ns2 needs.

The steps mentioned in this post were tested to be successful in Ubuntu 10.10 and I believe it would work in other Linux distros and Ubuntu versions too.(Remember that the command sudo doesn’t work in non-debian distributions of Linux.)

First, Download the following packages:

<Download Tracegraph>

<Download Mglinstaller>

Tracegraph seems to have been developed using Matlab and therefore supporting code is needed make it run in Linux. This is the reason behind installing mglinstaller.

Extract tracegraph202linux.tar.gz in  your homefolder. In my case this would result in /home/micman/tracegraph202

Next extract mglinstaller.gz into /home/micman/tracegraph202
A single executable named mglinstaller would appear in the tracegraph202 folder.

Next, provide executable permission to mglinstaller and run it using the following command:

$sudo chmod 777 mglinstaller

 

$./mglinstaller

You would then be prompted with an information, all you have to do is to hit ENTER.

This would create a new folder named glnx86 in the following location: /home/micman/tracegraph202/bin/

Next, copy all the folders and files in /home/micman/tracegraph202/  location and paste them into /home/micman/tracegraph202/bin/glnx86/

Finally, enter the following line in Terminal:

 $ sudo export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/home/micman/tracegraph202/bin/glnx86

Remember, micman in the above line is my account name, replace it with your account name(user name).

Exit the Terminal and Re-invoke it.

Now, navigate to this location: /home/micman/tracegraph202/bin/glnx86/

$ cd /home/micman/tracegraph202/bin/glnx86 

List all the files in this location

$ ls 

you would see an executable named trgraph in this location.Provide executable permission to this file and execute it.

$ sudo su 

 

# chmod 777 trgraph

 

# ./trgraph

To run tracegraph every time, just navigate to /home/micman/tracegraph202/bin/glnx86 in Terminal and execute trgraph as follows:

$ ./trgraph 

UPDATES:

Tip by Siddharth

Place the trgraph executable in the location /usr/bin/ so that you can execute it from the Terminal without having to “cd” into the installation directory everytime.  The command to copy the trgraph executable into /usr/bin/  looks like this:

$ sudo cp /home/micman/tracegraph202/bin/glnx86/trgraph /usr/bin

Update

If you encounter an error something like the following:

bash: ./trgraph: No such file or directory
It is probably because you are trying to run this tracegraph on a 64-bit machione.

To fix this issue, you need to install 32bit libraries, by running the following command in the Terminal:

sudo apt-get install ia32-libs 

after this you can just execute ./trgraph as mentioned in the tutorial.
This link helped me find this solution.

Was this post helpful? Then thank me by clicking <this link>

Finding Node Position,Velocity and Speed in NS2.34


My post on calculating node position and energy would have benefitted you in your work in ns2.In this article I would explain the use of three predefined functions in MobileNode.cc to access a nodes position,velocity and speed dynamically.As usual my work is on AODV protocol.

1. Add mobilenode.h header in aodv.h

#include<mobilenode.h>

2. In protected scope declare the variables you would be using to store the node parameters.

<see step5 in this post>

double xpos;

double ypos;

double zval;

int node_speed;

MobileNode  *iNode;

3. In aodv.cc initialize the declared variables.

xpos = 0.0;

ypos = 0.0;

zval = 0.0;

node_speed = 0;

MobileNode  *iNode;

4. Finally access the required functions from mobilenode.h. I am accesing those functions from AODV::forward() function
/***This code retrieves node position*****/

iNode = (MobileNode*) (Node::get_node_by_address(index));

((MobileNode *) iNode)->getLoc(&xpos,&ypos,&zpos);

printf(“Position of %d,  X=%f,  Y=%f,  Z=%f   \n “, index,  xpos, ypos, zpos);

/***This code retrieves the nodes velocity*****/

iNode = (MobileNode*) (Node::get_node_by_address(index));

((MobileNode *) iNode)->getVelo(&xpos, &ypos, &zpos);

printf(“Velocity of %d,  X=%f, Y=%f, Z=%f   \n”, index, xpos,  ypos, zpos);

/***This code retrieves the nodes speed*****/

iNode = (MobileNode*) (Node::get_node_by_address(index));

node_speed = ((MobileNode *) iNode)->speed();

printf(“Velocity of %d, Speed=%d  \n”,  index, node_speed);

Remember to make clean; make all after any such changes to aodv.cc or aodv.h

After all these steps are done, execute simple-wireless.tcl found at ~/ns-allinone-2.34/ns-2.34/tcl/ex with the protocol mentioned in it changed from DSDV to AODV. The result would be displayed on the terminal whenever AODV::forward() is invoked(in this case).

If you find any discrepancies in this post, please feel free to drop me a mail at micman.manoj@hotmail.com. By doing so, You would be saving the valuable time of many researchers.


Obtaining Node Position and Energy Dynamically in NS2.34

To read this article in Scribd go <here>

For an alternative method to obtain a nodes position, go <here>

Happy to meet you in another interesting task in NS2!

This time we will “dynamically” calculate a nodes position and remaining energy.This post is based on the valuable tips mentioned <here>  by Elmurod Talipov.
Now to the task…
I will be modifying the sample script simple-wireless.tcl found at ~/ns-allinone-2.34/ns-2.34/tcl/ex and all my tasks in ns2 would be based on AODV protocol.

1. In simple-wireless.tcl, change the routing protocol to AODV, enable Energy model and set the initial energy value.

2. In the node configuration set the EnergyModel, Initial Energy value, power spent in receiving mode,transmit mode,idle mode and sleep mode.

3. Now we will move to the backend code(c++). Our edits would be performed only in aodv.cc and aodv.h.

4. In aodv.h,first include the following header file that contains the procedures/functions needed to access node postion,energy and several other functions.

#include <mobilenode.h>
You will find class AODV,  something like the one shown below.

5. In that, declare the following variables in “protected” scope.

With that, no more work to be done in aodv.h. What we have actually done here is to declare the variables that we will using in aodv.cc to record a nodes position and energy.

6. In aodv.cc, we will initialize the variables that we have just declared in aodv.h. This we do in the AODV “constructor“(invoked only once during node creation).

7. Next, we include the code to access the functions in mobilenode.h, that fetch the nodes current position and energy.

I have included that code AODV::forward() function, so that the nodes position and energy are printed each time it forwards a packet. Where and When you want them to be printed is your choice. Alternatively, you may have the code included in the function of your choice and have the output redirected to a file.

8. Thats all! All we have to do now is to run simple-wireless.tcl
$ns simple-wireless.tcl
and the output would be something like this:


If you find any discrepancies in this post, please feel free to drop me a mail at micman.manoj@gmail.com. By doing so, You would be saving the valuable time of many researchers.

This article is licensed under GNU GENERAL PUBLIC LICENSE

Adding a new module to NS2

Suppose you have three files, viz:

  • myfile.h
  • myfile.cc
  • myfile.tcl

and if you want to integrate these into your existing NS2 installation, just follow the procedure explained by Mr. Teerawat Issariyakul.

Download PPT on [Adding a new module to NS2] by Mr. Teerawat Issariyakul

For more such interesting tips and NS2 guidance, have a look at:

* Mr. Teerawat’s slides

* Mr. Teerawat’s blog