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