Tuesday, November 11, 2008

How to execute hier-rtg-100.tcl


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


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

Installing gt-itm and sgb

Yesterday while i was installing ns-allinone-2.33 package in my friends system with the following configuration
GCC:version 3.4.6
I have observed that sgb and gt-itm were not installed...it flashed a error that gt-itm cannot be installed as sgb is not installed. But as these are optional components the installation continued and the rest of the components were installed successfully.
The gt-itm is an optional software which is used to create topologies in ns2. It uses sgb-A Stanford Graph base for creating topologies.
As we were working on the area of ROUTING this software is very useful to us as we need to test our protocol on various topologies....
So I decided to install the sgb and gt-itm packages manually.After carefully reading the install file of ns-allinone-2.33 package I managed to install them successfully.
These are the steps I followed......
1) Opened the terminal
2) I navigated to ~/ns-allinone-2.33/sgb/ directory and typed make
It gave me some instructions from which i understood that I need to first type
make tests
and after the tests are successful I need to type
make install
After typing the above two make commands I observed that the sgb package was successfully installed.
3) Now you need to go to the gt-itm directory ~ns-allinone-2.33/gt-itm/ directory
(a) Create a folder called lib in that directory and
(b) Copy the libgb.a file found in ~ns-allinone-2.33/sgb/ to ~ns-allinone-2.33/gt-itm/lib/ directory
4) Now come out of lib directory.....and go to ~ns-allinone-2.33/gt-itm/src directory. Now you need to type make. Now you get four .o (output) files namely
and a error saying "Cannot open output file ../bin/itm ------"
5) After seeing the error I created a bin file in ~/ns-allinone-2.33/gt-itm/ directory and copied the above four .o files into ~/ns-allinone-2.33/gt-itm/bin directory
6 Now I navigated to ~/ns-allinone-2.33/gt-itm/src/ directory and typed
7) And.....the gt-itm package was installed successfully.

Note:I know the procedure I followed is some-what obscured, there may be a relatively easy procedure to install these packages.

Hope it helped

Sunday, October 12, 2008

Learning NS2

Now you have installed NS2 successfully....Its time for next step, learn the basics and then move on to advanced stuff. There are a lot of resources available in web on ns-2. I have enclosed web-links to some of the resources in this post, for more resources just Google it.
To program NS-2 you need to know C++, TCL and OTCL.
It would be advantageous if you are well versed with C++ programming.If you are a novice, no need to panic, to learn C++ there are a large number of books available.The best book to follow is "C++ Programing Language" by Bjarne Stroustrap. This book is a big one and needs some time to read.You can also refer a large number of resources available freely on C++ in the web, just use Google to search them.
To learn TCL the best book is "Practical programming in TCL/TK" by Brent B Welch. For TCL also you can find a large number of resources in the web.
OTCL is an Object Oriented extension to TCL.I dont think, there are any printed books available on OTCL.

You can refer the below sites for Introduction and Tutorials on OTCL:
For Introduction to OTCL refer : http://en.wikipedia.org/wiki/OTcl
This one is a very good tutorial to OTCL : http://bmrc.berkeley.edu/research/cmt/cmtdoc/otcl/
This site has a short tutorial on OTCL : http://nile.wpi.edu/NS/otcl.html
The NS-Manual available at www.isi.edu/nsnam/ns/doc/ also has a brief introduction to OTCL concepts.

After getting familiar with C++, TCL & OTCL concepts, you can directly start learning the NS-2.

The best resource to start with, is Greiss Tutorial which can be found at http://www.isi.edu/nsnam/ns/tutorial/index.html
Greiss Tutorial is a hands-on tutorial which covers the basics of NS-2. It is better to execute all the programs in this tutorial.

The below web-sites have links to other ns-2 resources

There are a large number of Power Point slides available in web on NS-2. I am here-by enclosing the link to the Google search page on NS-2 PPT's

After reading the above resources you can start reading the NS-Manual found at site

This document can also be found in your ns-allinone-2.33 directory at

Hope would be Useful.............

Happy Learning :)
All The Best :)

Monday, September 8, 2008

Installing NS2

After having FEDORA (or any Linux) installed successfully on your PC, you can now install NS2. You need to download the copy of NS2 first, which is available at the below site


It is better to download the compressed allinone file as it contains all the files neccessary to install NS2.
I am providing the link to download the recent version of ns-allinone package-ns-2.33 here:


The file size is around 52.8 MB.

After downloading, follow the below steps

1. Copy the file to the directory you wish to install NS2(I have copied it to my home directory)

2. Open the terminal (which can be found at Applications->System Tools->Terminal in FEDORA)

3. Go to the directory where you have copied the ns-allinone compressed file (using cd command)
I have copied the file in my home directory
Now we need to extract the ns-allinone archive which can be done by using the below command
tar xzvf ns-allinone-2.33.tar.gz
Note:For more information on using tar command type man tar on your terminal

4. Go to the extracted directory
cd ns-allinone-2.33

5. Now type the below command
After you type Return (Enter) key the installation starts and will take some time

6. After installation you need to set-up the neccessary environment variables which can be done by using the export command or by editing the .bashrc file(which is the better option as these values remain permanently)

