Installation and Configuration of NS2 - Practical on NS2 (The Network Simulator)



Installation and Configuration of NS2 

(The Network Simulator)


Targeted for: Engineering Students : Mumbai University : IT/COMP/ENTC/ETRX Branch having NS2 based Practicals in their Academics.


Hey Guys,

Today I'm gonna  show you how the Installation of the Network Simulator (Mostly Abbreviated as NS2) is done. Of course the Link already has the steps to do so. But Generally Most of the Bachelors or even Masters that are having Project in ns2 usually get stuck on the initial phase only ie. Installation and Path Settings. The procedure is quite simple but the troubleshooting once the error or warning in installation occurs, it starts giving headaches.

I have found this good combination when we use the Fedora Core 8 (Server) version of Linux to install as well as validate NS2 having version 2.35 (The Latest one) with specified location as directory exactly given below, then it gets installed without single error.

[Pre-requisites : Basics of Linux commands and working.]

So here are the steps:

1. Install Fedora Core 8 Linux operating system as server mode (You can use VMware based on .iso file) (Get Fedora core 8 From official ftp here)

(Please Note: If you are installing Linux side by side of windows kindly follow some you-tube guides and be careful with GRUB boot loader or you might end-up with Windows boot-loader missing error. If at all this happens drop me mail I'll mail you procedure to rescue the windows boot-loader. Keeping such os installation things on VMWare/VirtualBox is always safe and preferable.)

2. Download NS2 from site given here.

3. Open Teminal > Login As Root > Copy Downloaded Tar File to / Directory.

4. Untar the Compressed file with command
#tar -xzvf ns2-allinone-2.35.tar.gz 
(Standard format #tar -xzvf .tar.gz)

5. Goto Directory where the NS2 is Extracted. (#cd ns2-all-in-one)
6. Execute #./install 
The above command takes around half an hour to install ns2.

7. After installation you can (optionally) validate the ns2 by going into the ns2-2.35 directory and by executing ./validate there.

8. Now the important thing is path setting.

9. If you have extracted the ns2 exactly in "/" directory then copy paste following content in you .bashrc file as follows:

open .bashrc file by 
#cd (Enter)
#nano .bashrc

Append the following contents in this bashrc file.

#environment values for NS2/NAM
# LD_LIBRARY_PATH
OTCL_LIB=/ns-allinone-2.35/otcl-1.14
NS2_LIB=/ns-allinone-2.35/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=/ns-allinone-2.35/tcl8.5.10/library
USR_LIB=/usr/lib
export TCL_LIBRARY=$TCL_LIB:$USR_LIB

# PATH
XGRAPH=/ns-allinone-2.35/bin:/ns-allinone-2.35/tcl8.5.10/unix:/ns-allinone-2.35/tk8.5.10/unix
NS=/ns-allinone-2.35/ns-2.35/
NAM=/ns-allinone-2.35/nam-1.15/
PATH=$PATH:$XGRAPH:$NS:$NAM 


10. Save file and close it with CRTL+X (Enter) > Y > Enter (Saving instruction)
The Bashrc file basically gets executed on each login instance by which the path of ns2 is set again.

11. Try Typing ns (enter) from any location as follows:
#ns (Enter)
%



12. If you successfully get the % sign after pressing enter when you type ns2 as root privileged user, that indicates the ns2 is properly installed and configured.

(Note: If you want to execute ns2 as standard user too as shown in the above screen-shot you can copy the bashrc file code given in path setting section to the .bashrc file present in /etc/skel/user directory and .bashrc of user's home(~) directory so that each existing and newly added user can have access to the ns2.)

13. Look out for some pre-built scripts which are examples given in ns2-2.35/tcl/ex directory of ns2 directory and you'll find many programs such as flow control, error control, wireless communications are already given.

Try executing them with #ns .tcl
If you are tracing .tr .nam or plotting output open them in their native program.
like .nam would open in network animator which comes with ns2.
To open nam file (if you trace it in tcl script of your program) syntax is,
#nam .nam

This is how the output (one existing nam file shown as example) is obtained if we are working on wired nodes and running the data packets or communicating with each other.

NAM Output 6 nodes communication




That's all Friends. Do give feedback or comment if you face any problems.

Njoy! :)

[Please note that the information given here is for educational purpose only. Author is not responsible for any misuse caused by reading document or any consequences caused to your computer by installing Linux os.]

Comments

Popular Posts