Monday, May 4, 2009

Errors I came across in the eve of Compiling ns-2

"To err is Human"
These errors have visited during my compilation, I made a log here so to save my time, if they visit again...

multiple type in same declaration
This error you get when you forget to enclose ; after your class definition.

undefined reference to `Agent::Agent(packet_t)'
This error you get if you dont follow the step
"touch common/packet.cc"
mentioned in nsrthowto. This is because you have modified only .h file without modifying .cc file.
You need to tell your compiler to recompile the packet.cc explicitly, I believe the gcc compiler is clever enough to recompile the modified .cc files, but it may not track the .h files.
(Sorry for my English).




Thursday, January 22, 2009

How to run Bonnmotion for NS-2

After installing the Bonnmotion in NS-2, I was literally confused on how to use this tool in NS-2. The readme file which came up with the package was not a well detailed one, it only explained how to produce the mobility scenarios for NS-2. The document did not cover any detail on how to use the scenario files generated. I refered the mailing lists for the answer, and I noticed that there were many users who all had the same question but I was unable to find the answer.
Finally searching in Google helped me. Here I am enclosing the link to a document, which helped me a lot
http://sce.uhcl.edu/yang/teaching/csci5931netSecuritySpr05/ns-tutorial.doc

Anyway in this post I will cover the details on how to run the bonnmotion and how to use the generated scenario files in NS-2.

1. After installing the Bonnmotion, open the dos window and navigate to the location where Bonnmotion is installed.
2. Now navigate to the bin folder
3. Type the below command to generate a scenario file
        bm -f scenario1 RandomWaypoint -n 100 -d 900 -i 3600
The above command will create a Random Waypoint scenario file with 100 nodes, with duration of 900 seconds and initial phase cutoff of 3600 seconds.
4. This command will produce 2 files
- scenario1.params which has complete set of paramaters used for the simulation
- and the second file is scenario1.movements.gz, which is a compressed file containing the movement data
5. These two files cannot be directly used in ns2, an application called "NSFILE" is provided with bonnmotion package which is used to transform these files so that they can be integrated to TCL and used with NS-2.
6. Open the dos prompt again, and navigate to the bin directory location of your Bonnmotion and type the following command
        bm NSFile -f scenario1
This command will generate two files
- scenario1.ns_params containing the parameters for running simulations in NS-2
-scenario1.ns_movements which contains the movements data essential for NS-2
7. Now comes the critical part,- How to use this files in NS-2
In the TCL script of your protocol, assign the path of the scenario1.ns_movements file to the sc variable,
you may ignore the scenario1.ns_params file.
#-----------------------------------------------------------------
# Scenario parameters
#------------------------------------------------------------------
set val(x) 2000 ;# X dimension of the topography
set val(y) 2000 ;# Y dimension of the topography
set val(ifqlen) 100 ;# max packet in queue
set val(seed) 0.0 ;#random seed
set val(adhocRouting) [routing protocol]
set val(nn) [no. of nodes] ;# how many nodes are simulated
set val(cp) [traffic pattern file]
set val(sc) [mobility scenario file]

You now have the Random Waypoint model successfully incorporated in your script.

Any Comments, Suggestions, Positive Criticism and Corrections are welcome!!!
Please apologise me for my English!!!!!

Hope that helped!
Good Luck :)

Friday, January 16, 2009

How I installed bonnmotion on WindowsXP system with jdk1.5

My project needs a Random way point scenario to be created, and on searching on Google i came across a useful tool called as Bonnmotion. The tool seemed to be useful but the problem is that it is a very old version. This tool can be downloaded from this link and you can find the documentation of this tool here. This is the homepage of this tool BonnMotion.

http://web.informatik.uni-bonn.de/IV/Mitarbeiter/dewaal/BonnMotion/

The BonnMotion is a Java software. It can be installed in Linux and also in Windows. It has been tested on jdk1.4. It can be used to create the following models
  • the Random Waypoint model,
  • the Gauss-Markov model,
  • the Manhattan Grid model and
  • the Reference Point Group Mobility model.
Coming to my experience, recently my whole day was wasted installing this tool. I initially tried to install it on Linux but as I need to install java in Linux and my Linux version is RHEL 3, which is a old version (I was concerned whether jdk6 will be compatible with RHEL 3 or not) so I decided I would go with Windows instead. The sad part of the story is that I was unable to install it straight-away in Windows either.

Once I tried to execute the install script it asked the java path which I provided, my Java path is
C:\Program Files\Java\jdk1.5.0
and next it asked the bonnmotion path. I placed my bonnmotion in the C: directory itself.

I initially thought the problem was concerning with version compatability of Java, Bonnmotion was tested with jdk1.4, and I have jdk1.5 installed on my system. I searched in the net for jdk1.4 and was unsuccessful in my effort, than I tested some of the scripts in batch file and felt like there were some problems with the scripts in batch files.[This I cannot guarantee, and is just my thought].

Ok this is what I did and successfully installed Bonnmotion in my Windows XP.
While looking at the errors
"The system cannot find the specified path"
I observed that the error emerged from the statements
if not exists ......
script statement in "install.bat" batch script
so I removed all such statements from that script, and also embeded the important JAVA variables within double quotes

Here are the steps to be followed:
1. Try to edit the install.bat file using notepad or any of your favourite text editor,

2. This is the install.bat file before modification(here I am showing only the lines to be modified, not the entire code)

.............................
.............................

set PACKAGE=edu.bonn.cs.iv.bonnmotion
set JAVA=%JAVAPATH%\bin\java.exe
set JAVAC=%JAVAPATH%\bin\javac.exe
set JAVADOC=%JAVAPATH%\bin\javadoc.exe

if not exist %JAVA% (
echo Don't forget to configure this script.
echo Could not find java.exe : %JAVA%
goto Ende
)
if not exist %JAVAC% (
echo Don't forget to configure this script.
echo Could not find javac.exe : %JAVAC%
goto Ende
)
if not exist %JAVADOC% (
echo Don't forget to configure this script.
echo Could not find javadoc.exe : %JAVACDOC%
goto Ende
)
if not exist %BONNMOTION% (
echo Don't forget to configure this script.
echo Could not find BonnMotion root directory: %BONNMOTION%
goto Ende
)

echo Installing ...

REM bm
set FILE=bm.bat
echo %FILE%
if exist bin\%FILE% del bin\%FILE%
echo @echo off >> bin\%FILE%
echo cd %BONNMOTION% >> bin\%FILE%
echo %JAVA% -cp %BONNMOTION%\classes %PACKAGE%.run.BM %%1 %%2 %%3 %%4 %%5 %%6 %%7 %%8 %%9 >> bin\%FILE%

REM compile
set FILE=compile.bat
echo %FILE%
if exist bin\%FILE% del bin\%FILE%
echo @echo off >> bin\%FILE%
echo cd %BONNMOTION% >> bin\%FILE%
echo if not exist classes mkdir classes >> bin\%FILE%
echo echo on >> bin\%FILE%
echo for /r %%%%i in (*.java) do %JAVAC% -d classes -sourcepath src -classpath classes %%%%i >> bin\%FILE%

REM makedoc
set FILE=makedoc.bat
echo %FILE%
if exist bin\%FILE% del bin\%FILE%
echo @echo off >> bin\%FILE%
echo cd %BONNMOTION% >> bin\%FILE%
echo if not exist doc mkdir doc >> bin\%FILE%
echo %JAVADOC% -quiet -d doc -use -windowtitle "BonnMotion" -sourcepath %BONNMOTION%\src edu.bonn.cs.iv.bonnmotion edu.bonn.cs.iv.bonnmotion.apps edu.bonn.cs.iv.bonnmotion.run edu.bonn.cs.iv.bonnmotion.models >> bin\%FILE%

echo done.
:Ende


......................................
......................................

3. After deleting the conditional statements which start with "if not exist" (You can also comment the lines if you do not want to delete them, by placing :: before the lines) and embeding some important Java variables (JAVA,JAVAC,JAVADOC) within doublequotes

The modified code looks like this

..............................
..............................

set PACKAGE=edu.bonn.cs.iv.bonnmotion
set JAVA=%JAVAPATH%\bin\java.exe
set JAVAC=%JAVAPATH%\bin\javac.exe
set JAVADOC=%JAVAPATH%\bin\javadoc.exe

::The conditional statements are deleted

echo Installing ...

REM bm
set FILE=bm.bat
echo %FILE%
if exist bin\%FILE% del bin\%FILE%
echo @echo off >> bin\%FILE%
echo cd %BONNMOTION% >> bin\%FILE%
echo "%JAVA%" -cp %BONNMOTION%\classes %PACKAGE%.run.BM %%1 %%2 %%3 %%4 %%5 %%6 %%7 %%8 %%9 >> bin\%FILE%

REM compile
set FILE=compile.bat
echo %FILE%
if exist bin\%FILE% del bin\%FILE%
echo @echo off >> bin\%FILE%
echo cd %BONNMOTION% >> bin\%FILE%
echo if not exist classes mkdir classes >> bin\%FILE%
echo echo on >> bin\%FILE%
echo for /r %%%%i in (*.java) do "%JAVAC%" -d classes -sourcepath src -classpath classes %%%%i >> bin\%FILE%

REM makedoc
set FILE=makedoc.bat
echo %FILE%
if exist bin\%FILE% del bin\%FILE%
echo @echo off >> bin\%FILE%
echo cd %BONNMOTION% >> bin\%FILE%
echo if not exist doc mkdir doc >> bin\%FILE%
echo "%JAVADOC%" -quiet -d doc -use -windowtitle "BonnMotion" -sourcepath %BONNMOTION%\src edu.bonn.cs.iv.bonnmotion edu.bonn.cs.iv.bonnmotion.apps edu.bonn.cs.iv.bonnmotion.run edu.bonn.cs.iv.bonnmotion.models >> bin\%FILE%

echo done.
:Ende

......................................
......................................

4. Now try to install the Bonnmotion by double clicking the install.bat file. If you see these files being created
bm.bat
compile.bat
makedoc.bat
than bonnmotion is successfully installed in your system. Congrats!!!

Any Comments, Suggestions, Positive Criticism and Corrections are welcome!!!

Hope it helped!
Good Luck!!! :)

Sunday, January 11, 2009

How to reset your Linux user password from root

A few days back I formatted my system and installed a fresh copy of RHEL-4(Red Hat Enterprise Linux). I was unable to attend the system on that day, and on the immediate next day I realised that I forgot my User password altough I remembered the root password. I was looking for a way to recover or at-least reset the User password. Lucky enough searching in Google once again saved my day. I was surprised how easy it was and am sure even you people out there would be after reading this.

This is what I have done to reset my User password
1. Login as root
2. Open the terminal
3. Type the below command
passwd username
where the username is the user whose password you need to reset (Ex: passwd chandra)
4. You will be prompted for new password.
5. Enter the new password. And you are done!!!

Dont you feel it is an easy way

Hope it helped!
Good Luck :)

Tuesday, January 6, 2009

How to access Windows FAT drives in Linux

Recently I was wondering, how to access my FAT32 formatted Windows drives in Linux, there was a reason for it. Most of my NS-2 tutorials were stored in Windows, and I cannot shift all of them to Linux because of space constraints. I used to reboot the system log into Windows refer the document and again reboot to log back to Linux to do the task. This was a rather hectic process.
As usual I used Google to find a way out. I was directed to a blog which solved my problem, and I was surprised how easy it was to access Windows FAT files in Linux. I regret that I should have done this earlier. Anyway as the proverb says "Better late then never" I am glad I have done this atleast now, and happy that I learned something Good.
Theses are the steps I followed to access the Windows formatted FAT drives in Linux
1. Login as root from the terminal.
2. Type the below command without "
"fdisk -l"
and press return key(Enter Key)
3. After the above step this was the data displayed on my system,

Disk /dev/hdb: 80.0 GB, 80026361856 bytes
255 heads, 63 sectors/track, 9729 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System
/dev/hdb1 * 1 1275 10241406 c W95 FAT32 (LBA)
/dev/hdb2 1276 9729 67906755 f W95 Ext'd (LBA)
/dev/hdb5 1276 2550 10241406 b W95 FAT32
/dev/hdb6 2551 3825 10241406 b W95 FAT32
/dev/hdb7 3826 5099 10233373+ b W95 FAT32
/dev/hdb8 5100 6374 10241406 b W95 FAT32
/dev/hdb9 6375 7943 12602961 b W95 FAT32
/dev/hdb10 7944 7956 104391 83 Linux
/dev/hdb11 7957 9660 13687348+ 83 Linux
/dev/hdb12 9661 9729 554211 82 Linux swap

4. Now I will show you how to access my C Drive in Linux.
As you can see my C drive is /dev/hdb1 (The * indicates primary partition of Windows which is C:)
To access C Drive do the following
Navigate to /mnt and create a new directory called c_drive (this will help you to identify your C Drive in case you mounted many drives) as shown below

[root@localhost mnt]# mkdir c_drive

You may be wondering what is this /mnt(mount). This is a standard location where the mounting takes place in Linux. For more info on mounting please refer Google.

Now type the below commands

[root@localhost /] mount /dev/hdb1 /mnt/c_drive

this will mount the C Drive to Linux, in plain English it means you can now access the C Drive in Linux
The location of this drive is "/mnt/c_drive"

In the similar way you can access the remaining drives, even your USB drive also can be mounted in the similar way.

For further information you can refer the following links
http://lampcomputing.com/node/39
http://www.linuxquestions.org/questions/linux-newbie-8/win-fat32-partition-on-rhel-3-614489/

Note:The above method was tested with Red Hat enterprise Linux release 4.

Hope it Helped
Good Luck
:)

Tuesday, November 11, 2008

How to execute hier-rtg-100.tcl

Hi,

The ns-allinone-2.33 package has a set of example scripts in the directory "~/ns-allinone-2.33/ns-2.33/tcl/ex" where you can find example TCL scripts, which can be executed. I have observed that the file hier-rtg-100.tcl gives some errors when you try to run it. Actually the problem is that the Network Simulator-2 is changing from version to version and a lot has changed from orignal version to now. Some scripts present in this tcl/ex directory are written for old versions of NS-2 and they are not updated for new version of NS-2 till date.

After searching in NS-2 mailing lists and Google I figured out what the problem was and after doing the neccessary modifications I was able to successfully run this hier-rtg-100.tcl script file.

Here I enclose in this post the modifications I have done:
Actually the hier-rtg-100.tcl calls another script hts100.tcl, which needs to be modified
1. Open the file hts100.tcl present in "~/ns-allinone-2.33/ns-2.33/tcl/ex/", in any of your favourite editor, and insert the below mentioned lines at the starting of the file

Simulator instproc duplex-link-of-interfaces {args} {

;# Defining the Arguments
set n1 [lindex $args 0]
set n2 [lindex $args 1]
set BW [lindex $args 2]
set delay [lindex $args 3]
set queue [lindex $args 4]

;#Execution statement
$self duplex-link $n1 $n2 $BW $delay $queue
}

2. Save the file and close it.

Now we also need to do a small but an important modification (fix) to the hier-rtg-100.tcl file also
1. Open the hier-rtg-100.tcl file present in "~/ns-allinone-2.33/ns-2.33/tcl/ex/" in any of your favourite editor.
2. Search for the line containing the following text

create-hier-topology {$linkBW}

It is probably the Line number 15
Now replace this line with the below mentioned line

create-hier-topology $linkBW

i.e.., we need to remove the flower braces
3. Save the file and close it.

Now comes the main part.....Execution :)
1. Open the terminal
2. Go to the directory where ns-allinone-2.33 is installed

$ cd ns-allinone-2.33

3. Navigate to the ns-2.33/tcl/ex

$ cd ns-2.33/tcl/ex

4. Now run the program

$ ns hier-rtg-100.tcl

5. If you are able to see animation in nam, then the program is successfully executed, else you are having some trouble, review the modifications again and try to execute the program or refer the NS-2 mailing list for further assistance.

Hope it helped you...
Good Luck :)

Sunday, October 26, 2008

How to install iNSpect-3.5 on systems with GCC version 3.4.6

The nam or the Network Animator found in ns2 is built for visualizing the simulations of wired-networks. So it is better to use some other specialised visualization tools built to support wireless-network simulations. One such tool that is built for visualizing Wireless simulations on ns2 is iNSpect which is freely available on request. The tool can be available by sending a request mail to Tracy Camp (tcamp@mines.edu).For more information on this tool visit this web-site

http://toilers.mines.edu/Public/NsInspect

I tried to install the iNSpect-release 3.5 on my system which has the following configuration
OS: Red Hat Enterprise Linux release 4
GCC Version: 3.4.6
and the installation failed.

I tried to figure out the problem and found out that the iNSpect needs at-least GCC version 4.
I tried to update my GCC.....but my net connection was slow and it was taking a hell lot of time...and one of my friend told me that the Linux kernel depends on the GCC and if you try to modify the GCC the OS may give you some problems......
I dont want to change my OS, so was looking for any fixes by which I could install this package....

After spending some time on Google, I realized that GCC version 4 added a new feature called
ffriend-injection
in-order to comply with new ANSI-standards.
Now I observed that I was getting the error because of this new feature......GCC 3.4.6 is not able to recognize ffriend-injection.

Then a post in one of the Help-Forums helped me.......
It said that by disabling the ffriend-injection flag in the installation script you can successfully install the software....
Now these are the steps I tried and successfully installed the iNSpect-release 3.5 on my GCC 3.4.6 system, I think the same steps can be followed to install this package on systems with GCC version less than 4.
1) Open the file install present in package iNSpect-release 3.5, in any editor
2) Search for the line containing -ffriend-injection (I think it is line no 93)
It appears like this
g++ -g -c \$(CFLAGS) \$(gtkCFLAGS) -ffriend-injection \$<
3) Now delete "-ffriend-injection", after deleting the resultant line looks like this
g++ -g -c \$(CFLAGS) \$(gtkCFLAGS) \$<
4) Now save the file and close it.
5) Now try to install the package......

It worked for me.......

Hope it helps
Good Luck
:)