2012年9月22日星期六

[ZT] Install NS2 (ns-allinone-2.35) on Ubuntu 11.04 for beginners

Part I: Introduction
#======================

This installation guide is on Linux Ubuntu 11.04 (download from here), and  uses ns-allinone-2.35 source file for NS2. I assume that you have the skill to install Ubuntu, so I skip this process, and focus on the installation of NS2 (step-by-step with commands).

#========================
Part II: Installation
#========================

[Step 1]

Before install NS2, you have to install some essential softwares:

sudo apt-get install tcl8.5-dev tk8.5-dev
sudo apt-get install build-essential autoconf automake 
sudo apt-get install perl xgraph libxt-dev libx11-dev libxmu-dev

[Step 2]

Download NS2 source file  from from here.
Then you will get a file named “ns-allinone-2.35.tar.gz

[Step 3]

Unpack ns-allinone-2.35.tar.gz to your home directory. (/home/stan is my home directory, you SHOULD change it to your own!)

tar -zxvf ns-allinone-2.35.tar.gz -C /home/stan

[Step 4]

4.1) Modify the makefile (NOTICE: I use “vi” for an editor, you can use “gedit” instead)

vi /home/stan/ns-allinone-2.35/otcl-1.14/Makefile.in

4.2) Change CC = @CC@ to CC = @CC@ -V 4.5

(For changing this because the gcc complier in Ubuntu 11.04 is version 4.5, however NS2 only supports gcc-4.3 below. NOTICE the V is capital.)

[Step 5]

Install NS2:

cd /home/stan/ns-allinone-2.35
sudo ./install

[Step 6]

6.1) Modify  .bahrc

vi /home/stan/.bashrc

6.2) Go to the last line and add the scripts below:

export PATH=$PATH:/home/stan/ns-allinone-2.35/bin:/home/stan/ns-allinone-2.35/tcl8.5.10/unix:/home/stan/ns-allinone-2.35/tk8.5.10/unix
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/home/stan/ns-allinone-2.35/otcl-1.14:/home/stan/ns-allinone-2.35/lib
export TCL_LIBRARY=$TCL_LIBRARY:/home/stan/ns-allinone-2.35/tcl8.5.10/library 

6.3) Enable the path setting:

cd /home/stan  source .bashrc

#======================
# Part III: Verifying
#======================

which ns

If it shows /home/stan/ns-allinone-2.35/bin/ns,  it works!

For the original version of this article, please refer to http://stanjuly.wordpress.com/2011/12/22/install-ns2-ns-allinone-2-35-on-ubuntu-11-04-for-beginners/

没有评论: