Direction of building NS2 platform using Cygwin under Windows OS
Huang Xuguang 220822281.
Introduction
This document aims to give the direction of building NS2 using Cygwin under windows os. The procedures and common errors are listed in this document.
The software and source codes we need are:
Cygwin:
Downloaded from http://www.cygwin.com NS2 source code:
Downloaded from http://www.isi.edu/nsnam/dist/ns-allinone-2.27.tar.gz
version: ns-allinone-2.27.tar.gz Patch of NS2:
Downloaded from http://www.ececs.uc.edu/~cdmc/ucbt/src/ns227-gcc34.patch Patch of tk:
Downloaded from http://bugs.gentoo.org/show_bug.cgi?id=225999
version: tk-8.4.18-tkbind.patch LEACH source code:
Downloaded http://www.internetworkflow.com/downloads/ns2leach/mit.tar.gz
2.
Steps
1>
Install Cygwin
It is easy to install Cygwin under windows os.
a. First, get the software from http://www.cygwin.com.
c. Here you must install these packages because NS2 needs them:
XFree86-base, XFree86-bin, XFree86-prog, XFree86-lib, XFree86-etc, make, patch, perl, gcc, gcc-g++, gawk, gnuplot, tar and gzip
Then checking the root of Cygwin, making sure there are one folder named “home” and there are three hidden files in “home/{username}” which are .bashrc, .bashrc_profile and .inputrc.
2>
Install NS2
a. Unzip the source code of NS2 and it includes these files:
Command: tar xvfz ns-allinone-2.27.tar.gz
b. Install patch.
Before we excuse the compilation process, we’d better to install patch of NS2 to avoid mistakes.
Download the patch named ns227-gcc34.patch and put it in the same dir with
ns-allinone-2.27.
Install it.
Command: patch -p0 <ns227-gcc34.patch
c. Enter the dir of ns2 and install it.
Command:
cd ns-allinone-2.27 ./install
ERROR
no ‘home’ folder and no three hidden files SOLVATION
Check the Environment Variable of your computer; delete the entry which named ‘HOME’
TCL release 8.4.5 (required component)
TK release 8.4.5 (required component)
Otcl release 1.8 (required component)
TclCL release 1.15 (required component)
Ns release 2.27 (required component)
Nam release 1.10 (optional component)
Xgraph version 12.1 (optional component)
CWeb (optional component)
SGB (optional component, builds sgblib for all UNIX type platforms)
Gt-itm (optional component)
d. Finish compiling.
Generally, the compilation process will cost about 4 hours (depended on your computer). If you finish this step successfully, you will see this:
During this step, you would meet many problems. I list the common errors I met and give the salvations.
e. Setting environment variables.
Edit the file “.bashrc” which is a hidden file in your “home/{username}” folder and insert these sentences:
f. Test NS2.
Now, you have finished installing NS2. You can use an example to test NS2.
Start xwindow Command: startxwin.bat export NS_HOME=`pwd`/ns-allinone-2.27 export PATH=$NS_HOME/tcl8.4.5/unix:$NS_HOME/tk8.4.5/unix:$NS_HOME/bin:$PATH export LD_LIBRARY_PATH=$NS_HOME/tcl8.4.5/unix:$NS_HOME/tk8.4.5/unix:$NS_HOME/otcl-1.8:$N S_HOME/lib:$LD_LIBRARY_PATH export TCL_LIBRARY=$NS_HOME/tcl8.4.5/library ERROR
Tcl is not part of the ns project SOLVATION
Modify the following files, find the words “.relid'`” and use “.relid`” instead.
ns-allinone-2.28\tcl8.4.5\unix\configure ns-allinone-2.28\tcl8.4.5\unix\tcl.m4 ns-allinone-2.28\tk8.4.5\unix\configure ns-allinone-2.28\tk8.4.5\unix\tcl.m4 ns-allinone-2.28\otcl-1.8\configure
Launch the example Command:
cd ns-allinone-2.27/ns-2.27/ns-tutorial/examples ns example2.tcl
Executing the example and you would see: ERROR
nam: no such file or directory SOLVATION
There are two methods:
1.Check the folder “ns-allinone-2.28/nam-1.11”, copy nam.exe to “ns-allinone-2.28/bin” if it exists. 2.Recompile the nam if there is no “nam.exe” in this catalog “ns-allinone-2.28/nam-1.11”.
Edit the file agent.h under “nam-1.11/agent.h” Change “NULL” to “0” in line 73.
Congratulations if you can see these two windows! You have installed NS2 sucessfully.
3>
Loading LEACH
a. Dowload LEACH source code and put it under “ns-allinone-2.27/ns-2.27”.
Unzip the package. Command:
gunzip mit.tar.gz tar -xvf mit.tar
b. Modify “makefile” file.
Find the paragraph beginning with “DEFINE”, add
-DMIT_uAMPS
in its end.
Find the paragraph beginning with “INCLUDES”, add one line
-I./mit/rca –I./mit/uAMPS in its end.
Find the line “gaf/gaf.o \”, add these before it.
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 \
The file should be like this:
c. Set environment variable
Edit the file “.bashrc” which is under the catalog “home/{username}”. Add
export RCA_LIBRARY={$NS_HOME}/ns-allinone-2.27/ns-2.27/mit/rca export uAMPS_LIBRARY={$NS_HOME}/ns-allinone-2.27/ns-2.27/mit/uAMPS
Edit wireless-phy.cc which is under “ns-allinone-2.27/ns-2.27/mac”, add the definition
#define min(a,b) (((a)>(b))?(b):(a))
behind the sentence “#define max(a,b) (((a)<(b))?(b):(a))”
d. Compile the LEACH
Command: make clean make
To compile the LEACH would cost about 10 to 30 minutes (depend on your computer). After this step, you can run an example to test LEACH.
Command: ./test
LEACH is successfully installed if you see this:
e. Check the leach.err file under “ns-allinone-2.27\ns-2.27\mit\leach_sims”, the content would be this if LEACH works well.
ERROR
line3: ns:command not found SOLVATION
1.Modify “./test” file, put the line “./leach_test” under the line “cd ../../”. It looks like this:
sleep 2 cd ../../ ./leach_test
2.Modify “./leach_test” file, add
RCA_LIBRARY=mit/rca export RCA_LIBRARY uAMPS_LIBRARY=mit/uAMPS export uAMPS_LIBRARY