Path to Higher Learning...

More and more about NS-2

To set different initial energy to every node

# set initial energy for first node
$ns node-config -initialEnergy 50
set node_(0) [$ns node]

# set initial energy for second node
$ns node-config -initialEnergy 100
set node_(1) [$ns node]

# set initial energy for third node
$ns node-config -initialEnergy 70
set node_(2) [$ns node]

and similarly for more nodes...

Read More......

Compile cc file to exe file

in ns-allinone-2.34/ns-2.34/indep-utils/propagation/

g++ -lm -o threshold threshold.cc

threshold of Cthresh and Rthresh can be calculated.

Read More......

Another app is currently holding the yum lock; waiting for it to exit…

Another app is currently holding the yum lock; waiting for it to exit…

error though I was not using yum any where else, but this crap was coming every time when I run the command, After googling a bit finally got the solution that I this error was coming coz there was something in the yum.pid.
We can this issue by two means
First
one killing the pid by doing follwing command.

# ps aux | grep yum

this command will show all the process with process id which is running by yum. so now you can kill the process. Say process Id 31542 is using the yum so you can do

# kill -9 31542
or
# kill 31542

Second:

If above method doesn’t work for you. you can remove the yum process from the machine. Now the question arise where you will get the process file. yum process resides in /var/run folder so simply type the following command and hit enter.
# rm -f /var/run/yum.pid


Read More......

Some useful stuff about ns-2

http://jsun74.blogspot.com/2010/10/fwd-ns2.html

Read More......

Command for AWK

I have been always in search for the command to run AWK script. To ease my job next time, I should have put in here too.. :)


The command is:

awk -f awkfilename tracefilename > outputfilename

Read More......

Adding new routing protocol in ns-2

Thanks to Elmurod A. Talipov

Writing routing protocol is fairly easy in NS2, but for beginners it seems very difficult. Therefore, if you are new to NS2 and want to write your own routing protocol, I would strongly recommend to revise AODV source code. Because, I believe AODV source code is straightforward and fairly easy to understand due to the simplicity of the AODV protocol.

Before you begin reading this post, I assume that you have already installed NS2 on Linux. I have used version 2.34, which is current release. If you have not installed yet, DOWNLOAD HERE and INSTALL. Okey, simple requirements to write your own routing protocol

NS2 installed
You should know how to program in C/C++.
Optionally, shell scripting and perl.
Let's start with creating directory of routing protocol. Goto the "$NS_ROOT/ ns-2.34/". Create directory named as wfrp, we call it WSN Flooding-based Routing Protocol in which sink nodes periodically send a beacon message and other nodes construct route towards the sink nodes. Then nodes report to sink node every certain period using UDP protocol. Direct Diffusion may be an example of such protocol, but what we are writing is simpler and has more functionalities.

mkdir wfrp
In the directory we create three files : wrfp.cc, wrfp.h, wrfp_packet.h. Download and put these files in wfrp directory. I will not explain the code here, and if you don't understand just leave comment I will try to answer.

Now, we are going to modify following files. Therefore it is better you backup these files before you start adding new protocol, so that you can easily go back.

$NS_ROOT/Makefile
$NS_ROOT/queue/priqueue.cc
$NS_ROOT/common/packet.h
$NS_ROOT/trace/cmu-trace.h
$NS_ROOT/trace/cmu-trace.cc
$NS_ROOT/tcl/lib/ns-packet.tcl
$NS_ROOT/tcl/lib/ns-lib.tcl
$NS_ROOT/tcl/lib/ns-agent.tcl
$NS_ROOT/tcl/lib/ns-mobilenode.tcl
Let's start with ~/ns-allinone-2.34/ns-2.34/Makefile just add following lien at 269

wfrp/wfrp.o \
Add following lines to ~/ns-allinone-2.34/ns-2.34/queue/priqueue.cc from line 93.