7. To set the environment variables go to your home directory (my home directory is /home/chandra)
cd /home/chandra
and edit the .bashrc file
gedit .bashrc
Now in the text window you need to type the following
HOME= $ HOME:/home/chandra/
PATH = $ PATH: $ HOME/ns-allinone-2.33/bin:
$ HOME/ns-allinone-2.33/tcl8.4.18/unix:
$ HOME/ns-allinone-2.33/tk8.4.18/unix
LD_LIBRARY_PATH = $ LD_LIBRARY_PATH:$ HOME/ns-allinone-2.33/otcl-1.13:
$ HOME/ns-allinone-2.33/lib
TCL_LIBRARY=$ TCL_LIBRARY:$ HOME/ns-allinone-2.33/tcl8.4.18/library:
$ HOME/ns-allinone-2.33/nam-1.13
export PATH
In my system I have copied the file in my home directory(/home/chandra), you need to specify your home directory path in the HOME variable.

8. Save the file

9. Go to the ns-2.31 directory
cd ns-2.31
and type the below command
after you type Return(Enter) key the validation takes place. It will consume some time.

10. In order to verify whether NS2 is successfully installed or not type
after typing ns if you get % prompt then ns is successfully installed.

If you are trying to install NS2 under Windows, visit the below link


Hope it helped you...........
Good Luck :)

Saturday, September 6, 2008

Uninstalling FEDORA

I think I messed up with FEDORA. During the first boot of FEDORA there was a power failure. When the power came back I tried to boot in to FEDORA and arrrrr....gggggg.......hhhhhh it showed me some errors which told me that the kernel is corrupted. The worse thing is I could not boot to WindowsXP either because of the GRUB-Linux Boot Loader.

I decided it would be better to uninstall FEDORA and install it on another day. I do not want to format my hard drive, so was trying to figure out a simple way to uninstall FEDORA which does not involve formatting my hard drive.

After searching in Google for a few hours....... I figured out two options
  • The first one was using SuperGrub software which is free. You could download a copy of this software form the link : http://www.supergrubdisk.org/

as i already told you I was searching for a simple way so I did not used this software as it appeared to me it was rather complex (as it requires you to burn a bootable CD of this software).

  • and the second option, which i followed, involves creating a new MBR(Master Boot Record) for windows, which is quite easier provided you have a bootable Windows XP CD.
To create a new MBR follow the below steps:

1. Boot the system using WindowsXP bootable CD
2. Then enter into Recovery console mode (by pressing R in Welcome to Setup screen)
3. Now you will be displayed with a screen which shows Windows installation to log into
4. Select the correct option(ie., the option which shows where correct windows is installed)
Note:It will be usually the option which shows C:\
5. Type the below command
and press Enter.
6. Now it will ask you whether you want to create a new MBR, press y and press Enter
7. You get a message "The new master boot has been successfully written"
8. Type exit and press Enter.
9. The system will Reboot, remove the CD.
10. Now you will be booted to Windows XP

Now after booting to Windows XP you need to delete the partitions created by Linux to completely remove the Linux from your system for this follow the below steps

1. Right-click on My Computer icon on your Desktop
2. Select Manage option
3. Now select Disk Management option
4. Select the drives which have File System as Unknown (these are EXT file system and cannot be recognized by Windows)
5. Right click on those drives and select Delete Logical Drive option
6. Now the selected drive is shown as un-allocated
7. Now in order to make Windows recognize thes drives, right-click on the drive and select "Create new Logical Drive" and follow the Windows instructions.

Pre-Requisites-Installing FEDORA

he Network Simulator-2 is coded to work on Linux. If you want to run the ns2 softaware on Windows (which is not recommended) you need to have Cygwin installed on your Windows for further information refer the below links:


Note:The Cygwin version of NS2 has a lot of bugs and there is a very little support available for it. It is better to have NS2 installed on Linux.

There are many flavours of Linux avaialble. I am using FEDORA-an open source version of Linux from Red Hat. You can download the new version of FEDORA form the below link


Installing FEDORA is very easy. You can also dual boot FEDORA with your existing Window s Operating Systems.

If you are planning to remove your Windows OS and install FEDORA then follow the step by step instructions in the below link


If you do not want to remove the Windows OS and planning to Dual Boot WinXP and FEDORA (as I have done) you need to follow the below link


If you are having a low capacity hard-disk(<=20 GB) then it is better to use VMware to dual boot Windows and FEDORA. There is a good video tutorial which illustrates how to install VMware o Windows, I have provided a link to that tutorial below http://showmedo.com/videos/video?name=linuxDevijverVMWare1&fromSeriesID=38

After installing VMware you can install the FEDORA in normal way.

After installing FEDORA we move to the next step-installing the Network Simulator-2 package.

Friday, September 5, 2008


This is just another blog on Network Simulator-2 like many other blogs.
"NS2 or the Network Simulator-2"-A Discrete Event Simulator is used to simulate the various Network Protocols which helps the graduates in Understanding the concepts of Network protocols and the researchers to publish Research papers on their new proposed protocols.In my next post I will cover pre-requisites and other preliminary stuff. Till then Bye.