Step 0: Prepare neccesary files for installation
- NS-2.27 package: ns-allinone-2.27.tar.gz
- Patch for compiling NS-2.27 with GCC 4.1.x: ns-2.27-gcc410.patch
- MIT’s LEACH extension: mit.tar.gz
- LEACH’s Makefile patch: leach_makefile-2.27.patch
Step 1: Download NS-2.27, apply ns-2.27-gcc410.patch, and install it
Under your home directory (~):
- wget http://www.isi.edu/nsnam/dist/ns-allinone-2.27.tar.gz
OR
wget http://www.internetworkflow.com/downloads/ns2leach/ns-allinone-2.27.tar.gz - tar zxvf ns-allinone-2.27.tar.gz
- wget http://www.tekno.chalmers.se/~yusheng/reports/ns-2.27-gcc410.patch
- patch -p0 < ns-2.27-gcc410.patch
- cd ns-allinone-2.27/
- ./install
Step 2: Set the environment variables to make NS-2.27 works
- cd ~
- gedit .bashrc
# LD_LIBRARY_PATH
OTCL_LIB=~/ns-allinone-2.27/otcl-1.8
NS2_LIB=~/ns-allinone-2.27/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.27/tcl8.4.5/library
USR_LIB=/usr/lib
export TCL_LIBRARY=$TCL_LIB:$USR_LIB
# PATH
PATH=$PATH:~/ns-allinone-2.27/bin:~/ns-allinone-2.27/tcl8.4.5/unix:~/ns-allinone-2.27/tk8.4.5/unix - source .bashrc
Step 3: Download, copy, and extract MIT’s LEACH extension
- wget http://www.internetworkflow.com/downloads/ns2leach/mit.tar.gz
- cp mit.tar.gz ~/ns-allinone-2.27/ns-2.27/
- cd ~/ns-allinone-2.27/ns-2.27/
- tar xzvf mit.tar.gz
- rm mit.tar.gz
Step 4: Modify NS-2 source code
- gedit ~/ns-allinone-2.27/ns-2.27/mac/wireless-phy.cc
Goto line 59, that is after line 58:
#define max(a,b) (((a)<(b))?(b):(a))
Insert:
#define min(a,b) (((a)>(b))?(b):(a))
Step 5: Add enviroment variables for LEACH extension
- gedit ~/.bashrc
Goto line 59, that is after line 58:
export RCA_LIBRARY=$NS/mit/rca
export uAMPS_LIBRARY=$NS/mit/uAMPS - source ~/.bashrc
Step 6: Download and apply patch for Makefile.vc, edit Makefile and re-compile NS-2.27 with LEACH extension
- wget http://voyager.ce.fit.ac.jp/wiki/tool/leach_makefile-2.27.patch
- patch -p0 < leach_makefile-2.27.patch
- gedit Makefile
- Add -DMIT_uAMPS to the DEFINE list
- Add -I./mit/rca -I./mit/uAMPS to the INCLUDE list
- Add the following just prior to the line gaf/gaf.o \
mit/rca/energy.o mit/rca/rcagent.o \
mit/rca/rca-ll.o mit/rca/resource.o \
mac/mac-sensor-timers.o mac/mac-sensor.o mit/uAMPS/bsagent.o \ - make clean
- make
Step 7: Test and debug
- Modify file test:
Move line:
cd ../../
above line:
./leach_test./test You may find the follwing warnings in leach.out: Warning dst_ is no longer being supported in NS. dst_ 0xffffffff
Use dst_addr_ and dst_port_ instead
Use this Linux command to search dst_ and replace with dst_addr_ (Note: dst_port_ is 0 by default and we don’t need to search it) : - cd ~/ns-allinone-2.27/ns-2.27/mit/uAMPS/
perl -pi -w -e ’s/dst_/dst_addr_/g;’ *.tcl - cd ~/ns-allinone-2.27/ns-2.27/mit/uAMPS/sims
perl -pi -w -e ’s/dst_/dst_addr_/g;’ *.tcl
//RTP 관련 소스 붙여넣기 하고 파일 오픈- 스페이스바- 저장 > make clean > make