// WFRP patch
case PT_WFRP:
To define new routing protocol packet type we have to modify ~/ns-allinone-2.34/ns-2.34/common/packet.h file. We change PT_NTYPE to 63, and for our protocol PT_WFRP = 62. If you have already installed another routing protocol. Just make sure PT_NTYPE is last, and protocol number is ordered sequentially. From line 85 changes would be :

// WFRP packet
static const packet_t PT_WFRP = 62;

// insert new packet types here
static packet_t PT_NTYPE = 63; // This MUST be the LAST one
We make following code change at line 254 of ~/ns-allinone-2.34/ns-2.34/common/packet.h. The code is used that the packet is routing protocol packet and has high priority.

type == PT_AODV ||
type == PT_WFRP)
And at line 390 of the same file

// WFRP patch
name_[PT_WFRP] = "WFRP";
Now we will make NS2 trace our simulation and write it to *something*.tr, in order to do that we have to modify cmu-trace.h and cmu-trace.cc.

To add trace function we add following line to ~/ns-allinone-2.34/ns-2.34/trace/cmu-trace.h at line 163:

void format_wfrp(Packet *p, int offset);
~/ns-allinone-2.34/ns-2.34/trace/cmu-trace.cc must be added following code at line 1071

// WFRP patch
void
CMUTrace::format_wfrp(Packet *p, int offset)
{
struct hdr_wfrp *wh = HDR_WFRP(p);
struct hdr_wfrp_beacon *wb = HDR_WFRP_BEACON(p);
struct hdr_wfrp_error *we = HDR_WFRP_ERROR(p);

switch(wh->pkt_type) {
case WFRP_BEACON:

if (pt_->tagged()) {
sprintf(pt_->buffer() + offset,
"-wfrp:t %x -wfrp:h %d -wfrp:b %d -wfrp:s %d "
"-wfrp:px %d -wfrp:py %d -wfrp:ts %f "
"-wfrp:c BEACON ",
wb->pkt_type,
wb->beacon_hops,
wb->beacon_id,
wb->beacon_src,
wb->beacon_posx,
wb->beacon_posy,
wb->timestamp);
} else if (newtrace_) {

sprintf(pt_->buffer() + offset,
"-P wfrp -Pt 0x%x -Ph %d -Pb %d -Ps %d -Ppx %d -Ppy %d -Pts %f -Pc BEACON ",
wb->pkt_type,
wb->beacon_hops,
wb->beacon_id,
wb->beacon_src,
wb->beacon_posx,
wb->beacon_posy,
wb->timestamp);

} else {

sprintf(pt_->buffer() + offset,
"[0x%x %d %d [%d %d] [%d %f]] (BEACON)",
wb->pkt_type,
wb->beacon_hops,
wb->beacon_id,
wb->beacon_src,
wb->beacon_posx,
wb->beacon_posy,
wb->timestamp);
}
break;

case WFRP_ERROR:
// TODO: need to add code
break;

default:
#ifdef WIN32
fprintf(stderr,
"CMUTrace::format_wfrp: invalid WFRP packet type\n");
#else
fprintf(stderr,
"%s: invalid WFRP packet type\n", __FUNCTION__);
#endif
abort();
}
}
Now we will modify tcl files to create routing agent. First we define protocol name to use in tcl file. It would done by modifying ~/ns-allinone-2.34/ns-2.34/tcl/lib/ns-packet.tcl @ line 172

# WFRP patch
WFRP
Now we set routing agent by modifying ~/ns-allinone-2.34/ns-2.34/tcl/lib/ns-lib.tcl @ line 633

WFRP {
set ragent [$self create-wfrp-agent $node]
}
From line 860 of the same file following code should be added.

Simulator instproc create-wfrp-agent { node } {
# Create WFRP routing agent
set ragent [new Agent/WFRP [$node node-addr]]
$self at 0.0 "$ragent start"
$node set ragent_ $ragent
return $ragent
}
Now we will set port numbers of routing agent. sport is source port, dport is destination port. Modify ~/ns-allinone-2.34/ns-2.34/tcl/lib/ns-agent.tcl line 202

