The need for network simulators

Source of this article: MOHIT’S DEN

The three main techniques to analyze the behavior of wired and wireless networks are:

  • Analytical Modeling,
  • Computer Simulations and
  • Real Time Physical Measurements.

Analytical Modeling is very tedious and Real Time Physical Measurements may not be possible all the time.

Computer Simulation is the only feasible approach to the quantitative analysis of networks.

Computer Simulations can be

Discrete Event Simulations (e.g.: arrival and departure of customers in a bank) or Continuous Simulations (e.g.: waterflow in a mountain).

Computer Simulations are generally Discrete Event Simulations.

Network Simulator – 2 (NS-2) is a discrete event and packet level simulator developed at UC Berkeley to analyze the performance of wired and wireless networks.

The architecture of NS-2 is composed of five components::

  • Event Scheduler (there are four: List, Heap, Calendar and Real),
  • Network Components (like nodes, links, protocols, etc),
  • Tool command language command language (Tclcl),
  • Object Oriented Tcl (OTcl) library and
  • TCL scripting language.

    NS-2 has C++ as the back-end language and TCL as the front-end language.

Cognitive Radio Network Simulator(CRCN) installation

Cognitive Radio Cognitive Networks(CRCN) Simulator is based on ns2 simulator. In this post I would explain in detail the steps needed to run CRCN simulations in your Linux.

Note: The installation is successful only in version 2.31 of ns (ns-allinone-2.31)

Step 1: Download CRCN from <here>
and ns-allinone-2.31 from <here>

Step 2: IMPORTANT: backup your ns-allinone-2.31 folder before proceeding. This is will help us to restore the working ns2 installation in case anything unexpected occurs.

Step 3: Extract CRCN.zip and you will see several files inside that. You have to copy each file in that and replace the corresponding files in ns2.31 folder.

Let me explain this in more detail.

If you have a folder named AODV in crcn. Copy all its contents and paste it in /home/micman/ns-allinone-2.31/ns-2.31/aodv folder.

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

You would be replacing the existing aodv folder contents with the new one you copied from crcn. Leave rest of the files unmodified.

Similarly, you will have folders named common,mac, mobile and so on. Repeat Step2 for all these folders.

Step4: Finally, you will be left with some tcl and perl scripts inside the crcn folder. Just copy them and place them in any folder, preferably /home/micman/ns-allinone-2.31/ns-2.31

Step5: Open Makefile in root user mode

$ su

# gedit /home/micman/ns-allinone-2.31/ns-2.31/Makefile

Here I have used gedit editor. replace it with the editor of your choice.

Step6: In the Makefile, find the line that says

OBJ_CC = \

In my system it is at line 164.

Step7: Copy the following lines and append it to OBJ_CC listing as shown

wcett/wcett_logs.o wcett/wcett.o \
wcett/wcett_rtable.o wcett/wcett_rqueue.o \
mac/macng.o mac/maccon.o\
mac/macngenhanced.o\

Save and close the Makefile.

Step8: Next execute the following commands in Terminal.

make clean
make depend
make

If each of these commands run without any error, then crcn installation is successful.

Errors were experienced in other versions of ns2.

There is also a GUI available for CRCN simulation. Its just a jar file that just needs to be executed. All you need to do is to run it straightaway, but before that it has some dependencies/pre-requisites:

* JDK 6 or later versions should have been installed. [Download Java JDK]

* Gnuplot should have been installed. [Download Gnuplot]

Ubuntu10.10 users could install it easily by executing the following line in Terminal.

$sudo apt-get install gnuplot

* Download <this> perl script and place it in /home/micman/ns-allinone-2.31/ns-2.31/

Here micman is my username

* Finally Download <this> jar file.

The jar file could be executed as follows:

$ java -jar CRCN.jar

For more help on how to use the CRCN GUI go <here>

Installing Ns2.34 with Mannasim in Linux Mint 14

GCC version used: 4.7.2

This is the version of GCC that comes default with Linux Mint 14.
If 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