Agent/WFRP instproc init args {
$self next $args
}

Agent/WFRP set sport_ 0
Agent/WFRP set dport_ 0
Frankly speaking I have no idea why I have to add following things. But I believe it should be done according to some tutorial : ~/ns-allinone-2.34/ns-2.34/tcl/lib/ns-mobilenode.tcl line 201

# Special processing for WFRP
set wfrponly [string first "WFRP" [$agent info class]]
if {$wfrponly != -1 } {
$agent if-queue [$self set ifq_(0)] ;# ifq between LL and MAC
}
We are done. got to ~/ns-allinone-2.34/ns-2.34/ directory and do

make clean
make
When the compile is finished, you can test using wfrp_802_15_4.tcl file as :

ns wfrp_802_15_4.tcl
In this test the NODE 0 is sink node, starts sending beacon 1 second after simulation i started, and NODE 10 is reporting node. It starts sending report over CBR/UDP at 5.0 seconds (after simulation is started). Report interval is 2 seconds.

To remove debugging WFRP, uncomment #define DEBUG (line 36 of wfrp.cc & re-make it).

Read More......

Fedora 10 Enable GUI Root Login

Q. How do I enable root login under Fedora 10 Gnome GUI login screen / manager?

A. Fedora 10 uses pam module called pam_succeed_if.so. This module is designed to succeed or fail authentication based on characteristics of the account belonging to the user being authenticated. One use is to select whether to load other modules based on this test. This module blocks root login using GUI.

Login as root

Log in as normal user

Then open GUI terminal (bash prompt) and type the following command to become root user:
$ su -

WARNING! These examples may crash your computer if not executed properly. It is recommended that you always login as normal user to avoid any damage to your system and then use su - to get root level access as required.

Fedora 10 update GDM config to allow root login

Type your root password. Next, make a backup of /etc/pam.d/gdm, enter:
cp /etc/pam.d/gdm /root
Now open /etc/pam.d/gdm using gedit or vi text editor, enter:
gedit /etc/pam.d/gdm
OR
vi /etc/pam.d/gdm
Alternatively, you can do everything in a one command:
su -c 'gedit /etc/pam.d/gdm'
Find line that read as follows:

auth required pam_succeed_if.so user != root quiet

Remove or comment out line by prefixing #.

# auth required pam_succeed_if.so user != root quiet

Save and close the file. Logout from terminal and from GUI itself. Now you should be able login as root user using GDM GUI login manager.

Read More......

NIST Wimax patch for NS-2.31

Download: NS-2.31 + NIST Wimax patch

Article obtained from: http://bestkid.pixnet.net/blog/post/15075795

Install ns-allinone-2.31

1. download ns-allinone-2.31 http://sourceforge.net/project/showfiles.php?group_id=149743&package_id=169689

2. Move ns-allinone-2.31.tar.gz to C:\cygwin\home\user

3. Start cygwin , tar zxvf ns-allinone-2.31.tar.gz

4. cd ns-allinone-2.31

5. ./install

6. Modify .bashrc file of C:\cygwin\home\user by inserting the following at the end of the file:

export NS_HOME=`pwd`/ns-allinone-2.31

export PATH=$NS_HOME/tcl8.4.14/unix:$NS_HOME/tk8.4.14/unix:$NS_HOME/bin:$NS_HOME/ns-2.31:$PATH

export LD_LIBRARY_PATH=$NS_HOME/tcl8.4.14/unix:$NS_HOME/tk8.4.14/unix:$NS_HOME/otcl-1.13:$NS_HOME/lib:$LD_LIBRARY_PATH

export TCL_LIBRARY=$NS_HOME/tcl8.4.14/library


7. after exit cygwin , restart cygwin ,with the command: ns , to test if ns install successfully.


Install wimax module and ns-2.31 patch

1. Can be downloaded from the blog or obtained from http://w3.antd.nist.gov/seamlessandsecure.shtml | Software Tools

Note: contains patch for ns-2.31. See documentation for the list of modifications. Use the request form to download the file.

The downloaded file is ns-nist-wimax.tgz
Copy the file to C:\cygwin\home\user

2. Start cygwin then unpacked the tarball with command: tar zxvf ns-nist-wimax.tgz

3. Then, with command: tar zxvf prerelease041707.tgz
After decompress completed, you will find patch-ns-2.31-041707 patch file.

4. Copy patch-ns-2.31-041707 to C:\cygwin\home\user\ns-allinone-2.31 folder

5. cd ns-allinone-2.31

6. patch -p0
patch-ns-2.31-041707.patch

Read More......

Accelerate NS-2 scheduler

Download: Scheduler-patch

This is a patch that can speed up the NS-2 scheduler by improving the Calendar Queue data structure in the scheduler. Especially, it can help to speed up many simulations with high speed long distance network. Some simulations that need one day with the original NS2 scheduler can now be finished in an hour.

  1. Copy the patch to ns-allinone-2.28/ns-2.28 (or ns-2.29)
  2. In the directory of ns-allinone-2.28/ns-2.28 (or ns-2.29) , run: make clean
  3. In the directory of ns-allinone-2.28/ns-2.28 (or ns-2.29), run: patch -p1 <>
  4. (Optional) delete the patch file by rm ns-scheduler.patch
  5. recompile the ns2 by make and make install


Many thanks to the author: David X. Wei

Read More......

Error: nam: command not found

Solution:
In nam directory (inside the ns-allinone)use the following command:
./configure and make

When compiling, you would encounter a series of errors. Erase for example, "abc::" from file and
in the line with error could solve the problem.
By solving all the errors, you could execute nam with the command:
nam

Read More......

Error free NIST mobility NS2.29 installation

Download: patch_nist_mobility

Download: ns-nist-mob.tgz

1. Extract the patch and insert the patch file in ns-2.29 folder.
2. Patch the folder with the command:
patch -p1 -i ns2_NIST_mobility.patch
3. Compile the whole ns-2.29 with the command:
./install

Special thanks to Mr Johann M. Márquez Barja for providing the patch.
***************************************************************
To install NIST mobility....
II- Version
This source files provided is for ns-2.29.


III- Installation
The mobility package is a complete ns-2.29 directory, not a patch.
Unzip and untar the source file:
tar -zxf ns-nist-mob.tgz
this will extract another compressedf file to unzip and untar:
tar -zxf ns-2.29-nist-mob-022707.tgz (this will uncompress a complete ns-2.29 directory)

Note: we have a generic name (ns-nist-mob.tgz) for download purposes. This file contains a compressed file with the release date to better keep track of the different versions.


IV- Compilation options
After extracting the ns-2.29 directory, you need to recompile the code. To do so, execute "make clean; ./configure ; make" in the ns-2.29 directory.
To debug the wimax code, edit the Makefile and add the -DDEBUG_WIMAX switch in the DEFINE entry.


V- Running examples
Examples of scenarios using homogeneous and heterogeneous handovers are located in the tcl/hsntg directory.
The scripts have been updated to run properly.

Read More......

To Save and Exit in "vi" Command - Linux

Esc, then shift+ctrl+":" and then "wq", enter.

Read More......

Learning C++

Due to NS-2 is heavily coded in C++, I am currently studying hard about it. My knowledge in C++ is really limited. Arghh... Feel like I have been wasting a lot of time of doing "don't know what"... I want to GRADUATE!!!!

Read More......

Actual Coverage Range in NS-2

Actual Coverage Range = square of 2*distInterference_centred in the reception node

PS: Information extracted from mailing list. Hopefully will be useful in later work.

Read More......

Installing INET Framework into OMNET++

Download: Inet Framework
Download: Inetmanet Framework

To install:
You should have a working OMNeT++ installation, version 4.0 or later.
It must be compiled with dynamic NED loading enabled (WITH_NETBUILDER=yes setting).

1. Make sure your OMNeT++ installation works OK (e.g. try running the samples)
and it is in the path (to test, try the command "which nedtool").

2. Change to the INET directory.

3. Type "make" to build the inet executable (debug version). Use "make MODE=release" to build release version.

Problem:
-lpcap is not found

Solution:
yum install libpcap-devel

Problem:
make: warning: Clock skew detected. Your build may be incomplete.

Solution:

   cd directory
# Remove output files
make clean
# Put timestamps on all files equal to current time
find . -exec touch {} \;
# Rebuild all output files
make

Finally, try running the demo simulations. Change into examples/ and type
"./rundemo".

Problem:
Error during startup: Cannot load library '../../../src//libinet.so': ../../../src//libinet.so: cannot open shared object file: No such file or directory.

For INET:
Solution:
SELinux blocks the library from running. Free the library with the command:
chcon -t textrel_shlib_t '/home/user/inet/out/gcc-debug/src/libinet.so'

For INETMANET:
The problem occurs due to "makefile"

1. Copy everything from "Makefile_dll" and replace all of "Makefile"

2. Execute "buildMakefiles" shell file with the command: sh buildMakefiles

3. Finally, compile with the command: make

4. You probably need this as last step:
chcon -t textrel_shlib_t '/home/user/inetmanet/out/gcc-debug/src/libinet.so'

Then you should be able to run the demo in the examples;
./rundemo

Read More......

Subversion of NS-MIRACLE+NS-MIRACLE 2.0 Beta

Download the latest NSMIRACLE: Subversion NS-MIRACLE

Download Beta version: NS-MIRACLE 2.0 Beta

The NS-MIRACLE codebase is kept on a subversion repository. In particular, the development version of nsmiracle is available at this URL:

https://telecom.dei.unipd.it:/tlcrepos/nsmiracle-dev/trunk

The above mentioned subversion repository provides read-only access for guest users using the following account:


username: nsmiracle-dev-guest
password: nsmiracleguest

As an example, using the svn command line client you can check out the latest development version using the guest account by typing the following command and add in the path to be copied to at the trail of the command:


svn co --username nsmiracle-dev-guest --password nsmiracleguest https://telecom.dei.unipd.it:/tlcrepos/nsmiracle-dev/trunk /home/username/nsmiraclerep


NSMIRACLE SVN repository Installation procedures:

1. Go to the "main" directory
command:
cd main
2. Execute the autogen.sh
command:
sh autogen.sh
3. Configure script will be generated and do the following:
command:
./configure --with-ns-allinone=/home/username/ns-allinone-2.33 --prefix=/home/username --disable-static --with-dei80211mr=/home/username/ns-allinone-2.33/dei80211mr-1.1.4
4. command:
make
5. command:
make install

NSMIRACLE ADDONS installation procedure:
1. Go to the "addons" directory and access to the addon need to be install
command:
cd addons
cd addontobeinstall
2. Execute the autogen.sh
command:
sh autogen.sh
3. Configure script will be generated and do the following:
command:
./configure --with-ns-allinone=/home/username/ns-allinone-2.33 --prefix=/home/username --disable-static --with-nsmiracle=/home/username/nsmiracledir/main
4. command:
make
5. command:
make install

PS:
Error occured during "./configure" of addons:
1. configure: error: Could not find boost graph header files, please install the boost graph library.
Solution:
yum install -y boost-devel
yum install boost

Error occured during "make" of addons:
1. error:
/usr/include/boost/pending/relaxed_heap.hpp:102: error: 'CHAR_BIT' was not declared in this scope
Solution:
This is a bug in the standard header. Apparently, an include of is missing in that header. Adding the following header to the problematic code fix the problem.

#include // for CHAR_BIT

Read More......

Installing NS-MIRACLE to NS-2.33

Download: NS-MIRACLE-1.2.2
Download: Paper on NS-MIRACLE-1.2.2

NS-MIRACLE: Multi-InteRfAce Cross-Layer Extension library for the Network Simulator

NS-MIRACLE is a set of libraries designed to enhance the functionalities provided by the Network Simulator ns2. It provides an efficient and embedded engine for handling cross-layer messages and, at the same time, enables the coexistance of multiple modules within each layer of the protocol stack. For instance, multiple IP, link layers, MACs or physical layers can be specified and used within the same node. The NS-MIRACLE framework facilitates the implementation and the simulation of modern communication systems in ns2; moreover, due to its modularity, the code will be portable, re-usable and extensible.


Installation of NS-MIRACLE:

1. Unpack the nsmiracle package at /home/username and cd into the newly created directory:
Command:
tar xzf nsmiracle-1.2.2.tar.gz
cd nsmiracle-1.2.2

2. In the /nsmiracle-1.2.2, do the following:
Command:
./configure --with-ns-allinone=/home/username/ns-allinone-2.33 --prefix=/home/username --disable-static --with-dei80211mr=/home/username/ns-allinone-2.33/dei80211mr-1.1.4

3. After that, execute as following:
Command:
make
make install

4. Lastly, check that your installed NS-MIRACLE is working by running the example found in /home/username/nsmiracle-1.2.2/samples
Command:
cd samples
ns link_with_errors_cbr.tcl

You should get the result as shown if NS-MIRACLE is installed successfully:
Simulating........................................done!
Packet Error Ratio : 0.050000
Throughput : 68360.897567
Tracefile : /tmp/link_with_errors_cbr.tcl.tr


NOTE:
  • remember to adapt all paths to your needs, unless you're using /home/username.
  • make sure that the tests run by ./configure have been successful, in particular the tests for ns-allinone
  • after running make install, make sure that the path in which library have been installed is in your LD_LIBRARY_PATH environment variable.
Ref. page: http://telecom.dei.unipd.it/pages/read/58/

Read More......

Install OMNET++ 4.0 at FEDORA 10

Download:

Pre-installation:
Install the items in the following list in FEDORA 10. You must be 'root' to execute the following command:

yum install tcl
yum install tcl-devel
yum install tk
yum install tk-devel
yum install blt
yum install gcc
yum install gcc-c++
yum install byacc
yum install bison
yum install flex
yum install make
yum install swig
yum install zlib-devel
yum install java-1.6.0-openjdk-plugin
yum install automake
yum install autoconf

Installation of OMNET++ 4.0:

Download the source package and copy the omnetpp file to where you want to install it.
Extract the package by the command:
tar zxvf omnetpp-4.0rc2-src.tgz

Add the following line to your startup file (.bashrc or .bash_profile):
export PATH=$PATH:~/omnetpp-4.0/bin export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:~/omnetpp-4.0/lib

Access into the newly created directory:
cd omnetpp-4.0

Install with command:
./configure

Locate .bash_profile (eg. /home/user/.bash_profile) and include the following line into it:
export TCL_LIBRARY=/usr/share/tcl8.5

After that, at the omnetpp-4.0 directory too, type this command:
make

After compilation completed, you can try the samples, for eg:
cd ~/omnetpp-4.0/samples/dyna
./dyna

To start omnet++ IDE, use the command:
omnetpp

Read More......

My current dilemma....

I am using NS-MIRACLE, the extension of NS-2 in order to create multi technology nodes. My intention is to create nodes with two interfaces, which are UMTS interface and WLAN interface respectively.

For long I have been analyzing the sample codes in NS-MIRACLE, but still I am unable to create my dual interface nodes yet. HELP!~~ @ @

Read More......

Prevent FEDORA 10 from always log out

Check your screensaver setting:
system|preferences|look and feel|screensaver|untick all

Check your power management setting:
system|preferences|system|power management|On AC power, set to never for all

Read More......